Skip to content

Commit

Permalink
Added new constants from fanotify linux api
Browse files Browse the repository at this point in the history
  • Loading branch information
ad0 committed Oct 28, 2023
1 parent 77a5c7e commit b25b425
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 17 deletions.
18 changes: 16 additions & 2 deletions libc-test/build.rs
Expand Up @@ -3738,8 +3738,6 @@ fn test_linux(target: &str) {

// kernel constants not available in uclibc 1.0.34
| "EXTPROC"
| "FAN_MARK_FILESYSTEM"
| "FAN_MARK_INODE"
| "IPPROTO_BEETPH"
| "IPPROTO_MPLS"
| "IPV6_HDRINCL"
Expand Down Expand Up @@ -3876,6 +3874,22 @@ fn test_linux(target: &str) {
// kernel 6.5 minimum
"MOVE_MOUNT_BENEATH" => true,

// FIXME: Requires more recent kernel headers
| "FAN_FS_ERROR" // linux v5.16+
| "FAN_RENAME" // linux v5.17+
| "FAN_REPORT_TARGET_FID" // linux v5.17+
| "FAN_REPORT_DFID_NAME_TARGET" // linux v5.17+
| "FAN_MARK_EVICTABLE" // linux v5.19+
| "FAN_MARK_IGNORE" // linux v6.0+
| "FAN_MARK_IGNORE_SURV" // linux v6.0+
| "FAN_EVENT_INFO_TYPE_ERROR" // linux v5.16+
| "FAN_EVENT_INFO_TYPE_OLD_DFID_NAME" // linux v5.17+
| "FAN_EVENT_INFO_TYPE_NEW_DFID_NAME" // linux v5.17+
| "FAN_RESPONSE_INFO_NONE" // linux v5.16+
| "FAN_RESPONSE_INFO_AUDIT_RULE" // linux v5.16+
| "FAN_INFO" // linux v5.16+
=> true,

_ => false,
}
});
Expand Down
37 changes: 37 additions & 0 deletions libc-test/semver/linux.txt
Expand Up @@ -717,32 +717,69 @@ FANOTIFY_METADATA_VERSION
FAN_ACCESS
FAN_ACCESS_PERM
FAN_ALLOW
FAN_ATTRIB
FAN_AUDIT
FAN_CLASS_CONTENT
FAN_CLASS_NOTIF
FAN_CLASS_PRE_CONTENT
FAN_CLOEXEC
FAN_CLOSE
FAN_CLOSE_NOWRITE
FAN_CLOSE_WRITE
FAN_CREATE
FAN_DELETE
FAN_DELETE_SELF
FAN_DENY
FAN_ENABLE_AUDIT
FAN_EPIDFD
FAN_EVENT_INFO_TYPE_DFID
FAN_EVENT_INFO_TYPE_DFID_NAME
FAN_EVENT_INFO_TYPE_ERROR
FAN_EVENT_INFO_TYPE_FID
FAN_EVENT_INFO_TYPE_NEW_DFID_NAME
FAN_EVENT_INFO_TYPE_OLD_DFID_NAME
FAN_EVENT_INFO_TYPE_PIDFD
FAN_EVENT_ON_CHILD
FAN_FS_ERROR
FAN_INFO
FAN_MARK_ADD
FAN_MARK_DONT_FOLLOW
FAN_MARK_EVICTABLE
FAN_MARK_FILESYSTEM
FAN_MARK_FLUSH
FAN_MARK_IGNORE
FAN_MARK_IGNORED_MASK
FAN_MARK_IGNORED_SURV_MODIFY
FAN_MARK_IGNORE_SURV
FAN_MARK_INODE
FAN_MARK_MOUNT
FAN_MARK_ONLYDIR
FAN_MARK_REMOVE
FAN_MODIFY
FAN_MOVE
FAN_MOVED_FROM
FAN_MOVED_TO
FAN_MOVE_SELF
FAN_NOFD
FAN_NONBLOCK
FAN_NOPIDFD
FAN_ONDIR
FAN_OPEN
FAN_OPEN_EXEC
FAN_OPEN_EXEC_PERM
FAN_OPEN_PERM
FAN_Q_OVERFLOW
FAN_RENAME
FAN_REPORT_DFID_NAME
FAN_REPORT_DFID_NAME_TARGET
FAN_REPORT_DIR_FID
FAN_REPORT_FID
FAN_REPORT_NAME
FAN_REPORT_PIDFD
FAN_REPORT_TARGET_FID
FAN_REPORT_TID
FAN_RESPONSE_INFO_AUDIT_RULE
FAN_RESPONSE_INFO_NONE
FAN_UNLIMITED_MARKS
FAN_UNLIMITED_QUEUE
FF0
Expand Down
5 changes: 0 additions & 5 deletions src/unix/linux_like/linux/gnu/mod.rs
Expand Up @@ -718,11 +718,6 @@ pub const SOCK_SEQPACKET: ::c_int = 5;
pub const SOCK_DCCP: ::c_int = 6;
pub const SOCK_PACKET: ::c_int = 10;

