On Mon, Dec 26, 2011 at 03:38:33PM -0500, Dave Reisner wrote:
On Mon, Dec 26, 2011 at 05:21:49PM -0300, Gerardo Exequiel Pozzi wrote:
Hello
I recently discovered an issue when _not_ using "none" as source of nodev filesystems. For example in our default fstab for /tmp as source is used "tmp". If you run "mount -a" under a directory with a "tmp" directory, /tmp will be mounted again as tmpfs with "fake source" as $PWD/tmp:
# mount | grep /tmp tmp on /tmp type tmpfs (rw,relatime) # pwd /root # mkdir tmp # mount -a # mount | grep /tmp tmp on /tmp type tmpfs (rw,relatime) /root/tmp on /tmp type tmpfs (rw,relatime)
It's insane behavior, and should be fixed in util-linux.
But if using special keyword "none" as source this does not happen.
# mount | grep /tmp none on /tmp type tmpfs (rw,relatime) # pwd /root # mkdir none # mount -a # mount | grep /tmp none on /tmp type tmpfs (rw,relatime)
In the past (when /etc/mtab was not linked to /proc/self/mounts) weird behaviours appears when using "none" as source, but now seems that works fine.
Yeah... I can tell you from looking through the sources for libmount and mount that "none" is treated specially, and generally results in functions returning NULL. If you recall the problem we ran into with mountpoint from u-l segfaulting in AIF, it was in part because of using "none" for the mounts (and dereferencing the NULL return).
Other ways to workaround this is using the same path as source. I think we can also change source to "none" of /dev /run /proc /dev/shm and /dev/pts, looks like more correct. (or using the same path as source).
Correct? I disagree. It shouldn't matter what you call it -- the behavior should be consistent (unless I'm horribly misinformed). Again, blame where blame is due. In the case of a 'nodev' filesystem, the source should just be flat out ignored.
d
I tested using none in all nodev fs and shutdown is clean without errors. what do you think?
-- Gerardo Exequiel Pozzi \cos^2\alpha + \sin^2\alpha = 1
Quick update... Just as I suspected, libmount will always try to canonicalize the source of a device with no regard for what it is. This is a simple change. This is a simple change in the fstab parsing to always trust the source when you encounter a pseudofs (such as tmpfs, cgroup, rpc_pipefs, etc). Patch for this will go out by the end of the night regardless of the mayhem that follows... Digging into this further -- you don't even need to mount /tmp to duplicate the bad behavior, e.g. # echo 'foo /foo tmpfs defaults 0 0' >> /etc/fstab # cd /root # mkdir foo # mount -a ...and you'll have a tmpfs on /root/foo. I'm not sure yet if this can be worked around. Seems really ugly... almost like mount(2) might be at fault here and there isn't much libmount can do. d