1 | #ifndef _LINUX_PROC_FS_H
|
---|
2 | #define _LINUX_PROC_FS_H
|
---|
3 |
|
---|
4 | #include <linux/config.h>
|
---|
5 | #include <linux/malloc.h>
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * The proc filesystem constants/structures
|
---|
9 | */
|
---|
10 |
|
---|
11 | struct proc_ops {
|
---|
12 | int (*proc_open)(struct inode *, struct file *);
|
---|
13 | ssize_t (*proc_read)(struct file *, char __user *, size_t, loff_t *);
|
---|
14 | ssize_t (*proc_write)(struct file *, const char __user *, size_t, loff_t *);
|
---|
15 | loff_t (*proc_lseek)(struct file *, loff_t, int);
|
---|
16 | int (*proc_release)(struct inode *, struct file *);
|
---|
17 | __poll_t (*proc_poll)(struct file *, struct poll_table_struct *);
|
---|
18 | long (*proc_ioctl)(struct file *, unsigned int, unsigned long);
|
---|
19 | #ifdef CONFIG_COMPAT
|
---|
20 | long (*proc_compat_ioctl)(struct file *, unsigned int, unsigned long);
|
---|
21 | #endif
|
---|
22 | int (*proc_mmap)(struct file *, struct vm_area_struct *);
|
---|
23 | unsigned long (*proc_get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
|
---|
24 | };
|
---|
25 |
|
---|
26 | /*
|
---|
27 | * Offset of the first process in the /proc root directory..
|
---|
28 | */
|
---|
29 | #define FIRST_PROCESS_ENTRY 256
|
---|
30 |
|
---|
31 |
|
---|
32 | /*
|
---|
33 | * We always define these enumerators
|
---|
34 | */
|
---|
35 |
|
---|
36 | enum {
|
---|
37 | PROC_ROOT_INO = 1,
|
---|
38 | };
|
---|
39 |
|
---|
40 | /* Finally, the dynamically allocatable proc entries are reserved: */
|
---|
41 |
|
---|
42 | #define PROC_DYNAMIC_FIRST 4096
|
---|
43 | #define PROC_NDYNAMIC 4096
|
---|
44 | #define PROC_OPENPROM_FIRST (PROC_DYNAMIC_FIRST+PROC_NDYNAMIC)
|
---|
45 | #define PROC_OPENPROM PROC_OPENPROM_FIRST
|
---|
46 | #define PROC_NOPENPROM 4096
|
---|
47 | #define PROC_OPENPROMD_FIRST (PROC_OPENPROM_FIRST+PROC_NOPENPROM)
|
---|
48 | #define PROC_NOPENPROMD 4096
|
---|
49 |
|
---|
50 | #define PROC_SUPER_MAGIC 0x9fa0
|
---|
51 |
|
---|
52 | /*
|
---|
53 | * This is not completely implemented yet. The idea is to
|
---|
54 | * create an in-memory tree (like the actual /proc filesystem
|
---|
55 | * tree) of these proc_dir_entries, so that we can dynamically
|
---|
56 | * add new files to /proc.
|
---|
57 | *
|
---|
58 | * The "next" pointer creates a linked list of one /proc directory,
|
---|
59 | * while parent/subdir create the directory structure (every
|
---|
60 | * /proc file has a parent, but "subdir" is NULL for all
|
---|
61 | * non-directory entries).
|
---|
62 | *
|
---|
63 | * "get_info" is called at "read", while "owner" is used to protect module
|
---|
64 | * from unloading while proc_dir_entry is in use
|
---|
65 | */
|
---|
66 |
|
---|
67 | typedef int (read_proc_t)(char *page, char **start, off_t off,
|
---|
68 | int count, int *eof, void *data);
|
---|
69 | typedef int (write_proc_t)(struct file *file, const char *buffer,
|
---|
70 | unsigned long count, void *data);
|
---|
71 | typedef int (get_info_t)(char *, char **, off_t, int, int);
|
---|
72 |
|
---|
73 | struct proc_dir_entry {
|
---|
74 | unsigned short low_ino;
|
---|
75 | unsigned short namelen;
|
---|
76 | const char *name;
|
---|
77 | mode_t mode;
|
---|
78 | nlink_t nlink;
|
---|
79 | uid_t uid;
|
---|
80 | gid_t gid;
|
---|
81 | unsigned long size;
|
---|
82 | struct inode_operations * ops;
|
---|
83 | get_info_t *get_info;
|
---|
84 | struct module *owner;
|
---|
85 | struct proc_dir_entry *next, *parent, *subdir;
|
---|
86 | void *data;
|
---|
87 | read_proc_t *read_proc;
|
---|
88 | write_proc_t *write_proc;
|
---|
89 | int (*readlink_proc)(struct proc_dir_entry *de, char *page);
|
---|
90 | void (*fill_inode)(struct inode *inode, int fill);
|
---|
91 | unsigned int count; /* use count */
|
---|
92 | int deleted; /* delete flag */
|
---|
93 | };
|
---|
94 |
|
---|
95 | #define PROC_INODE_PROPER(inode) ((inode)->i_ino & ~0xffff)
|
---|
96 | #define PROC_INODE_OPENPROM(inode) \
|
---|
97 | ((inode->i_ino >= PROC_OPENPROM_FIRST) \
|
---|
98 | && (inode->i_ino < PROC_OPENPROM_FIRST + PROC_NOPENPROM))
|
---|
99 |
|
---|
100 | #ifdef CONFIG_PROC_FS
|
---|
101 | extern struct proc_dir_entry proc_root;
|
---|
102 | extern struct proc_dir_entry *proc_root_fs;
|
---|
103 | extern struct proc_dir_entry *proc_net;
|
---|
104 | extern struct proc_dir_entry proc_sys;
|
---|
105 | extern struct proc_dir_entry proc_openprom;
|
---|
106 | extern struct proc_dir_entry *proc_mca;
|
---|
107 | extern struct proc_dir_entry *proc_bus;
|
---|
108 | extern struct proc_dir_entry *proc_root_driver;
|
---|
109 | extern struct proc_dir_entry proc_root_kcore;
|
---|
110 |
|
---|
111 | extern void proc_root_init(void);
|
---|
112 | extern void proc_misc_init(void);
|
---|
113 |
|
---|
114 | struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry);
|
---|
115 | void proc_pid_delete_inode(struct inode *inode);
|
---|
116 | int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir);
|
---|
117 |
|
---|
118 | extern int proc_register(struct proc_dir_entry *, struct proc_dir_entry *);
|
---|
119 | extern int proc_unregister(struct proc_dir_entry *, int);
|
---|
120 |
|
---|
121 | extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
|
---|
122 | struct proc_dir_entry *parent);
|
---|
123 |
|
---|
124 | extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
|
---|
125 |
|
---|
126 |
|
---|
127 | /*
|
---|
128 | * retrieve the proc_dir_entry associated with /proc/driver/$module_name
|
---|
129 | */
|
---|
130 | struct proc_dir_entry *proc_driver_find (const char *module_name);
|
---|
131 |
|
---|
132 |
|
---|
133 | /*
|
---|
134 | * remove /proc/driver/$module_name, and all its contents
|
---|
135 | */
|
---|
136 | int proc_driver_unregister(const char *module_name);
|
---|
137 |
|
---|
138 |
|
---|
139 | /*
|
---|
140 | * create driver-specific playground directory, /proc/driver/$module_name
|
---|
141 | */
|
---|
142 | int proc_driver_register(const char *module_name);
|
---|
143 |
|
---|
144 | extern struct super_block *proc_super_blocks;
|
---|
145 | extern struct dentry_operations proc_dentry_operations;
|
---|
146 | extern struct super_block *proc_read_super(struct super_block *,void *,int);
|
---|
147 | extern int init_proc_fs(void);
|
---|
148 | extern struct inode * proc_get_inode(struct super_block *, int, struct proc_dir_entry *);
|
---|
149 | extern int proc_statfs(struct super_block *, struct statfs *, int);
|
---|
150 | extern void proc_read_inode(struct inode *);
|
---|
151 | extern void proc_write_inode(struct inode *);
|
---|
152 |
|
---|
153 | extern int proc_match(int, const char *,struct proc_dir_entry *);
|
---|
154 |
|
---|
155 | /*
|
---|
156 | * These are generic /proc routines that use the internal
|
---|
157 | * "struct proc_dir_entry" tree to traverse the filesystem.
|
---|
158 | *
|
---|
159 | * The /proc root directory has extended versions to take care
|
---|
160 | * of the /proc/<pid> subdirectories.
|
---|
161 | */
|
---|
162 | extern int proc_readdir(struct file *, void *, filldir_t);
|
---|
163 | extern struct dentry *proc_lookup(struct inode *, struct dentry *);
|
---|
164 |
|
---|
165 | struct openpromfs_dev {
|
---|
166 | struct openpromfs_dev *next;
|
---|
167 | u32 node;
|
---|
168 | ino_t inode;
|
---|
169 | kdev_t rdev;
|
---|
170 | mode_t mode;
|
---|
171 | char name[32];
|
---|
172 | };
|
---|
173 | extern struct inode_operations *
|
---|
174 | proc_openprom_register(int (*readdir)(struct file *, void *, filldir_t),
|
---|
175 | struct dentry * (*lookup)(struct inode *, struct dentry *),
|
---|
176 | void (*use)(struct inode *, int),
|
---|
177 | struct openpromfs_dev ***);
|
---|
178 | extern void proc_openprom_deregister(void);
|
---|
179 | extern void (*proc_openprom_use)(struct inode *,int);
|
---|
180 | extern int proc_openprom_regdev(struct openpromfs_dev *);
|
---|
181 | extern int proc_openprom_unregdev(struct openpromfs_dev *);
|
---|
182 |
|
---|
183 | extern struct inode_operations proc_dir_inode_operations;
|
---|
184 | extern struct inode_operations proc_file_inode_operations;
|
---|
185 | extern struct inode_operations proc_openprom_inode_operations;
|
---|
186 | extern struct inode_operations proc_sys_inode_operations;
|
---|
187 | extern struct inode_operations proc_kcore_inode_operations;
|
---|
188 | extern struct inode_operations proc_profile_inode_operations;
|
---|
189 | extern struct inode_operations proc_kmsg_inode_operations;
|
---|
190 | #if CONFIG_AP1000
|
---|
191 | extern struct inode_operations proc_ringbuf_inode_operations;
|
---|
192 | #endif
|
---|
193 | extern struct inode_operations proc_omirr_inode_operations;
|
---|
194 | extern struct inode_operations proc_ppc_htab_inode_operations;
|
---|
195 |
|
---|
196 | /*
|
---|
197 | * proc_tty.c
|
---|
198 | */
|
---|
199 | extern void proc_tty_init(void);
|
---|
200 | extern void proc_tty_register_driver(struct tty_driver *driver);
|
---|
201 | extern void proc_tty_unregister_driver(struct tty_driver *driver);
|
---|
202 |
|
---|
203 | /*
|
---|
204 | * proc_devtree.c
|
---|
205 | */
|
---|
206 | extern void proc_device_tree_init(void);
|
---|
207 |
|
---|
208 | static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
|
---|
209 | mode_t mode, struct proc_dir_entry *base,
|
---|
210 | read_proc_t *read_proc, void * data)
|
---|
211 | {
|
---|
212 | struct proc_dir_entry *res=create_proc_entry(name,mode,base);
|
---|
213 | if (res) {
|
---|
214 | res->read_proc=read_proc;
|
---|
215 | res->data=data;
|
---|
216 | }
|
---|
217 | return res;
|
---|
218 | }
|
---|
219 |
|
---|
220 | struct proc_dir_entry *create_proc_info_entry(const char *name,
|
---|
221 | mode_t mode, struct proc_dir_entry *base, get_info_t *get_info);
|
---|
222 | struct proc_dir_entry *proc_net_create(const char *name);
|
---|
223 | void proc_net_remove(const char *name);
|
---|
224 | static inline void proc_remove(struct proc_dir_entry *de) {}
|
---|
225 | #else
|
---|
226 |
|
---|
227 | extern inline int proc_register(struct proc_dir_entry *a, struct proc_dir_entry *b) { return 0; }
|
---|
228 | extern inline int proc_unregister(struct proc_dir_entry *a, int b) { return 0; }
|
---|
229 | extern inline struct proc_dir_entry *proc_net_create(const char *name, mode_t mode,
|
---|
230 | get_info_t *get_info) {return NULL;}
|
---|
231 | extern inline void proc_net_remove(const char *name) {}
|
---|
232 |
|
---|
233 | extern inline struct proc_dir_entry *create_proc_entry(const char *name,
|
---|
234 | mode_t mode, struct proc_dir_entry *parent) { return NULL; }
|
---|
235 |
|
---|
236 | extern inline void remove_proc_entry(const char *name, struct proc_dir_entry *parent) {};
|
---|
237 |
|
---|
238 | extern inline void proc_tty_register_driver(struct tty_driver *driver) {};
|
---|
239 | extern inline void proc_tty_unregister_driver(struct tty_driver *driver) {};
|
---|
240 |
|
---|
241 | static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
|
---|
242 | mode_t mode, struct proc_dir_entry *base,
|
---|
243 | read_proc_t *read_proc, void * data) { return NULL; }
|
---|
244 | struct proc_dir_entry *create_proc_info_entry(const char *name,
|
---|
245 | mode_t mode, struct proc_dir_entry *base, get_info_t *get_info);
|
---|
246 | void proc_net_remove(const char *name);
|
---|
247 |
|
---|
248 | extern struct proc_dir_entry proc_root;
|
---|
249 | static inline void proc_remove(struct proc_dir_entry *de) {}
|
---|
250 | static inline void *PDE_DATA(const struct inode *inode) {return NULL;}
|
---|
251 | #endif /* CONFIG_PROC_FS */
|
---|
252 |
|
---|
253 | static inline struct proc_dir_entry *PDE(const struct inode *inode)
|
---|
254 | {
|
---|
255 | return (struct proc_dir_entry *) inode->u.generic_ip;
|
---|
256 | }
|
---|
257 | static inline void *PDE_DATA(const struct inode *inode) {return NULL;}
|
---|
258 |
|
---|
259 | extern struct proc_dir_entry *proc_symlink(const char *,
|
---|
260 | struct proc_dir_entry *, const char *);
|
---|
261 | extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *);
|
---|
262 | #endif /* _LINUX_PROC_FS_H */
|
---|