Skip to content

Commit ae5ca81

Browse files
Refactor mount path check and add comments
Co-authored-by: Danail Branekov <[email protected]> Signed-off-by: Georgi Sabev <[email protected]>
1 parent c0f0b21 commit ae5ca81

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

mount/mount_linux.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,18 @@ func unmount(target string, flags int) error {
111111
// UnmountAll repeatedly unmounts the given mount point until there
112112
// are no mounts remaining (EINVAL is returned by mount), which is
113113
// useful for undoing a stack of mounts on the same mount point.
114+
// UnmountAll all is noop when the first argument is an empty string.
115+
// This is done when the containerd client did not specify any rootfs
116+
// mounts (e.g. because the rootfs is managed outside containerd)
117+
// UnmountAll is noop when the mount path does not exist.
114118
func UnmountAll(mount string, flags int) error {
115-
if _, err := os.Stat(mount); err != nil {
119+
if mount == "" {
116120
return nil
117121
}
122+
if _, err := os.Stat(mount); os.IsNotExist(err) {
123+
return nil
124+
}
125+
118126
for {
119127
if err := unmount(mount, flags); err != nil {
120128
// EINVAL is returned if the target is not a

0 commit comments

Comments
 (0)