summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmount/docs/libmount-sections.txt3
-rw-r--r--libmount/src/libmount.h.in2
-rw-r--r--libmount/src/libmount.sym2
-rw-r--r--libmount/src/monitor.c24
4 files changed, 23 insertions, 8 deletions
diff --git a/libmount/docs/libmount-sections.txt b/libmount/docs/libmount-sections.txt
index 7f0106781..4e3b9774d 100644
--- a/libmount/docs/libmount-sections.txt
+++ b/libmount/docs/libmount-sections.txt
@@ -390,9 +390,10 @@ mnt_new_monitor
mnt_ref_monitor
mnt_unref_monitor
mnt_monitor_enable_userspace
+mnt_monitor_enable_kernel
mnt_monitor_get_fd
mnt_monitor_close_fd
-mnt_monitor_is_changed
mnt_monitor_next_changed
+mnt_monitor_event_cleanup
mnt_monitor_wait
</SECTION>
diff --git a/libmount/src/libmount.h.in b/libmount/src/libmount.h.in
index c5fc516c4..789979c44 100644
--- a/libmount/src/libmount.h.in
+++ b/libmount/src/libmount.h.in
@@ -546,6 +546,7 @@ 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);
+extern int mnt_monitor_enable_kernel(struct libmnt_monitor *mn, int enable);
extern int mnt_monitor_enable_userspace(struct libmnt_monitor *mn,
int enable, const char *filename);
@@ -555,6 +556,7 @@ extern int mnt_monitor_wait(struct libmnt_monitor *mn, int timeout);
extern int mnt_monitor_next_changed(struct libmnt_monitor *mn,
const char **filename, int *type);
+extern int mnt_monitor_event_cleanup(struct libmnt_monitor *mn);
/* context.c */
diff --git a/libmount/src/libmount.sym b/libmount/src/libmount.sym
index fc8cc08f0..33f55a97e 100644
--- a/libmount/src/libmount.sym
+++ b/libmount/src/libmount.sym
@@ -301,6 +301,8 @@ MOUNT_2.25 {
MOUNT_2.26 {
mnt_monitor_close_fd;
mnt_monitor_enable_userspace;
+ mnt_monitor_enable_kernel;
+ mnt_monitor_event_cleanup;
mnt_monitor_get_fd;
mnt_monitor_next_changed;
mnt_monitor_wait;
diff --git a/libmount/src/monitor.c b/libmount/src/monitor.c
index cf91f32c3..2ec2510ed 100644
--- a/libmount/src/monitor.c
+++ b/libmount/src/monitor.c
@@ -304,7 +304,11 @@ static const struct monitor_opers userspace_opers = {
* or mnt_monitor_wait()) then it's updated according to @enable.
*
* The @filename is used only first time when you enable the monitor. It's
- * impossible to have more than one userspace monitor.
+ * impossible to have more than one userspace monitor. The recommended is to
+ * use NULL as filename.
+ *
+ * The userspace monitor is unsupported for systems with classic regular
+ * /etc/mtab file.
*
* Return: 0 on success and <0 on error
*/
@@ -329,8 +333,10 @@ int mnt_monitor_enable_userspace(struct libmnt_monitor *mn, int enable, const ch
DBG(MONITOR, ul_debugobj(mn, "allocate new userspace monitor"));
/* create a new entry */
- if (!mnt_has_regular_mtab(&filename, NULL)) /* /etc/mtab */
- filename = mnt_get_utab_path(); /* /run/mount/utab */
+ if (mnt_has_regular_mtab(NULL, NULL))
+ return -ENOSYS;
+
+ filename = mnt_get_utab_path(); /* /run/mount/utab */
if (!filename) {
DBG(MONITOR, ul_debugobj(mn, "failed to get userspace mount table path"));
return -EINVAL;
@@ -412,8 +418,8 @@ static const struct monitor_opers kernel_opers = {
* @mn: monitor
* @enable: 0 or 1
*
- * Enables or disables userspace monitoring. If the userspace monitor does not
- * exist and enable=1 then allocates new resources necessary for the monitor.
+ * Enables or disables kernel VFS monitoring. 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.
@@ -550,6 +556,11 @@ int mnt_monitor_close_fd(struct libmnt_monitor *mn)
* The file descriptor is associated with all monitored files and it's usable
* for example for epoll.
*
+ * Note that if you want to use the @fd in your epoll then you will get only
+ * notification, but mnt_monitor_next_changed() does not work in this case. You
+ * have to call mnt_monitor_event_cleanup() after each event if you do not use
+ * mnt_monitor_next_changed().
+ *
* Returns: >=0 on success, <0 on error
*/
int mnt_monitor_get_fd(struct libmnt_monitor *mn)
@@ -653,8 +664,7 @@ static struct monitor_entry *get_changed(struct libmnt_monitor *mn)
* @filename: returns changed file (optional argument)
* @type: returns MNT_MONITOR_TYPE_* (optional argument)
*
- * The function does not wait and it's designed to provide details and to avoid
- * false positives after detected activity on monitor file descriptor.
+ * The function does not wait and it's designed to provide details about chnages.
*
* Returns: 0 on success, 1 no change, <0 on error
*/