Skip to content

Update pidfd constants and types (Linux 6.9-6.15) #4402

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

Merged
merged 1 commit into from
Apr 25, 2025
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
29 changes: 29 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4046,6 +4046,10 @@ fn test_linux(target: &str) {
// Might differ between kernel versions
"open_how" => true,

// Linux >= 6.13 (pidfd_info.exit_code: Linux >= 6.15)
// Might differ between kernel versions
"pidfd_info" => true,

"sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo"
| "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true,

Expand Down Expand Up @@ -4152,6 +4156,7 @@ fn test_linux(target: &str) {
|| name.starts_with("OPEN_TREE_")
|| name.starts_with("P_")
|| name.starts_with("PF_")
|| name.starts_with("PIDFD_")
|| name.starts_with("RLIMIT_")
|| name.starts_with("RTEXT_FILTER_")
|| name.starts_with("SOL_")
Expand Down Expand Up @@ -4355,6 +4360,30 @@ fn test_linux(target: &str) {

// headers conflicts with linux/pidfd.h
"PIDFD_NONBLOCK" => true,
// Linux >= 6.9
"PIDFD_THREAD"
| "PIDFD_SIGNAL_THREAD"
| "PIDFD_SIGNAL_THREAD_GROUP"
| "PIDFD_SIGNAL_PROCESS_GROUP" => true,
// Linux >= 6.11
"PIDFD_GET_CGROUP_NAMESPACE"
| "PIDFD_GET_IPC_NAMESPACE"
| "PIDFD_GET_MNT_NAMESPACE"
| "PIDFD_GET_NET_NAMESPACE"
| "PIDFD_GET_PID_NAMESPACE"
| "PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE"
| "PIDFD_GET_TIME_NAMESPACE"
| "PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE"
| "PIDFD_GET_USER_NAMESPACE"
| "PIDFD_GET_UTS_NAMESPACE" => true,
// Linux >= 6.13
"PIDFD_GET_INFO"
| "PIDFD_INFO_PID"
| "PIDFD_INFO_CREDS"
| "PIDFD_INFO_CGROUPID"
| "PIDFD_INFO_SIZE_VER0" => true,
// Linux >= 6.15
"PIDFD_INFO_EXIT" | "PIDFD_SELF" | "PIDFD_SELF_PROCESS" => true,

// is a private value for kernel usage normally
"FUSE_SUPER_MAGIC" => true,
Expand Down
1 change: 0 additions & 1 deletion libc-test/semver/linux-musl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ OLD_TIME
PF_IB
PF_MPLS
PF_XDP
PIDFD_NONBLOCK
PR_SET_VMA
PR_SET_VMA_ANON_NAME
RUN_LVL
Expand Down
22 changes: 22 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2171,6 +2171,27 @@ PF_WANPIPE
PF_WQ_WORKER
PF_X
PF_X25
PIDFD_GET_CGROUP_NAMESPACE
PIDFD_GET_INFO
PIDFD_GET_IPC_NAMESPACE
PIDFD_GET_MNT_NAMESPACE
PIDFD_GET_NET_NAMESPACE
PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE
PIDFD_GET_PID_NAMESPACE
PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE
PIDFD_GET_TIME_NAMESPACE
PIDFD_GET_USER_NAMESPACE
PIDFD_GET_UTS_NAMESPACE
PIDFD_INFO_CGROUPID
PIDFD_INFO_CREDS
PIDFD_INFO_EXIT
PIDFD_INFO_PID
PIDFD_INFO_SIZE_VER0
PIDFD_NONBLOCK
PIDFD_SIGNAL_PROCESS_GROUP
PIDFD_SIGNAL_THREAD
PIDFD_SIGNAL_THREAD_GROUP
PIDFD_THREAD
PIDTYPE_MAX
PIDTYPE_PGID
PIDTYPE_PID
Expand Down Expand Up @@ -4043,6 +4064,7 @@ pause
personality
pgn_t
pid_type
pidfd_info
pipe2
popen
posix_fadvise
Expand Down
1 change: 0 additions & 1 deletion src/unix/linux_like/linux/gnu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,6 @@ pub const RTLD_DI_TLS_MODID: c_int = 9;
pub const RTLD_DI_TLS_DATA: c_int = 10;

pub const SOCK_NONBLOCK: c_int = O_NONBLOCK;
pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint;

pub const SOL_RXRPC: c_int = 272;
pub const SOL_PPPOL2TP: c_int = 273;
Expand Down
48 changes: 48 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,25 @@ s! {
pub userns_fd: crate::__u64,
}

// linux/pidfd.h

pub struct pidfd_info {
mask: crate::__u64,
cgroupid: crate::__u64,
pid: crate::__u32,
tgid: crate::__u32,
ppid: crate::__u32,
ruid: crate::__u32,
rgid: crate::__u32,
euid: crate::__u32,
egid: crate::__u32,
suid: crate::__u32,
sgid: crate::__u32,
fsuid: crate::__u32,
fsgid: crate::__u32,
exit_code: crate::__s32,
}

// linux/uio.h

pub struct dmabuf_cmsg {
Expand Down Expand Up @@ -3153,6 +3172,35 @@ pub const MREMAP_MAYMOVE: c_int = 1;
pub const MREMAP_FIXED: c_int = 2;
pub const MREMAP_DONTUNMAP: c_int = 4;

// linux/pidfd.h
pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint;
pub const PIDFD_THREAD: c_uint = O_EXCL as c_uint;

pub const PIDFD_SIGNAL_THREAD: c_uint = 1 << 0;
pub const PIDFD_SIGNAL_THREAD_GROUP: c_uint = 1 << 1;
pub const PIDFD_SIGNAL_PROCESS_GROUP: c_uint = 1 << 2;

pub const PIDFD_INFO_PID: c_uint = 1 << 0;
pub const PIDFD_INFO_CREDS: c_uint = 1 << 1;
pub const PIDFD_INFO_CGROUPID: c_uint = 1 << 2;
pub const PIDFD_INFO_EXIT: c_uint = 1 << 3;

pub const PIDFD_INFO_SIZE_VER0: c_uint = 64;

const PIDFS_IOCTL_MAGIC: c_uint = 0xFF;
pub const PIDFD_GET_CGROUP_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 1);
pub const PIDFD_GET_IPC_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 2);
pub const PIDFD_GET_MNT_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 3);
pub const PIDFD_GET_NET_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 4);
pub const PIDFD_GET_PID_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 5);
pub const PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 6);
pub const PIDFD_GET_TIME_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 7);
pub const PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 8);
pub const PIDFD_GET_USER_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 9);
pub const PIDFD_GET_UTS_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 10);
pub const PIDFD_GET_INFO: c_uint = _IOWR::<pidfd_info>(PIDFS_IOCTL_MAGIC, 11);

