Skip to content

Commit

Permalink
adding a handful of linux fanotify data types.
Browse files Browse the repository at this point in the history
close #3688
  • Loading branch information
devnexen committed Aug 15, 2024
1 parent bcd5546 commit 8de6537
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3615,7 +3615,11 @@ fn test_linux(target: &str) {
return true;
}
// FIXME: sparc64 CI has old headers
if sparc64 && (ty == "uinput_ff_erase" || ty == "uinput_abs_setup") {
if sparc64
&& (ty == "uinput_ff_erase"
|| ty == "uinput_abs_setup"
|| ty == "fanotify_event_info_error")
{
return true;
}
// FIXME(https://github.com/rust-lang/libc/issues/1558): passing by
Expand Down Expand Up @@ -4369,7 +4373,11 @@ fn test_linux(target: &str) {
// the `ifr_ifrn` field is an anonymous union
(struct_ == "iwreq" && field == "ifr_ifrn") ||
// the `key` field is a zero-sized array
(struct_ == "iw_encode_ext" && field == "key")
(struct_ == "iw_encode_ext" && field == "key") ||
// either fsid_t or int[2] type
(struct_ == "fanotify_event_info_fid" && field == "fsid") ||
// `handle` is a VLA
(struct_ == "fanotify_event_info_fid" && field == "handle")
});

cfg.skip_roundtrip(move |s| match s {
Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/linux-gnu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,8 @@ dlinfo
dlmopen
endutxent
explicit_bzero
fanotify_event_info_error
fanotify_event_info_pidfd
fgetgrent_r
fgetspent_r
futimes
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3537,6 +3537,7 @@ execvpe
faccessat
fallocate
fallocate64
fanotify_event_info_fid
fanotify_event_metadata
fanotify_init
fanotify_mark
Expand Down
7 changes: 7 additions & 0 deletions src/unix/linux_like/linux/align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ macro_rules! expand_align {
pub fd: ::c_int,
pub pid: ::c_int,
}

#[repr(align(2))]
pub struct fanotify_event_info_header {
pub info_type: __u8,
pub pad: __u8,
pub len: __u16,
}
}

s_no_extra_traits! {
Expand Down
11 changes: 11 additions & 0 deletions src/unix/linux_like/linux/gnu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,17 @@ s! {
pub aio_flags: ::__u32,
pub aio_resfd: ::__u32,
}

pub struct fanotify_event_info_pidfd {
pub hdr: ::fanotify_event_info_header,
pub pidfd: ::__s32,
}

pub struct fanotify_event_info_error {
pub hdr: ::fanotify_event_info_header,
pub error: ::__s32,
pub error_count: ::__u32,
}
}

impl siginfo_t {
Expand Down
11 changes: 11 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub type loff_t = ::c_longlong;
pub type pthread_key_t = ::c_uint;
pub type pthread_once_t = ::c_int;
pub type pthread_spinlock_t = ::c_int;
pub type __kernel_fsid_t = __c_anonymous__kernel_fsid_t;

pub type __u8 = ::c_uchar;
pub type __u16 = ::c_ushort;
Expand Down Expand Up @@ -590,6 +591,10 @@ s! {
pub r_info: Elf64_Xword,
}

pub struct __c_anonymous__kernel_fsid_t {
pub val: [::c_int; 2],
}

pub struct ucred {
pub pid: ::pid_t,
pub uid: ::uid_t,
Expand Down Expand Up @@ -657,6 +662,12 @@ s! {
pub response: __u32,
}

pub struct fanotify_event_info_fid {
pub hdr: fanotify_event_info_header,
pub fsid: ::__kernel_fsid_t,
pub handle: [::c_uchar; 0],
}

pub struct sockaddr_vm {
pub svm_family: ::sa_family_t,
pub svm_reserved1: ::c_ushort,
Expand Down

0 comments on commit 8de6537

Please sign in to comment.