os.Unmount: do not consult mountinfo, drop flags
1. Currently, 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. This also introduces a slight change: in case target does not exist, the appropriate error (ENOENT) is returned -- document that. 2. As Unmount() is always used with MNT_DETACH flag, let's drop the flags argument. This way, the only reason of EINVAL returned from umount(2) can only be "target is not mounted". 3. While at it, remove the 'containerdmount' alias from the package. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -49,7 +49,7 @@ type FakeOS struct {
|
||||
CopyFileFn func(string, string, os.FileMode) error
|
||||
WriteFileFn func(string, []byte, os.FileMode) error
|
||||
MountFn func(source string, target string, fstype string, flags uintptr, data string) error
|
||||
UnmountFn func(target string, flags int) error
|
||||
UnmountFn func(target string) error
|
||||
LookupMountFn func(path string) (containerdmount.Info, error)
|
||||
calls []CalledDetail
|
||||
errors map[string]error
|
||||
@@ -230,14 +230,14 @@ func (f *FakeOS) Mount(source string, target string, fstype string, flags uintpt
|
||||
}
|
||||
|
||||
// Unmount is a fake call that invokes UnmountFn or just return nil.
|
||||
func (f *FakeOS) Unmount(target string, flags int) error {
|
||||
f.appendCalls("Unmount", target, flags)
|
||||
func (f *FakeOS) Unmount(target string) error {
|
||||
f.appendCalls("Unmount", target)
|
||||
if err := f.getError("Unmount"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if f.UnmountFn != nil {
|
||||
return f.UnmountFn(target, flags)
|
||||
return f.UnmountFn(target)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user