Skip to content

Commit

Permalink
Append force flag to mkfs.btrfs (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdesaintleger authored Dec 4, 2024
1 parent cfe101e commit 614a362
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/plugins/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,9 @@ func (mkfs MkfsCall) buildOptions() ([]string, error) {
opts = append(opts, "-L")
opts = append(opts, mkfs.part.FSLabel)
}
if mkfs.part.FileSystem == "btrfs" {
opts = append(opts, "-f")
}
if len(mkfs.customOpts) > 0 {
opts = append(opts, mkfs.customOpts...)
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/plugins/layout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ var CmdsExpandPartXfs []console.CmdMock = []console.CmdMock{
}

func CmdsAddPartByLabel(fs string) []console.CmdMock {
mkfsTmpl := "mkfs.%s -L %s /some/device5"
if (fs == "btrfs") {
// for btrfs adds force flag
mkfsTmpl = "mkfs.%s -L %s -f /some/device5"
}

return []console.CmdMock{
{Cmd: "udevadm settle"},
{Cmd: fmt.Sprintf("blkid -l --match-token LABEL=%s -o device", deviceLabel), Output: "/some/part"},
Expand All @@ -247,7 +253,7 @@ func CmdsAddPartByLabel(fs string) []console.CmdMock {
{Cmd: "partprobe /some/device"}, sync,
{Cmd: "udevadm settle"},
lsblkTypes,
{Cmd: fmt.Sprintf("mkfs.%s -L %s /some/device5", fs, label)},
{Cmd: fmt.Sprintf(mkfsTmpl, fs, label)},
{Cmd: "udevadm settle"},
{Cmd: "partprobe /some/device"},
sync,
Expand Down

0 comments on commit 614a362

Please sign in to comment.