diff options
| author | Karel Zak <kzak@redhat.com> | 2025-08-06 14:09:12 +0200 |
|---|---|---|
| committer | Karel Zak <kzak@redhat.com> | 2025-08-06 15:08:38 +0200 |
| commit | cfebab23ab06cf2b646b4c0afdbc0ebb9e25c6dd (patch) | |
| tree | 854d82601c9d1d57b0cb1aee95928aea5dedfc1b /libmount/src | |
| parent | 938264b1ff764ea60e8c9fb257bddc2070850b86 (diff) | |
| download | util-linux-cfebab23ab06cf2b646b4c0afdbc0ebb9e25c6dd.tar.gz | |
libmount: (monitor) rename public API to "mountinfo"
There will be more kernel monitors in the future. Ensure the API is
easy to understand.
* Rename MNT_MONITOR_TYPE_KERNEL to MNT_MONITOR_TYPE_MOUNTINFO
* Rename mnt_monitor_enable_kernel() to mnt_monitor_enable_mountinfo()
The change is backward compatible; the old names are still usable.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
| -rw-r--r-- | libmount/src/libmount.h.in | 7 | ||||
| -rw-r--r-- | libmount/src/libmount.sym | 1 | ||||
| -rw-r--r-- | libmount/src/monitor.c | 12 | ||||
| -rw-r--r-- | libmount/src/monitor_mountinfo.c | 27 |
4 files changed, 34 insertions, 13 deletions
diff --git a/libmount/src/libmount.h.in b/libmount/src/libmount.h.in index 23cf0a4fda..a009b92122 100644 --- a/libmount/src/libmount.h.in +++ b/libmount/src/libmount.h.in @@ -746,14 +746,19 @@ extern int mnt_tabdiff_next_change(struct libmnt_tabdiff *df, /* monitor.c */ enum { MNT_MONITOR_TYPE_USERSPACE = 1, /* userspace mount options */ - MNT_MONITOR_TYPE_KERNEL /* kernel mount table */ + MNT_MONITOR_TYPE_MOUNTINFO = 2, /* /proc/self/mountinfo based kernel monitor */ + + MNT_MONITOR_TYPE_KERNEL = MNT_MONITOR_TYPE_MOUNTINFO, /* deprecated */ }; extern struct libmnt_monitor *mnt_new_monitor(void); extern void mnt_ref_monitor(struct libmnt_monitor *mn); extern void mnt_unref_monitor(struct libmnt_monitor *mn); +/* deprecated alias to mnt_monitor_enable_mountinfo() */ extern int mnt_monitor_enable_kernel(struct libmnt_monitor *mn, int enable); + +extern int mnt_monitor_enable_mountinfo(struct libmnt_monitor *mn, int enable); extern int mnt_monitor_enable_userspace(struct libmnt_monitor *mn, int enable, const char *filename); diff --git a/libmount/src/libmount.sym b/libmount/src/libmount.sym index cd3c5fb869..9a142f4287 100644 --- a/libmount/src/libmount.sym +++ b/libmount/src/libmount.sym @@ -412,6 +412,7 @@ MOUNT_2_41 { MOUNT_2_42 { mnt_context_enable_exclusive; mnt_context_is_exclusive; + mnt_monitor_enable_mountinfo; mnt_monitor_event_next_fs; mnt_fs_is_moved; mnt_fs_is_attached; diff --git a/libmount/src/monitor.c b/libmount/src/monitor.c index 6bede6b58f..dca037d46f 100644 --- a/libmount/src/monitor.c +++ b/libmount/src/monitor.c @@ -22,7 +22,7 @@ * const char *filename; * struct libmount_monitor *mn = mnt_new_monitor(); * - * mnt_monitor_enable_kernel(mn, TRUE)); + * mnt_monitor_enable_mountinfo(mn, TRUE)); * * printf("waiting for changes...\n"); * while (mnt_monitor_wait(mn, -1) > 0) { @@ -530,8 +530,8 @@ static struct libmnt_monitor *create_test_monitor(int argc, char *argv[]) goto err; } - } else if (strcmp(argv[i], "kernel") == 0) { - if (mnt_monitor_enable_kernel(mn, TRUE)) { + } else if (strcmp(argv[i], "mountinfo") == 0) { + if (mnt_monitor_enable_mountinfo(mn, TRUE)) { warn("failed to initialize kernel monitor"); goto err; } @@ -658,9 +658,9 @@ static int test_wait(struct libmnt_test *ts __attribute__((unused)), int main(int argc, char *argv[]) { struct libmnt_test tss[] = { - { "--epoll", test_epoll, "<userspace kernel veil ...> monitor in epoll" }, - { "--epoll-clean", test_epoll_cleanup, "<userspace kernel veil ...> monitor in epoll and clean events" }, - { "--wait", test_wait, "<userspace kernel veil ...> monitor wait function" }, + { "--epoll", test_epoll, "<userspace mountinfo veil ...> monitor in epoll" }, + { "--epoll-clean", test_epoll_cleanup, "<userspace mountinfo veil ...> monitor in epoll and clean events" }, + { "--wait", test_wait, "<userspace mountinfo veil ...> monitor wait function" }, { NULL } }; diff --git a/libmount/src/monitor_mountinfo.c b/libmount/src/monitor_mountinfo.c index 0b9dda664a..171d2e172f 100644 --- a/libmount/src/monitor_mountinfo.c +++ b/libmount/src/monitor_mountinfo.c @@ -78,19 +78,22 @@ static const struct monitor_opers mountinfo_opers = { }; /** - * mnt_monitor_enable_kernel: + * mnt_monitor_enable_mountinfo: * @mn: monitor * @enable: 0 or 1 * - * Enables or disables kernel VFS monitoring. If the monitor does not exist and - * enable=1 then allocates new resources necessary for the monitor. + * Enables or disables kernel VFS monitoring based on /proc/self/mountinfo. If + * the monitor does not exist and enable=1 then allocates new resources + * necessary for the monitor. * * If the top-level monitor has been already created (by mnt_monitor_get_fd() * or mnt_monitor_wait()) then it's updated according to @enable. * * Return: 0 on success and <0 on error + * + * Since: v2.42 */ -int mnt_monitor_enable_kernel(struct libmnt_monitor *mn, int enable) +int mnt_monitor_enable_mountinfo(struct libmnt_monitor *mn, int enable) { struct monitor_entry *me; int rc = 0; @@ -98,7 +101,7 @@ int mnt_monitor_enable_kernel(struct libmnt_monitor *mn, int enable) if (!mn) return -EINVAL; - me = monitor_get_entry(mn, MNT_MONITOR_TYPE_KERNEL, -1); + me = monitor_get_entry(mn, MNT_MONITOR_TYPE_MOUNTINFO, -1); if (me) { rc = monitor_modify_epoll(mn, me, enable); if (!enable) @@ -129,7 +132,7 @@ int mnt_monitor_enable_kernel(struct libmnt_monitor *mn, int enable) */ me->events = EPOLLIN | EPOLLET; - me->type = MNT_MONITOR_TYPE_KERNEL; + me->type = MNT_MONITOR_TYPE_MOUNTINFO; me->opers = &mountinfo_opers; me->path = strdup(_PATH_PROC_MOUNTINFO); if (!me->path) @@ -144,6 +147,18 @@ err: } /** + * mnt_monitor_enable_kernel: + * @mn: monitor + * @enable: 0 or 1 + * + * Deprecated alias to mnt_monitor_enable_mountinfo(). + * + * Return: 0 on success and <0 on error + */ +int mnt_monitor_enable_kernel(struct libmnt_monitor *mn, int enable) + __attribute__((alias("mnt_monitor_enable_mountinfo"))); + +/** * mnt_monitor_veil_kernel: * @mn: monitor instance * @enable: 1 or 0 |
