Skip to content

Commit 2c5520d

Browse files
cmd/mount: preserve parameter values in fstab options (#6412)
1 parent f91d771 commit 2c5520d

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

cmd/mount_unix.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -666,25 +666,27 @@ func tellFstabOptions(c *cli.Context) string {
666666
continue
667667
}
668668
s = strings.TrimLeft(s, "-")
669-
s = strings.Split(s, "=")[0]
670-
if !c.IsSet(s) || s == "update-fstab" || s == "background" || s == "d" {
669+
paramName := strings.Split(s, "=")[0]
670+
if !c.IsSet(paramName) || paramName == "update-fstab" || paramName == "background" || paramName == "d" {
671671
continue
672672
}
673-
if s == "o" {
674-
opts = append(opts, c.String(s))
675-
} else if v := c.Bool(s); v {
673+
if paramName == "o" {
674+
opts = append(opts, c.String(paramName))
675+
} else if strings.Contains(s, "=") {
676676
opts = append(opts, s)
677-
} else if s == "cache-dir" {
677+
} else if v := c.Bool(paramName); v {
678+
opts = append(opts, paramName)
679+
} else if paramName == "cache-dir" {
678680
var dirString string
679-
if c.String(s) == "memory" {
681+
if c.String(paramName) == "memory" {
680682
dirString = "memory"
681683
} else {
682-
dirs := utils.SplitDir(c.String(s))
684+
dirs := utils.SplitDir(c.String(paramName))
683685
dirString = strings.Join(relPathToAbs(dirs), string(os.PathListSeparator))
684686
}
685-
opts = append(opts, fmt.Sprintf("%s=%s", s, dirString))
687+
opts = append(opts, fmt.Sprintf("%s=%s", paramName, dirString))
686688
} else {
687-
opts = append(opts, fmt.Sprintf("%s=%s", s, c.Generic(s)))
689+
opts = append(opts, fmt.Sprintf("%s=%s", paramName, c.Generic(paramName)))
688690
}
689691
}
690692
sort.Strings(opts)

0 commit comments

Comments
 (0)