aboutsummaryrefslogtreecommitdiffstats
path: root/libmount/src
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2025-05-27 13:14:34 +0200
committerKarel Zak <kzak@redhat.com>2025-08-06 14:50:56 +0200
commit9d93bc087b3b0da67b5eef0a1319c5ea016c0f29 (patch)
treedb8d9623453d7e98125dad113581fbfcc5afba3f /libmount/src
parentcfb81f8959b67e678d01e3048a80871bbf6cc18d (diff)
downloadutil-linux-9d93bc087b3b0da67b5eef0a1319c5ea016c0f29.tar.gz
libmount: (monitor) clean up internal names
In future changes, we need to process active monitor entries in entry type-specific code to return data from events. This requires a slight change in the function's logic, so it makes sense to rename the function according to the new logic, meaning changes --> active, verify --> process. The patch also replaces bit fields with booleans. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
-rw-r--r--libmount/src/monitor.c24
-rw-r--r--libmount/src/monitor.h11
-rw-r--r--libmount/src/monitor_mountinfo.c8
-rw-r--r--libmount/src/monitor_utab.c8
4 files changed, 27 insertions, 24 deletions
diff --git a/libmount/src/monitor.c b/libmount/src/monitor.c
index 55de02174d..3890b18c2a 100644
--- a/libmount/src/monitor.c
+++ b/libmount/src/monitor.c
@@ -181,8 +181,8 @@ int monitor_modify_epoll(struct libmnt_monitor *mn,
assert(mn);
assert(me);
- me->enable = enable ? 1 : 0;
- me->changed = 0;
+ me->enabled = enable ? 1 : 0;
+ me->active = 0;
if (mn->fd < 0)
return 0; /* no epoll, ignore request */
@@ -292,7 +292,7 @@ int mnt_monitor_get_fd(struct libmnt_monitor *mn)
DBG(MONITOR, ul_debugobj(mn, "adding monitor entries to epoll (fd=%d)", mn->fd));
while (monitor_next_entry(mn, &itr, &me) == 0) {
- if (!me->enable)
+ if (!me->enabled)
continue;
rc = monitor_modify_epoll(mn, me, TRUE);
if (rc)
@@ -347,9 +347,9 @@ int mnt_monitor_wait(struct libmnt_monitor *mn, int timeout)
if (!me)
return -EINVAL;
- if (me->opers->op_event_verify == NULL ||
- me->opers->op_event_verify(mn, me) == 1) {
- me->changed = 1;
+ if (me->opers->op_process_event == NULL ||
+ me->opers->op_process_event(mn, me) == 1) {
+ me->active = 1;
break;
}
} while (1);
@@ -358,14 +358,14 @@ int mnt_monitor_wait(struct libmnt_monitor *mn, int timeout)
}
-static struct monitor_entry *get_changed(struct libmnt_monitor *mn)
+static struct monitor_entry *get_active(struct libmnt_monitor *mn)
{
struct libmnt_iter itr;
struct monitor_entry *me;
mnt_reset_iter(&itr, MNT_ITER_FORWARD);
while (monitor_next_entry(mn, &itr, &me) == 0) {
- if (me->changed)
+ if (me->active)
return me;
}
return NULL;
@@ -398,7 +398,7 @@ int mnt_monitor_next_change(struct libmnt_monitor *mn,
*
* If we get nothing, then ask kernel.
*/
- me = get_changed(mn);
+ me = get_active(mn);
while (!me) {
struct epoll_event events[1];
@@ -418,12 +418,12 @@ int mnt_monitor_next_change(struct libmnt_monitor *mn,
if (!me)
return -EINVAL;
- if (me->opers->op_event_verify != NULL &&
- me->opers->op_event_verify(mn, me) != 1)
+ if (me->opers->op_process_event != NULL &&
+ me->opers->op_process_event(mn, me) != 1)
me = NULL;
}
- me->changed = 0;
+ me->active = 0;
if (filename)
*filename = me->path;
diff --git a/libmount/src/monitor.h b/libmount/src/monitor.h
index 38e3dfce8b..25c6c1f674 100644
--- a/libmount/src/monitor.h
+++ b/libmount/src/monitor.h
@@ -4,6 +4,9 @@
#ifndef _MNTMONITOR_PRIVATE_H
#define _MNTMONITOR_PRIVATE_H
+#include "c.h"
+#include <stdbool.h>
+
struct monitor_opers;
struct monitor_entry {
@@ -16,8 +19,8 @@ struct monitor_entry {
const struct monitor_opers *opers;
void *data; /* private type-specific data */
- unsigned int enable : 1,
- changed : 1;
+ bool enabled, /* monitoring fd */
+ active; /* ready for mnt_monitor_next_change() */
struct list_head ents;
};
@@ -28,14 +31,14 @@ struct libmnt_monitor {
struct list_head ents;
- unsigned int kernel_veiled: 1;
+ bool kernel_veiled;
};
struct monitor_opers {
int (*op_get_fd)(struct libmnt_monitor *, struct monitor_entry *);
int (*op_close_fd)(struct libmnt_monitor *, struct monitor_entry *);
int (*op_free_data)(struct monitor_entry *);
- int (*op_event_verify)(struct libmnt_monitor *, struct monitor_entry *);
+ int (*op_process_event)(struct libmnt_monitor *, struct monitor_entry *);
};
int monitor_modify_epoll(struct libmnt_monitor *mn, struct monitor_entry *me, int enable);
diff --git a/libmount/src/monitor_mountinfo.c b/libmount/src/monitor_mountinfo.c
index 3bffcb31fd..0c05051b06 100644
--- a/libmount/src/monitor_mountinfo.c
+++ b/libmount/src/monitor_mountinfo.c
@@ -35,7 +35,7 @@ static int kernel_monitor_get_fd(struct libmnt_monitor *mn,
{
int rc;
- if (!me || me->enable == 0) /* not-initialized or disabled */
+ if (!me || me->enabled == 0) /* not-initialized or disabled */
return -EINVAL;
if (me->fd >= 0)
return me->fd; /* already initialized */
@@ -54,8 +54,8 @@ err:
return rc;
}
-static int kernel_event_verify(struct libmnt_monitor *mn,
- struct monitor_entry *me)
+static int kernel_process_event(struct libmnt_monitor *mn,
+ struct monitor_entry *me)
{
int status = 1;
@@ -75,7 +75,7 @@ static int kernel_event_verify(struct libmnt_monitor *mn,
static const struct monitor_opers kernel_opers = {
.op_get_fd = kernel_monitor_get_fd,
.op_close_fd = kernel_monitor_close_fd,
- .op_event_verify = kernel_event_verify
+ .op_process_event = kernel_process_event
};
/**
diff --git a/libmount/src/monitor_utab.c b/libmount/src/monitor_utab.c
index 593e163296..4cc1b3acb4 100644
--- a/libmount/src/monitor_utab.c
+++ b/libmount/src/monitor_utab.c
@@ -96,7 +96,7 @@ static int userspace_monitor_get_fd(struct libmnt_monitor *mn,
{
int rc;
- if (!me || me->enable == 0) /* not-initialized or disabled */
+ if (!me || me->enabled == 0) /* not-initialized or disabled */
return -EINVAL;
if (me->fd >= 0)
return me->fd; /* already initialized */
@@ -124,7 +124,7 @@ err:
/*
* verify and drain inotify buffer
*/
-static int userspace_event_verify(struct libmnt_monitor *mn,
+static int userspace_process_event(struct libmnt_monitor *mn,
struct monitor_entry *me)
{
char buf[sizeof(struct inotify_event) + NAME_MAX + 1];
@@ -133,7 +133,7 @@ static int userspace_event_verify(struct libmnt_monitor *mn,
if (!me || me->fd < 0)
return 0;
- DBG(MONITOR, ul_debugobj(mn, "drain and verify userspace monitor inotify"));
+ DBG(MONITOR, ul_debugobj(mn, "process utab event"));
/* the me->fd is non-blocking */
do {
@@ -177,7 +177,7 @@ static int userspace_event_verify(struct libmnt_monitor *mn,
static const struct monitor_opers userspace_opers = {
.op_get_fd = userspace_monitor_get_fd,
.op_close_fd = userspace_monitor_close_fd,
- .op_event_verify = userspace_event_verify
+ .op_process_event = userspace_process_event
};
/**