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 *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 kdev_t rdev;
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);
90int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir);
91
92extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
93 struct proc_dir_entry *parent);
94extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
95
96extern struct vfsmount *proc_mnt;
97extern int proc_fill_super(struct super_block *,void *,int);
98extern struct inode * proc_get_inode(struct super_block *, int, struct proc_dir_entry *);
99
100extern int proc_match(int, const char *,struct proc_dir_entry *);
101
102
103
104
105
106
107
108
109extern int proc_readdir(struct file *, void *, filldir_t);
110extern struct dentry *proc_lookup(struct inode *, struct dentry *);
111
112extern struct file_operations proc_kcore_operations;
113extern struct file_operations proc_kmsg_operations;
114extern struct file_operations ppc_htab_operations;
115
116
117
118
119struct tty_driver;
120extern void proc_tty_init(void);
121extern void proc_tty_register_driver(struct tty_driver *driver);
122extern void proc_tty_unregister_driver(struct tty_driver *driver);
123
124
125
126
127extern void proc_device_tree_init(void);
128
129
130
131
132extern void proc_rtas_init(void);
133
134extern struct proc_dir_entry *proc_symlink(const char *,
135 struct proc_dir_entry *, const char *);
136extern struct proc_dir_entry *proc_mknod(const char *,mode_t,
137 struct proc_dir_entry *,kdev_t);
138extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *);
139
140static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
141 mode_t mode, struct proc_dir_entry *base,
142 read_proc_t *read_proc, void * data)
143{
144 struct proc_dir_entry *res=create_proc_entry(name,mode,base);
145 if (res) {
146 res->read_proc=read_proc;
147 res->data=data;
148 }
149 return res;
150}
151
152static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
153 mode_t mode, struct proc_dir_entry *base, get_info_t *get_info)
154{
155 struct proc_dir_entry *res=create_proc_entry(name,mode,base);
156 if (res) res->get_info=get_info;
157 return res;
158}
159
160static inline struct proc_dir_entry *proc_net_create(const char *name,
161 mode_t mode, get_info_t *get_info)
162{
163 return create_proc_info_entry(name,mode,proc_net,get_info);
164}
165
166static inline void proc_net_remove(const char *name)
167{
168 remove_proc_entry(name,proc_net);
169}
170
171#else
172
173#define proc_root_driver NULL
174
175static inline struct proc_dir_entry *proc_net_create(const char *name, mode_t mode,
176 get_info_t *get_info) {return NULL;}
177static inline void proc_net_remove(const char *name) {}
178
179static inline struct proc_dir_entry *create_proc_entry(const char *name,
180 mode_t mode, struct proc_dir_entry *parent) { return NULL; }
181
182static inline void remove_proc_entry(const char *name, struct proc_dir_entry *parent) {};
183static inline struct proc_dir_entry *proc_symlink(const char *name,
184 struct proc_dir_entry *parent,char *dest) {return NULL;}
185static inline struct proc_dir_entry *proc_mknod(const char *name,mode_t mode,
186 struct proc_dir_entry *parent,kdev_t rdev) {return NULL;}
187static inline struct proc_dir_entry *proc_mkdir(const char *name,
188 struct proc_dir_entry *parent) {return NULL;}
189
190static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
191 mode_t mode, struct proc_dir_entry *base,
192 int (*read_proc)(char *, char **, off_t, int, int *, void *),
193 void * data) { return NULL; }
194static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
195 mode_t mode, struct proc_dir_entry *base, get_info_t *get_info)
196 { return NULL; }
197
198struct tty_driver;
199static inline void proc_tty_register_driver(struct tty_driver *driver) {};
200static inline void proc_tty_unregister_driver(struct tty_driver *driver) {};
201
202extern struct proc_dir_entry proc_root;
203
204#endif
205
206struct proc_inode {
207 struct task_struct *task;
208 int type;
209 union {
210 int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
211 int (*proc_read)(struct task_struct *task, char *page);
212 } op;
213 struct proc_dir_entry *pde;
214 struct inode vfs_inode;
215};
216
217static inline struct proc_inode *PROC_I(const struct inode *inode)
218{
219 return container_of(inode, struct proc_inode, vfs_inode);
220}
221
222static inline struct proc_dir_entry *PDE(const struct inode *inode)
223{
224 return PROC_I(inode)->pde;
225}
226
227#endif
228