Commit | Line | Data |
---|---|---|
0bb80f24 DH |
1 | /* |
2 | * procfs namespace bits | |
3 | */ | |
4 | #ifndef _LINUX_PROC_NS_H | |
5 | #define _LINUX_PROC_NS_H | |
6 | ||
7 | struct pid_namespace; | |
8 | struct nsproxy; | |
64964528 | 9 | struct ns_common; |
0bb80f24 DH |
10 | |
11 | struct proc_ns_operations { | |
12 | const char *name; | |
13 | int type; | |
64964528 AV |
14 | struct ns_common *(*get)(struct task_struct *task); |
15 | void (*put)(struct ns_common *ns); | |
16 | int (*install)(struct nsproxy *nsproxy, struct ns_common *ns); | |
0bb80f24 DH |
17 | }; |
18 | ||
0bb80f24 DH |
19 | extern const struct proc_ns_operations netns_operations; |
20 | extern const struct proc_ns_operations utsns_operations; | |
21 | extern const struct proc_ns_operations ipcns_operations; | |
22 | extern const struct proc_ns_operations pidns_operations; | |
23 | extern const struct proc_ns_operations userns_operations; | |
24 | extern const struct proc_ns_operations mntns_operations; | |
25 | ||
26 | /* | |
27 | * We always define these enumerators | |
28 | */ | |
29 | enum { | |
30 | PROC_ROOT_INO = 1, | |
31 | PROC_IPC_INIT_INO = 0xEFFFFFFFU, | |
32 | PROC_UTS_INIT_INO = 0xEFFFFFFEU, | |
33 | PROC_USER_INIT_INO = 0xEFFFFFFDU, | |
34 | PROC_PID_INIT_INO = 0xEFFFFFFCU, | |
35 | }; | |
36 | ||
37 | #ifdef CONFIG_PROC_FS | |
38 | ||
39 | extern int pid_ns_prepare_proc(struct pid_namespace *ns); | |
40 | extern void pid_ns_release_proc(struct pid_namespace *ns); | |
41 | extern struct file *proc_ns_fget(int fd); | |
f77c8014 | 42 | extern struct ns_common *get_proc_ns(struct inode *); |
0bb80f24 DH |
43 | extern int proc_alloc_inum(unsigned int *pino); |
44 | extern void proc_free_inum(unsigned int inum); | |
45 | extern bool proc_ns_inode(struct inode *inode); | |
46 | ||
47 | #else /* CONFIG_PROC_FS */ | |
48 | ||
49 | static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; } | |
50 | static inline void pid_ns_release_proc(struct pid_namespace *ns) {} | |
51 | ||
52 | static inline struct file *proc_ns_fget(int fd) | |
53 | { | |
54 | return ERR_PTR(-EINVAL); | |
55 | } | |
56 | ||
f77c8014 | 57 | static inline struct ns_common *get_proc_ns(struct inode *inode) { return NULL; } |
0bb80f24 DH |
58 | |
59 | static inline int proc_alloc_inum(unsigned int *inum) | |
60 | { | |
61 | *inum = 1; | |
62 | return 0; | |
63 | } | |
64 | static inline void proc_free_inum(unsigned int inum) {} | |
65 | static inline bool proc_ns_inode(struct inode *inode) { return false; } | |
66 | ||
67 | #endif /* CONFIG_PROC_FS */ | |
68 | ||
6344c433 AV |
69 | #define ns_alloc_inum(ns) proc_alloc_inum(&(ns)->inum) |
70 | #define ns_free_inum(ns) proc_free_inum((ns)->inum) | |
71 | ||
0bb80f24 | 72 | #endif /* _LINUX_PROC_NS_H */ |