From: Sebastian Krzyszkowiak Date: Thu, 10 Nov 2022 20:55:44 +0000 (+0100) Subject: helpers/mount: Add an option to mount even if mount point already exists X-Git-Tag: 1.4.0~49 X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/waydroid.git/commitdiff_plain/e2f4f942f28d3a7132cd29d047a0a243c867a089 helpers/mount: Add an option to mount even if mount point already exists This is needed for mounting overlays on top of existing mount points. --- diff --git a/tools/helpers/mount.py b/tools/helpers/mount.py index 1d61037..2660952 100644 --- a/tools/helpers/mount.py +++ b/tools/helpers/mount.py @@ -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):