Skip to content

Commit d0343c4

Browse files
rusty-snaketgross35
authored andcommitted
Update pidfd constants and types (Linux 6.9-6.15)
(cherry picked from commit 126f2c6) (backport <rust-lang#4402>)
1 parent e4c5199 commit d0343c4

File tree

9 files changed

+99
-7
lines changed

9 files changed

+99
-7
lines changed

libc-test/build.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4123,6 +4123,10 @@ fn test_linux(target: &str) {
41234123
// Might differ between kernel versions
41244124
"open_how" => true,
41254125

4126+
// Linux >= 6.13 (pidfd_info.exit_code: Linux >= 6.15)
4127+
// Might differ between kernel versions
4128+
"pidfd_info" => true,
4129+
41264130
"sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo"
41274131
| "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true,
41284132

@@ -4229,6 +4233,7 @@ fn test_linux(target: &str) {
42294233
|| name.starts_with("OPEN_TREE_")
42304234
|| name.starts_with("P_")
42314235
|| name.starts_with("PF_")
4236+
|| name.starts_with("PIDFD_")
42324237
|| name.starts_with("RLIMIT_")
42334238
|| name.starts_with("RTEXT_FILTER_")
42344239
|| name.starts_with("SOL_")
@@ -4432,6 +4437,30 @@ fn test_linux(target: &str) {
44324437

44334438
// headers conflicts with linux/pidfd.h
44344439
"PIDFD_NONBLOCK" => true,
4440+
// Linux >= 6.9
4441+
"PIDFD_THREAD"
4442+
| "PIDFD_SIGNAL_THREAD"
4443+
| "PIDFD_SIGNAL_THREAD_GROUP"
4444+
| "PIDFD_SIGNAL_PROCESS_GROUP" => true,
4445+
// Linux >= 6.11
4446+
"PIDFD_GET_CGROUP_NAMESPACE"
4447+
| "PIDFD_GET_IPC_NAMESPACE"
4448+
| "PIDFD_GET_MNT_NAMESPACE"
4449+
| "PIDFD_GET_NET_NAMESPACE"
4450+
| "PIDFD_GET_PID_NAMESPACE"
4451+
| "PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE"
4452+
| "PIDFD_GET_TIME_NAMESPACE"
4453+
| "PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE"
4454+
| "PIDFD_GET_USER_NAMESPACE"
4455+
| "PIDFD_GET_UTS_NAMESPACE" => true,
4456+
// Linux >= 6.13
4457+
"PIDFD_GET_INFO"
4458+
| "PIDFD_INFO_PID"
4459+
| "PIDFD_INFO_CREDS"
4460+
| "PIDFD_INFO_CGROUPID"
4461+
| "PIDFD_INFO_SIZE_VER0" => true,
4462+
// Linux >= 6.15
4463+
"PIDFD_INFO_EXIT" | "PIDFD_SELF" | "PIDFD_SELF_PROCESS" => true,
44354464

44364465
// is a private value for kernel usage normally
44374466
"FUSE_SUPER_MAGIC" => true,

libc-test/semver/linux-musl.txt

Lines changed: 0 additions & 1 deletion
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

Lines changed: 22 additions & 0 deletions
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
@@ -4045,6 +4066,7 @@ pause
40454066
personality
40464067
pgn_t
40474068
pid_type
4069+
pidfd_info
40484070
pipe2
40494071
popen
40504072
posix_fadvise

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,6 @@ pub const RTLD_DI_TLS_MODID: c_int = 9;
751751
pub const RTLD_DI_TLS_DATA: c_int = 10;
752752

753753
pub const SOCK_NONBLOCK: c_int = O_NONBLOCK;
754-
pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint;
755754

756755
pub const SOL_RXRPC: c_int = 272;
757756
pub const SOL_PPPOL2TP: c_int = 273;

src/unix/linux_like/linux/mod.rs

Lines changed: 48 additions & 0 deletions
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 {
@@ -3192,6 +3211,35 @@ pub const MREMAP_MAYMOVE: c_int = 1;
31923211
pub const MREMAP_FIXED: c_int = 2;
31933212
pub const MREMAP_DONTUNMAP: c_int = 4;
31943213

3214+
// linux/pidfd.h
3215+
pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint;
3216+
pub const PIDFD_THREAD: c_uint = O_EXCL as c_uint;
3217+
3218+
pub const PIDFD_SIGNAL_THREAD: c_uint = 1 << 0;
3219+
pub const PIDFD_SIGNAL_THREAD_GROUP: c_uint = 1 << 1;
3220+
pub const PIDFD_SIGNAL_PROCESS_GROUP: c_uint = 1 << 2;
3221+
3222+
pub const PIDFD_INFO_PID: c_uint = 1 << 0;
3223+
pub const PIDFD_INFO_CREDS: c_uint = 1 << 1;
3224+
pub const PIDFD_INFO_CGROUPID: c_uint = 1 << 2;
3225+
pub const PIDFD_INFO_EXIT: c_uint = 1 << 3;
3226+
3227+
pub const PIDFD_INFO_SIZE_VER0: c_uint = 64;
3228+
3229+
const PIDFS_IOCTL_MAGIC: c_uint = 0xFF;
3230+
pub const PIDFD_GET_CGROUP_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 1);
3231+
pub const PIDFD_GET_IPC_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 2);
3232+
pub const PIDFD_GET_MNT_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 3);
3233+
pub const PIDFD_GET_NET_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 4);
3234+
pub const PIDFD_GET_PID_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 5);
3235+
pub const PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 6);
3236+
pub const PIDFD_GET_TIME_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 7);
3237+
pub const PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 8);
3238+
pub const PIDFD_GET_USER_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 9);
3239+
pub const PIDFD_GET_UTS_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 10);
3240+
pub const PIDFD_GET_INFO: c_uint = _IOWR::<pidfd_info>(PIDFS_IOCTL_MAGIC, 11);
3241+
3242+
// linux/prctl.h
31953243
pub const PR_SET_PDEATHSIG: c_int = 1;
31963244
pub const PR_GET_PDEATHSIG: c_int = 2;
31973245

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,8 +787,6 @@ pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK;
787787

788788
pub const SFD_NONBLOCK: c_int = crate::O_NONBLOCK;
789789

790-
pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint;
791-
792790
pub const TCSANOW: c_int = 0;
793791
pub const TCSADRAIN: c_int = 1;
794792
pub const TCSAFLUSH: c_int = 2;

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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
342342
pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
343343
pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32;
344344
pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
345-
pub const PIDFD_NONBLOCK: c_int = 0o4000;
346345

347346
cfg_if! {
348347
if #[cfg(target_os = "l4re")] {

0 commit comments

Comments
 (0)