diff options
author | Maciej Żenczykowski <maze@google.com> | 2020-05-15 14:12:30 -0700 |
---|---|---|
committer | Maciej Żenczykowski <maze@google.com> | 2020-05-15 21:27:10 +0000 |
commit | 6f6675fe292bba25b36bc13ab1ea57e7b0133f82 (patch) | |
tree | 8ae7649c309acab0e3b2180ef2e0fc8b3f6212bd /net/test | |
parent | 5793ff852ddb3fbd5c963c74d7717f025573f304 (diff) | |
download | kernel_tests-6f6675fe292bba25b36bc13ab1ea57e7b0133f82.tar.gz kernel_tests-6f6675fe292bba25b36bc13ab1ea57e7b0133f82.tar.bz2 kernel_tests-6f6675fe292bba25b36bc13ab1ea57e7b0133f82.zip |
net-test: namespace support lib - use 'lazy' umount
This makes umount succeed even if stuff is mounted below the mount point.
vm:~# unshare -u -m -n -- bash -c 'umount -l /proc; mount -t proc proc /proc; umount -l /sys; mount -t sysfs sys /sys; egrep " /(proc|sys)" < /proc/mounts'
proc /proc proc rw 0 0
sys /sys sysfs rw 0 0
which fails without the 2 -l's:
[pid X] umount("/proc", 0) = -1 EBUSY (Device or resource busy)
umount: /proc: target is busy
(In some cases useful info about processes that
use the device is found by lsof(8) or fuser(1).)
[pid X] umount("/sys", 0) = -1 EBUSY (Device or resource busy)
umount: /sys: target is busy
(In some cases useful info about processes that
use the device is found by lsof(8) or fuser(1).)
due to (among other things): /proc/bus/usb and /sys/fs/bpf being mounted.
Test: ran uml net tests against Android Common Kernel 4.14-stable ('r')
Bug: 149894399
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4957722e109cfd55c8efa55ebd8f718bd049a811
Diffstat (limited to 'net/test')
-rw-r--r-- | net/test/namespace.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/net/test/namespace.py b/net/test/namespace.py index 4533b5d0..11448920 100644 --- a/net/test/namespace.py +++ b/net/test/namespace.py @@ -22,6 +22,12 @@ import os import net_test +# //include/linux/fs.h +MNT_FORCE = 1 # Attempt to forcibily umount +MNT_DETACH = 2 # Just detach from the tree +MNT_EXPIRE = 4 # Mark for expiry +UMOUNT_NOFOLLOW = 8 # Don't follow symlink on umount + # //include/uapi/linux/fs.h MS_RDONLY = 1 # Mount read-only MS_NOSUID = 2 # Ignore suid and sgid bits @@ -62,7 +68,7 @@ libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True) libc.mount.argtypes = (ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_void_p) libc.sethostname.argtype = (ctypes.c_char_p, ctypes.c_size_t) -libc.umount.argtypes = (ctypes.c_char_p,) +libc.umount2.argtypes = (ctypes.c_char_p, ctypes.c_int) libc.unshare.argtypes = (ctypes.c_int,) @@ -75,12 +81,12 @@ def Mount(src, tgt, fs, flags=MS_NODEV|MS_NOEXEC|MS_NOSUID|MS_RELATIME): def ReMountProc(): - libc.umount('/proc') # Ignore failure: might not be mounted + libc.umount2('/proc', MNT_DETACH) # Ignore failure: might not be mounted Mount('proc', '/proc', 'proc') def ReMountSys(): - libc.umount('/sys') # Ignore failure: might not be mounted + libc.umount2('/sys', MNT_DETACH) # Ignore failure: might not be mounted Mount('sysfs', '/sys', 'sysfs') |