Re: mount on tmpfs failing to parse context option

From: Karel Zak
Date: Tue Oct 08 2019 - 08:56:21 EST


On Tue, Oct 08, 2019 at 08:38:18PM +0800, Ian Kent wrote:
> > That's because the options in shmem_parse_options() are
> > "size=4G,nr_inodes=0", which indeed looks like an attempt to
> > retroactively limit size; but the user never asked "size=4G" there.
>
> I believe that's mount(8) doing that.
> I don't think it's specific to the new mount api.
>
> AFAIK it's not new but it does mean the that things that come
> through that have been found in mtab by mount(8) need to be
> checked against the current value before failing or ignored if
> changing them is not allowed.
>
> I wonder if the problem has been present for quite a while but
> gone unnoticed perhaps.
>
> IIUC the order should always be command line options last and it
> must be that way to honour the last specified option takes
> precedence convention.
>
> I thought this was well known, but maybe I'm wrong ... and TBH
> I wasn't aware of it until recently myself.

Yep, the common behavior is "the last option wins". See man mount,
remount option:

remount functionality follows the standard way the mount command
works with options from fstab. This means that mount does not read
fstab (or mtab) only when both device and dir are specified.

mount -o remount,rw /dev/foo /dir

After this call all old mount options are replaced and arbitrary
stuff from fstab (or mtab) is ignored, except the loop= option which
is internally generated and maintained by the mount command.

mount -o remount,rw /dir

After this call, mount reads fstab and merges these options with
the options from the command line (-o). If no mountpoint is found
in fstab, then a remount with unspeciâ fied source is allowed.


If you do not like this classic behavior than recent mount(8) versions
provide --options-mode={ignore,append,prepend,replace} to keep it in
your hands.


Karel

>
> >
> > Hugh
>

--
Karel Zak <kzak@xxxxxxxxxx>
http://karelzak.blogspot.com