pub const FAN_MARK_INODE: ::c_uint = 0x0000_0000;
pub const FAN_MARK_MOUNT: ::c_uint = 0x0000_0010;
// NOTE: FAN_MARK_FILESYSTEM requires Linux Kernel >= 4.20.0
pub const FAN_MARK_FILESYSTEM: ::c_uint = 0x0000_0100;

pub const AF_IB: ::c_int = 27;
pub const AF_MPLS: ::c_int = 28;
pub const AF_NFC: ::c_int = 39;
Expand Down
53 changes: 51 additions & 2 deletions src/unix/linux_like/linux/mod.rs
Expand Up @@ -3566,20 +3566,33 @@ pub const UINPUT_MAX_NAME_SIZE: usize = 80;
// uapi/linux/fanotify.h
pub const FAN_ACCESS: u64 = 0x0000_0001;
pub const FAN_MODIFY: u64 = 0x0000_0002;
pub const FAN_ATTRIB: u64 = 0x0000_0004;
pub const FAN_CLOSE_WRITE: u64 = 0x0000_0008;
pub const FAN_CLOSE_NOWRITE: u64 = 0x0000_0010;
pub const FAN_OPEN: u64 = 0x0000_0020;
pub const FAN_MOVED_FROM: u64 = 0x0000_0040;
pub const FAN_MOVED_TO: u64 = 0x0000_0080;
pub const FAN_CREATE: u64 = 0x0000_0100;
pub const FAN_DELETE: u64 = 0x0000_0200;
pub const FAN_DELETE_SELF: u64 = 0x0000_0400;
pub const FAN_MOVE_SELF: u64 = 0x0000_0800;
pub const FAN_OPEN_EXEC: u64 = 0x0000_1000;

pub const FAN_Q_OVERFLOW: u64 = 0x0000_4000;
pub const FAN_FS_ERROR: u64 = 0x0000_8000;

pub const FAN_OPEN_PERM: u64 = 0x0001_0000;
pub const FAN_ACCESS_PERM: u64 = 0x0002_0000;

pub const FAN_ONDIR: u64 = 0x4000_0000;
pub const FAN_OPEN_EXEC_PERM: u64 = 0x0004_0000;

pub const FAN_EVENT_ON_CHILD: u64 = 0x0800_0000;

pub const FAN_RENAME: u64 = 0x1000_0000;

pub const FAN_ONDIR: u64 = 0x4000_0000;

pub const FAN_CLOSE: u64 = FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE;
pub const FAN_MOVE: u64 = FAN_MOVED_FROM | FAN_MOVED_TO;

pub const FAN_CLOEXEC: ::c_uint = 0x0000_0001;
pub const FAN_NONBLOCK: ::c_uint = 0x0000_0002;
Expand All @@ -3590,6 +3603,18 @@ pub const FAN_CLASS_PRE_CONTENT: ::c_uint = 0x0000_0008;

pub const FAN_UNLIMITED_QUEUE: ::c_uint = 0x0000_0010;
pub const FAN_UNLIMITED_MARKS: ::c_uint = 0x0000_0020;
pub const FAN_ENABLE_AUDIT: ::c_uint = 0x0000_0040;

pub const FAN_REPORT_PIDFD: ::c_uint = 0x0000_0080;
pub const FAN_REPORT_TID: ::c_uint = 0x0000_0100;
pub const FAN_REPORT_FID: ::c_uint = 0x0000_0200;
pub const FAN_REPORT_DIR_FID: ::c_uint = 0x0000_0400;
pub const FAN_REPORT_NAME: ::c_uint = 0x0000_0800;
pub const FAN_REPORT_TARGET_FID: ::c_uint = 0x0000_1000;

pub const FAN_REPORT_DFID_NAME: ::c_uint = FAN_REPORT_DIR_FID | FAN_REPORT_NAME;
pub const FAN_REPORT_DFID_NAME_TARGET: ::c_uint =
FAN_REPORT_DFID_NAME | FAN_REPORT_FID | FAN_REPORT_TARGET_FID;

