Skip to content

Commit c7e481e

Browse files
committed
Added new constants from fanotify linux api
1 parent 77a5c7e commit c7e481e

File tree

6 files changed

+118
-17
lines changed

6 files changed

+118
-17
lines changed

libc-test/build.rs

+30-2
Original file line numberDiff line numberDiff line change
@@ -3738,8 +3738,6 @@ fn test_linux(target: &str) {
37383738

37393739
// kernel constants not available in uclibc 1.0.34
37403740
| "EXTPROC"
3741-
| "FAN_MARK_FILESYSTEM"
3742-
| "FAN_MARK_INODE"
37433741
| "IPPROTO_BEETPH"
37443742
| "IPPROTO_MPLS"
37453743
| "IPV6_HDRINCL"
@@ -3876,6 +3874,36 @@ fn test_linux(target: &str) {
38763874
// kernel 6.5 minimum
38773875
"MOVE_MOUNT_BENEATH" => true,
38783876

3877+
// FIXME: Requires more recent kernel headers
3878+
| "FAN_FS_ERROR" // linux v5.16+
3879+
| "FAN_RENAME" // linux v5.17+
3880+
| "FAN_REPORT_TARGET_FID" // linux v5.17+
3881+
| "FAN_REPORT_DFID_NAME_TARGET" // linux v5.17+
3882+
| "FAN_MARK_EVICTABLE" // linux v5.19+
3883+
| "FAN_MARK_IGNORE" // linux v6.0+
3884+
| "FAN_MARK_IGNORE_SURV" // linux v6.0+
3885+
| "FAN_EVENT_INFO_TYPE_ERROR" // linux v5.16+
3886+
| "FAN_EVENT_INFO_TYPE_OLD_DFID_NAME" // linux v5.17+
3887+
| "FAN_EVENT_INFO_TYPE_NEW_DFID_NAME" // linux v5.17+
3888+
| "FAN_RESPONSE_INFO_NONE" // linux v5.16+
3889+
| "FAN_RESPONSE_INFO_AUDIT_RULE" // linux v5.16+
3890+
| "FAN_INFO" // linux v5.16+
3891+
=> true,
3892+
3893+
// FIXME: Requires linux 5.15+
3894+
"FAN_REPORT_PIDFD" if musl => true,
3895+
3896+
// FIXME: Requires linux 5.9+
3897+
| "FAN_REPORT_DIR_FID"
3898+
| "FAN_REPORT_NAME"
3899+
| "FAN_REPORT_DFID_NAME"
3900+
| "FAN_EVENT_INFO_TYPE_DFID_NAME"
3901+
| "FAN_EVENT_INFO_TYPE_DFID"
3902+
| "FAN_EVENT_INFO_TYPE_PIDFD"
3903+
| "FAN_NOPIDFD"
3904+
| "FAN_EPIDFD"
3905+
if musl => true,
3906+
38793907
_ => false,
38803908
}
38813909
});

libc-test/semver/linux.txt

+37
Original file line numberDiff line numberDiff line change
@@ -717,32 +717,69 @@ FANOTIFY_METADATA_VERSION
717717
FAN_ACCESS
718718
FAN_ACCESS_PERM
719719
FAN_ALLOW
720+
FAN_ATTRIB
721+
FAN_AUDIT
720722
FAN_CLASS_CONTENT
721723
FAN_CLASS_NOTIF
722724
FAN_CLASS_PRE_CONTENT
723725
FAN_CLOEXEC
724726
FAN_CLOSE
725727
FAN_CLOSE_NOWRITE
726728
FAN_CLOSE_WRITE
729+
FAN_CREATE
730+
FAN_DELETE
731+
FAN_DELETE_SELF
727732
FAN_DENY
733+
FAN_ENABLE_AUDIT
734+
FAN_EPIDFD
735+
FAN_EVENT_INFO_TYPE_DFID
736+
FAN_EVENT_INFO_TYPE_DFID_NAME
737+
FAN_EVENT_INFO_TYPE_ERROR
738+
FAN_EVENT_INFO_TYPE_FID
739+
FAN_EVENT_INFO_TYPE_NEW_DFID_NAME
740+
FAN_EVENT_INFO_TYPE_OLD_DFID_NAME
741+
FAN_EVENT_INFO_TYPE_PIDFD
728742
FAN_EVENT_ON_CHILD
743+
FAN_FS_ERROR
744+
FAN_INFO
729745
FAN_MARK_ADD
730746
FAN_MARK_DONT_FOLLOW
747+
FAN_MARK_EVICTABLE
731748
FAN_MARK_FILESYSTEM
732749
FAN_MARK_FLUSH
750+
FAN_MARK_IGNORE
733751
FAN_MARK_IGNORED_MASK
734752
FAN_MARK_IGNORED_SURV_MODIFY
753+
FAN_MARK_IGNORE_SURV
735754
FAN_MARK_INODE
736755
FAN_MARK_MOUNT
737756
FAN_MARK_ONLYDIR
738757
FAN_MARK_REMOVE
739758
FAN_MODIFY
759+
FAN_MOVE
760+
FAN_MOVED_FROM
761+
FAN_MOVED_TO
762+
FAN_MOVE_SELF
740763
FAN_NOFD
741764
FAN_NONBLOCK
765+
FAN_NOPIDFD
742766
FAN_ONDIR
743767
FAN_OPEN
768+
FAN_OPEN_EXEC
769+
FAN_OPEN_EXEC_PERM
744770
FAN_OPEN_PERM
745771
FAN_Q_OVERFLOW
772+
FAN_RENAME
773+
FAN_REPORT_DFID_NAME
774+
FAN_REPORT_DFID_NAME_TARGET
775+
FAN_REPORT_DIR_FID
776+
FAN_REPORT_FID
777+
FAN_REPORT_NAME
778+
FAN_REPORT_PIDFD
779+
FAN_REPORT_TARGET_FID
780+
FAN_REPORT_TID
781+
FAN_RESPONSE_INFO_AUDIT_RULE
782+
FAN_RESPONSE_INFO_NONE
746783
FAN_UNLIMITED_MARKS
747784
FAN_UNLIMITED_QUEUE
748785
FF0

