loopdev auto-clear flag vs. /etc/mtab

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 Hi,

 unfortunately SUSE and RHEL users don't like the auto-clear support
 for loopdevs in mount(8), because there is not information about
 the mapping between backing file and the device. 
 
 The original patch with auto-clear support:

   http://thread.gmane.org/gmane.linux.utilities.util-linux-ng/840/focus=1300

 The patch below is temporary solution, the real solution must be
 something better than store information about the backing file to
 /etc/mtab.
 
 My suggestion is to use /sys as alternative to useless
 LOOP_GET_STATUS ioctl, something like:

    /sys/block/<devname>/loop/backing_file
    /sys/block/<devname>/loop/offset
    /sys/block/<devname>/loop/sizelimit
    /sys/block/<devname>/loop/autoclear

 I think /sys more usable for userspace (non-root, udev, ...).
 Comments?

  Karel


>From af092544d2b3c8809874251bd5fe05ae6d0e3be2 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@xxxxxxxxxx>
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 <kzak@xxxxxxxxxx>
---
 mount/mount.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/mount/mount.c b/mount/mount.c
index b2e445a..fef1a85 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)
-- 
1.6.6.1

--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux