mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
mount.Unmount(): don't look into /proc/self/mountinfo
Now, every Unmount() call takes a burden to parse the whole nine yards of /proc/self/mountinfo to figure out whether the given mount point is mounted or not (and returns an error in case parsing fails somehow). Instead, let's just call umount() and ignore EINVAL, which results in the same behavior, but much better performance. Note that EINVAL is returned from umount(2) not only in the case when `target` is not mounted, but also for invalid flags. As the flags are hardcoded here, it can't be the case. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
c611f18a7f
commit
a1d095199d
1 changed files with 5 additions and 4 deletions
|
@ -3,7 +3,6 @@ package mount // import "github.com/docker/docker/pkg/mount"
|
|||
import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"syscall"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -90,10 +89,12 @@ func ForceMount(device, target, mType, options string) error {
|
|||
// Unmount lazily unmounts a filesystem on supported platforms, otherwise
|
||||
// does a normal unmount.
|
||||
func Unmount(target string) error {
|
||||
if mounted, err := Mounted(target); err != nil || !mounted {
|
||||
return err
|
||||
err := unmount(target, mntDetach)
|
||||
if err == syscall.EINVAL {
|
||||
// ignore "not mounted" error
|
||||
err = nil
|
||||
}
|
||||
return unmount(target, mntDetach)
|
||||
return err
|
||||
}
|
||||
|
||||
// RecursiveUnmount unmounts the target and all mounts underneath, starting with
|
||||
|
|
Loading…
Reference in a new issue