blob: 2837ff41cfe3998b98cacf6d8a7784db212ae422 [file] [log] [blame]
David Howells0bb80f22013-04-12 01:50:06 +01001/*
2 * procfs namespace bits
3 */
4#ifndef _LINUX_PROC_NS_H
5#define _LINUX_PROC_NS_H
6
7struct pid_namespace;
8struct nsproxy;
Al Viro64964522014-11-01 00:37:32 -04009struct ns_common;
David Howells0bb80f22013-04-12 01:50:06 +010010
11struct proc_ns_operations {
12 const char *name;
13 int type;
Al Viro64964522014-11-01 00:37:32 -040014 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);
David Howells0bb80f22013-04-12 01:50:06 +010017};
18
David Howells0bb80f22013-04-12 01:50:06 +010019extern const struct proc_ns_operations netns_operations;
20extern const struct proc_ns_operations utsns_operations;
21extern const struct proc_ns_operations ipcns_operations;
22extern const struct proc_ns_operations pidns_operations;
23extern const struct proc_ns_operations userns_operations;
24extern const struct proc_ns_operations mntns_operations;
25
26/*
27 * We always define these enumerators
28 */
29enum {
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
39extern int pid_ns_prepare_proc(struct pid_namespace *ns);
40extern void pid_ns_release_proc(struct pid_namespace *ns);
41extern struct file *proc_ns_fget(int fd);
Al Virof77c80142014-11-01 03:13:17 -040042extern struct ns_common *get_proc_ns(struct inode *);
David Howells0bb80f22013-04-12 01:50:06 +010043extern int proc_alloc_inum(unsigned int *pino);
44extern void proc_free_inum(unsigned int inum);
45extern bool proc_ns_inode(struct inode *inode);
46
47#else /* CONFIG_PROC_FS */
48
49static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; }
50static inline void pid_ns_release_proc(struct pid_namespace *ns) {}
51
52static inline struct file *proc_ns_fget(int fd)
53{
54 return ERR_PTR(-EINVAL);
55}
56
Al Virof77c80142014-11-01 03:13:17 -040057static inline struct ns_common *get_proc_ns(struct inode *inode) { return NULL; }
David Howells0bb80f22013-04-12 01:50:06 +010058
59static inline int proc_alloc_inum(unsigned int *inum)
60{
61 *inum = 1;
62 return 0;
63}
64static inline void proc_free_inum(unsigned int inum) {}
65static inline bool proc_ns_inode(struct inode *inode) { return false; }
66
67#endif /* CONFIG_PROC_FS */
68
Al Viro6344c432014-11-01 00:45:45 -040069#define ns_alloc_inum(ns) proc_alloc_inum(&(ns)->inum)
70#define ns_free_inum(ns) proc_free_inum((ns)->inum)
71
David Howells0bb80f22013-04-12 01:50:06 +010072#endif /* _LINUX_PROC_NS_H */