From af092544d2b3c8809874251bd5fe05ae6d0e3be2 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 20 Jul 2010 11:37:23 +0200 Subject: [PATCH] mount: don't use auto-clear loopdev if mtab is available # mount /home/images/floppy.img /mnt/test2 # mount | grep loop /dev/loop0 on /mnt/test2 type udf (rw) mount(8) with auto-clear loopdev does not store information about the original backing file (the image) to /etc/mtab. (Note that this is our long-term goal, because we want to remove mtab from Linux.) Unfortunately, losetup(8) is not able to provide full path for the backing file, because LOOP_GET_STATUS ioctl uses 64 bytes for the filename... So, without the information about the backing file in mtab the information about mapping between the file and the loopdev is unaccessible from userspace. From my point of view it would be nice to add all necessary information about loopdevs to /sys rather than rely on broken LOOP_GET_STATUS[64] ioctls. with this patch: # mount /home/images/floppy.img /mnt/test2 # mount | grep loop# mount | grep loop /home/images/floppy.img on /mnt/test2 type udf (ro,loop=/dev/loop0) Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=615389 Signed-off-by: Karel Zak --- mount/mount.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mount/mount.c b/mount/mount.c index b2e445a4..fef1a852 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -1141,7 +1141,8 @@ loop_check(const char **spec, const char **type, int *flags, if (verbose) printf(_("mount: skipping the setup of a loop device\n")); } else { - int loop_opts = SETLOOP_AUTOCLEAR; /* always attempt autoclear */ + /* use autoclear loopdev on system without regular mtab only */ + int loop_opts = mtab_is_writable() ? 0 : SETLOOP_AUTOCLEAR; int res; if (*flags & MS_RDONLY) -- 2.39.5