Import 2.3.6
[davej-history.git] / include / linux / proc_fs.h
blob6297457d299321f1a2e784fd0b26851c347a94e6
1 #ifndef _LINUX_PROC_FS_H
2 #define _LINUX_PROC_FS_H
4 #include <linux/config.h>
5 #include <linux/malloc.h>
7 /*
8 * The proc filesystem constants/structures
9 */
12 * We always define these enumerators
15 enum root_directory_inos {
16 PROC_ROOT_INO = 1,
17 PROC_LOADAVG,
18 PROC_UPTIME,
19 PROC_MEMINFO,
20 PROC_KMSG,
21 PROC_VERSION,
22 PROC_CPUINFO,
23 PROC_PCI,
24 PROC_MCA,
25 PROC_NUBUS,
26 PROC_SELF, /* will change inode # */
27 PROC_NET,
28 PROC_SCSI,
29 PROC_MALLOC,
30 PROC_KCORE,
31 PROC_MODULES,
32 PROC_STAT,
33 PROC_DEVICES,
34 PROC_PARTITIONS,
35 PROC_INTERRUPTS,
36 PROC_FILESYSTEMS,
37 PROC_KSYMS,
38 PROC_DMA,
39 PROC_IOPORTS,
40 PROC_PROFILE, /* whether enabled or not */
41 PROC_CMDLINE,
42 PROC_SYS,
43 PROC_MTAB,
44 PROC_SWAP,
45 PROC_MD,
46 PROC_RTC,
47 PROC_LOCKS,
48 PROC_HARDWARE,
49 PROC_SLABINFO,
50 PROC_PARPORT,
51 PROC_PPC_HTAB,
52 PROC_STRAM,
53 PROC_SOUND,
54 PROC_MTRR, /* whether enabled or not */
55 PROC_FS,
56 PROC_SYSVIPC
59 enum pid_directory_inos {
60 PROC_PID_INO = 2,
61 PROC_PID_STATUS,
62 PROC_PID_MEM,
63 PROC_PID_CWD,
64 PROC_PID_ROOT,
65 PROC_PID_EXE,
66 PROC_PID_FD,
67 PROC_PID_ENVIRON,
68 PROC_PID_CMDLINE,
69 PROC_PID_STAT,
70 PROC_PID_STATM,
71 PROC_PID_MAPS,
72 #if CONFIG_AP1000
73 PROC_PID_RINGBUF,
74 #endif
75 PROC_PID_CPU,
78 enum pid_subdirectory_inos {
79 PROC_PID_FD_DIR = 0x8000, /* 0x8000-0xffff */
82 enum net_directory_inos {
83 PROC_NET_UNIX = 128,
84 PROC_NET_ARP,
85 PROC_NET_ROUTE,
86 PROC_NET_DEV,
87 PROC_NET_RAW,
88 PROC_NET_RAW6,
89 PROC_NET_TCP,
90 PROC_NET_TCP6,
91 PROC_NET_UDP,
92 PROC_NET_UDP6,
93 PROC_NET_SNMP,
94 PROC_NET_RARP,
95 PROC_NET_IGMP,
96 PROC_NET_IPMR_VIF,
97 PROC_NET_IPMR_MFC,
98 PROC_NET_IPFWFWD,
99 PROC_NET_IPFWIN,
100 PROC_NET_IPFWOUT,
101 PROC_NET_IPACCT,
102 PROC_NET_IPMSQHST,
103 PROC_NET_WIRELESS,
104 PROC_NET_IPX_INTERFACE,
105 PROC_NET_IPX_ROUTE,
106 PROC_NET_IPX,
107 PROC_NET_ATALK,
108 PROC_NET_AT_ROUTE,
109 PROC_NET_ATIF,
110 PROC_NET_AX25_ROUTE,
111 PROC_NET_AX25,
112 PROC_NET_AX25_CALLS,
113 PROC_NET_BMAC,
114 PROC_NET_NR_NODES,
115 PROC_NET_NR_NEIGH,
116 PROC_NET_NR,
117 PROC_NET_SOCKSTAT,
118 PROC_NET_SOCKSTAT6,
119 PROC_NET_RTCACHE,
120 PROC_NET_AX25_BPQETHER,
121 PROC_NET_IP_MASQ_APP,
122 PROC_NET_RT6,
123 PROC_NET_SNMP6,
124 PROC_NET_RT6_STATS,
125 PROC_NET_NDISC,
126 PROC_NET_STRIP_STATUS,
127 PROC_NET_STRIP_TRACE,
128 PROC_NET_Z8530,
129 PROC_NET_RS_NODES,
130 PROC_NET_RS_NEIGH,
131 PROC_NET_RS_ROUTES,
132 PROC_NET_RS,
133 PROC_NET_CL2LLC,
134 PROC_NET_X25_ROUTES,
135 PROC_NET_X25,
136 PROC_NET_TR_RIF,
137 PROC_NET_DN_DEV,
138 PROC_NET_DN_ADJ,
139 PROC_NET_DN_ROUTE,
140 PROC_NET_DN_CACHE,
141 PROC_NET_DN_SKT,
142 PROC_NET_DN_FW_CHAINS,
143 PROC_NET_DN_FW_CHAIN_NAMES,
144 PROC_NET_DN_RAW,
145 PROC_NET_NETSTAT,
146 PROC_NET_IPFW_CHAINS,
147 PROC_NET_IPFW_CHAIN_NAMES,
148 PROC_NET_AT_AARP,
149 PROC_NET_BRIDGE,
150 PROC_NET_LAST
153 enum scsi_directory_inos {
154 PROC_SCSI_SCSI = 256,
155 PROC_SCSI_ADVANSYS,
156 PROC_SCSI_PCI2000,
157 PROC_SCSI_PCI2220I,
158 PROC_SCSI_PSI240I,
159 PROC_SCSI_EATA,
160 PROC_SCSI_EATA_PIO,
161 PROC_SCSI_AHA152X,
162 PROC_SCSI_AHA1542,
163 PROC_SCSI_AHA1740,
164 PROC_SCSI_AIC7XXX,
165 PROC_SCSI_BUSLOGIC,
166 PROC_SCSI_U14_34F,
167 PROC_SCSI_FDOMAIN,
168 PROC_SCSI_GDTH,
169 PROC_SCSI_GENERIC_NCR5380,
170 PROC_SCSI_IN2000,
171 PROC_SCSI_PAS16,
172 PROC_SCSI_QLOGICFAS,
173 PROC_SCSI_QLOGICISP,
174 PROC_SCSI_QLOGICFC,
175 PROC_SCSI_SEAGATE,
176 PROC_SCSI_T128,
177 PROC_SCSI_NCR53C7xx,
178 PROC_SCSI_SYM53C8XX,
179 PROC_SCSI_NCR53C8XX,
180 PROC_SCSI_ULTRASTOR,
181 PROC_SCSI_7000FASST,
182 PROC_SCSI_IBMMCA,
183 PROC_SCSI_FD_MCS,
184 PROC_SCSI_EATA2X,
185 PROC_SCSI_DC390T,
186 PROC_SCSI_AM53C974,
187 PROC_SCSI_SSC,
188 PROC_SCSI_NCR53C406A,
189 PROC_SCSI_SYM53C416,
190 PROC_SCSI_MEGARAID,
191 PROC_SCSI_PPA,
192 PROC_SCSI_ATP870U,
193 PROC_SCSI_ESP,
194 PROC_SCSI_QLOGICPTI,
195 PROC_SCSI_AMIGA7XX,
196 PROC_SCSI_MVME16x,
197 PROC_SCSI_BVME6000,
198 PROC_SCSI_A3000,
199 PROC_SCSI_A2091,
200 PROC_SCSI_GVP11,
201 PROC_SCSI_ATARI,
202 PROC_SCSI_MAC,
203 PROC_SCSI_IDESCSI,
204 PROC_SCSI_MESH,
205 PROC_SCSI_53C94,
206 PROC_SCSI_PLUTO,
207 PROC_SCSI_INI9100U,
208 PROC_SCSI_INIA100,
209 PROC_SCSI_FCAL,
210 PROC_SCSI_I2O,
211 PROC_SCSI_USB_SCSI,
212 PROC_SCSI_SCSI_DEBUG,
213 PROC_SCSI_NOT_PRESENT,
214 PROC_SCSI_FILE, /* I'm assuming here that we */
215 PROC_SCSI_LAST = (PROC_SCSI_FILE + 16) /* won't ever see more than */
216 }; /* 16 HBAs in one machine */
218 enum mca_directory_inos {
219 PROC_MCA_MACHINE = (PROC_SCSI_LAST+1),
220 PROC_MCA_REGISTERS,
221 PROC_MCA_VIDEO,
222 PROC_MCA_SCSI,
223 PROC_MCA_SLOT, /* the 8 adapter slots */
224 PROC_MCA_LAST = (PROC_MCA_SLOT + 8)
227 enum bus_directory_inos {
228 PROC_BUS_PCI = PROC_MCA_LAST,
229 PROC_BUS_PCI_DEVICES,
230 PROC_BUS_ZORRO,
231 PROC_BUS_ZORRO_DEVICES,
232 PROC_BUS_LAST
235 enum fs_directory_inos {
236 PROC_FS_CODA = PROC_BUS_LAST,
237 PROC_FS_LAST
240 enum fs_coda_directory_inos {
241 PROC_VFS_STATS = PROC_FS_LAST,
242 PROC_UPCALL_STATS,
243 PROC_PERMISSION_STATS,
244 PROC_CACHE_INV_STATS,
245 PROC_CODA_FS_LAST
248 enum sysvipc_directory_inos {
249 PROC_SYSVIPC_SHM = PROC_CODA_FS_LAST,
250 PROC_SYSVIPC_SEM,
251 PROC_SYSVIPC_MSG
254 /* Finally, the dynamically allocatable proc entries are reserved: */
256 #define PROC_DYNAMIC_FIRST 4096
257 #define PROC_NDYNAMIC 4096
258 #define PROC_OPENPROM_FIRST (PROC_DYNAMIC_FIRST+PROC_NDYNAMIC)
259 #define PROC_OPENPROM PROC_OPENPROM_FIRST
260 #define PROC_NOPENPROM 4096
261 #define PROC_OPENPROMD_FIRST (PROC_OPENPROM_FIRST+PROC_NOPENPROM)
262 #define PROC_NOPENPROMD 4096
264 #define PROC_SUPER_MAGIC 0x9fa0
267 * This is not completely implemented yet. The idea is to
268 * create an in-memory tree (like the actual /proc filesystem
269 * tree) of these proc_dir_entries, so that we can dynamically
270 * add new files to /proc.
272 * The "next" pointer creates a linked list of one /proc directory,
273 * while parent/subdir create the directory structure (every
274 * /proc file has a parent, but "subdir" is NULL for all
275 * non-directory entries).
277 * "get_info" is called at "read", while "fill_inode" is used to
278 * fill in file type/protection/owner information specific to the
279 * particular /proc file.
281 struct proc_dir_entry {
282 unsigned short low_ino;
283 unsigned short namelen;
284 const char *name;
285 mode_t mode;
286 nlink_t nlink;
287 uid_t uid;
288 gid_t gid;
289 unsigned long size;
290 struct inode_operations * ops;
291 int (*get_info)(char *, char **, off_t, int, int);
292 void (*fill_inode)(struct inode *, int);
293 struct proc_dir_entry *next, *parent, *subdir;
294 void *data;
295 int (*read_proc)(char *page, char **start, off_t off,
296 int count, int *eof, void *data);
297 int (*write_proc)(struct file *file, const char *buffer,
298 unsigned long count, void *data);
299 int (*readlink_proc)(struct proc_dir_entry *de, char *page);
300 unsigned int count; /* use count */
301 int deleted; /* delete flag */
304 typedef int (read_proc_t)(char *page, char **start, off_t off,
305 int count, int *eof, void *data);
306 typedef int (write_proc_t)(struct file *file, const char *buffer,
307 unsigned long count, void *data);
309 extern int (* dispatch_scsi_info_ptr) (int ino, char *buffer, char **start,
310 off_t offset, int length, int inout);
312 #ifdef CONFIG_PROC_FS
314 extern struct proc_dir_entry proc_root;
315 extern struct proc_dir_entry proc_root_fs;
316 extern struct proc_dir_entry *proc_net;
317 extern struct proc_dir_entry *proc_scsi;
318 extern struct proc_dir_entry proc_sys;
319 extern struct proc_dir_entry proc_openprom;
320 extern struct proc_dir_entry proc_pid;
321 extern struct proc_dir_entry proc_pid_fd;
322 extern struct proc_dir_entry proc_mca;
323 extern struct proc_dir_entry *proc_bus;
324 extern struct proc_dir_entry *proc_sysvipc;
326 extern struct inode_operations proc_scsi_inode_operations;
328 extern void proc_root_init(void);
329 extern void proc_base_init(void);
331 extern int proc_register(struct proc_dir_entry *, struct proc_dir_entry *);
332 extern int proc_unregister(struct proc_dir_entry *, int);
334 static inline int proc_net_register(struct proc_dir_entry * x)
336 return proc_register(proc_net, x);
339 static inline int proc_net_unregister(int x)
341 return proc_unregister(proc_net, x);
344 static inline int proc_scsi_register(struct proc_dir_entry *driver,
345 struct proc_dir_entry *x)
347 x->ops = &proc_scsi_inode_operations;
348 if(x->low_ino < PROC_SCSI_FILE){
349 return(proc_register(proc_scsi, x));
350 }else{
351 return(proc_register(driver, x));
355 static inline int proc_scsi_unregister(struct proc_dir_entry *driver, int x)
357 extern void scsi_init_free(char *ptr, unsigned int size);
359 if(x < PROC_SCSI_FILE)
360 return(proc_unregister(proc_scsi, x));
361 else {
362 struct proc_dir_entry **p = &driver->subdir, *dp;
363 int ret;
365 while ((dp = *p) != NULL) {
366 if (dp->low_ino == x)
367 break;
368 p = &dp->next;
370 ret = proc_unregister(driver, x);
371 scsi_init_free((char *) dp, sizeof(struct proc_dir_entry) + 4);
372 return(ret);
376 extern struct dentry_operations proc_dentry_operations;
377 extern struct super_block *proc_read_super(struct super_block *,void *,int);
378 extern int init_proc_fs(void);
379 extern struct inode * proc_get_inode(struct super_block *, int, struct proc_dir_entry *);
380 extern int proc_statfs(struct super_block *, struct statfs *, int);
381 extern void proc_read_inode(struct inode *);
382 extern void proc_write_inode(struct inode *);
383 extern int proc_permission(struct inode *, int);
385 extern int proc_match(int, const char *,struct proc_dir_entry *);
388 * These are generic /proc routines that use the internal
389 * "struct proc_dir_entry" tree to traverse the filesystem.
391 * The /proc root directory has extended versions to take care
392 * of the /proc/<pid> subdirectories.
394 extern int proc_readdir(struct file *, void *, filldir_t);
395 extern struct dentry *proc_lookup(struct inode *, struct dentry *);
397 struct openpromfs_dev {
398 struct openpromfs_dev *next;
399 u32 node;
400 ino_t inode;
401 kdev_t rdev;
402 mode_t mode;
403 char name[32];
405 extern struct inode_operations *
406 proc_openprom_register(int (*readdir)(struct file *, void *, filldir_t),
407 struct dentry * (*lookup)(struct inode *, struct dentry *),
408 void (*use)(struct inode *, int),
409 struct openpromfs_dev ***);
410 extern void proc_openprom_deregister(void);
411 extern void (*proc_openprom_use)(struct inode *,int);
412 extern int proc_openprom_regdev(struct openpromfs_dev *);
413 extern int proc_openprom_unregdev(struct openpromfs_dev *);
415 extern struct inode_operations proc_dir_inode_operations;
416 extern struct inode_operations proc_file_inode_operations;
417 extern struct inode_operations proc_net_inode_operations;
418 extern struct inode_operations proc_netdir_inode_operations;
419 extern struct inode_operations proc_openprom_inode_operations;
420 extern struct inode_operations proc_mem_inode_operations;
421 extern struct inode_operations proc_sys_inode_operations;
422 extern struct inode_operations proc_array_inode_operations;
423 extern struct inode_operations proc_arraylong_inode_operations;
424 extern struct inode_operations proc_kcore_inode_operations;
425 extern struct inode_operations proc_profile_inode_operations;
426 extern struct inode_operations proc_kmsg_inode_operations;
427 extern struct inode_operations proc_link_inode_operations;
428 extern struct inode_operations proc_fd_inode_operations;
429 #if CONFIG_AP1000
430 extern struct inode_operations proc_ringbuf_inode_operations;
431 #endif
432 extern struct inode_operations proc_omirr_inode_operations;
433 extern struct inode_operations proc_ppc_htab_inode_operations;
434 extern struct inode_operations proc_sysvipc_inode_operations;
437 * generic.c
439 struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
440 struct proc_dir_entry *parent);
441 void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
444 * proc_tty.c
446 extern void proc_tty_init(void);
447 extern void proc_tty_register_driver(struct tty_driver *driver);
448 extern void proc_tty_unregister_driver(struct tty_driver *driver);
451 * proc_devtree.c
453 extern void proc_device_tree_init(void);
455 #else
457 extern inline int proc_register(struct proc_dir_entry *a, struct proc_dir_entry *b) {};
458 extern inline int proc_unregister(struct proc_dir_entry *a, int b) {};
459 extern inline int proc_net_register(struct proc_dir_entry *a) {};
460 extern inline int proc_net_unregister(int x) {};
461 extern inline int proc_scsi_register(struct proc_dir_entry *b, struct proc_dir_entry *c) {};
462 extern inline int proc_scsi_unregister(struct proc_dir_entry *a, int x);
464 extern inline struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
465 struct proc_dir_entry *parent)
467 return NULL;
470 extern inline void remove_proc_entry(const char *name, struct proc_dir_entry *parent) {};
472 extern inline void proc_tty_register_driver(struct tty_driver *driver) {};
473 extern inline void proc_tty_unregister_driver(struct tty_driver *driver) {};
476 #endif
477 #endif /* _LINUX_PROC_FS_H */