1#ifndef _LINUX_PROC_FS_H
2#define _LINUX_PROC_FS_H
3
4#include <linux/config.h>
5#include <linux/slab.h>
6#include <linux/fs.h>
7#include <asm/atomic.h>
8
9
10
11
12
13
14
15
16#define FIRST_PROCESS_ENTRY 256
17
18
19
20
21
22
23enum {
24 PROC_ROOT_INO = 1,
25};
26
27#define PROC_SUPER_MAGIC 0x9fa0
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44typedef int (read_proc_t)(char *page, char **start, off_t off,
45 int count, int *eof, void *data);
46typedef int (write_proc_t)(struct file *file, const char __user *buffer,
47 unsigned long count, void *data);
48typedef int (get_info_t)(char *, char **, off_t, int);
49
50struct proc_dir_entry {
51 unsigned int low_ino;
52 unsigned short namelen;
53 const char *name;
54 mode_t mode;
55 nlink_t nlink;
56 uid_t uid;
57 gid_t gid;
58 unsigned long size;
59 struct inode_operations * proc_iops;
60 struct file_operations * proc_fops;
61 get_info_t *get_info;
62 struct module *owner;
63 struct proc_dir_entry *next, *parent, *subdir;
64 void *data;
65 read_proc_t *read_proc;
66 write_proc_t *write_proc;
67 atomic_t count;
68 int deleted;
69};
70
71struct kcore_list {
72 struct kcore_list *next;
73 unsigned long addr;
74 size_t size;
75};
76
77#ifdef CONFIG_PROC_FS
78
79extern struct proc_dir_entry proc_root;
80extern struct proc_dir_entry *proc_root_fs;
81extern struct proc_dir_entry *proc_net;
82extern struct proc_dir_entry *proc_bus;
83extern struct proc_dir_entry *proc_root_driver;
84extern struct proc_dir_entry *proc_root_kcore;
85
86extern void proc_root_init(void);
87extern void proc_misc_init(void);
88
89struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *);
90struct dentry *proc_pid_unhash(struct task_struct *p);
91void proc_pid_flush(struct dentry *proc_dentry);
92int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir);
93
94extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
95 struct proc_dir_entry *parent);
96extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
97
98extern struct vfsmount *proc_mnt;
99extern int proc_fill_super(struct super_block *,void *,int);
100extern struct inode *proc_get_inode(struct super_block *, unsigned int, struct proc_dir_entry *);
101
102extern int proc_match(int, const char *,struct proc_dir_entry *);
103
104
105
106
107
108
109
110
111extern int proc_readdir(struct file *, void *, filldir_t);
112extern struct dentry *proc_lookup(struct inode *, struct dentry *, struct nameidata *);
113
114extern struct file_operations proc_kcore_operations;
115extern struct file_operations proc_kmsg_operations;
116extern struct file_operations ppc_htab_operations;
117
118
119
120
121struct tty_driver;
122extern void proc_tty_init(void);
123extern void proc_tty_register_driver(struct tty_driver *driver);
124extern void proc_tty_unregister_driver(struct tty_driver *driver);
125
126
127
128
129struct device_node;
130extern void proc_device_tree_init(void);
131#ifdef CONFIG_PROC_DEVICETREE
132extern void proc_device_tree_add_node(struct device_node *, struct proc_dir_entry *);
133#else
134static inline void proc_device_tree_add_node(struct device_node *np, struct proc_dir_entry *pde)
135{
136 return;
137}
138#endif
139
140extern struct proc_dir_entry *proc_symlink(const char *,
141 struct proc_dir_entry *, const char *);
142extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *);
143extern struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode,
144 struct proc_dir_entry *parent);
145
146static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
147 mode_t mode, struct proc_dir_entry *base,
148 read_proc_t *read_proc, void * data)
149{
150 struct proc_dir_entry *res=create_proc_entry(name,mode,base);
151 if (res) {
152 res->read_proc=read_proc;
153 res->data=data;
154 }
155 return res;
156}
157
158static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
159 mode_t mode, struct proc_dir_entry *base, get_info_t *get_info)
160{
161 struct proc_dir_entry *res=create_proc_entry(name,mode,base);
162 if (res) res->get_info=get_info;
163 return res;
164}
165
166static inline struct proc_dir_entry *proc_net_create(const char *name,
167 mode_t mode, get_info_t *get_info)
168{
169 return create_proc_info_entry(name,mode,proc_net,get_info);
170}
171
172static inline struct proc_dir_entry *proc_net_fops_create(const char *name,
173 mode_t mode, struct file_operations *fops)
174{
175 struct proc_dir_entry *res = create_proc_entry(name, mode, proc_net);
176 if (res)
177 res->proc_fops = fops;
178 return res;
179}
180
181static inline void proc_net_remove(const char *name)
182{
183 remove_proc_entry(name,proc_net);
184}
185
186#else
187
188#define proc_root_driver NULL
189#define proc_net NULL
190
191#define proc_net_fops_create(name, mode, fops) ({ (void)(mode), NULL; })
192#define proc_net_create(name, mode, info) ({ (void)(mode), NULL; })
193static inline void proc_net_remove(const char *name) {}
194
195static inline struct dentry *proc_pid_unhash(struct task_struct *p) { return NULL; }
196static inline void proc_pid_flush(struct dentry *proc_dentry) { }
197
198static inline struct proc_dir_entry *create_proc_entry(const char *name,
199 mode_t mode, struct proc_dir_entry *parent) { return NULL; }
200
201#define remove_proc_entry(name, parent) do {} while (0)
202
203static inline struct proc_dir_entry *proc_symlink(const char *name,
204 struct proc_dir_entry *parent,char *dest) {return NULL;}
205static inline struct proc_dir_entry *proc_mkdir(const char *name,
206 struct proc_dir_entry *parent) {return NULL;}
207
208static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
209 mode_t mode, struct proc_dir_entry *base,
210 int (*read_proc)(char *, char **, off_t, int, int *, void *),
211 void * data) { return NULL; }
212static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
213 mode_t mode, struct proc_dir_entry *base, get_info_t *get_info)
214 { return NULL; }
215
216struct tty_driver;
217static inline void proc_tty_register_driver(struct tty_driver *driver) {};
218static inline void proc_tty_unregister_driver(struct tty_driver *driver) {};
219
220extern struct proc_dir_entry proc_root;
221
222#endif
223
224#if !defined(CONFIG_PROC_FS)
225static inline void kclist_add(struct kcore_list *new, void *addr, size_t size)
226{
227}
228static inline struct kcore_list * kclist_del(void *addr)
229{
230 return NULL;
231}
232#else
233extern void kclist_add(struct kcore_list *, void *, size_t);
234extern struct kcore_list *kclist_del(void *);
235#endif
236
237struct proc_inode {
238 struct task_struct *task;
239 int type;
240 union {
241 int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
242 int (*proc_read)(struct task_struct *task, char *page);
243 } op;
244 struct proc_dir_entry *pde;
245 struct inode vfs_inode;
246};
247
248static inline struct proc_inode *PROC_I(const struct inode *inode)
249{
250 return container_of(inode, struct proc_inode, vfs_inode);
251}
252
253static inline struct proc_dir_entry *PDE(const struct inode *inode)
254{
255 return PROC_I(inode)->pde;
256}
257
258#endif
259