From: Karel Zak Date: Tue, 29 Oct 2019 11:59:08 +0000 (+0100) Subject: libmount: don't use /proc/mounts fallback if filename specified X-Git-Tag: v2.35-rc1~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05842a92d891ddc883bf37280937fccde7eaac31;p=thirdparty%2Futil-linux.git libmount: don't use /proc/mounts fallback if filename specified 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 Signed-off-by: Karel Zak --- diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c index c118a59d7c..ffcf245790 100644 --- a/libmount/src/tab_parse.c +++ b/libmount/src/tab_parse.c @@ -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);