2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 13:58:34 +00:00

criu-ns: Extract mount new /proc into a function

By extracting this code into a function the main code becomes
smaller and more obvious.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
Radostin Stoyanov
2020-12-21 20:25:47 +00:00
committed by Andrei Vagin
parent a0a02c73e7
commit a08aa44064

View File

@@ -56,6 +56,18 @@ else:
_umount.restype = ctypes.c_int
def _mount_new_proc():
"""
Mount new /proc filesystem.
"""
if _mount(None, b"/", None, MS_SLAVE|MS_REC, None):
_errno = ctypes.get_errno()
raise OSError(_errno, errno.errorcode[_errno])
if _mount(b'proc', b'/proc', b'proc', 0, None):
_errno = ctypes.get_errno()
raise OSError(_errno, errno.errorcode[_errno])
def run_criu():
print(sys.argv)
os.execlp('criu', *['criu'] + sys.argv[1:])
@@ -69,14 +81,7 @@ def wrap_restore():
criu_pid = os.fork()
if criu_pid == 0:
# Mount new /proc
if _mount(None, b"/", None, MS_SLAVE|MS_REC, None) != 0:
_errno = ctypes.get_errno()
raise OSError(_errno, errno.errorcode[_errno])
if _mount(b'proc', b'/proc', b'proc', 0, None) != 0:
_errno = ctypes.get_errno()
raise OSError(_errno, errno.errorcode[_errno])
_mount_new_proc()
# Spawn CRIU binary
run_criu()