]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: don't use /proc/mounts fallback if filename specified
authorKarel Zak <kzak@redhat.com>
Tue, 29 Oct 2019 11:59:08 +0000 (12:59 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 29 Oct 2019 11:59:08 +0000 (12:59 +0100)
The current solution is to use /proc/mounts if previous attempt to
open /proc/self/mountinfo failed. The fallback should not be used when
mount table path is explicitly specified by application. The default
is NULL, only in this case libmount should be try to be smart.

Reported-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/tab_parse.c

index c118a59d7cc93b24df98c732b8880a7e280f6348..ffcf245790be23e312ea70bb60915be70462060e 100644 (file)
@@ -1222,6 +1222,7 @@ int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename,
                           struct libmnt_table *u_tb)
 {
        int rc = 0, priv_utab = 0;
+       int explicit_file = filename ? 1 : 0;
 
        assert(tb);
 
@@ -1258,6 +1259,9 @@ int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename,
 
        rc = mnt_table_parse_file(tb, filename);
        if (rc) {
+               if (explicit_file)
+                       return rc;
+
                /* hmm, old kernel? ...try /proc/mounts */
                tb->fmt = MNT_FMT_MTAB;
                return mnt_table_parse_file(tb, _PATH_PROC_MOUNTS);