]> glassweightruler.freedombox.rocks Git - waydroid.git/blobdiff - tools/helpers/mount.py
helpers/mount: Allow to specify explicit mount type and options
[waydroid.git] / tools / helpers / mount.py
index fdf647776b3412781757c3388da26b4b6bd7063c..1d610373013e656904e440964730450e131d407d 100644 (file)
@@ -102,12 +102,14 @@ def umount_all(args, folder):
     """
     Umount all folders, that are mounted inside a given folder.
     """
-    for mountpoint in umount_all_list(folder):
+    all_list = umount_all_list(folder)
+    for mountpoint in all_list:
         tools.helpers.run.user(args, ["umount", mountpoint])
+    for mountpoint in all_list:
         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.
@@ -127,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):