From abe8dad3449b38dee845358d0da5ababa8d8c157 Mon Sep 17 00:00:00 2001 From: Doug Rabson Date: Tue, 20 Sep 2022 11:30:12 +0100 Subject: libpod: Factor out usage of unix.MNT_DETACH from (*Volume).unmount There is an existing wrapper for unix.Unmount(..., MNT_DETACH) in util_linux.go but that filters all errors and for volumes, we only want to filter EINVAL. The existing libpod.Unmount seems to only have one call site so perhaps these can be merged. [NO NEW TESTS NEEDED] Signed-off-by: Doug Rabson --- libpod/volume_internal_common.go | 2 +- libpod/volume_internal_linux.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 libpod/volume_internal_linux.go diff --git a/libpod/volume_internal_common.go b/libpod/volume_internal_common.go index 440bceec3..c85782e4b 100644 --- a/libpod/volume_internal_common.go +++ b/libpod/volume_internal_common.go @@ -180,7 +180,7 @@ func (v *Volume) unmount(force bool) error { } // Unmount the volume - if err := unix.Unmount(v.config.MountPoint, unix.MNT_DETACH); err != nil { + if err := detachUnmount(v.config.MountPoint); err != nil { if err == unix.EINVAL { // Ignore EINVAL - the mount no longer exists. return nil diff --git a/libpod/volume_internal_linux.go b/libpod/volume_internal_linux.go new file mode 100644 index 000000000..eb4309dc3 --- /dev/null +++ b/libpod/volume_internal_linux.go @@ -0,0 +1,9 @@ +package libpod + +import ( + "golang.org/x/sys/unix" +) + +func detachUnmount(mountPoint string) error { + return unix.Unmount(mountPoint, unix.MNT_DETACH) +} -- cgit v1.2.3-54-g00ecf