]> Pileus Git - ~andy/linux/blob - include/linux/proc_fs.h
proc: Move PDE_NET() to fs/proc/proc_net.c
[~andy/linux] / include / linux / proc_fs.h
1 #ifndef _LINUX_PROC_FS_H
2 #define _LINUX_PROC_FS_H
3
4 #include <linux/slab.h>
5 #include <linux/fs.h>
6 #include <linux/spinlock.h>
7 #include <linux/magic.h>
8 #include <linux/atomic.h>
9 #include <linux/proc_ns.h>
10
11 struct net;
12 struct completion;
13 struct mm_struct;
14
15 /*
16  * The proc filesystem constants/structures
17  */
18
19 /*
20  * Offset of the first process in the /proc root directory..
21  */
22 #define FIRST_PROCESS_ENTRY 256
23
24 /* Worst case buffer size needed for holding an integer. */
25 #define PROC_NUMBUF 13
26
27 /*
28  * This is not completely implemented yet. The idea is to
29  * create an in-memory tree (like the actual /proc filesystem
30  * tree) of these proc_dir_entries, so that we can dynamically
31  * add new files to /proc.
32  *
33  * The "next" pointer creates a linked list of one /proc directory,
34  * while parent/subdir create the directory structure (every
35  * /proc file has a parent, but "subdir" is NULL for all
36  * non-directory entries).
37  */
38
39 struct proc_dir_entry {
40         unsigned int low_ino;
41         umode_t mode;
42         nlink_t nlink;
43         kuid_t uid;
44         kgid_t gid;
45         loff_t size;
46         const struct inode_operations *proc_iops;
47         const struct file_operations *proc_fops;
48         struct proc_dir_entry *next, *parent, *subdir;
49         void *data;
50         atomic_t count;         /* use count */
51         atomic_t in_use;        /* number of callers into module in progress; */
52                         /* negative -> it's going away RSN */
53         struct completion *pde_unload_completion;
54         struct list_head pde_openers;   /* who did ->open, but not ->release */
55         spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */
56         u8 namelen;
57         char name[];
58 };
59
60 #ifdef CONFIG_PROC_FS
61
62 extern void proc_root_init(void);
63
64 void proc_flush_task(struct task_struct *task);
65
66 struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
67                                 struct proc_dir_entry *parent,
68                                 const struct file_operations *proc_fops,
69                                 void *data);
70 extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
71 extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent);
72
73
74 /*
75  * proc_tty.c
76  */
77 struct tty_driver;
78 #ifdef CONFIG_TTY
79 extern void proc_tty_init(void);
80 #else
81 static inline void proc_tty_init(void)
82 { }
83 #endif
84 extern void proc_tty_register_driver(struct tty_driver *driver);
85 extern void proc_tty_unregister_driver(struct tty_driver *driver);
86
87 /*
88  * proc_devtree.c
89  */
90 #ifdef CONFIG_PROC_DEVICETREE
91 struct device_node;
92 struct property;
93 extern void proc_device_tree_init(void);
94 extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *);
95 extern void proc_device_tree_add_prop(struct proc_dir_entry *pde, struct property *prop);
96 extern void proc_device_tree_remove_prop(struct proc_dir_entry *pde,
97                                          struct property *prop);
98 extern void proc_device_tree_update_prop(struct proc_dir_entry *pde,
99                                          struct property *newprop,
100                                          struct property *oldprop);
101 #endif /* CONFIG_PROC_DEVICETREE */
102
103 extern struct proc_dir_entry *proc_symlink(const char *,
104                 struct proc_dir_entry *, const char *);
105 extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *);
106 extern struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode,
107                         struct proc_dir_entry *parent);
108
109 static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
110         struct proc_dir_entry *parent, const struct file_operations *proc_fops)
111 {
112         return proc_create_data(name, mode, parent, proc_fops, NULL);
113 }
114  
115 extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name,
116         struct proc_dir_entry *parent);
117
118 extern void proc_set_size(struct proc_dir_entry *, loff_t);
119 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
120 #else
121
122 static inline void proc_flush_task(struct task_struct *task)
123 {
124 }
125
126 #define proc_create(name, mode, parent, fops)  ({ (void)(mode), NULL; })
127
128 static inline struct proc_dir_entry *proc_create_data(const char *name,
129         umode_t mode, struct proc_dir_entry *parent,
130         const struct file_operations *proc_fops, void *data)
131 {
132         return NULL;
133 }
134 #define remove_proc_entry(name, parent) do {} while (0)
135 #define remove_proc_subtree(name, parent) do {} while (0)
136
137 static inline struct proc_dir_entry *proc_symlink(const char *name,
138                 struct proc_dir_entry *parent,const char *dest) {return NULL;}
139 static inline struct proc_dir_entry *proc_mkdir(const char *name,
140         struct proc_dir_entry *parent) {return NULL;}
141 static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
142         umode_t mode, struct proc_dir_entry *parent) { return NULL; }
143 static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
144 static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
145
146 struct tty_driver;
147 static inline void proc_tty_register_driver(struct tty_driver *driver) {};
148 static inline void proc_tty_unregister_driver(struct tty_driver *driver) {};
149
150 #endif /* CONFIG_PROC_FS */
151
152
153 union proc_op {
154         int (*proc_get_link)(struct dentry *, struct path *);
155         int (*proc_read)(struct task_struct *task, char *page);
156         int (*proc_show)(struct seq_file *m,
157                 struct pid_namespace *ns, struct pid *pid,
158                 struct task_struct *task);
159 };
160
161 struct ctl_table_header;
162 struct ctl_table;
163
164 struct proc_inode {
165         struct pid *pid;
166         int fd;
167         union proc_op op;
168         struct proc_dir_entry *pde;
169         struct ctl_table_header *sysctl;
170         struct ctl_table *sysctl_entry;
171         struct proc_ns ns;
172         struct inode vfs_inode;
173 };
174
175 static inline struct proc_inode *PROC_I(const struct inode *inode)
176 {
177         return container_of(inode, struct proc_inode, vfs_inode);
178 }
179
180 static inline struct proc_dir_entry *PDE(const struct inode *inode)
181 {
182         return PROC_I(inode)->pde;
183 }
184
185 static inline void *PDE_DATA(const struct inode *inode)
186 {
187         return PROC_I(inode)->pde->data;
188 }
189
190 #include <linux/signal.h>
191
192 void render_sigset_t(struct seq_file *m, const char *header, sigset_t *set);
193 #endif /* _LINUX_PROC_FS_H */