]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: add --enable-libmount-force-mountinfo
authorKarel Zak <kzak@redhat.com>
Mon, 16 Feb 2015 11:49:49 +0000 (12:49 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 16 Feb 2015 11:49:49 +0000 (12:49 +0100)
The default libmount mtab management depends on mtan symlink. If the
symlink exists than libmount parses /proc/self/mountinfo, otherwise it
parses regular classic /etc/mtab. This is backwardly compatible and
transparent solution.

Unfortunately, this is not robust enough because some broken init
scripts or 3-party mount helpers may remove the symlink and create
regular mtab file. This is pretty bad if initd (systemd) depends on
libmount.

Fortunately we known that mtab is absolutely unwanted on some distros,
so it's fine too ignore mtab at all and don't care about the symlink.

Reported-by: Martin Pitt <martin.pitt@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
libmount/src/context.c
libmount/src/tab_parse.c

index 118dcb777c237a49668074eaccd717b87c46beb9..c846efbdaf37b4710f1ff1812e902d6b3c30bea4 100644 (file)
@@ -851,6 +851,15 @@ AC_SUBST([LIBMOUNT_PATCH_VERSION], $PACKAGE_VERSION_RELEASE)
 AC_SUBST([LIBMOUNT_VERSION_INFO])
 AC_DEFINE_UNQUOTED([LIBMOUNT_VERSION], ["$LIBMOUNT_VERSION"], [libmount version string])
 
+AC_ARG_ENABLE([libmount-force-mountinfo],
+  AS_HELP_STRING([--enable-libmount-force-mountinfo], [ignore /etc/mtab in all situations (recommended for systemd)]),
+  [], [enable_libmount_force_mountinfo=no]
+)
+
+AS_IF([test "x$enable_libmount_force_mountinfo" == xyes], [
+  AC_DEFINE([USE_LIBMOUNT_FORCE_MOUNTINFO], [1], [Define to 1 if want to ignore mtab in all situations.])
+])
+
 
 dnl
 dnl libsmartcols
index c902f396e0d76cd8ab320200d7bc84b6bc51c8a6..0fb9f6f8045e916e8828788c87efbf49184249fc 100644 (file)
@@ -219,7 +219,11 @@ static int context_init_paths(struct libmnt_context *cxt, int writable)
 
        DBG(CXT, ul_debugobj(cxt, "checking for writable tab files"));
 
+#ifdef USE_LIBMOUNT_FORCE_MOUNTINFO
+       cxt->mtab_writable = 0;
+#else
        mnt_has_regular_mtab(&cxt->mtab_path, &cxt->mtab_writable);
+#endif
 
        if (!cxt->mtab_writable)
                /* use /run/mount/utab if /etc/mtab is useless */
index 2757d0fee001a42d8e48f52eff39ad79795cfc67..0f87730ee5ceac5bc9befdef7ebcc8297de06e65 100644 (file)
@@ -1052,6 +1052,9 @@ int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename,
 
        assert(tb);
 
+#ifdef USE_LIBMOUNT_FORCE_MOUNTINFO
+       DBG(TAB, ul_debugobj(tb, "mtab parse: ignore %s", filename ? filename : "mtab"));
+#else
        if (mnt_has_regular_mtab(&filename, NULL)) {
 
                DBG(TAB, ul_debugobj(tb, "force mtab usage [filename=%s]", filename));
@@ -1069,7 +1072,7 @@ int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename,
                        return 0;
                filename = NULL;        /* failed */
        }
-
+#endif
        DBG(TAB, ul_debugobj(tb, "mtab parse: #1 read mountinfo"));
 
        /*