History

fanotify: notify on mount attach and detach

Add notifications for attaching and detaching mounts. The following new event masks are added: FAN_MNT_ATTACH - Mount was attached FAN_MNT_DETACH - Mount was detached If a mount is moved, then the event is reported with (FAN_MNT_ATTACH | FAN_MNT_DETACH). These events add an info record of type FAN_EVENT_INFO_TYPE_MNT containing these fields identifying the affected mounts: __u64 mnt_id - the ID of the mount (see statmount(2)) FAN_REPORT_MNT must be supplied to fanotify_init() to receive these events and no other type of event can be received with this report type. Marks are added with FAN_MARK_MNTNS, which records the mount namespace from an nsfs file (e.g. /proc/self/ns/mnt).

Miklos Szeredi committed 1 year ago

Commit 0f46d811 parent b9442498 files · +164 −24Browse files

Showing the changes to include/uapi/linux (1 of 8 files). Show all

Unified · Split

include/uapi/linux/fanotify.h+10−0
@@ -28,6 +28,8 @@ · 27 unmodified lines
2828 /* #define FAN_DIR_MODIFY 0x00080000 */ /* Deprecated (reserved) */
2929
3030 #define FAN_PRE_ACCESS 0x00100000 /* Pre-content access hook */
31+#define FAN_MNT_ATTACH 0x01000000 /* Mount was attached */
32+#define FAN_MNT_DETACH 0x02000000 /* Mount was detached */
3133
3234 #define FAN_EVENT_ON_CHILD 0x08000000 /* Interested in child events */
3335
@@ -64,6 +66,7 @@ · 30 unmodified lines
6466 #define FAN_REPORT_NAME 0x00000800 /* Report events with name */
6567 #define FAN_REPORT_TARGET_FID 0x00001000 /* Report dirent target id */
6668 #define FAN_REPORT_FD_ERROR 0x00002000 /* event->fd can report error */
69+#define FAN_REPORT_MNT 0x00004000 /* Report mount events */
6770
6871 /* Convenience macro - FAN_REPORT_NAME requires FAN_REPORT_DIR_FID */
6972 #define FAN_REPORT_DFID_NAME (FAN_REPORT_DIR_FID | FAN_REPORT_NAME)
@@ -94,6 +97,7 @@ · 24 unmodified lines
9497 #define FAN_MARK_INODE 0x00000000
9598 #define FAN_MARK_MOUNT 0x00000010
9699 #define FAN_MARK_FILESYSTEM 0x00000100
100+#define FAN_MARK_MNTNS 0x00000110
97101
98102 /*
99103 * Convenience macro - FAN_MARK_IGNORE requires FAN_MARK_IGNORED_SURV_MODIFY
@@ -147,6 +151,7 @@ struct fanotify_event_metadata { · 47 unmodified lines
147151 #define FAN_EVENT_INFO_TYPE_PIDFD 4
148152 #define FAN_EVENT_INFO_TYPE_ERROR 5
149153 #define FAN_EVENT_INFO_TYPE_RANGE 6
154+#define FAN_EVENT_INFO_TYPE_MNT 7
150155
151156 /* Special info types for FAN_RENAME */
152157 #define FAN_EVENT_INFO_TYPE_OLD_DFID_NAME 10
@@ -200,6 +205,11 @@ struct fanotify_event_info_range { · 47 unmodified lines
200205 __u64 count;
201206 };
202207
208+struct fanotify_event_info_mnt {
209+ struct fanotify_event_info_header hdr;
210+ __u64 mnt_id;
211+};
212+
203213 /*
204214 * User space may need to record additional information about its decision.
205215 * The extra information type records what kind of information is included.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t