diff options
author | Sebastiaan van Stijn <github@gone.nl> | 2020-09-19 18:45:41 +0200 |
---|---|---|
committer | Sebastiaan van Stijn <github@gone.nl> | 2020-10-29 23:00:16 +0100 |
commit | 182795cff6bbeb93090b5b973cf5b07884e8c5b8 (patch) | |
tree | 6e75d0e7309d8fe8ca29ffb1a5344dca8d061409 /volume | |
parent | bb23f1bf61cb49c5aa3f7df934d79c305afb7c8c (diff) | |
download | docker-182795cff6bbeb93090b5b973cf5b07884e8c5b8.tar.gz |
Do not call mount.RecursiveUnmount() on Windows
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'volume')
-rw-r--r-- | volume/local/local.go | 20 | ||||
-rw-r--r-- | volume/local/local_unix.go | 17 | ||||
-rw-r--r-- | volume/local/local_windows.go | 5 |
3 files changed, 25 insertions, 17 deletions
diff --git a/volume/local/local.go b/volume/local/local.go index bf97e181e1..89252cf627 100644 --- a/volume/local/local.go +++ b/volume/local/local.go @@ -18,8 +18,6 @@ import ( "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/quota" "github.com/docker/docker/volume" - "github.com/moby/sys/mount" - "github.com/moby/sys/mountinfo" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -96,9 +94,9 @@ func New(scope string, rootIdentity idtools.Identity) (*Root, error) { if !reflect.DeepEqual(opts, optsConfig{}) { v.opts = &opts } - - // unmount anything that may still be mounted (for example, from an unclean shutdown) - mount.Unmount(v.path) + // unmount anything that may still be mounted (for example, from an + // unclean shutdown). This is a no-op on windows + unmount(v.path) } } @@ -347,18 +345,6 @@ func (v *localVolume) Unmount(id string) error { return v.unmount() } -func (v *localVolume) unmount() error { - if v.needsMount() { - if err := mount.Unmount(v.path); err != nil { - if mounted, mErr := mountinfo.Mounted(v.path); mounted || mErr != nil { - return errdefs.System(err) - } - } - v.active.mounted = false - } - return nil -} - func (v *localVolume) Status() map[string]interface{} { return nil } diff --git a/volume/local/local_unix.go b/volume/local/local_unix.go index 9d4b37f53e..c8163ccd13 100644 --- a/volume/local/local_unix.go +++ b/volume/local/local_unix.go @@ -18,6 +18,7 @@ import ( "github.com/docker/docker/quota" units "github.com/docker/go-units" "github.com/moby/sys/mount" + "github.com/moby/sys/mountinfo" "github.com/pkg/errors" ) @@ -111,6 +112,10 @@ func validateOpts(opts map[string]string) error { return nil } +func unmount(path string) { + _ = mount.Unmount(path) +} + func (v *localVolume) needsMount() bool { if v.opts == nil { return false @@ -157,6 +162,18 @@ func (v *localVolume) postMount() error { return nil } +func (v *localVolume) unmount() error { + if v.needsMount() { + if err := mount.Unmount(v.path); err != nil { + if mounted, mErr := mountinfo.Mounted(v.path); mounted || mErr != nil { + return errdefs.System(err) + } + } + v.active.mounted = false + } + return nil +} + func (v *localVolume) CreatedAt() (time.Time, error) { fileInfo, err := os.Stat(v.path) if err != nil { diff --git a/volume/local/local_windows.go b/volume/local/local_windows.go index b05510d098..9fc2092720 100644 --- a/volume/local/local_windows.go +++ b/volume/local/local_windows.go @@ -39,6 +39,11 @@ func (v *localVolume) needsMount() bool { func (v *localVolume) mount() error { return nil } +func (v *localVolume) unmount() error { + return nil +} + +func unmount(_ string) {} func (v *localVolume) postMount() error { return nil |