Skip to content

Commit af8b812

Browse files
raushan728JohnTitor
authored andcommitted
linux: relocate PIDFD definitions to src/new
(backport <#4981>) (cherry picked from commit cec13cb)
1 parent d0bd7e2 commit af8b812

File tree

4 files changed

+61
-46
lines changed

4 files changed

+61
-46
lines changed

src/new/linux_uapi/linux/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ pub(crate) mod can;
66
pub(crate) mod keyctl;
77
pub(crate) mod membarrier;
88
pub(crate) mod netlink;
9+
pub(crate) mod pidfd;

src/new/linux_uapi/linux/pidfd.rs

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

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
@@ -1012,24 +1012,6 @@ s! {
10121012

10131013
// linux/pidfd.h
10141014

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

10351017
pub struct dmabuf_cmsg {
@@ -1635,34 +1617,6 @@ pub const NS_MNT_GET_INFO: Ioctl = _IOR::<mnt_ns_info>(NSIO, 10);
16351617
pub const NS_MNT_GET_NEXT: Ioctl = _IOR::<mnt_ns_info>(NSIO, 11);
16361618
pub const NS_MNT_GET_PREV: Ioctl = _IOR::<mnt_ns_info>(NSIO, 12);
16371619

1638-
// linux/pidfd.h
1639-
pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint;
1640-
pub const PIDFD_THREAD: c_uint = O_EXCL as c_uint;
1641-
1642-
pub const PIDFD_SIGNAL_THREAD: c_uint = 1 << 0;
1643-
pub const PIDFD_SIGNAL_THREAD_GROUP: c_uint = 1 << 1;
1644-
pub const PIDFD_SIGNAL_PROCESS_GROUP: c_uint = 1 << 2;
1645-
1646-
pub const PIDFD_INFO_PID: c_uint = 1 << 0;
1647-
pub const PIDFD_INFO_CREDS: c_uint = 1 << 1;
1648-
pub const PIDFD_INFO_CGROUPID: c_uint = 1 << 2;
1649-
pub const PIDFD_INFO_EXIT: c_uint = 1 << 3;
1650-
1651-
pub const PIDFD_INFO_SIZE_VER0: c_uint = 64;
1652-
1653-
const PIDFS_IOCTL_MAGIC: c_uint = 0xFF;
1654-
pub const PIDFD_GET_CGROUP_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 1);
1655-
pub const PIDFD_GET_IPC_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 2);
1656-
pub const PIDFD_GET_MNT_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 3);
1657-
pub const PIDFD_GET_NET_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 4);
1658-
pub const PIDFD_GET_PID_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 5);
1659-
pub const PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 6);
1660-
pub const PIDFD_GET_TIME_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 7);
1661-
pub const PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 8);
1662-
pub const PIDFD_GET_USER_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 9);
1663-
pub const PIDFD_GET_UTS_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 10);
1664-
pub const PIDFD_GET_INFO: Ioctl = _IOWR::<pidfd_info>(PIDFS_IOCTL_MAGIC, 11);
1665-
16661620
pub const PR_SET_MDWE: c_int = 65;
16671621
pub const PR_GET_MDWE: c_int = 66;
16681622
pub const PR_MDWE_REFUSE_EXEC_GAIN: c_uint = 1 << 0;

0 commit comments

Comments
 (0)