From 05cdd0bf45eb29ff6d20a3e9d7018dfd1618a062 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 13 Jan 2015 12:13:09 +0100 Subject: [PATCH] libmount: (docs) add monitor example Signed-off-by: Karel Zak --- libmount/src/monitor.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libmount/src/monitor.c b/libmount/src/monitor.c index f7323f6938..28064b8968 100644 --- a/libmount/src/monitor.c +++ b/libmount/src/monitor.c @@ -10,6 +10,26 @@ * @title: Monitor * @short_description: interface to monitor mount tables * + * For example monitor VFS (/proc/self/mountinfo) for changes: + * + * + * + * const char *filename; + * struct libmount_monitor *mn = mnt_new_monitor(); + * + * mnt_monitor_enable_kernel(mn, TRUE)); + * + * printf("waiting for changes...\n"); + * while (mnt_monitor_wait(mn, -1) > 0) { + * printf("notification detected\n"); + * + * while (mnt_monitor_next_change(mn, &filename, NULL) == 0) + * printf(" %s: change detected\n", filename); + * } + * mnt_unref_monitor(mn); + * + * + * */ #include "fileutils.h" -- 2.47.2