aboutsummaryrefslogtreecommitdiffstats
path: root/libmount/src
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2025-05-21 12:39:17 +0200
committerKarel Zak <kzak@redhat.com>2025-08-06 14:50:56 +0200
commit3285ebe18773dfcd6ed7ae7a1a9952d0abb3fb04 (patch)
tree8bf456dbdd99e2e193afb0f24cd9937dd2b1ba5e /libmount/src
parentdefd0a7eb534df5d4e3c5d72e228bcf8c18b8b72 (diff)
downloadutil-linux-3285ebe18773dfcd6ed7ae7a1a9952d0abb3fb04.tar.gz
libmount: (monitor) support additional monitor identifiers
This is necessary to support multiple monitors of the same type. Currently, only one monitor per type is supported. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
-rw-r--r--libmount/src/monitor.c5
-rw-r--r--libmount/src/monitor.h3
-rw-r--r--libmount/src/monitor_mountinfo.c2
-rw-r--r--libmount/src/monitor_utab.c2
4 files changed, 7 insertions, 5 deletions
diff --git a/libmount/src/monitor.c b/libmount/src/monitor.c
index fb68d0d67a..3044dcf682 100644
--- a/libmount/src/monitor.c
+++ b/libmount/src/monitor.c
@@ -124,6 +124,7 @@ struct monitor_entry *monitor_new_entry(struct libmnt_monitor *mn)
list_add_tail(&me->ents, &mn->ents);
me->fd = -1;
+ me->id = -1;
return me;
}
@@ -153,14 +154,14 @@ static int monitor_next_entry(struct libmnt_monitor *mn,
}
/* returns entry by type */
-struct monitor_entry *monitor_get_entry(struct libmnt_monitor *mn, int type)
+struct monitor_entry *monitor_get_entry(struct libmnt_monitor *mn, int type, int id)
{
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->type == type)
+ if (me->type == type && me->id == id)
return me;
}
return NULL;
diff --git a/libmount/src/monitor.h b/libmount/src/monitor.h
index a72658e953..6c6ba44506 100644
--- a/libmount/src/monitor.h
+++ b/libmount/src/monitor.h
@@ -8,6 +8,7 @@ struct monitor_opers;
struct monitor_entry {
int fd; /* private entry file descriptor */
+ int id; /* external identifier (-1 for undefined) */
char *path; /* path to the monitored file */
int type; /* MNT_MONITOR_TYPE_* */
uint32_t events; /* wanted epoll events */
@@ -36,7 +37,7 @@ struct monitor_opers {
};
int monitor_modify_epoll(struct libmnt_monitor *mn, struct monitor_entry *me, int enable);
-struct monitor_entry *monitor_get_entry(struct libmnt_monitor *mn, int type);
+struct monitor_entry *monitor_get_entry(struct libmnt_monitor *mn, int type, int id);
struct monitor_entry *monitor_new_entry(struct libmnt_monitor *mn);
void free_monitor_entry(struct monitor_entry *me);
diff --git a/libmount/src/monitor_mountinfo.c b/libmount/src/monitor_mountinfo.c
index 56171fd91a..3bffcb31fd 100644
--- a/libmount/src/monitor_mountinfo.c
+++ b/libmount/src/monitor_mountinfo.c
@@ -99,7 +99,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);
+ me = monitor_get_entry(mn, MNT_MONITOR_TYPE_KERNEL, -1);
if (me) {
rc = monitor_modify_epoll(mn, me, enable);
if (!enable)
diff --git a/libmount/src/monitor_utab.c b/libmount/src/monitor_utab.c
index d7261a9471..593e163296 100644
--- a/libmount/src/monitor_utab.c
+++ b/libmount/src/monitor_utab.c
@@ -209,7 +209,7 @@ int mnt_monitor_enable_userspace(struct libmnt_monitor *mn, int enable, const ch
if (!mn)
return -EINVAL;
- me = monitor_get_entry(mn, MNT_MONITOR_TYPE_USERSPACE);
+ me = monitor_get_entry(mn, MNT_MONITOR_TYPE_USERSPACE, -1);
if (me) {
rc = monitor_modify_epoll(mn, me, enable);
if (!enable)