]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: add mnt_table_parse_utab()
authorKarel Zak <kzak@redhat.com>
Wed, 1 Jul 2026 10:49:25 +0000 (12:49 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 1 Jul 2026 10:49:25 +0000 (12:49 +0200)
Add new public API to parse the utab file into a table. The utab path
and format are private library details; this function hides them from
callers. NULL as filename is recommended to let the library determine
the correct path.

This is needed by systemd for incremental fanotify-based mount
monitoring, where utab needs to be parsed independently of the full
mountinfo/listmount rescan path.

Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/docs/libmount-sections.txt
libmount/src/libmount.h.in
libmount/src/libmount.sym
libmount/src/tab_parse.c

index 8d11867aaaf4a62c6de349bd8cb619df8ffaa77b..e9683b06f3d3525bfb625943d41a13e30c2bff02 100644 (file)
@@ -418,6 +418,7 @@ mnt_table_parse_fstab
 mnt_table_parse_mtab
 mnt_table_parse_stream
 mnt_table_parse_swaps
+mnt_table_parse_utab
 mnt_table_remove_fs
 mnt_table_set_cache
 mnt_table_set_intro_comment
index d3b39e66103b2f41fbe2c34404adf2715055e5e2..ca9a1ad231909aed7cd2c8c5fa0a15e783186455 100644 (file)
@@ -608,6 +608,7 @@ extern int mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname);
 extern int mnt_table_parse_fstab(struct libmnt_table *tb, const char *filename);
 extern int mnt_table_parse_swaps(struct libmnt_table *tb, const char *filename);
 extern int mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename);
+extern int mnt_table_parse_utab(struct libmnt_table *tb, const char *filename);
 extern int mnt_table_disable_useropts(struct libmnt_table *tb, int disable);
 extern int mnt_table_set_parser_errcb(struct libmnt_table *tb,
                 int (*cb)(struct libmnt_table *tb, const char *filename, int line));
index 0240b5fe08506fff9c1ef0609b2aac4d77f73eaa..de757eda48272cd4448634923bb4d16a8659a7f4 100644 (file)
@@ -424,4 +424,5 @@ MOUNT_2_42 {
 
 MOUNT_2_43 {
        mnt_table_disable_useropts;
+       mnt_table_parse_utab;
 } MOUNT_2_42;
index c21d5d019bdb2021cd0c3a9804aac3f26f7d0257..99d440cf844efc58b34f20ef1a8c6f5aa6f12b0f 100644 (file)
@@ -1155,6 +1155,32 @@ int mnt_table_parse_swaps(struct libmnt_table *tb, const char *filename)
        return mnt_table_parse_file(tb, filename);
 }
 
+/**
+ * mnt_table_parse_utab:
+ * @tb: table
+ * @filename: overwrites default or NULL (recommended)
+ *
+ * This function parses the utab file and appends new lines to the @tb. The utab
+ * is a private libmount file that stores userspace mount options. The file
+ * location and format are library implementation details and subject to change;
+ * use NULL as @filename to let the library determine the correct path.
+ *
+ * Returns: 0 on success or negative number in case of error.
+ */
+int mnt_table_parse_utab(struct libmnt_table *tb, const char *filename)
+{
+       if (!tb)
+               return -EINVAL;
+       if (!filename)
+               filename = mnt_get_utab_path();
+       if (!filename || is_file_empty(filename))
+               return 0;
+
+       tb->fmt = MNT_FMT_UTAB;
+
+       return mnt_table_parse_file(tb, filename);
+}
+
 /**
  * mnt_table_parse_fstab:
  * @tb: table