[Pkg-sysvinit-devel] Unexpected problem with /etc/mtab
-> /proc/mounts
Miquel van Smoorenburg
miquels at cistron.nl
Mon Jan 23 02:31:28 UTC 2006
On Mon, 2006-01-23 at 00:10 -0200, Henrique de Moraes Holschuh wrote:
> Hi Thomas!
>
> On Sat, 21 Jan 2006, Thomas Hood wrote:
>
> > Miquel van Smoorenburg wrote:
> > > Ehm, I haven't been following the development due to a chronic lack of
> > > time, but using /proc/mounts instead of /etc/mtab when umounting
> > > probably breaks loopback mounts.
> >
> >
> > I haven't tested unmounting it but loopback mounts do appear in /proc/mounts:
> >
> > sudo losetup /dev/loop/0 foo
> > sudo mke2fs /dev/loop/0
> > sudo mkdir /mnt/loop
> > sudo mount /dev/loop/0 /mnt/loop
> > cat /proc/mounts
> > [...]
> > /dev/loop/0 /mnt/loop ext2 rw,nogrpid 0 0
> >
> > How would the problem arise?
Because of mount -o loop foo /mnt/loop. In this case mount does the
losetup for you, and it records that fact in /etc/mtab. When you
umount /mnt/loop it also losetup -d's for you. You don't have that info
in /proc/mounts.
root at laptop:/mnt# mount -o loop /mnt/foo /mnt
root at laptop:/mnt# grep /mnt /etc/mtab
/mnt/foo /mnt ext3 rw,loop=/dev/loop0 0 0
root at laptop:/mnt# grep /mnt /proc/mounts
/dev/loop0 /mnt ext3 rw 0 0
See the difference ?
> I have been always told that /etc/mtab has MORE data about loopback mounts
> than /proc/mount, so you may have to compare them.
>
> I repeat my idea: we should parse /etc/mtab, THEN parse /proc/mounts (and
> that does mean read /proc/mounts only after completing /etc/mtab). That
> will take care of everything, I think.
You'll have to patch mount for that I guess ?
Mike.
More information about the Pkg-sysvinit-devel
mailing list