Skip to content

Commit 1b5abd7

Browse files
authored
Merge pull request #4402 from rusty-snake/pidfd-threaded
Update pidfd constants and types (Linux 6.9-6.15)
2 parents 393e909 + 126f2c6 commit 1b5abd7

File tree

9 files changed

+99
-7
lines changed

9 files changed

+99
-7
lines changed

libc-test/build.rs

+29
Original file line numberDiff line numberDiff line change
@@ -4039,6 +4039,10 @@ fn test_linux(target: &str) {
40394039
// Might differ between kernel versions
40404040
"open_how" => true,
40414041

4042+
// Linux >= 6.13 (pidfd_info.exit_code: Linux >= 6.15)
4043+
// Might differ between kernel versions
4044+
"pidfd_info" => true,
4045+
40424046
"sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo"
40434047
| "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true,
40444048

@@ -4145,6 +4149,7 @@ fn test_linux(target: &str) {
41454149
|| name.starts_with("OPEN_TREE_")
41464150
|| name.starts_with("P_")
41474151
|| name.starts_with("PF_")
4152+
|| name.starts_with("PIDFD_")
41484153
|| name.starts_with("RLIMIT_")
41494154
|| name.starts_with("RTEXT_FILTER_")
41504155
|| name.starts_with("SOL_")
@@ -4348,6 +4353,30 @@ fn test_linux(target: &str) {
43484353

43494354
// headers conflicts with linux/pidfd.h
43504355
"PIDFD_NONBLOCK" => true,
4356+
// Linux >= 6.9
4357+
"PIDFD_THREAD"
4358+
| "PIDFD_SIGNAL_THREAD"
4359+
| "PIDFD_SIGNAL_THREAD_GROUP"
4360+
| "PIDFD_SIGNAL_PROCESS_GROUP" => true,
4361+
// Linux >= 6.11
4362+
"PIDFD_GET_CGROUP_NAMESPACE"
4363+
| "PIDFD_GET_IPC_NAMESPACE"
4364+
| "PIDFD_GET_MNT_NAMESPACE"
4365+
| "PIDFD_GET_NET_NAMESPACE"
4366+
| "PIDFD_GET_PID_NAMESPACE"
4367+
| "PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE"
4368+
| "PIDFD_GET_TIME_NAMESPACE"
4369+
| "PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE"
4370+
| "PIDFD_GET_USER_NAMESPACE"
4371+
| "PIDFD_GET_UTS_NAMESPACE" => true,
4372+
// Linux >= 6.13
4373+
"PIDFD_GET_INFO"
4374+
| "PIDFD_INFO_PID"
4375+
| "PIDFD_INFO_CREDS"
4376+
| "PIDFD_INFO_CGROUPID"
4377+
| "PIDFD_INFO_SIZE_VER0" => true,
4378+
// Linux >= 6.15
4379+
"PIDFD_INFO_EXIT" | "PIDFD_SELF" | "PIDFD_SELF_PROCESS" => true,
43514380

43524381
// is a private value for kernel usage normally
43534382
"FUSE_SUPER_MAGIC" => true,

libc-test/semver/linux-musl.txt

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ OLD_TIME
2828
PF_IB
2929
PF_MPLS
3030
PF_XDP
31-
PIDFD_NONBLOCK
3231
PR_SET_VMA
3332
PR_SET_VMA_ANON_NAME
3433
RUN_LVL

libc-test/semver/linux.txt

+22
Original file line numberDiff line numberDiff line change
@@ -2172,6 +2172,27 @@ PF_WANPIPE
21722172
PF_WQ_WORKER
21732173
PF_X
21742174
PF_X25
2175+
PIDFD_GET_CGROUP_NAMESPACE
2176+
PIDFD_GET_INFO
2177+
PIDFD_GET_IPC_NAMESPACE
2178+
PIDFD_GET_MNT_NAMESPACE
2179+
PIDFD_GET_NET_NAMESPACE
2180+
PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE
2181+
PIDFD_GET_PID_NAMESPACE
2182+
PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE
2183+
PIDFD_GET_TIME_NAMESPACE
2184+
PIDFD_GET_USER_NAMESPACE
2185+
PIDFD_GET_UTS_NAMESPACE
2186+
PIDFD_INFO_CGROUPID
2187+
PIDFD_INFO_CREDS
2188+
PIDFD_INFO_EXIT
2189+
PIDFD_INFO_PID
2190+
PIDFD_INFO_SIZE_VER0
2191+
PIDFD_NONBLOCK
2192+
PIDFD_SIGNAL_PROCESS_GROUP
2193+
PIDFD_SIGNAL_THREAD
2194+
PIDFD_SIGNAL_THREAD_GROUP
2195+
PIDFD_THREAD
21752196
PIDTYPE_MAX
21762197
PIDTYPE_PGID
21772198
PIDTYPE_PID
@@ -4044,6 +4065,7 @@ pause
40444065
personality
40454066
pgn_t
40464067
pid_type
4068+
pidfd_info
40474069
pipe2
40484070
popen
40494071
posix_fadvise

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

-1
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,6 @@ pub const RTLD_DI_TLS_MODID: c_int = 9;
755755
pub const RTLD_DI_TLS_DATA: c_int = 10;
756756

757757
pub const SOCK_NONBLOCK: c_int = O_NONBLOCK;
758-
pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint;
759758

760759
pub const SOL_RXRPC: c_int = 272;
761760
pub const SOL_PPPOL2TP: c_int = 273;

src/unix/linux_like/linux/mod.rs

+48
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,25 @@ s! {
13761376
pub userns_fd: crate::__u64,
13771377
}
13781378

1379+
// linux/pidfd.h
1380+
1381+
pub struct pidfd_info {
1382+
mask: crate::__u64,
1383+
cgroupid: crate::__u64,
1384+
pid: crate::__u32,
1385+
tgid: crate::__u32,
1386+
ppid: crate::__u32,
1387+
ruid: crate::__u32,
1388+
rgid: crate::__u32,
1389+
euid: crate::__u32,
1390+
egid: crate::__u32,
1391+
suid: crate::__u32,
1392+
sgid: crate::__u32,
1393+
fsuid: crate::__u32,
1394+
fsgid: crate::__u32,
1395+
exit_code: crate::__s32,
1396+
}
1397+
13791398
// linux/uio.h
13801399

13811400
pub struct dmabuf_cmsg {
@@ -3153,6 +3172,35 @@ pub const MREMAP_MAYMOVE: c_int = 1;
31533172
pub const MREMAP_FIXED: c_int = 2;
31543173
pub const MREMAP_DONTUNMAP: c_int = 4;
31553174

3175+
// linux/pidfd.h
3176+
pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint;
3177+
pub const PIDFD_THREAD: c_uint = O_EXCL as c_uint;
3178+
3179+
pub const PIDFD_SIGNAL_THREAD: c_uint = 1 << 0;
3180+
pub const PIDFD_SIGNAL_THREAD_GROUP: c_uint = 1 << 1;
3181+
pub const PIDFD_SIGNAL_PROCESS_GROUP: c_uint = 1 << 2;
3182+
3183+
pub const PIDFD_INFO_PID: c_uint = 1 << 0;
3184+
pub const PIDFD_INFO_CREDS: c_uint = 1 << 1;
3185+
pub const PIDFD_INFO_CGROUPID: c_uint = 1 << 2;
3186+
pub const PIDFD_INFO_EXIT: c_uint = 1 << 3;
3187+
3188+
pub const PIDFD_INFO_SIZE_VER0: c_uint = 64;
3189+
3190+
const PIDFS_IOCTL_MAGIC: c_uint = 0xFF;
3191+
pub const PIDFD_GET_CGROUP_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 1);
3192+
pub const PIDFD_GET_IPC_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 2);
3193+
pub const PIDFD_GET_MNT_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 3);
3194+
pub const PIDFD_GET_NET_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 4);
3195+
pub const PIDFD_GET_PID_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 5);
3196+
pub const PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 6);
3197+
pub const PIDFD_GET_TIME_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 7);
3198+
pub const PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 8);
3199+
pub const PIDFD_GET_USER_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 9);
3200+
pub const PIDFD_GET_UTS_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 10);
3201+
pub const PIDFD_GET_INFO: c_uint = _IOWR::<pidfd_info>(PIDFS_IOCTL_MAGIC, 11);
3202+
3203+
// linux/prctl.h
31563204
pub const PR_SET_PDEATHSIG: c_int = 1;
31573205
pub const PR_GET_PDEATHSIG: c_int = 2;
31583206

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

