Skip to content

Commit fb6ebf3

Browse files
author
EKatWired
committed
Add fanotify
1 parent 3b15c17 commit fb6ebf3

21 files changed

Lines changed: 3183 additions & 0 deletions

File tree

gen/modules/general.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/eventpoll.h>
1010
#include <linux/fadvise.h>
1111
#include <linux/falloc.h>
12+
#include <linux/fanotify.h>
1213
#include <linux/fcntl.h>
1314
#include <linux/fs.h>
1415
#include <linux/futex.h>

src/aarch64/general.rs

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,79 @@ pub __pad: __u8,
170170
}
171171
#[repr(C)]
172172
#[derive(Debug, Copy, Clone)]
173+
pub struct fanotify_event_metadata {
174+
pub event_len: __u32,
175+
pub vers: __u8,
176+
pub reserved: __u8,
177+
pub metadata_len: __u16,
178+
pub mask: __u64,
179+
pub fd: __s32,
180+
pub pid: __s32,
181+
}
182+
#[repr(C)]
183+
#[derive(Debug, Copy, Clone)]
184+
pub struct fanotify_event_info_header {
185+
pub info_type: __u8,
186+
pub pad: __u8,
187+
pub len: __u16,
188+
}
189+
#[repr(C)]
190+
#[derive(Debug)]
191+
pub struct fanotify_event_info_fid {
192+
pub hdr: fanotify_event_info_header,
193+
pub fsid: __kernel_fsid_t,
194+
pub handle: __IncompleteArrayField<crate::ctypes::c_uchar>,
195+
}
196+
#[repr(C)]
197+
#[derive(Debug, Copy, Clone)]
198+
pub struct fanotify_event_info_pidfd {
199+
pub hdr: fanotify_event_info_header,
200+
pub pidfd: __s32,
201+
}
202+
#[repr(C)]
203+
#[derive(Debug, Copy, Clone)]
204+
pub struct fanotify_event_info_error {
205+
pub hdr: fanotify_event_info_header,
206+
pub error: __s32,
207+
pub error_count: __u32,
208+
}
209+
#[repr(C)]
210+
#[derive(Debug, Copy, Clone)]
211+
pub struct fanotify_event_info_range {
212+
pub hdr: fanotify_event_info_header,
213+
pub pad: __u32,
214+
pub offset: __u64,
215+
pub count: __u64,
216+
}
217+
#[repr(C)]
218+
#[derive(Debug, Copy, Clone)]
219+
pub struct fanotify_event_info_mnt {
220+
pub hdr: fanotify_event_info_header,
221+
pub mnt_id: __u64,
222+
}
223+
#[repr(C)]
224+
#[derive(Debug, Copy, Clone)]
225+
pub struct fanotify_response {
226+
pub fd: __s32,
227+
pub response: __u32,
228+
}
229+
#[repr(C)]
230+
#[derive(Debug, Copy, Clone)]
231+
pub struct fanotify_response_info_header {
232+
pub type_: __u8,
233+
pub pad: __u8,
234+
pub len: __u16,
235+
}
236+
#[repr(C)]
237+
#[derive(Debug, Copy, Clone)]
238+
pub struct fanotify_response_info_audit_rule {
239+
pub hdr: fanotify_response_info_header,
240+
pub rule_number: __u32,
241+
pub subj_trust: __u32,
242+
pub obj_trust: __u32,
243+
}
244+
#[repr(C)]
245+
#[derive(Debug, Copy, Clone)]
173246
pub struct fscrypt_policy_v1 {
174247
pub version: __u8,
175248
pub contents_encryption_mode: __u8,
@@ -1271,6 +1344,92 @@ pub const FALLOC_FL_ZERO_RANGE: u32 = 16;
12711344
pub const FALLOC_FL_INSERT_RANGE: u32 = 32;
12721345
pub const FALLOC_FL_UNSHARE_RANGE: u32 = 64;
12731346
pub const FALLOC_FL_WRITE_ZEROES: u32 = 128;
1347+
pub const FAN_ACCESS: u32 = 1;
1348+
pub const FAN_MODIFY: u32 = 2;
1349+
pub const FAN_ATTRIB: u32 = 4;
1350+
pub const FAN_CLOSE_WRITE: u32 = 8;
1351+
pub const FAN_CLOSE_NOWRITE: u32 = 16;
1352+
pub const FAN_OPEN: u32 = 32;
1353+
pub const FAN_MOVED_FROM: u32 = 64;
1354+
pub const FAN_MOVED_TO: u32 = 128;
1355+
pub const FAN_CREATE: u32 = 256;
1356+
pub const FAN_DELETE: u32 = 512;
1357+
pub const FAN_DELETE_SELF: u32 = 1024;
1358+
pub const FAN_MOVE_SELF: u32 = 2048;
1359+
pub const FAN_OPEN_EXEC: u32 = 4096;
1360+
pub const FAN_Q_OVERFLOW: u32 = 16384;
1361+
pub const FAN_FS_ERROR: u32 = 32768;
1362+
pub const FAN_OPEN_PERM: u32 = 65536;
1363+
pub const FAN_ACCESS_PERM: u32 = 131072;
1364+
pub const FAN_OPEN_EXEC_PERM: u32 = 262144;
1365+
pub const FAN_PRE_ACCESS: u32 = 1048576;
1366+
pub const FAN_MNT_ATTACH: u32 = 16777216;
1367+
pub const FAN_MNT_DETACH: u32 = 33554432;
1368+
pub const FAN_EVENT_ON_CHILD: u32 = 134217728;
1369+
pub const FAN_RENAME: u32 = 268435456;
1370+
pub const FAN_ONDIR: u32 = 1073741824;
1371+
pub const FAN_CLOSE: u32 = 24;
1372+
pub const FAN_MOVE: u32 = 192;
1373+
pub const FAN_CLOEXEC: u32 = 1;
1374+
pub const FAN_NONBLOCK: u32 = 2;
1375+
pub const FAN_CLASS_NOTIF: u32 = 0;
1376+
pub const FAN_CLASS_CONTENT: u32 = 4;
1377+
pub const FAN_CLASS_PRE_CONTENT: u32 = 8;
1378+
pub const FAN_ALL_CLASS_BITS: u32 = 12;
1379+
pub const FAN_UNLIMITED_QUEUE: u32 = 16;
1380+
pub const FAN_UNLIMITED_MARKS: u32 = 32;
1381+
pub const FAN_ENABLE_AUDIT: u32 = 64;
1382+
pub const FAN_REPORT_PIDFD: u32 = 128;
1383+
pub const FAN_REPORT_TID: u32 = 256;
1384+
pub const FAN_REPORT_FID: u32 = 512;
1385+
pub const FAN_REPORT_DIR_FID: u32 = 1024;
1386+
pub const FAN_REPORT_NAME: u32 = 2048;
1387+
pub const FAN_REPORT_TARGET_FID: u32 = 4096;
1388+
pub const FAN_REPORT_FD_ERROR: u32 = 8192;
1389+
pub const FAN_REPORT_MNT: u32 = 16384;
1390+
pub const FAN_REPORT_DFID_NAME: u32 = 3072;
1391+
pub const FAN_REPORT_DFID_NAME_TARGET: u32 = 7680;
1392+
pub const FAN_ALL_INIT_FLAGS: u32 = 63;
1393+
pub const FAN_MARK_ADD: u32 = 1;
1394+
pub const FAN_MARK_REMOVE: u32 = 2;
1395+
pub const FAN_MARK_DONT_FOLLOW: u32 = 4;
1396+
pub const FAN_MARK_ONLYDIR: u32 = 8;
1397+
pub const FAN_MARK_IGNORED_MASK: u32 = 32;
1398+
pub const FAN_MARK_IGNORED_SURV_MODIFY: u32 = 64;
1399+
pub const FAN_MARK_FLUSH: u32 = 128;
1400+
pub const FAN_MARK_EVICTABLE: u32 = 512;
1401+
pub const FAN_MARK_IGNORE: u32 = 1024;
1402+
pub const FAN_MARK_INODE: u32 = 0;
1403+
pub const FAN_MARK_MOUNT: u32 = 16;
1404+
pub const FAN_MARK_FILESYSTEM: u32 = 256;
1405+
pub const FAN_MARK_MNTNS: u32 = 272;
1406+
pub const FAN_MARK_IGNORE_SURV: u32 = 1088;
1407+
pub const FAN_ALL_MARK_FLAGS: u32 = 255;
1408+
pub const FAN_ALL_EVENTS: u32 = 59;
1409+
pub const FAN_ALL_PERM_EVENTS: u32 = 196608;
1410+
pub const FAN_ALL_OUTGOING_EVENTS: u32 = 213051;
1411+
pub const FANOTIFY_METADATA_VERSION: u32 = 3;
1412+
pub const FAN_EVENT_INFO_TYPE_FID: u32 = 1;
1413+
pub const FAN_EVENT_INFO_TYPE_DFID_NAME: u32 = 2;
1414+
pub const FAN_EVENT_INFO_TYPE_DFID: u32 = 3;
1415+
pub const FAN_EVENT_INFO_TYPE_PIDFD: u32 = 4;
1416+
pub const FAN_EVENT_INFO_TYPE_ERROR: u32 = 5;
1417+
pub const FAN_EVENT_INFO_TYPE_RANGE: u32 = 6;
1418+
pub const FAN_EVENT_INFO_TYPE_MNT: u32 = 7;
1419+
pub const FAN_EVENT_INFO_TYPE_OLD_DFID_NAME: u32 = 10;
1420+
pub const FAN_EVENT_INFO_TYPE_NEW_DFID_NAME: u32 = 12;
1421+
pub const FAN_RESPONSE_INFO_NONE: u32 = 0;
1422+
pub const FAN_RESPONSE_INFO_AUDIT_RULE: u32 = 1;
1423+
pub const FAN_ALLOW: u32 = 1;
1424+
pub const FAN_DENY: u32 = 2;
1425+
pub const FAN_ERRNO_BITS: u32 = 8;
1426+
pub const FAN_ERRNO_SHIFT: u32 = 24;
1427+
pub const FAN_ERRNO_MASK: u32 = 255;
1428+
pub const FAN_AUDIT: u32 = 16;
1429+
pub const FAN_INFO: u32 = 32;
1430+
pub const FAN_NOFD: i32 = -1;
1431+
pub const FAN_NOPIDFD: i32 = -1;
1432+
pub const FAN_EPIDFD: i32 = -2;
12741433
pub const NR_OPEN: u32 = 1024;
12751434
pub const NGROUPS_MAX: u32 = 65536;
12761435
pub const ARG_MAX: u32 = 131072;

src/arm/general.rs

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,79 @@ pub __pad: __u8,
168168
}
169169
#[repr(C)]
170170
#[derive(Debug, Copy, Clone)]
171+
pub struct fanotify_event_metadata {
172+
pub event_len: __u32,
173+
pub vers: __u8,
174+
pub reserved: __u8,
175+
pub metadata_len: __u16,
176+
pub mask: __u64,
177+
pub fd: __s32,
178+
pub pid: __s32,
179+
}
180+
#[repr(C)]
181+
#[derive(Debug, Copy, Clone)]
182+
pub struct fanotify_event_info_header {
183+
pub info_type: __u8,
184+
pub pad: __u8,
185+
pub len: __u16,
186+
}
187+
#[repr(C)]
188+
#[derive(Debug)]
189+
pub struct fanotify_event_info_fid {
190+
pub hdr: fanotify_event_info_header,
191+
pub fsid: __kernel_fsid_t,
192+
pub handle: __IncompleteArrayField<crate::ctypes::c_uchar>,
193+
}
194+
#[repr(C)]
195+
#[derive(Debug, Copy, Clone)]
196+
pub struct fanotify_event_info_pidfd {
197+
pub hdr: fanotify_event_info_header,
198+
pub pidfd: __s32,
199+
}
200+
#[repr(C)]
201+
#[derive(Debug, Copy, Clone)]
202+
pub struct fanotify_event_info_error {
203+
pub hdr: fanotify_event_info_header,
204+
pub error: __s32,
205+
pub error_count: __u32,
206+
}
207+
#[repr(C)]
208+
#[derive(Debug, Copy, Clone)]
209+
pub struct fanotify_event_info_range {
210+
pub hdr: fanotify_event_info_header,
211+
pub pad: __u32,
212+
pub offset: __u64,
213+
pub count: __u64,
214+
}
215+
#[repr(C)]
216+
#[derive(Debug, Copy, Clone)]
217+
pub struct fanotify_event_info_mnt {
218+
pub hdr: fanotify_event_info_header,
219+
pub mnt_id: __u64,
220+
}
221+
#[repr(C)]
222+
#[derive(Debug, Copy, Clone)]
223+
pub struct fanotify_response {
224+
pub fd: __s32,
225+
pub response: __u32,
226+
}
227+
#[repr(C)]
228+
#[derive(Debug, Copy, Clone)]
229+
pub struct fanotify_response_info_header {
230+
pub type_: __u8,
231+
pub pad: __u8,
232+
pub len: __u16,
233+
}
234+
#[repr(C)]
235+
#[derive(Debug, Copy, Clone)]
236+
pub struct fanotify_response_info_audit_rule {
237+
pub hdr: fanotify_response_info_header,
238+
pub rule_number: __u32,
239+
pub subj_trust: __u32,
240+
pub obj_trust: __u32,
241+
}
242+
#[repr(C)]
243+
#[derive(Debug, Copy, Clone)]
171244
pub struct fscrypt_policy_v1 {
172245
pub version: __u8,
173246
pub contents_encryption_mode: __u8,
@@ -1303,6 +1376,92 @@ pub const FALLOC_FL_ZERO_RANGE: u32 = 16;
13031376
pub const FALLOC_FL_INSERT_RANGE: u32 = 32;
13041377
pub const FALLOC_FL_UNSHARE_RANGE: u32 = 64;
13051378
pub const FALLOC_FL_WRITE_ZEROES: u32 = 128;
1379+
pub const FAN_ACCESS: u32 = 1;
1380+
pub const FAN_MODIFY: u32 = 2;
1381+
pub const FAN_ATTRIB: u32 = 4;
1382+
pub const FAN_CLOSE_WRITE: u32 = 8;
1383+
pub const FAN_CLOSE_NOWRITE: u32 = 16;
1384+
pub const FAN_OPEN: u32 = 32;
1385+
pub const FAN_MOVED_FROM: u32 = 64;
1386+
pub const FAN_MOVED_TO: u32 = 128;
1387+
pub const FAN_CREATE: u32 = 256;
1388+
pub const FAN_DELETE: u32 = 512;
1389+
pub const FAN_DELETE_SELF: u32 = 1024;
1390+
pub const FAN_MOVE_SELF: u32 = 2048;
1391+
pub const FAN_OPEN_EXEC: u32 = 4096;
1392+
pub const FAN_Q_OVERFLOW: u32 = 16384;
1393+
pub const FAN_FS_ERROR: u32 = 32768;
1394+
pub const FAN_OPEN_PERM: u32 = 65536;
1395+
pub const FAN_ACCESS_PERM: u32 = 131072;
1396+
pub const FAN_OPEN_EXEC_PERM: u32 = 262144;
1397+
pub const FAN_PRE_ACCESS: u32 = 1048576;
1398+
pub const FAN_MNT_ATTACH: u32 = 16777216;
1399+
pub const FAN_MNT_DETACH: u32 = 33554432;
1400+
pub const FAN_EVENT_ON_CHILD: u32 = 134217728;
1401+
pub const FAN_RENAME: u32 = 268435456;
1402+
pub const FAN_ONDIR: u32 = 1073741824;
1403+
pub const FAN_CLOSE: u32 = 24;
1404+
pub const FAN_MOVE: u32 = 192;
1405+
pub const FAN_CLOEXEC: u32 = 1;
1406+
pub const FAN_NONBLOCK: u32 = 2;
1407+
pub const FAN_CLASS_NOTIF: u32 = 0;
1408+
pub const FAN_CLASS_CONTENT: u32 = 4;
1409+
pub const FAN_CLASS_PRE_CONTENT: u32 = 8;
1410+
pub const FAN_ALL_CLASS_BITS: u32 = 12;
1411+
pub const FAN_UNLIMITED_QUEUE: u32 = 16;
1412+
pub const FAN_UNLIMITED_MARKS: u32 = 32;
1413+
pub const FAN_ENABLE_AUDIT: u32 = 64;
1414+
pub const FAN_REPORT_PIDFD: u32 = 128;
1415+
pub const FAN_REPORT_TID: u32 = 256;
1416+
pub const FAN_REPORT_FID: u32 = 512;
1417+
pub const FAN_REPORT_DIR_FID: u32 = 1024;
1418+
pub const FAN_REPORT_NAME: u32 = 2048;
1419+
pub const FAN_REPORT_TARGET_FID: u32 = 4096;
1420+
pub const FAN_REPORT_FD_ERROR: u32 = 8192;
1421+
pub const FAN_REPORT_MNT: u32 = 16384;
1422+
pub const FAN_REPORT_DFID_NAME: u32 = 3072;
1423+
pub const FAN_REPORT_DFID_NAME_TARGET: u32 = 7680;
1424+
pub const FAN_ALL_INIT_FLAGS: u32 = 63;
1425+
pub const FAN_MARK_ADD: u32 = 1;
1426+
pub const FAN_MARK_REMOVE: u32 = 2;
1427+
pub const FAN_MARK_DONT_FOLLOW: u32 = 4;
1428+
pub const FAN_MARK_ONLYDIR: u32 = 8;
1429+
pub const FAN_MARK_IGNORED_MASK: u32 = 32;
1430+
pub const FAN_MARK_IGNORED_SURV_MODIFY: u32 = 64;
1431+
pub const FAN_MARK_FLUSH: u32 = 128;
1432+
pub const FAN_MARK_EVICTABLE: u32 = 512;
1433+
pub const FAN_MARK_IGNORE: u32 = 1024;
1434+
pub const FAN_MARK_INODE: u32 = 0;
1435+
pub const FAN_MARK_MOUNT: u32 = 16;
1436+
pub const FAN_MARK_FILESYSTEM: u32 = 256;
1437+
pub const FAN_MARK_MNTNS: u32 = 272;
1438+
pub const FAN_MARK_IGNORE_SURV: u32 = 1088;
1439+
pub const FAN_ALL_MARK_FLAGS: u32 = 255;
1440+
pub const FAN_ALL_EVENTS: u32 = 59;
1441+
pub const FAN_ALL_PERM_EVENTS: u32 = 196608;
1442+
pub const FAN_ALL_OUTGOING_EVENTS: u32 = 213051;
1443+
pub const FANOTIFY_METADATA_VERSION: u32 = 3;
1444+
pub const FAN_EVENT_INFO_TYPE_FID: u32 = 1;
1445+
pub const FAN_EVENT_INFO_TYPE_DFID_NAME: u32 = 2;
1446+
pub const FAN_EVENT_INFO_TYPE_DFID: u32 = 3;
1447+
pub const FAN_EVENT_INFO_TYPE_PIDFD: u32 = 4;
1448+
pub const FAN_EVENT_INFO_TYPE_ERROR: u32 = 5;
1449+
pub const FAN_EVENT_INFO_TYPE_RANGE: u32 = 6;
1450+
pub const FAN_EVENT_INFO_TYPE_MNT: u32 = 7;
1451+
pub const FAN_EVENT_INFO_TYPE_OLD_DFID_NAME: u32 = 10;
1452+
pub const FAN_EVENT_INFO_TYPE_NEW_DFID_NAME: u32 = 12;
1453+
pub const FAN_RESPONSE_INFO_NONE: u32 = 0;
1454+
pub const FAN_RESPONSE_INFO_AUDIT_RULE: u32 = 1;
1455+
pub const FAN_ALLOW: u32 = 1;
1456+
pub const FAN_DENY: u32 = 2;
1457+
pub const FAN_ERRNO_BITS: u32 = 8;
1458+
pub const FAN_ERRNO_SHIFT: u32 = 24;
1459+
pub const FAN_ERRNO_MASK: u32 = 255;
1460+
pub const FAN_AUDIT: u32 = 16;
1461+
pub const FAN_INFO: u32 = 32;
1462+
pub const FAN_NOFD: i32 = -1;
1463+
pub const FAN_NOPIDFD: i32 = -1;
1464+
pub const FAN_EPIDFD: i32 = -2;
13061465
pub const NR_OPEN: u32 = 1024;
13071466
pub const NGROUPS_MAX: u32 = 65536;
13081467
pub const ARG_MAX: u32 = 131072;

0 commit comments

Comments
 (0)