summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2020-05-16 05:36:05 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-05-16 05:36:05 +0000
commitd08f8906961877a4949a5e5a99f576aa880687e3 (patch)
tree8ae7649c309acab0e3b2180ef2e0fc8b3f6212bd
parent1a0e5a2b8d70c9284c013f53eb39fb6e4fa271ff (diff)
parent1e25f89c47e85fca63b273405b36c9fb709a6456 (diff)
downloadtests-d08f8906961877a4949a5e5a99f576aa880687e3.tar.gz
net-test: namespace support lib - use 'lazy' umount am: f3a01a9c9f am: 1e25f89c47
Change-Id: Ia602c358c39682cfe200a9471fffa0a022a8da86
-rw-r--r--net/test/namespace.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/net/test/namespace.py b/net/test/namespace.py
index 4533b5d..1144892 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')