blob: f284959391fd5df82b45c8d02e6eca773d91ea3d [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
19struct proc_ns {
Al Viro64964522014-11-01 00:37:32 -040020 struct ns_common *ns;
David Howells0bb80f22013-04-12 01:50:06 +010021 const struct proc_ns_operations *ns_ops;
22};
23
24extern const struct proc_ns_operations netns_operations;
25extern const struct proc_ns_operations utsns_operations;
26extern const struct proc_ns_operations ipcns_operations;
27extern const struct proc_ns_operations pidns_operations;
28extern const struct proc_ns_operations userns_operations;
29extern const struct proc_ns_operations mntns_operations;
30
31/*
32 * We always define these enumerators
33 */
34enum {
35 PROC_ROOT_INO = 1,
36 PROC_IPC_INIT_INO = 0xEFFFFFFFU,
37 PROC_UTS_INIT_INO = 0xEFFFFFFEU,
38 PROC_USER_INIT_INO = 0xEFFFFFFDU,
39 PROC_PID_INIT_INO = 0xEFFFFFFCU,
40};
41
42#ifdef CONFIG_PROC_FS
43
44extern int pid_ns_prepare_proc(struct pid_namespace *ns);
45extern void pid_ns_release_proc(struct pid_namespace *ns);
46extern struct file *proc_ns_fget(int fd);
47extern struct proc_ns *get_proc_ns(struct inode *);
48extern int proc_alloc_inum(unsigned int *pino);
49extern void proc_free_inum(unsigned int inum);
50extern bool proc_ns_inode(struct inode *inode);
51
52#else /* CONFIG_PROC_FS */
53
54static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; }
55static inline void pid_ns_release_proc(struct pid_namespace *ns) {}
56
57static inline struct file *proc_ns_fget(int fd)
58{
59 return ERR_PTR(-EINVAL);
60}
61
62static inline struct proc_ns *get_proc_ns(struct inode *inode) { return NULL; }
63
64static inline int proc_alloc_inum(unsigned int *inum)
65{
66 *inum = 1;
67 return 0;
68}
69static inline void proc_free_inum(unsigned int inum) {}
70static inline bool proc_ns_inode(struct inode *inode) { return false; }
71
72#endif /* CONFIG_PROC_FS */
73
74#endif /* _LINUX_PROC_NS_H */