Skip to content

Commit c3d43be

Browse files
committed
Fix libc-test and add more pidfd definitions
Add new constants to semver txt
1 parent ae57d0c commit c3d43be

File tree

3 files changed

+95
-7
lines changed

3 files changed

+95
-7
lines changed

libc-test/build.rs

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

4049+
// Linux >= 6.13 (pidfd_info.exit_code: Linux >= 6.15)
4050+
// Might differ between kernel versions
4051+
"pidfd_info" => true,
4052+
40494053
"sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo"
40504054
| "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true,
40514055

@@ -4551,6 +4555,31 @@ fn test_linux(target: &str) {
45514555
// FIXME(linux): Requires >= 6.4 kernel headers.
45524556
"PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG" | "PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG" => true,
45534557

4558+
// Linux >= 6.9
4559+
"PIDFD_THREAD"
4560+
| "PIDFD_SIGNAL_THREAD"
4561+
| "PIDFD_SIGNAL_THREAD_GROUP"
4562+
| "PIDFD_SIGNAL_PROCESS_GROUP" => true,
4563+
// Linux >= 6.11
4564+
"PIDFD_GET_CGROUP_NAMESPACE"
4565+
| "PIDFD_GET_IPC_NAMESPACE"
4566+
| "PIDFD_GET_MNT_NAMESPACE"
4567+
| "PIDFD_GET_NET_NAMESPACE"
4568+
| "PIDFD_GET_PID_NAMESPACE"
4569+
| "PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE"
4570+
| "PIDFD_GET_TIME_NAMESPACE"
4571+
| "PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE"
4572+
| "PIDFD_GET_USER_NAMESPACE"
4573+
| "PIDFD_GET_UTS_NAMESPACE" => true,
4574+
// Linux >= 6.13
4575+
"PIDFD_GET_INFO"
4576+
| "PIDFD_INFO_PID"
4577+
| "PIDFD_INFO_CREDS"
4578+
| "PIDFD_INFO_CGROUPID"
4579+
| "PIDFD_INFO_SIZE_VER0" => true,
4580+
// Linux >= 6.15
4581+
"PIDFD_INFO_EXIT" | "PIDFD_SELF" | "PIDFD_SELF_PROCESS" => true,
4582+
45544583
_ => false,
45554584
}
45564585
});

libc-test/semver/linux-gnu.txt

+21
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,27 @@ O_FSYNC
343343
PF_IB
344344
PF_MPLS
345345
PF_XDP
346+
PIDFD_GET_CGROUP_NAMESPACE
347+
PIDFD_GET_INFO
348+
PIDFD_GET_IPC_NAMESPACE
349+
PIDFD_GET_MNT_NAMESPACE
350+
PIDFD_GET_NET_NAMESPACE
351+
PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE
352+
PIDFD_GET_PID_NAMESPACE
353+
PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE
354+
PIDFD_GET_TIME_NAMESPACE
355+
PIDFD_GET_USER_NAMESPACE
356+
PIDFD_GET_UTS_NAMESPACE
357+
PIDFD_INFO_CGROUPID
358+
PIDFD_INFO_CREDS
359+
PIDFD_INFO_EXIT
360+
PIDFD_INFO_PID
361+
PIDFD_INFO_SIZE_VER0
346362
PIDFD_NONBLOCK
363+
PIDFD_SIGNAL_PROCESS_GROUP
364+
PIDFD_SIGNAL_THREAD
365+
PIDFD_SIGNAL_THREAD_GROUP
366+
PIDFD_THREAD
347367
PROC_SUPER_MAGIC
348368
PR_SET_VMA
349369
PR_SET_VMA_ANON_NAME
@@ -638,6 +658,7 @@ ntp_adjtime
638658
ntp_gettime
639659
ntptimeval
640660
open_wmemstream
661+
pidfd_info
641662
posix_basename
642663
posix_spawn_file_actions_addchdir_np
643664
posix_spawn_file_actions_addclosefrom_np

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

+45-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use crate::off64_t;
22
use crate::prelude::*;
33

4+
use super::_IO;
5+
use super::_IOWR;
6+
47
pub type pthread_t = c_ulong;
58
pub type __priority_which_t = c_uint;
69
pub type __rlimit_resource_t = c_uint;
@@ -414,6 +417,23 @@ s! {
414417
__pos: off64_t,
415418
__state: crate::mbstate_t,
416419
}
420+
421+
pub struct pidfd_info {
422+
mask: crate::__u64,
423+
cgroupid: crate::__u64,
424+
pid: crate::__u32,
425+
tgid: crate::__u32,
426+
ppid: crate::__u32,
427+
ruid: crate::__u32,
428+
rgid: crate::__u32,
429+
euid: crate::__u32,
430+
egid: crate::__u32,
431+
suid: crate::__u32,
432+
sgid: crate::__u32,
433+
fsuid: crate::__u32,
434+
fsgid: crate::__u32,
435+
exit_code: crate::__s32,
436+
}
417437
}
418438

419439
impl siginfo_t {
@@ -757,13 +777,31 @@ pub const RTLD_DI_TLS_DATA: c_int = 10;
757777
pub const SOCK_NONBLOCK: c_int = O_NONBLOCK;
758778

759779
pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint;
760-
// libc-test failure. To new?
761-
// pub const PIDFD_THREAD: c_uint = O_EXCL as c_uint;
762-
763-
// libc-test failure. To new?
764-
// pub const PIDFD_SIGNAL_THREAD: c_uint = 1;
765-
// pub const PIDFD_SIGNAL_THREAD_GROUP: c_uint = 2;
766-
// pub const PIDFD_SIGNAL_PROCESS_GROUP: c_uint = 4;
780+
pub const PIDFD_THREAD: c_uint = O_EXCL as c_uint;
781+
782+
pub const PIDFD_SIGNAL_THREAD: c_uint = 1;
783+
pub const PIDFD_SIGNAL_THREAD_GROUP: c_uint = 2;
784+
pub const PIDFD_SIGNAL_PROCESS_GROUP: c_uint = 4;
785+
786+
pub const PIDFD_INFO_PID: c_uint = 1;
787+
pub const PIDFD_INFO_CREDS: c_uint = 2;
788+
pub const PIDFD_INFO_CGROUPID: c_uint = 4;
789+
pub const PIDFD_INFO_EXIT: c_uint = 8;
790+
791+
pub const PIDFD_INFO_SIZE_VER0: c_uint = 64;
792+
793+
const PIDFS_IOCTL_MAGIC: c_uint = 0xFF;
794+
pub const PIDFD_GET_CGROUP_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 1);
795+
pub const PIDFD_GET_IPC_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 2);
796+
pub const PIDFD_GET_MNT_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 3);
797+
pub const PIDFD_GET_NET_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 4);
798+
pub const PIDFD_GET_PID_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 5);
799+
pub const PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 6);
800+
pub const PIDFD_GET_TIME_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 7);
801+
pub const PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 8);
802+
pub const PIDFD_GET_USER_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 9);
803+
pub const PIDFD_GET_UTS_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 10);
804+
pub const PIDFD_GET_INFO: c_uint = _IOWR::<pidfd_info>(PIDFS_IOCTL_MAGIC, 11);
767805

768806
pub const SOL_RXRPC: c_int = 272;
769807
pub const SOL_PPPOL2TP: c_int = 273;

0 commit comments

Comments
 (0)