0001
0002
0003
0004
0005 #ifndef _LINUX_PROC_NS_H
0006 #define _LINUX_PROC_NS_H
0007
0008 #include <linux/ns_common.h>
0009
0010 struct pid_namespace;
0011 struct nsset;
0012 struct path;
0013 struct task_struct;
0014 struct inode;
0015
0016 struct proc_ns_operations {
0017 const char *name;
0018 const char *real_ns_name;
0019 int type;
0020 struct ns_common *(*get)(struct task_struct *task);
0021 void (*put)(struct ns_common *ns);
0022 int (*install)(struct nsset *nsset, struct ns_common *ns);
0023 struct user_namespace *(*owner)(struct ns_common *ns);
0024 struct ns_common *(*get_parent)(struct ns_common *ns);
0025 } __randomize_layout;
0026
0027 extern const struct proc_ns_operations netns_operations;
0028 extern const struct proc_ns_operations utsns_operations;
0029 extern const struct proc_ns_operations ipcns_operations;
0030 extern const struct proc_ns_operations pidns_operations;
0031 extern const struct proc_ns_operations pidns_for_children_operations;
0032 extern const struct proc_ns_operations userns_operations;
0033 extern const struct proc_ns_operations mntns_operations;
0034 extern const struct proc_ns_operations cgroupns_operations;
0035 extern const struct proc_ns_operations timens_operations;
0036 extern const struct proc_ns_operations timens_for_children_operations;
0037
0038
0039
0040
0041 enum {
0042 PROC_ROOT_INO = 1,
0043 PROC_IPC_INIT_INO = 0xEFFFFFFFU,
0044 PROC_UTS_INIT_INO = 0xEFFFFFFEU,
0045 PROC_USER_INIT_INO = 0xEFFFFFFDU,
0046 PROC_PID_INIT_INO = 0xEFFFFFFCU,
0047 PROC_CGROUP_INIT_INO = 0xEFFFFFFBU,
0048 PROC_TIME_INIT_INO = 0xEFFFFFFAU,
0049 };
0050
0051 #ifdef CONFIG_PROC_FS
0052
0053 extern int proc_alloc_inum(unsigned int *pino);
0054 extern void proc_free_inum(unsigned int inum);
0055
0056 #else
0057
0058 static inline int proc_alloc_inum(unsigned int *inum)
0059 {
0060 *inum = 1;
0061 return 0;
0062 }
0063 static inline void proc_free_inum(unsigned int inum) {}
0064
0065 #endif
0066
0067 static inline int ns_alloc_inum(struct ns_common *ns)
0068 {
0069 atomic_long_set(&ns->stashed, 0);
0070 return proc_alloc_inum(&ns->inum);
0071 }
0072
0073 #define ns_free_inum(ns) proc_free_inum((ns)->inum)
0074
0075 extern struct file *proc_ns_fget(int fd);
0076 #define get_proc_ns(inode) ((struct ns_common *)(inode)->i_private)
0077 extern int ns_get_path(struct path *path, struct task_struct *task,
0078 const struct proc_ns_operations *ns_ops);
0079 typedef struct ns_common *ns_get_path_helper_t(void *);
0080 extern int ns_get_path_cb(struct path *path, ns_get_path_helper_t ns_get_cb,
0081 void *private_data);
0082
0083 extern bool ns_match(const struct ns_common *ns, dev_t dev, ino_t ino);
0084
0085 extern int ns_get_name(char *buf, size_t size, struct task_struct *task,
0086 const struct proc_ns_operations *ns_ops);
0087 extern void nsfs_init(void);
0088
0089 #endif