return tb ? tb->noautofs : 0;
}
+/**
+ * mnt_table_disable_useropts:
+ * @tb: table
+ * @disable: 1 to disable, 0 to enable
+ *
+ * Disable or enable merging of userspace mount options from utab when
+ * populating the mount table. This applies to both mountinfo and
+ * listmount-based table sources.
+ *
+ * Returns: 0 on success, <0 on error.
+ *
+ * Since: 2.43
+ */
+int mnt_table_disable_useropts(struct libmnt_table *tb, int disable)
+{
+ if (!tb)
+ return -EINVAL;
+ tb->nouseropts = disable ? 1 : 0;
+ return 0;
+}
+
/**
* mnt_table_parse_swaps:
* @tb: table
if (fs) {
DBG_OBJ(TAB, tb, ul_debug(" found"));
- mnt_fs_append_options(fs, optstr);
+ mnt_optstr_append_option(&fs->user_optstr, optstr, NULL);
+ free(fs->optstr);
+ fs->optstr = NULL;
mnt_fs_append_attributes(fs, attrs);
mnt_fs_set_bindsrc(fs, mnt_fs_get_bindsrc(uf));
fs->flags |= MNT_FS_MERGED;
return fs;
}
-/* default filename is /proc/self/mountinfo
+/*
+ * Read utab and merge userspace options into the mount table @tb.
+ * If @u_tb is provided, use it as utab; otherwise read from
+ * /run/mount/utab.
*/
-int __mnt_table_parse_mountinfo(struct libmnt_table *tb, const char *filename,
- struct libmnt_table *u_tb)
+int mnt_table_merge_utab(struct libmnt_table *tb, struct libmnt_table *u_tb)
{
int rc = 0, priv_utab = 0;
- int explicit_file = filename ? 1 : 0;
assert(tb);
- if (filename)
- DBG_OBJ(TAB, tb, ul_debug("%s requested as mount table", filename));
-
- if (!filename || strcmp(filename, _PATH_PROC_MOUNTINFO) == 0) {
- filename = _PATH_PROC_MOUNTINFO;
- tb->fmt = MNT_FMT_MOUNTINFO;
- DBG_OBJ(TAB, tb, ul_debug("mountinfo parse: #1 read mountinfo"));
- } else
- tb->fmt = MNT_FMT_GUESS;
-
- 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);
- }
-
- if (!is_mountinfo(tb))
+ if (tb->nouseropts)
return 0;
- DBG_OBJ(TAB, tb, ul_debug("mountinfo parse: #2 read utab"));
-
if (mnt_table_get_nents(tb) == 0)
- return 0; /* empty, ignore utab */
- /*
- * try to read the user specific information from /run/mount/utabs
- */
+ return 0;
+
if (!u_tb) {
const char *utab = mnt_get_utab_path();
priv_utab = 1;
}
- DBG_OBJ(TAB, tb, ul_debug("mountinfo parse: #3 merge utab"));
+ DBG_OBJ(TAB, tb, ul_debug("merging utab"));
if (rc == 0) {
struct libmnt_fs *u_fs;
mnt_reset_iter(&itr, MNT_ITER_BACKWARD);
- /* merge user options into mountinfo from the kernel */
- while(mnt_table_next_fs(u_tb, &itr, &u_fs) == 0)
+ while (mnt_table_next_fs(u_tb, &itr, &u_fs) == 0)
mnt_table_merge_user_fs(tb, u_fs);
}
-
if (priv_utab)
mnt_unref_table(u_tb);
return 0;
}
+
+/* default filename is /proc/self/mountinfo
+ */
+int __mnt_table_parse_mountinfo(struct libmnt_table *tb, const char *filename,
+ struct libmnt_table *u_tb)
+{
+ int rc = 0;
+ int explicit_file = filename ? 1 : 0;
+
+ assert(tb);
+
+ if (filename)
+ DBG_OBJ(TAB, tb, ul_debug("%s requested as mount table", filename));
+
+ if (!filename || strcmp(filename, _PATH_PROC_MOUNTINFO) == 0) {
+ filename = _PATH_PROC_MOUNTINFO;
+ tb->fmt = MNT_FMT_MOUNTINFO;
+ DBG_OBJ(TAB, tb, ul_debug("mountinfo parse: #1 read mountinfo"));
+ } else
+ tb->fmt = MNT_FMT_GUESS;
+
+ 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);
+ }
+
+ if (!is_mountinfo(tb))
+ return 0;
+
+ DBG_OBJ(TAB, tb, ul_debug("mountinfo parse: #2 merge utab"));
+ return mnt_table_merge_utab(tb, u_tb);
+}
+
/**
* mnt_table_parse_mtab:
* @tb: table