From: Sebastian Krzyszkowiak Date: Thu, 10 Nov 2022 20:39:21 +0000 (+0100) Subject: helpers/mount: Allow to specify explicit mount type and options X-Git-Tag: 1.4.0~50 X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/waydroid.git/commitdiff_plain/e620e51bbb86b3fc2776e4d041df928391f944ab helpers/mount: Allow to specify explicit mount type and options Also, set mount option to ro right away instead of relying on remount. --- diff --git a/tools/helpers/mount.py b/tools/helpers/mount.py index fce1035..1d61037 100644 --- a/tools/helpers/mount.py +++ b/tools/helpers/mount.py @@ -109,7 +109,7 @@ def umount_all(args, folder): if ismount(mountpoint): raise RuntimeError("Failed to umount: " + mountpoint) -def mount(args, source, destination, create_folders=True, umount=False, readonly=True): +def mount(args, source, destination, create_folders=True, umount=False, readonly=True, mount_type=None, options=None): """ Mount and create necessary directory structure. :param umount: when destination is already a mount point, umount it first. @@ -129,10 +129,19 @@ def mount(args, source, destination, create_folders=True, umount=False, readonly raise RuntimeError("Mount failed, folder does not exist: " + destination) - # Actually mount the folder - tools.helpers.run.user(args, ["mount", source, destination]) + extra_args = [] + opt_args = [] + if mount_type: + extra_args.extend(["-t", mount_type]) if readonly: - tools.helpers.run.user(args, ["mount", "-o", "remount,ro", source, destination]) + opt_args.append("ro") + if options: + opt_args.extend(options) + if opt_args: + extra_args.extend(["-o", ",".join(opt_args)]) + + # Actually mount the folder + tools.helpers.run.user(args, ["mount", *extra_args, source, destination]) # Verify, that it has worked if not ismount(destination):