// linux/prctl.h
pub const PR_SET_PDEATHSIG: c_int = 1;
pub const PR_GET_PDEATHSIG: c_int = 2;

Expand Down
2 changes: 0 additions & 2 deletions src/unix/linux_like/linux/musl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,8 +789,6 @@ pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK;

pub const SFD_NONBLOCK: c_int = crate::O_NONBLOCK;

pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint;

pub const TCSANOW: c_int = 0;
pub const TCSADRAIN: c_int = 1;
pub const TCSAFLUSH: c_int = 2;
Expand Down
1 change: 0 additions & 1 deletion src/unix/linux_like/linux/uclibc/arm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ pub const POLLWRBAND: c_short = 0x200;
pub const POLLWRNORM: c_short = 0x100;
pub const PTHREAD_STACK_MIN: size_t = 16384;
pub const RTLD_GLOBAL: c_int = 0x00100;
pub const PIDFD_NONBLOCK: c_int = 0x800;

// These are typed unsigned to match sigaction
pub const SA_NOCLDSTOP: c_ulong = 0x1;
Expand Down
1 change: 0 additions & 1 deletion src/unix/linux_like/linux/uclibc/mips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ pub const O_LARGEFILE: c_int = 0x2000;
pub const O_NDELAY: c_int = 0x80;

pub const SOCK_NONBLOCK: c_int = 128;
pub const PIDFD_NONBLOCK: c_int = 128;

pub const EDEADLK: c_int = 45;
pub const ENAMETOOLONG: c_int = 78;
Expand Down
1 change: 0 additions & 1 deletion src/unix/linux_like/linux/uclibc/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32;
pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
pub const PIDFD_NONBLOCK: c_int = 0o4000;

cfg_if! {
if #[cfg(target_os = "l4re")] {
Expand Down
Loading