]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: support X-mount.noloop
authorKarel Zak <kzak@redhat.com>
Tue, 19 Nov 2024 10:54:00 +0000 (11:54 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 19 Nov 2024 10:54:00 +0000 (11:54 +0100)
libmount automatically creates a loop device and mounts it if the
source of the mount is a regular file that contains a well-known
filesystem. However, in some cases, this feature may be unwanted. The
new mount option "X-mount.noloop" forces libmount to use the file
directly as the mount source.

Addresses: https://github.com/util-linux/util-linux/pull/3288
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/hook_loopdev.c
sys-utils/mount.8.adoc

index c01d536ce1520c56ec73c88ca1debad42c007ec2..a19ddab3be4b6ec1d368ed98a2b8b905f7a08a4e 100644 (file)
@@ -423,6 +423,9 @@ static int is_loopdev_required(struct libmnt_context *cxt, struct libmnt_optlist
            || mnt_context_propagation_only(cxt))
                return 0;
 
+       if (mnt_optlist_get_named(ol, "X-mount.noloop", cxt->map_userspace))
+               return 0;
+
        src = mnt_fs_get_srcpath(cxt->fs);
        if (!src)
                return 0;               /* backing file not set */
index f25c1c488a53f5db76d828e8ae379a8aea42d0ef..3a458c52e4b980aeba478bd1469af2dcf594236c 100644 (file)
@@ -760,7 +760,10 @@ The command line option *--no-canonicalize* overrides this mount option and affe
 +
 Note that *mount*(8) still sanitizes and canonicalizes the source and target paths specified on the command line by non-root users, regardless of the X-mount.nocanonicalize setting.
 
-**X-mount.subdir=**__directory__::
+*X-mount.noloop*::
+Do not create and mount a loop device, even if the source of the mount is a regular file.
+
+*X-mount.subdir=*__directory__::
 Allow mounting sub-directory from a filesystem instead of the root directory. For now, this feature is implemented by temporary filesystem root directory mount in unshared namespace and then bind the sub-directory to the final mount point and umount the root of the filesystem. The sub-directory mount shows up atomically for the rest of the system although it is implemented by multiple *mount*(2) syscalls.
 +
 Note that this feature will not work in session with an unshared private mount namespace (after *unshare --mount*) on old kernels or with *mount*(8) without support for file-descriptors-based mount kernel API. In this case, you need *unshare --mount --propagation shared*.