]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
helpers/mount: Add an option to mount even if mount point already exists
authorSebastian Krzyszkowiak <dos@dosowisko.net>
Thu, 10 Nov 2022 20:55:44 +0000 (21:55 +0100)
committerAlessandro Astone <ales.astone@gmail.com>
Thu, 12 Jan 2023 20:31:19 +0000 (21:31 +0100)
This is needed for mounting overlays on top of existing mount points.

tools/helpers/mount.py

index 1d610373013e656904e440964730450e131d407d..2660952696a156b2b0e266be58feb6098c12baf5 100644 (file)
@@ -109,17 +109,20 @@ 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, mount_type=None, options=None):
+def mount(args, source, destination, create_folders=True, umount=False,
+          readonly=True, mount_type=None, options=None, force=True):
     """
     Mount and create necessary directory structure.
     :param umount: when destination is already a mount point, umount it first.
+    :param force: attempt mounting even if the mount point already exists.
     """
     # Check/umount destination
     if ismount(destination):
         if umount:
             umount_all(args, destination)
         else:
-            return
+            if not force:
+                return
 
     # Check/create folders
     if not os.path.exists(destination):