Some loop device mount issues

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

 



Hi,

I have some issues about loop device based mounts.
I already work on patches for this, but first want to have some
feedback if the changes are reasonable, before proceeding.

1. Setting up the loop device does not canonicalize the file name
# losetup /dev/loop0 /tmp/volume
# cd /tmp; losetup /dev/loop1 volume
# cd /tmp; mkdir foo; cd foo; losetup /dev/loop2 ../volume
# losetup -a
/dev/loop0: [0803]:523558 (/tmp/volume)
/dev/loop1: [0803]:523558 (volume)
/dev/loop2: [0803]:523558 (../volume)

I think the setup function should canonicalize the loop filename,
for a better indication of the loop filename. In the above case
there is no indication, that these 3 files are actually the same.

2. When issuing a normal mount and mounting the same device on
the *same* mountpoint again, mount spits out a warning and
refuses to mount:

# mount /dev/sda7 /mnt/
# mount /dev/sda7 /mnt/
mount: /dev/sda7 already mounted or /mnt/ busy
mount: according to mtab, /dev/sda7 is mounted on /mnt

Note, this is not a problem when mounting the same device 
twice on *different* mount points.

Now, if you do the same (mounting the same 'device' on the
same mountpoint) with the -oloop option, mount does not warn,
because for each mount a new loop device is allocated, so we
are actually mount *different* devices:

# mount -oloop /tmp/volume /mnt/
# mount -oloop /tmp/volume /mnt/
# mount
/tmp/volume on /mnt type ext2 (rw,loop=/dev/loop0)
/tmp/volume on /mnt type ext2 (rw,loop=/dev/loop1)

This already came up in 1999 [1], where the general attitude has been,
that you should not do stupid things as root.

The problem is that you cannot just check the filename, because you might
have two loop device on the same file with different offsets.
So my proposal is to add at least a check for mount -oloop if a pair of
(filename, offset) is already in use (thats why we need 1. first, because
we need a full path for unique comparison). In case it is in use, the mount
will fail.

Any thoughts about this or something I have missed?

Matthias

[1] http://www.uwsg.iu.edu/hypermail/linux/kernel/9910.2/0389.html
-
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