diff options
Diffstat (limited to 'sandboxlib/chroot.py')
-rw-r--r-- | sandboxlib/chroot.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/sandboxlib/chroot.py b/sandboxlib/chroot.py index b5d2da5..9724368 100644 --- a/sandboxlib/chroot.py +++ b/sandboxlib/chroot.py @@ -101,8 +101,18 @@ def mount(source, path, mount_type, mount_options): # little sad. It's possible to call the libc's mount() function # directly from Python using the 'ctypes' library, and perhaps we # should do that instead. - argv = [ - 'mount', '-t', mount_type, '-o', mount_options, source, path] + def is_none(value): + return value in (None, 'none', '') + + argv = ['mount'] + if not is_none(mount_type): + argv.extend(('-t', mount_type)) + if not is_none(mount_options): + argv.extend(('-o', mount_options)) + if not is_none(source): + argv.append(source) + argv.append(path) + exit, out, err = sandboxlib._run_command( argv, stdout=sandboxlib.CAPTURE, stderr=sandboxlib.CAPTURE) @@ -137,7 +147,8 @@ def mount_all(rootfs_path, mount_info_list): os.makedirs(path) mount(source, path, mount_type, mount_options) - mounted.append(path) + if not mount_options or 'remount' not in mount_options: + mounted.append(path) yield finally: |