diff options
Diffstat (limited to 'src/utils/fs.py')
-rw-r--r-- | src/utils/fs.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/utils/fs.py b/src/utils/fs.py index 381f65b..d6cf36a 100644 --- a/src/utils/fs.py +++ b/src/utils/fs.py @@ -29,7 +29,7 @@ def find_mountpoint(path): return path -def mount_mkdir(source, target): +def mount_mkdir(source, target, readonly=False): """ Mounts and creates the mountpoint directory if it's not present. @@ -43,18 +43,21 @@ def mount_mkdir(source, target): return False if not os.path.ismount(target): - return mount(source, target) + return mount(source, target, readonly) return True -def mount(source, target): +def mount(source, target, readonly): """ Mounts source into target directoru using mount(8). Return true if exit code is 0. False otherwise. """ - cmd = f'mount {source} {target}' + if readonly: + cmd = f'mount -o ro {source} {target}' + else: + cmd = f'mount {source} {target}' proc = subprocess.run(cmd.split(), stderr=DEVNULL) return not proc.returncode |