Skip to content

Commit e6203ea

Browse files
committed
linux: move PIDFD definitions to src/new
1 parent a41bc08 commit e6203ea

6 files changed

Lines changed: 126 additions & 58 deletions

File tree

libc-test/build.rs

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2147,6 +2147,41 @@ fn test_android(target: &str) {
21472147
| "PF_BLOCK_TS"
21482148
| "PF_SUSPEND_TASK" => true,
21492149

2150+
// FIXME(android): Requires >= 6.12 kernel headers.
2151+
| "PIDFD_NONBLOCK"
2152+
| "PIDFD_THREAD"
2153+
| "PIDFD_SIGNAL_THREAD"
2154+
| "PIDFD_SIGNAL_THREAD_GROUP"
2155+
| "PIDFD_SIGNAL_PROCESS_GROUP"
2156+
| "PIDFD_GET_CGROUP_NAMESPACE"
2157+
| "PIDFD_GET_IPC_NAMESPACE"
2158+
| "PIDFD_GET_MNT_NAMESPACE"
2159+
| "PIDFD_GET_NET_NAMESPACE"
2160+
| "PIDFD_GET_PID_NAMESPACE"
2161+
| "PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE"
2162+
| "PIDFD_GET_TIME_NAMESPACE"
2163+
| "PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE"
2164+
| "PIDFD_GET_USER_NAMESPACE"
2165+
| "PIDFD_GET_UTS_NAMESPACE"
2166+
| "PIDFD_GET_INFO"
2167+
| "PIDFD_INFO_PID"
2168+
| "PIDFD_INFO_CREDS"
2169+
| "PIDFD_INFO_CGROUPID"
2170+
| "PIDFD_INFO_EXIT"
2171+
| "PIDFD_INFO_COREDUMP"
2172+
| "PIDFD_INFO_SUPPORTED_MASK"
2173+
| "PIDFD_INFO_COREDUMP_SIGNAL"
2174+
| "PIDFD_INFO_SIZE_VER0"
2175+
| "PIDFD_INFO_SIZE_VER1"
2176+
| "PIDFD_INFO_SIZE_VER2"
2177+
| "PIDFD_SELF"
2178+
| "PIDFD_SELF_PROCESS"
2179+
| "PIDFS_IOCTL_MAGIC"
2180+
| "PIDFD_COREDUMPED"
2181+
| "PIDFD_COREDUMP_SKIP"
2182+
| "PIDFD_COREDUMP_USER"
2183+
| "PIDFD_COREDUMP_ROOT" => true,
2184+
21502185
// FIXME(android): Requires >= 6.12 kernel headers.
21512186
"SOF_TIMESTAMPING_OPT_RX_FILTER" => true,
21522187

@@ -4373,7 +4408,19 @@ fn test_linux(target: &str) {
43734408
| "PIDFD_INFO_CGROUPID"
43744409
| "PIDFD_INFO_SIZE_VER0" => true,
43754410
// Linux >= 6.15
4376-
"PIDFD_INFO_EXIT" | "PIDFD_SELF" | "PIDFD_SELF_PROCESS" => true,
4411+
"PIDFD_INFO_EXIT"
4412+
| "PIDFD_SELF"
4413+
| "PIDFD_SELF_PROCESS"
4414+
| "PIDFS_IOCTL_MAGIC"
4415+
| "PIDFD_COREDUMPED"
4416+
| "PIDFD_COREDUMP_SKIP"
4417+
| "PIDFD_COREDUMP_USER"
4418+
| "PIDFD_COREDUMP_ROOT"
4419+
| "PIDFD_INFO_SUPPORTED_MASK"
4420+
| "PIDFD_INFO_COREDUMP"
4421+
| "PIDFD_INFO_COREDUMP_SIGNAL"
4422+
| "PIDFD_INFO_SIZE_VER1"
4423+
| "PIDFD_INFO_SIZE_VER2" => true,
43774424

43784425
// is a private value for kernel usage normally
43794426
"FUSE_SUPER_MAGIC" => true,

src/new/linux_uapi/linux/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
//! Directory: `linux/`
2-
//!
3-
//! <https://github.com/torvalds/linux/tree/master/include/uapi/linux>
4-
5-
pub(crate) mod can;
6-
pub(crate) mod keyctl;
7-
pub(crate) mod membarrier;
8-
pub(crate) mod netlink;
1+
pub mod can;
2+
pub mod keyctl;
3+
pub mod membarrier;
4+
pub mod netlink;
5+
pub mod pidfd;

src/new/linux_uapi/linux/pidfd.rs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
use crate::prelude::*;
2+
use crate::{
3+
Ioctl,
4+
_IO,
5+
_IOWR,
6+
};
7+
8+
/* Flags for pidfd_open(). */
9+
pub const PIDFD_NONBLOCK: c_uint = crate::O_NONBLOCK as c_uint;
10+
pub const PIDFD_THREAD: c_uint = crate::O_EXCL as c_uint;
11+
12+
/* Flags for pidfd_send_signal(). */
13+
pub const PIDFD_SIGNAL_THREAD: c_uint = 1 << 0;
14+
pub const PIDFD_SIGNAL_THREAD_GROUP: c_uint = 1 << 1;
15+
pub const PIDFD_SIGNAL_PROCESS_GROUP: c_uint = 1 << 2;
16+
17+
/* Flags for pidfd_info. */
18+
pub const PIDFD_INFO_PID: c_uint = 1 << 0;
19+
pub const PIDFD_INFO_CREDS: c_uint = 1 << 1;
20+
pub const PIDFD_INFO_CGROUPID: c_uint = 1 << 2;
21+
pub const PIDFD_INFO_EXIT: c_uint = 1 << 3;
22+
pub const PIDFD_INFO_COREDUMP: c_uint = 1 << 4;
23+
pub const PIDFD_INFO_SUPPORTED_MASK: c_uint = 1 << 5;
24+
pub const PIDFD_INFO_COREDUMP_SIGNAL: c_uint = 1 << 6;
25+
26+
pub const PIDFD_INFO_SIZE_VER0: c_uint = 64;
27+
pub const PIDFD_INFO_SIZE_VER1: c_uint = 72;
28+
pub const PIDFD_INFO_SIZE_VER2: c_uint = 80;
29+
30+
/*
31+
* Values for @coredump_mask in pidfd_info.
32+
* Only valid if PIDFD_INFO_COREDUMP is set in @mask.
33+
*/
34+
pub const PIDFD_COREDUMPED: c_uint = 1 << 0;
35+
pub const PIDFD_COREDUMP_SKIP: c_uint = 1 << 1;
36+
pub const PIDFD_COREDUMP_USER: c_uint = 1 << 2;
37+
pub const PIDFD_COREDUMP_ROOT: c_uint = 1 << 3;
38+
39+
s! {
40+
#[non_exhaustive]
41+
pub struct pidfd_info {
42+
pub mask: crate::__u64,
43+
pub cgroupid: crate::__u64,
44+
pub pid: crate::__u32,
45+
pub tgid: crate::__u32,
46+
pub ppid: crate::__u32,
47+
pub ruid: crate::__u32,
48+
pub rgid: crate::__u32,
49+
pub euid: crate::__u32,
50+
pub egid: crate::__u32,
51+
pub suid: crate::__u32,
52+
pub sgid: crate::__u32,
53+
pub fsuid: crate::__u32,
54+
pub fsgid: crate::__u32,
55+
pub exit_code: crate::__s32,
56+
}
57+
}
58+
59+
pub const PIDFS_IOCTL_MAGIC: c_uint = 0xFF;
60+
61+
pub const PIDFD_GET_CGROUP_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 1);
62+
pub const PIDFD_GET_IPC_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 2);
63+
pub const PIDFD_GET_MNT_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 3);
64+
pub const PIDFD_GET_NET_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 4);
65+
pub const PIDFD_GET_PID_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 5);
66+
pub const PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 6);
67+
pub const PIDFD_GET_TIME_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 7);
68+
pub const PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 8);
69+
pub const PIDFD_GET_USER_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 9);
70+
pub const PIDFD_GET_UTS_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 10);
71+
pub const PIDFD_GET_INFO: Ioctl = _IOWR::<pidfd_info>(PIDFS_IOCTL_MAGIC, 11);

