From: Karel Zak Date: Wed, 1 Jul 2026 10:49:25 +0000 (+0200) Subject: libmount: add mnt_table_parse_utab() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0926f4a70bd88beaa10cbecee58db9c28b5452d3;p=thirdparty%2Futil-linux.git libmount: add mnt_table_parse_utab() 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 --- diff --git a/libmount/docs/libmount-sections.txt b/libmount/docs/libmount-sections.txt index 8d11867aa..e9683b06f 100644 --- a/libmount/docs/libmount-sections.txt +++ b/libmount/docs/libmount-sections.txt @@ -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 diff --git a/libmount/src/libmount.h.in b/libmount/src/libmount.h.in index d3b39e661..ca9a1ad23 100644 --- a/libmount/src/libmount.h.in +++ b/libmount/src/libmount.h.in @@ -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)); diff --git a/libmount/src/libmount.sym b/libmount/src/libmount.sym index 0240b5fe0..de757eda4 100644 --- a/libmount/src/libmount.sym +++ b/libmount/src/libmount.sym @@ -424,4 +424,5 @@ MOUNT_2_42 { MOUNT_2_43 { mnt_table_disable_useropts; + mnt_table_parse_utab; } MOUNT_2_42; diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c index c21d5d019..99d440cf8 100644 --- a/libmount/src/tab_parse.c +++ b/libmount/src/tab_parse.c @@ -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