pub const FAN_MARK_ADD: ::c_uint = 0x0000_0001;
pub const FAN_MARK_REMOVE: ::c_uint = 0x0000_0002;
Expand All @@ -3598,13 +3623,37 @@ pub const FAN_MARK_ONLYDIR: ::c_uint = 0x0000_0008;
pub const FAN_MARK_IGNORED_MASK: ::c_uint = 0x0000_0020;
pub const FAN_MARK_IGNORED_SURV_MODIFY: ::c_uint = 0x0000_0040;
pub const FAN_MARK_FLUSH: ::c_uint = 0x0000_0080;
pub const FAN_MARK_EVICTABLE: ::c_uint = 0x0000_0200;
pub const FAN_MARK_IGNORE: ::c_uint = 0x0000_0100;

pub const FAN_MARK_INODE: ::c_uint = 0x0000_0000;
pub const FAN_MARK_MOUNT: ::c_uint = 0x0000_0010;
pub const FAN_MARK_FILESYSTEM: ::c_uint = 0x0000_0100;

pub const FAN_MARK_IGNORE_SURV: ::c_uint = FAN_MARK_IGNORE | FAN_MARK_IGNORED_SURV_MODIFY;

pub const FANOTIFY_METADATA_VERSION: u8 = 3;

pub const FAN_EVENT_INFO_TYPE_FID: u8 = 1;
pub const FAN_EVENT_INFO_TYPE_DFID_NAME: u8 = 2;
pub const FAN_EVENT_INFO_TYPE_DFID: u8 = 3;
pub const FAN_EVENT_INFO_TYPE_PIDFD: u8 = 4;
pub const FAN_EVENT_INFO_TYPE_ERROR: u8 = 5;

pub const FAN_EVENT_INFO_TYPE_OLD_DFID_NAME: u8 = 10;
pub const FAN_EVENT_INFO_TYPE_NEW_DFID_NAME: u8 = 12;

pub const FAN_RESPONSE_INFO_NONE: u8 = 0;
pub const FAN_RESPONSE_INFO_AUDIT_RULE: u8 = 1;

pub const FAN_ALLOW: u32 = 0x01;
pub const FAN_DENY: u32 = 0x02;
pub const FAN_AUDIT: u32 = 0x10;
pub const FAN_INFO: u32 = 0x20;

pub const FAN_NOFD: ::c_int = -1;
pub const FAN_NOPIDFD: ::c_int = FAN_NOFD;
pub const FAN_EPIDFD: ::c_int = -2;

pub const FUTEX_WAIT: ::c_int = 0;
pub const FUTEX_WAKE: ::c_int = 1;
Expand Down
5 changes: 0 additions & 5 deletions src/unix/linux_like/linux/musl/mod.rs
Expand Up @@ -592,11 +592,6 @@ pub const PTRACE_INTERRUPT: ::c_int = 0x4207;
pub const PTRACE_LISTEN: ::c_int = 0x4208;
pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209;

pub const FAN_MARK_INODE: ::c_uint = 0x0000_0000;
pub const FAN_MARK_MOUNT: ::c_uint = 0x0000_0010;
// NOTE: FAN_MARK_FILESYSTEM requires Linux Kernel >= 4.20.0
pub const FAN_MARK_FILESYSTEM: ::c_uint = 0x0000_0100;

pub const AF_IB: ::c_int = 27;
pub const AF_MPLS: ::c_int = 28;
pub const AF_NFC: ::c_int = 39;
Expand Down
3 changes: 0 additions & 3 deletions src/unix/linux_like/linux/uclibc/mod.rs
Expand Up @@ -246,9 +246,6 @@ pub const EDEADLOCK: ::c_int = EDEADLK;
pub const EXTA: ::c_uint = B19200;
pub const EXTB: ::c_uint = B38400;
pub const EXTPROC: ::tcflag_t = 0200000;
pub const FAN_MARK_FILESYSTEM: ::c_int = 0x00000100;
pub const FAN_MARK_INODE: ::c_int = 0x00000000;
pub const FAN_MARK_MOUNT: ::c_int = 0x10;
pub const FOPEN_MAX: ::c_int = 16;
pub const F_GETOWN: ::c_int = 9;
pub const F_OFD_GETLK: ::c_int = 36;
Expand Down

0 comments on commit b25b425

Please sign in to comment.