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 rust-lang#3688

(backport <rust-lang#3695>)
(cherry picked from commit 7b338f9)
  • Loading branch information
devnexen authored and tgross35 committed Oct 15, 2024
1 parent a5adc5f commit bcc77f9
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
9 changes: 8 additions & 1 deletion libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3746,6 +3746,9 @@ fn test_linux(target: &str) {
if musl && ty == "fanout_args" {
return true;
}
if sparc64 && ty == "fanotify_event_info_error" {
return true;
}

match ty {
// These cannot be tested when "resolv.h" is included and are tested
Expand Down Expand Up @@ -4490,7 +4493,11 @@ fn test_linux(target: &str) {
// the `tcpi_delivery_rate_app_limited` field is a bitfield on musl
(musl && struct_ == "tcp_info" && field == "tcpi_delivery_rate_app_limited") ||
// the `tcpi_fast_open_client_fail` field is a bitfield on musl
(musl && struct_ == "tcp_info" && field == "tcpi_fast_open_client_fail")
(musl && struct_ == "tcp_info" && field == "tcpi_fast_open_client_fail") ||
// 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
5 changes: 4 additions & 1 deletion libc-test/semver/linux-gnu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -628,12 +628,15 @@ dlinfo
dlmopen
endutxent
explicit_bzero
fanotify_event_info_error
fanotify_event_info_header
fanotify_event_info_pidfd
fgetgrent_r
fgetspent_r
futimes
getauxval
getentropy
getgrent_r
fgetgrent_r
getloadavg
getpt
getpwent_r
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 @@ -3497,6 +3497,7 @@ execvpe
faccessat
fallocate
fallocate64
fanotify_event_info_fid
fanotify_event_metadata
fanotify_init
fanotify_mark
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 @@ -492,6 +492,17 @@ s! {
pub tcpi_rcv_space: u32,
pub tcpi_total_retrans: 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
27 changes: 27 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 @@ -548,6 +549,20 @@ s! {
pub sh_entsize: Elf64_Xword,
}

pub struct __c_anonymous_elf32_rel {
pub r_offset: Elf32_Addr,
pub r_info: Elf32_Word,
}

pub struct __c_anonymous_elf64_rel {
pub r_offset: Elf64_Addr,
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 @@ -615,6 +630,18 @@ s! {
pub response: __u32,
}

pub struct fanotify_event_info_header {
pub info_type: __u8,
pub pad: __u8,
pub len: __u16,
}

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 bcc77f9

Please sign in to comment.