]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
helpers/mount: Allow to specify explicit mount type and options
authorSebastian Krzyszkowiak <dos@dosowisko.net>
Thu, 10 Nov 2022 20:39:21 +0000 (21:39 +0100)
committerAlessandro Astone <ales.astone@gmail.com>
Thu, 12 Jan 2023 20:31:19 +0000 (21:31 +0100)
Also, set mount option to ro right away instead of relying on remount.

tools/helpers/mount.py

index fce103567648072646289a045fd28548d6f0434d..1d610373013e656904e440964730450e131d407d 100644 (file)
@@ -109,7 +109,7 @@ def umount_all(args, folder):
         if ismount(mountpoint):
             raise RuntimeError("Failed to umount: " + mountpoint)
 
         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.
     """
     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)
 
             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:
     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):
 
     # Verify, that it has worked
     if not ismount(destination):