summaryrefslogtreecommitdiffstats
path: root/libmount/src
diff options
context:
space:
mode:
Diffstat (limited to 'libmount/src')
-rw-r--r--libmount/src/context.c13
-rw-r--r--libmount/src/tab_parse.c18
-rw-r--r--libmount/src/tab_update.c2
3 files changed, 22 insertions, 11 deletions
diff --git a/libmount/src/context.c b/libmount/src/context.c
index e26135fb0..d9bda4375 100644
--- a/libmount/src/context.c
+++ b/libmount/src/context.c
@@ -204,8 +204,10 @@ static int context_init_paths(struct libmnt_context *cxt, int writable)
{
assert(cxt);
+#ifdef USE_LIBMOUNT_SUPPORT_MTAB
if (!cxt->mtab_path)
cxt->mtab_path = mnt_get_mtab_path();
+#endif
if (!cxt->utab_path)
cxt->utab_path = mnt_get_utab_path();
@@ -218,13 +220,12 @@ 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
+#ifdef USE_LIBMOUNT_SUPPORT_MTAB
+ mnt_has_regular_mtab(&cxt->mtab_path, &cxt->mtab_writable);
if (!cxt->mtab_writable)
+#endif
/* use /run/mount/utab if /etc/mtab is useless */
mnt_has_regular_utab(&cxt->utab_path, &cxt->utab_writable);
@@ -1023,6 +1024,10 @@ int mnt_context_get_mtab(struct libmnt_context *cxt, struct libmnt_table **tb)
cxt->table_fltrcb_data);
mnt_table_set_cache(cxt->mtab, mnt_context_get_cache(cxt));
+
+ /*
+ * Note that mtab_path is NULL if mtab is useless or unsupported
+ */
if (cxt->utab)
/* utab already parsed, don't parse it again */
rc = __mnt_table_parse_mtab(cxt->mtab,
diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c
index 23076bfc0..3253db714 100644
--- a/libmount/src/tab_parse.c
+++ b/libmount/src/tab_parse.c
@@ -679,7 +679,7 @@ err:
* @tb: tab pointer
* @filename: file
*
- * Parses the whole table (e.g. /etc/mtab) and appends new records to the @tab.
+ * Parses the whole table (e.g. /etc/fstab) and appends new records to the @tab.
*
* The libmount parser ignores broken (syntax error) lines, these lines are
* reported to the caller by the errcb() function (see mnt_table_set_parser_errcb()).
@@ -1051,6 +1051,8 @@ static struct libmnt_fs *mnt_table_merge_user_fs(struct libmnt_table *tb, struct
return fs;
}
+/* default filename is /proc/self/mountinfo
+ */
int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename,
struct libmnt_table *u_tb)
{
@@ -1058,9 +1060,7 @@ 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
+#ifdef USE_LIBMOUNT_SUPPORT_MTAB
if (mnt_has_regular_mtab(&filename, NULL)) {
DBG(TAB, ul_debugobj(tb, "force mtab usage [filename=%s]", filename));
@@ -1085,15 +1085,19 @@ int __mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename,
* useless /etc/mtab
* -- read kernel information from /proc/self/mountinfo
*/
- tb->fmt = MNT_FMT_MOUNTINFO;
- rc = mnt_table_parse_file(tb, _PATH_PROC_MOUNTINFO);
+ tb->fmt = filename ? MNT_FMT_GUESS : MNT_FMT_MOUNTINFO;
+ rc = mnt_table_parse_file(tb, filename ? filename : _PATH_PROC_MOUNTINFO);
if (rc) {
/* hmm, old kernel? ...try /proc/mounts */
tb->fmt = MNT_FMT_MTAB;
return mnt_table_parse_file(tb, _PATH_PROC_MOUNTS);
}
+ if (!is_mountinfo(tb))
+ return 0;
+#ifdef USE_LIBMOUNT_SUPPORT_MTAB
read_utab:
+#endif
DBG(TAB, ul_debugobj(tb, "mtab parse: #2 read utab"));
if (mnt_table_get_nents(tb) == 0)
@@ -1139,7 +1143,7 @@ read_utab:
/**
* mnt_table_parse_mtab:
* @tb: table
- * @filename: overwrites default (/etc/mtab or $LIBMOUNT_MTAB) or NULL
+ * @filename: overwrites default or NULL
*
* This function parses /etc/mtab or /proc/self/mountinfo +
* /run/mount/utabs or /proc/mounts.
diff --git a/libmount/src/tab_update.c b/libmount/src/tab_update.c
index 631e1cd9f..d85cb89da 100644
--- a/libmount/src/tab_update.c
+++ b/libmount/src/tab_update.c
@@ -105,7 +105,9 @@ int mnt_update_set_filename(struct libmnt_update *upd, const char *filename,
/* detect tab filename -- /etc/mtab or /run/mount/utab
*/
+#ifdef USE_LIBMOUNT_SUPPORT_MTAB
mnt_has_regular_mtab(&path, &rw);
+#endif
if (!rw) {
path = NULL;
mnt_has_regular_utab(&path, &rw);