svn commit: r320803 - head/sbin/mount

John Baldwin jhb at freebsd.org
Tue Jul 11 21:47:21 UTC 2017


On Tuesday, July 11, 2017 02:35:15 PM Ian Lepore wrote:
> I think the docs on this are pretty clear... under -u it says:
> 
>     The set of options is determined by applying the options specified
>     in the argument to -o and finally applying the -r or -w option.
> 
> To me, that says that nothing in /etc/fstab is germane to mount -u
> unless one of the other args to mount -u is -o fstab.
> 
> This change (r320803) seems like an acceptable workaround, but I think
> the correct long term fix would be to not even open /etc/fstab on mount
> -u without -o fstab.  But that may be harder to do than to say; I still
> haven't actually looked at the code involved.

I concur with this.  I've always viewed '-u' as meaning "apply a delta
to the current configuration", not "add this delta to the fstab options
and then apply that entire set of options".   In practice, it seems that
it doesn't do either of those, but instead it seems to treats the options
passed to -o as the entire list of options.  This is perhaps a bit
surprising.

For example, suppose you had this:

/etc/fstab:

/dev/md0        /bar            ufs     ro,noauto,noexec        0       0

# mount /bar
# mount | grep bar
/dev/md0 on /bar (ufs, local, noexec, read-only)
# mount -u -o rw /bar
/dev/md0 on /bar (ufs, local)

(We just lost "noexec" from fstab by upgrading to read-write)

# mount -u -o nosuid /bar
# mount | grep bar
/dev/md0 on /bar (ufs, local, nosuid)

(Did not lose "read-write" somehow, RO vs RW must be magically sticky?)

# mount -u -o fstab,nosuid /bar
# mount |grep bar
/dev/md0 on /bar (ufs, local, noexec, nosuid)

(Did not honor "ro" from fstab!  Left mount RW)

It would seem that there is no actual rhyme or reason to how mount -u works,
and certainly Edward's change doesn't make it worse.  I would like to have
some kind of mode where you can toggle one or more options without disturbing
others.  Maybe if we had a new "special" option called "current" or some such
that is like "fstab" but instead represents the options currently in force,
then you could do true delta operations via 'mount -o current,rw -u /foo'.
As it is, there doesn't currently seem to a reliable way to achieve that
functionality.

(I started this mail expecting that '-u' operated by performing deltas against
the current configuration and was quite Astonished to discover the actual
behavior.  It seems very unsafe to use mount -u if you have any options in
your fstab outside of things like "noauto" or "late".)

-- 
John Baldwin


More information about the svn-src-head mailing list