Re: [d_path 0/7] Fixes to d_path: Respin

Andreas Gruenbacher
2007-04-20T16:39:59Z

On Friday 20 April 2007 17:24, Ulrich Drepper wrote:
> On 4/20/07, Andreas Gruenbacher <agruen@suse.de> wrote:
> > Yes, that one, sorry. The values it obtains that way are not reliable.
>
> Why should the mount point info together with the filesystem type not
> be reliable?

Ah ... I overlooked that fstatvfs() also checks the device number, not only
the name, and so then it can find the right device from that.

So for how glibc uses /proc/mounts in fstatvfs(), hiding unreachable mount
points from /proc/mounts wouldn't improve things. The heuristic already
doesn't work for file descriptors from other namespaces, so it's already
broken unfortunately. A more robust mechanism for glibc to use would be nice;
not sure it would be worth it only for fstatvfs though.

The code also seems to stop at the first matching mount point. You can have
the same device mounted on the same mount point multiple times but with
different mount options, e.g.,

$ dd if=/dev/zero of=/var/tmp/ext2 bs=4096 count=16384
$ mkfs.ext2 -F /var/tmp/ext2
$ mount -o loop /var/tmp/ext2 /mnt
$ mount -o loop,ro /var/tmp/ext2 /mnt
$ tail -n 2 /proc/mounts
/dev/loop0 /mnt ext2 rw 0 0
/dev/loop1 /mnt ext2 ro 0 0

The topmost mount point appears last in /proc/mounts, and so unless I am
overlooking something else, that's another minor problem.

The third problem, as I already tried to argue several times now, is that the
mount points path that /proc/mounts reports may or may not actually exist.
That's a problem for glibc, and you should be one of the first to notice and
acknowledge that. I gave a chroot example that showed that in the current
implementation, you can get pretty random clashes between mounts; there are
other cases with lazy unmounts as well.

> You're trying to find an excuse to break tings, that seems all there is.

Now what makes you think that??

Andreas