From 05842a92d891ddc883bf37280937fccde7eaac31 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 29 Oct 2019 12:59:08 +0100 Subject: [PATCH] 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 --- libmount/src/tab_parse.c | 4 ++++ 1 file changed, 4 insertions(+) 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); -- 2.47.2