History

pidfs: allow retrieval of namespace file descriptors

For users that hold a reference to a pidfd procfs might not even be available nor is it desirable to parse through procfs just for the sake of getting namespace file descriptors for a process. Make it possible to directly retrieve namespace file descriptors from a pidfd. Pidfds already can be used with setns() to change a set of namespaces atomically.

Christian Brauner committed 2 years ago

Commit 5b08bd41 parent 460695a2 files · +104 −0Browse files

Showing the changes to include/uapi (1 of 2 files). Show all

Unified · Split

include/uapi/linux/pidfd.h+14−0
@@ -5,6 +5,7 @@ · 4 unmodified lines
5 5
6#include <linux/types.h>6#include <linux/types.h>
7#include <linux/fcntl.h>7#include <linux/fcntl.h>
8#include <linux/ioctl.h>
8 9
9/* Flags for pidfd_open(). */10/* Flags for pidfd_open(). */
10#define PIDFD_NONBLOCK O_NONBLOCK11#define PIDFD_NONBLOCK O_NONBLOCK
@@ -15,4 +16,17 @@ · 4 unmodified lines
15#define PIDFD_SIGNAL_THREAD_GROUP (1UL << 1)16#define PIDFD_SIGNAL_THREAD_GROUP (1UL << 1)
16#define PIDFD_SIGNAL_PROCESS_GROUP (1UL << 2)17#define PIDFD_SIGNAL_PROCESS_GROUP (1UL << 2)
17 18
19#define PIDFS_IOCTL_MAGIC 0xFF
20
21#define PIDFD_GET_CGROUP_NAMESPACE _IO(PIDFS_IOCTL_MAGIC, 1)
22#define PIDFD_GET_IPC_NAMESPACE _IO(PIDFS_IOCTL_MAGIC, 2)
23#define PIDFD_GET_MNT_NAMESPACE _IO(PIDFS_IOCTL_MAGIC, 3)
24#define PIDFD_GET_NET_NAMESPACE _IO(PIDFS_IOCTL_MAGIC, 4)
25#define PIDFD_GET_PID_NAMESPACE _IO(PIDFS_IOCTL_MAGIC, 5)
26#define PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE _IO(PIDFS_IOCTL_MAGIC, 6)
27#define PIDFD_GET_TIME_NAMESPACE _IO(PIDFS_IOCTL_MAGIC, 7)
28#define PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE _IO(PIDFS_IOCTL_MAGIC, 8)
29#define PIDFD_GET_USER_NAMESPACE _IO(PIDFS_IOCTL_MAGIC, 9)
30#define PIDFD_GET_UTS_NAMESPACE _IO(PIDFS_IOCTL_MAGIC, 10)
31
18#endif /* _UAPI_LINUX_PIDFD_H */32#endif /* _UAPI_LINUX_PIDFD_H */