aboutsummaryrefslogtreecommitdiffstats
path: root/libmount/src/monitor.h
blob: a7859c0750eff270689e447802e0114ac7a21987 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* SPDX-License-Identifier: LGPL-2.1-or-later */

#ifndef _MNTMONITOR_PRIVATE_H
#define _MNTMONITOR_PRIVATE_H

#include "c.h"
#include <stdbool.h>

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 */

	const struct monitor_opers *opers;
	void			*data;		/* private type-specific data */

	bool			enabled,	/* monitoring fd */
				active;		/* ready for mnt_monitor_next_change() */

	struct list_head	ents;
};

struct libmnt_monitor {
	int			refcount;
	int			fd;		/* public monitor file descriptor */

	struct list_head	ents;
	struct monitor_entry	*last;		/* last active returned by mnt_monitor_next_change() */

	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_process_event)(struct libmnt_monitor *, struct monitor_entry *);
	int (*op_next_fs)(struct libmnt_monitor *, struct monitor_entry *, struct libmnt_fs *);
};

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, int id);
struct monitor_entry *monitor_new_entry(struct libmnt_monitor *mn);
void free_monitor_entry(struct monitor_entry *me);

#endif /* _MNTMONITOR_PRIVATE_H */