Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding a handful of linux fanotify data types. #3695

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3700,6 +3700,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 @@ -4449,7 +4452,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
3 changes: 3 additions & 0 deletions libc-test/semver/linux-gnu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,9 @@ dlinfo
dlmopen
endutxent
explicit_bzero
fanotify_event_info_error
fanotify_event_info_header
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 @@ -3540,6 +3540,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 @@ -491,6 +491,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,
}
Comment on lines +495 to +504
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these GNU-only? I don't see them reexported in glibc, only uapi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it s a bit of a mess on musl. with glibc it s enough to include sys/fanotify.h which in turn include linux/fanotify.h so you have all you need for this. in musl sys/fanotify.h which does not include linux/fanotify.h and if you do include both there are couple of type redefinition conflicts.

}

impl siginfo_t {
Expand Down
17 changes: 17 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,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