src/new/linux_uapi/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
//! This directory maps to `include/uapi` in the Linux source tree.
2-
3-
pub(crate) mod linux;
1+
pub mod linux;

src/new/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ cfg_if! {
184184
pub use linux::keyctl::*;
185185
pub use linux::membarrier::*;
186186
pub use linux::netlink::*;
187+
pub use linux::pidfd::*;
187188
#[cfg(target_env = "gnu")]
188189
pub use net::route::*;
189190
} else if #[cfg(target_vendor = "apple")] {

src/unix/linux_like/linux/mod.rs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,24 +1011,6 @@ s! {
10111011

10121012
// linux/pidfd.h
10131013

1014-
#[non_exhaustive]
1015-
pub struct pidfd_info {
1016-
pub mask: crate::__u64,
1017-
pub cgroupid: crate::__u64,
1018-
pub pid: crate::__u32,
1019-
pub tgid: crate::__u32,
1020-
pub ppid: crate::__u32,
1021-
pub ruid: crate::__u32,
1022-
pub rgid: crate::__u32,
1023-
pub euid: crate::__u32,
1024-
pub egid: crate::__u32,
1025-
pub suid: crate::__u32,
1026-
pub sgid: crate::__u32,
1027-
pub fsuid: crate::__u32,
1028-
pub fsgid: crate::__u32,
1029-
pub exit_code: crate::__s32,
1030-
}
1031-
10321014
// linux/uio.h
10331015

10341016
pub struct dmabuf_cmsg {
@@ -1599,34 +1581,6 @@ pub const NS_MNT_GET_INFO: Ioctl = _IOR::<mnt_ns_info>(NSIO, 10);
15991581
pub const NS_MNT_GET_NEXT: Ioctl = _IOR::<mnt_ns_info>(NSIO, 11);
16001582
pub const NS_MNT_GET_PREV: Ioctl = _IOR::<mnt_ns_info>(NSIO, 12);
16011583

1602-
// linux/pidfd.h
1603-
pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint;
1604-
pub const PIDFD_THREAD: c_uint = O_EXCL as c_uint;
1605-
1606-
pub const PIDFD_SIGNAL_THREAD: c_uint = 1 << 0;
1607-
pub const PIDFD_SIGNAL_THREAD_GROUP: c_uint = 1 << 1;
1608-
pub const PIDFD_SIGNAL_PROCESS_GROUP: c_uint = 1 << 2;
1609-
1610-
pub const PIDFD_INFO_PID: c_uint = 1 << 0;
1611-
pub const PIDFD_INFO_CREDS: c_uint = 1 << 1;
1612-
pub const PIDFD_INFO_CGROUPID: c_uint = 1 << 2;
1613-
pub const PIDFD_INFO_EXIT: c_uint = 1 << 3;
1614-
1615-
pub const PIDFD_INFO_SIZE_VER0: c_uint = 64;
1616-
1617-
const PIDFS_IOCTL_MAGIC: c_uint = 0xFF;
1618-
pub const PIDFD_GET_CGROUP_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 1);
1619-
pub const PIDFD_GET_IPC_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 2);
1620-
pub const PIDFD_GET_MNT_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 3);
1621-
pub const PIDFD_GET_NET_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 4);
1622-
pub const PIDFD_GET_PID_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 5);
1623-
pub const PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 6);
1624-
pub const PIDFD_GET_TIME_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 7);
1625-
pub const PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 8);
1626-
pub const PIDFD_GET_USER_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 9);
1627-
pub const PIDFD_GET_UTS_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 10);
1628-
pub const PIDFD_GET_INFO: Ioctl = _IOWR::<pidfd_info>(PIDFS_IOCTL_MAGIC, 11);
1629-
16301584
pub const PR_SET_MDWE: c_int = 65;
16311585
pub const PR_GET_MDWE: c_int = 66;
16321586
pub const PR_MDWE_REFUSE_EXEC_GAIN: c_uint = 1 << 0;

0 commit comments

Comments
 (0)