The function is being used in a number of places, notably container
removal and cleanup. While container removal already loops over EBUSY,
cleanup does not.
To make sure that all callers of Unmount get a fair chance of unmounting
cleanly, also loop there. I used the same values as containerd: 50
loops with 50ms sleeps.
Context: containers/podman/issues/11594
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
The errors returned from Mount and Unmount functions are raw
syscall.Errno errors (like EPERM or EINVAL), which provides
no context about what has happened and why.
Similar to os.PathError type, introduce mount.Error type
with some context. The error messages will now look like this:
> mount /tmp/mount-tests/source:/tmp/mount-tests/target, flags: 0x1001: operation not permitted
or
> mount tmpfs:/tmp/mount-test-source-516297835: operation not permitted
Before this patch, it was just
> operation not permitted
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1. There is absolutely no need to consult /proc/self/mountinfo
before calling umount(2) -- it's easier to go ahead and ignore
EINVAL.
Here, EINVAL can mean two things:
- the path argument is not a mount point (i.e. it's not mounted)
- the flags argument is invalid (i.e. bad flags)
We assume we never pass the wrong flags to umount(2), so
EINVAL means "not mounted" and can safely be ignored.
This should speed up Umount() a lot.
2. For every Unix, umount is implemented in the same way,
so let's consolidate the umount code.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>