src/unix/linux_like/linux/gnu/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -718,11 +718,6 @@ pub const SOCK_SEQPACKET: ::c_int = 5;
718718
pub const SOCK_DCCP: ::c_int = 6;
719719
pub const SOCK_PACKET: ::c_int = 10;
720720

721-
pub const FAN_MARK_INODE: ::c_uint = 0x0000_0000;
722-
pub const FAN_MARK_MOUNT: ::c_uint = 0x0000_0010;
723-
// NOTE: FAN_MARK_FILESYSTEM requires Linux Kernel >= 4.20.0
724-
pub const FAN_MARK_FILESYSTEM: ::c_uint = 0x0000_0100;
725-
726721
pub const AF_IB: ::c_int = 27;
727722
pub const AF_MPLS: ::c_int = 28;
728723
pub const AF_NFC: ::c_int = 39;

src/unix/linux_like/linux/mod.rs

+51-2
Original file line numberDiff line numberDiff line change
@@ -3566,20 +3566,33 @@ pub const UINPUT_MAX_NAME_SIZE: usize = 80;
35663566
// uapi/linux/fanotify.h
35673567
pub const FAN_ACCESS: u64 = 0x0000_0001;
35683568
pub const FAN_MODIFY: u64 = 0x0000_0002;
3569+
pub const FAN_ATTRIB: u64 = 0x0000_0004;
35693570
pub const FAN_CLOSE_WRITE: u64 = 0x0000_0008;
35703571
pub const FAN_CLOSE_NOWRITE: u64 = 0x0000_0010;
35713572
pub const FAN_OPEN: u64 = 0x0000_0020;
3573+
pub const FAN_MOVED_FROM: u64 = 0x0000_0040;
3574+
pub const FAN_MOVED_TO: u64 = 0x0000_0080;
3575+
pub const FAN_CREATE: u64 = 0x0000_0100;
3576+
pub const FAN_DELETE: u64 = 0x0000_0200;
3577+
pub const FAN_DELETE_SELF: u64 = 0x0000_0400;
3578+
pub const FAN_MOVE_SELF: u64 = 0x0000_0800;
3579+
pub const FAN_OPEN_EXEC: u64 = 0x0000_1000;
35723580

35733581
pub const FAN_Q_OVERFLOW: u64 = 0x0000_4000;
3582+
pub const FAN_FS_ERROR: u64 = 0x0000_8000;
35743583

35753584
pub const FAN_OPEN_PERM: u64 = 0x0001_0000;
35763585
pub const FAN_ACCESS_PERM: u64 = 0x0002_0000;
3577-
3578-
pub const FAN_ONDIR: u64 = 0x4000_0000;
3586+
pub const FAN_OPEN_EXEC_PERM: u64 = 0x0004_0000;
35793587

35803588
pub const FAN_EVENT_ON_CHILD: u64 = 0x0800_0000;
35813589

3590+
pub const FAN_RENAME: u64 = 0x1000_0000;
3591+
3592+
pub const FAN_ONDIR: u64 = 0x4000_0000;
3593+
35823594
pub const FAN_CLOSE: u64 = FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE;
3595+
pub const FAN_MOVE: u64 = FAN_MOVED_FROM | FAN_MOVED_TO;
35833596

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

35913604
pub const FAN_UNLIMITED_QUEUE: ::c_uint = 0x0000_0010;
35923605
pub const FAN_UNLIMITED_MARKS: ::c_uint = 0x0000_0020;
3606+
pub const FAN_ENABLE_AUDIT: ::c_uint = 0x0000_0040;
3607+
3608+
pub const FAN_REPORT_PIDFD: ::c_uint = 0x0000_0080;
3609+
pub const FAN_REPORT_TID: ::c_uint = 0x0000_0100;
3610+
pub const FAN_REPORT_FID: ::c_uint = 0x0000_0200;
3611+
pub const FAN_REPORT_DIR_FID: ::c_uint = 0x0000_0400;
3612+
pub const FAN_REPORT_NAME: ::c_uint = 0x0000_0800;
3613+
pub const FAN_REPORT_TARGET_FID: ::c_uint = 0x0000_1000;
3614+
3615+
pub const FAN_REPORT_DFID_NAME: ::c_uint = FAN_REPORT_DIR_FID | FAN_REPORT_NAME;
3616+
pub const FAN_REPORT_DFID_NAME_TARGET: ::c_uint =
3617+
FAN_REPORT_DFID_NAME | FAN_REPORT_FID | FAN_REPORT_TARGET_FID;
35933618

