diff options
author | Karel Zak | 2015-02-12 13:14:52 +0100 |
---|---|---|
committer | Karel Zak | 2015-02-12 13:21:08 +0100 |
commit | 60d29f827b94097fb718dcb02fad6ccb571bdb2b (patch) | |
tree | 8cd9066bf122a56b9a58ff7e243d61e5fde058e9 /libmount/src/tab_parse.c | |
parent | findmnt: don't parse mountinfo twice (diff) | |
download | kernel-qcow2-util-linux-60d29f827b94097fb718dcb02fad6ccb571bdb2b.tar.gz kernel-qcow2-util-linux-60d29f827b94097fb718dcb02fad6ccb571bdb2b.tar.xz kernel-qcow2-util-linux-60d29f827b94097fb718dcb02fad6ccb571bdb2b.zip |
libmount: read utab always when read mtab from /proc
Now libmount reads utab only when mtab filename is no explicitly
specified, but for example:
mnt_table_parse_mtab(tb, "/proc/self/mountinfo");
ignores utab because filename points to regular file. This is mistake,
we wnat to read utab always when we read mount table from kernel.
Reported-by: Martin Pitt <martin.pitt@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/tab_parse.c')
-rw-r--r-- | libmount/src/tab_parse.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c index 05496f760..2757d0fee 100644 --- a/libmount/src/tab_parse.c +++ b/libmount/src/tab_parse.c @@ -687,8 +687,9 @@ int mnt_table_parse_file(struct libmnt_table *tb, const char *filename) rc = mnt_table_parse_stream(tb, f, filename); fclose(f); } else - return -errno; + rc = -errno; + DBG(TAB, ul_debugobj(tb, "parsing done [filename=%s, rc=%d]", filename, rc)); return rc; } @@ -1053,14 +1054,24 @@ int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename, if (mnt_has_regular_mtab(&filename, NULL)) { - DBG(TAB, ul_debugobj(tb, "force %s usage", filename)); + DBG(TAB, ul_debugobj(tb, "force mtab usage [filename=%s]", filename)); rc = mnt_table_parse_file(tb, filename); + + /* + * If @filename forces us to read from /proc then also read + * utab file to merge userspace mount options. + */ + if (rc == 0 && is_mountinfo(tb)) + goto read_utab; + if (!rc) return 0; filename = NULL; /* failed */ } + DBG(TAB, ul_debugobj(tb, "mtab parse: #1 read mountinfo")); + /* * useless /etc/mtab * -- read kernel information from /proc/self/mountinfo @@ -1073,6 +1084,9 @@ int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename, return mnt_table_parse_file(tb, _PATH_PROC_MOUNTS); } +read_utab: + DBG(TAB, ul_debugobj(tb, "mtab parse: #2 read utab")); + if (mnt_table_get_nents(tb) == 0) return 0; /* empty, ignore utab */ /* @@ -1080,6 +1094,7 @@ int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename, */ if (!u_tb) { const char *utab = mnt_get_utab_path(); + if (!utab || is_file_empty(utab)) return 0; @@ -1094,6 +1109,8 @@ int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename, priv_utab = 1; } + DBG(TAB, ul_debugobj(tb, "mtab parse: #3 merge utab")); + if (rc == 0) { struct libmnt_fs *u_fs; struct libmnt_iter itr; |