[systemd-devel] [PATCH] Re: fstab mounts get unmounted during boot (.device unit bouncing?) -- solution
Lennart Poettering
lennart at poettering.net
Thu Feb 12 03:01:13 PST 2015
On Thu, 12.02.15 11:58, Martin Pitt (martin.pitt at ubuntu.com) wrote:
> Lennart Poettering [2015-02-12 11:22 +0100]:
> > > To make systemd robust against this, I fixed
> > > mount_load_proc_self_mountinfo() to actually do what it intends to do,
> > > instead of loading /etc/mtab (which is still util-linux' default for
> > > mnt_table_parse_mtab()).
> >
> > Urks, we never want to read /etc/mtab from PID 1, indeed. I am a bit
> > puzzled by mnt_table_parse_mtab() thiugh. The name suggests it parses
> > /etc/mtab files (which have the same format as /proc/self/mounts). But
> > Can we really just arse /proc/self/mountinfo to it, which has a very
> > different format?
>
> Yes, it arses it just fine :-) It supports the mtab, the fstab, and
> the mountinfo format:
>
> https://github.com/karelzak/util-linux/blob/master/libmount/src/tab_parse.c#L1047
>
> If you don't specify a file name, it defaults to /etc/mtab;
> mnt_has_regular_mtab() checks if /etc/mtab is a regular file, and if
> so, parses it as mtab format; if it's a symlink, then
> mnt_has_regular_mtab() is false. (See
> https://github.com/karelzak/util-linux/blob/master/libmount/src/utils.c#L772)
>
> If the passed filename (or /etc/mtab default) is a symlink, it falls
> back to line 1068 ff. where it ignores filename entirely. It first
> tries to parse /proc/self/mountinfo as MNT_FMT_MOUNTINFO, and if that
> fails, it falls back to parsing /proc/mounts (in old _PATH_PROC_MOUNTS
> format, i. e. mtab).
>
> So it doesn't matter that much what filename is, as long as it's not
> NULL or /etc/mtab, but for readability I still suggest using
> "/proc/self/mountinfo", as that's what it will actually end up
> reading.
>
> FTR, I added a log_debug() to it (not contained in the submitted
> patch) and tested it with regular /etc/mtab, a symlink to /proc/mounts
> and a symlink to /proc/self/mountinfo, and it comes out just fine.
And the stuff from /run is always merged into it, regardless which
file is read?
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list