Re: loopback device semantics and UNIX mount(2) philosophy.

Rogier Wolff (R.E.Wolff@BitWizard.nl)
Tue, 19 Oct 1999 11:25:32 +0200 (MEST)


Tigran Aivazian wrote:
> Hello,
>
> The mount(2) system call will refuse to mount a device if it is already
> mounted elsewhere. And rightly so. But mounting via loopback (-o loop)
> allows to mount the same file on different mount points which causes some
> unexpected results. I understand that this is because a
> different /dev/loopX is allocated for each instance, but shouldn't the
> mount fail even on a different /dev/loopX if it refers to a file already
> attached to some other /dev/loopY to simulate the normal mount(2)
> semantics?

Suppose I have

disk.img

with at two partitions.

Then I do

losetup -o 32256 /dev/loop0 disk.img
losetup -o 41126400 /dev/loop1 disk.img

and then mount loop0 and loop1.

It is very hard for the kernel to see that these are really different
parts of the same file, while if I had used the same offset in the
second case it would've been the same.

In short, you can mess up your system if you do stupid things being
logged in as "root".

Always has been. Always will be.

(From how you say things, I understand that you let "mount" do the
losetup for you. Fine. Behind the scenes, mount calls losetup just
like I did by hand here.... )

Roger.

-- 
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
 "I didn't say it was your fault. I said I was going to blame it on you."

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/