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