[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <200610281537.07145.rob@landley.net>
Date: Sat, 28 Oct 2006 15:37:06 -0400
From: Rob Landley <rob@...dley.net>
To: linux-kernel@...r.kernel.org
Subject: Problems with /proc/mounts and statvfs (implementing df).
I'm trying to implement a df command that works based on /proc/mounts and
statvfs. To make this work, I need to be able to detect duplicate mounts
(including --bind mounts), and I need to be able to detect overmounted
filesystems.
Problem #1: mount --move doesn't reorder /proc/mounts.
My first naieve idea was to reverse the order of entries in /proc/mounts and
do simple string comparisons on the directory names to detect overmounts. An
example of why this doesn't work is in ubuntu 6.06, where "/proc" and "/sys"
get mounted from initramfs, then the new root (/dev/hda1 in my case) is
mounted after that, and the proc and sys mounts are "mount --move"d under
that. So they're before the current "/" in the /proc/mounts order, but
they've been moved under that mount anyway. It would be really nice if
mount --move would reorder /proc/mounts when the new parent filesystem is
after the old one in the list. (Another thing that depends on this to work
is "umount -a", which can't umount "/" in this case either because /proc
and /sys are still under it.)
In theory I can work around this by just having umount -a loop until
everything's unmounted (which is ugly), and by having df call statvfs on
everything and discard duplicate f_fsid entries (although with mount --move
it can still find the wrong entry mounted at a given mount point, but at
least this can filter sub-mounts and restricts the problem to direct
overmounts).
Problem #2: statfs() and statvfs() are returning 0 in the f_fsid.
What's the recommended way to detect --bind mounts or duplicate mounts? A df
command needs to know "these two mount points are in the same filesystem",
and according to the man pages there's supposed to be a unique identifier for
each filesystem.
The man page suggested that this was crippled to work around yet another
design flaw in NFS, but I tried doing it as root and still got 0 for all the
filesystems. (Not that setting the suid bit on the df command struck me as a
good solution.)
Any suggestions? (All this was done on the ubuntu 6.06 kernel. Will it make
a difference to try 2.6.19-rc3?)
Rob
--
"Perfection is reached, not when there is no longer anything to add, but
when there is no longer anything to take away." - Antoine de Saint-Exupery
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists