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