35943619
pub const FAN_MARK_ADD: ::c_uint = 0x0000_0001;
35953620
pub const FAN_MARK_REMOVE: ::c_uint = 0x0000_0002;
@@ -3598,13 +3623,37 @@ pub const FAN_MARK_ONLYDIR: ::c_uint = 0x0000_0008;
35983623
pub const FAN_MARK_IGNORED_MASK: ::c_uint = 0x0000_0020;
35993624
pub const FAN_MARK_IGNORED_SURV_MODIFY: ::c_uint = 0x0000_0040;
36003625
pub const FAN_MARK_FLUSH: ::c_uint = 0x0000_0080;
3626+
pub const FAN_MARK_EVICTABLE: ::c_uint = 0x0000_0200;
3627+
pub const FAN_MARK_IGNORE: ::c_uint = 0x0000_0100;
3628+
3629+
pub const FAN_MARK_INODE: ::c_uint = 0x0000_0000;
3630+
pub const FAN_MARK_MOUNT: ::c_uint = 0x0000_0010;
3631+
pub const FAN_MARK_FILESYSTEM: ::c_uint = 0x0000_0100;
3632+
3633+
pub const FAN_MARK_IGNORE_SURV: ::c_uint = FAN_MARK_IGNORE | FAN_MARK_IGNORED_SURV_MODIFY;
36013634

36023635
pub const FANOTIFY_METADATA_VERSION: u8 = 3;
36033636

3637+
pub const FAN_EVENT_INFO_TYPE_FID: u8 = 1;
3638+
pub const FAN_EVENT_INFO_TYPE_DFID_NAME: u8 = 2;
3639+
pub const FAN_EVENT_INFO_TYPE_DFID: u8 = 3;
3640+
pub const FAN_EVENT_INFO_TYPE_PIDFD: u8 = 4;
3641+
pub const FAN_EVENT_INFO_TYPE_ERROR: u8 = 5;
3642+
3643+
pub const FAN_EVENT_INFO_TYPE_OLD_DFID_NAME: u8 = 10;
3644+
pub const FAN_EVENT_INFO_TYPE_NEW_DFID_NAME: u8 = 12;
3645+
3646+
pub const FAN_RESPONSE_INFO_NONE: u8 = 0;
3647+
pub const FAN_RESPONSE_INFO_AUDIT_RULE: u8 = 1;
3648+
36043649
pub const FAN_ALLOW: u32 = 0x01;
36053650
pub const FAN_DENY: u32 = 0x02;
3651+
pub const FAN_AUDIT: u32 = 0x10;
3652+
pub const FAN_INFO: u32 = 0x20;
36063653

36073654
pub const FAN_NOFD: ::c_int = -1;
3655+
pub const FAN_NOPIDFD: ::c_int = FAN_NOFD;
3656+
pub const FAN_EPIDFD: ::c_int = -2;
36083657

36093658
pub const FUTEX_WAIT: ::c_int = 0;
36103659
pub const FUTEX_WAKE: ::c_int = 1;

src/unix/linux_like/linux/musl/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,6 @@ pub const PTRACE_INTERRUPT: ::c_int = 0x4207;
592592
pub const PTRACE_LISTEN: ::c_int = 0x4208;
593593
pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209;
594594

595-
pub const FAN_MARK_INODE: ::c_uint = 0x0000_0000;
596-
pub const FAN_MARK_MOUNT: ::c_uint = 0x0000_0010;
597-
// NOTE: FAN_MARK_FILESYSTEM requires Linux Kernel >= 4.20.0
598-
pub const FAN_MARK_FILESYSTEM: ::c_uint = 0x0000_0100;
599-
600595
pub const AF_IB: ::c_int = 27;
601596
pub const AF_MPLS: ::c_int = 28;
602597
pub const AF_NFC: ::c_int = 39;

src/unix/linux_like/linux/uclibc/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,6 @@ pub const EDEADLOCK: ::c_int = EDEADLK;
246246
pub const EXTA: ::c_uint = B19200;
247247
pub const EXTB: ::c_uint = B38400;
248248
pub const EXTPROC: ::tcflag_t = 0200000;
249-
pub const FAN_MARK_FILESYSTEM: ::c_int = 0x00000100;
250-
pub const FAN_MARK_INODE: ::c_int = 0x00000000;
251-
pub const FAN_MARK_MOUNT: ::c_int = 0x10;
252249
pub const FOPEN_MAX: ::c_int = 16;
253250
pub const F_GETOWN: ::c_int = 9;
254251
pub const F_OFD_GETLK: ::c_int = 36;

0 commit comments

Comments
 (0)