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>
list_add_tail(&me->ents, &mn->ents);
me->fd = -1;
+ me->id = -1;
return me;
}
}
/* 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;
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 */
};
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);
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)
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)