]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libmount: use autofs mount hint to ignore autofs mount entries
authorIan Kent <raven@themaw.net>
Thu, 24 Nov 2022 08:54:19 +0000 (16:54 +0800)
committerKarel Zak <kzak@redhat.com>
Tue, 29 Nov 2022 10:14:29 +0000 (11:14 +0100)
commit22147e08c98731a9c5fe284ab3063b46347ec579
tree282ff51010aa7392be89cdebdd0d5596d6fa8ec8
parentd739298044c5f83b12965676edbb94d78af7312e
libmount: use autofs mount hint to ignore autofs mount entries

Historically autofs mounts were not included in mount table listings.
This is the case in other SysV autofs implementations and was also
the case with Linux autofs.

But now that /etc/mtab is a symlink to the proc filesystem mount
table the autofs mount entries appear in the mount table on Linux.

Prior to the symlinking of /etc/mtab mount table it was sufficient
to call mount(2) and simply not update /etc/mtab to exclude autofs
mounts from mount listings.

Also, with this symlinking of /etc/mtab we have seen a shift in usage
toward using the proc mount tables directly.

But the autofs mount entries need to be retained when coming from the
proc file system for applications that need them (such as systemd) so
filtering out these entries within the kernel itself can't be done,
it needs be done in user space.

There are three reasons to omit the autofs mount entries.

One is that certain types of auto-mounts have an autofs mount for every
entry in their autofs mount map (autofs direct mounts) and these maps
can be quite large. This leads to mount table listings containing a lot
of unnecessary entries.

Also, this difference in behaviour between autofs implementations can
cause problems for applications that need to use the mount table and
expect autofs entries aren't present.

Lastly, there's very little that user space can do with autofs mount
entries since this must be left to the autofs mount owner, typically
the automount daemon. And it can also lead to attempts to access
automount managed paths resulting in mounts being triggered when they
aren't needed or mounts staying mounted for much longer thay they
need to be.

So the Linux autofs file system has been modified to accept a pseudo
mount option of "ignore" (as is used in other OS implementations) so
that user space utilities can use this as a hint to skip these autofs
entries on reading the mount table.

The Linux autofs automount daemon used getmntent(3) itself and has been
modified to use the proc file system directly so that it isn't affected
by the presence of the "ignore" mount option.

The use of the "ignore" mount option is opt-in by autofs users and a
configuration option has been added which defaults to not use the option
so if there are applications that need these entries, other than autofs
itself, they can be retained. Also, since this filtering is based on an
added mount option earlier versions of Linux autofs and other autofs file
system users will not use the option and so won't be affected by the change.

Changes in v2:
- make naming consistent with util-linux conventions.
- make ignoring autofs mount entries the default since it will only
  have an effect if it has been enabled in the autofs configuration.
- drop patch to set ingore autofs mounts for mount(8) since it's now
  default.

Signed-off-by: Ian Kent <raven@themaw.net>
libmount/src/context.c
libmount/src/libmount.h.in
libmount/src/libmount.sym
libmount/src/mountP.h
libmount/src/tab_parse.c