diff options
author | Kir Kolyshkin <kolyshkin@gmail.com> | 2020-03-31 10:20:05 -0700 |
---|---|---|
committer | Kir Kolyshkin <kolyshkin@gmail.com> | 2020-04-01 15:30:59 -0700 |
commit | f2c42a3958d12b45375aeb2384a3a8a103203c1c (patch) | |
tree | 9f6f9c1d4456145de6965f2a73ff3d47f6093908 /pkg/spec/storage.go | |
parent | c11c5e180a6e00e0093f51b050962ee1e2e30f7a (diff) | |
download | podman-f2c42a3958d12b45375aeb2384a3a8a103203c1c.tar.gz podman-f2c42a3958d12b45375aeb2384a3a8a103203c1c.tar.bz2 podman-f2c42a3958d12b45375aeb2384a3a8a103203c1c.zip |
pkg/spec.InitFSMounts: fix mount opts in place
... rather than create a new slice and then make the caller
replace the original with the new one.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Diffstat (limited to 'pkg/spec/storage.go')
-rw-r--r-- | pkg/spec/storage.go | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/pkg/spec/storage.go b/pkg/spec/storage.go index 404d94432..335907d12 100644 --- a/pkg/spec/storage.go +++ b/pkg/spec/storage.go @@ -855,21 +855,19 @@ func SupercedeUserMounts(mounts []spec.Mount, configMount []spec.Mount) []spec.M } // Ensure mount options on all mounts are correct -func InitFSMounts(inputMounts []spec.Mount) ([]spec.Mount, error) { +func InitFSMounts(mounts []spec.Mount) error { // We need to look up mounts so we can figure out the proper mount flags // to apply. systemMounts, err := pmount.GetMounts() if err != nil { - return nil, errors.Wrapf(err, "error retrieving system mounts to look up mount options") + return errors.Wrapf(err, "error retrieving system mounts to look up mount options") } - // TODO: We probably don't need to re-build the mounts array - var mounts []spec.Mount - for _, m := range inputMounts { + for i, m := range mounts { if m.Type == TypeBind { baseMnt, err := findMount(m.Source, systemMounts) if err != nil { - return nil, errors.Wrapf(err, "error looking up mountpoint for mount %s", m.Source) + return errors.Wrapf(err, "error looking up mountpoint for mount %s", m.Source) } var noexec, nosuid, nodev bool for _, baseOpt := range strings.Split(baseMnt.Opts, ",") { @@ -890,21 +888,19 @@ func InitFSMounts(inputMounts []spec.Mount) ([]spec.Mount, error) { opts, err := util.ProcessOptions(m.Options, false, defaultMountOpts) if err != nil { - return nil, err + return err } - m.Options = opts + mounts[i].Options = opts } if m.Type == TypeTmpfs && filepath.Clean(m.Destination) != "/dev" { opts, err := util.ProcessOptions(m.Options, true, nil) if err != nil { - return nil, err + return err } - m.Options = opts + mounts[i].Options = opts } - - mounts = append(mounts, m) } - return mounts, nil + return nil } // TODO: We could make this a bit faster by building a tree of the mountpoints |