-2
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,6 @@ pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK;
789789

790790
pub const SFD_NONBLOCK: c_int = crate::O_NONBLOCK;
791791

792-
pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint;
793-
794792
pub const TCSANOW: c_int = 0;
795793
pub const TCSADRAIN: c_int = 1;
796794
pub const TCSAFLUSH: c_int = 2;

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

-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ pub const POLLWRBAND: c_short = 0x200;
475475
pub const POLLWRNORM: c_short = 0x100;
476476
pub const PTHREAD_STACK_MIN: size_t = 16384;
477477
pub const RTLD_GLOBAL: c_int = 0x00100;
478-
pub const PIDFD_NONBLOCK: c_int = 0x800;
479478

480479
// These are typed unsigned to match sigaction
481480
pub const SA_NOCLDSTOP: c_ulong = 0x1;

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

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ pub const O_LARGEFILE: c_int = 0x2000;
5757
pub const O_NDELAY: c_int = 0x80;
5858

5959
pub const SOCK_NONBLOCK: c_int = 128;
60-
pub const PIDFD_NONBLOCK: c_int = 128;
6160

6261
pub const EDEADLK: c_int = 45;
6362
pub const ENAMETOOLONG: c_int = 78;

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

-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
330330
pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
331331
pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32;
332332
pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
333-
pub const PIDFD_NONBLOCK: c_int = 0o4000;
334333

335334
cfg_if! {
336335
if #[cfg(target_os = "l4re")] {

0 commit comments

Comments
 (0)