1 #ifndef _LINUX_PROC_FS_H
2 #define _LINUX_PROC_FS_H
4 #include <linux/config.h>
5 #include <linux/malloc.h>
8 * The proc filesystem constants/structures
12 * We always define these enumerators
15 enum root_directory_inos
{
26 PROC_SELF
, /* will change inode # */
40 PROC_PROFILE
, /* whether enabled or not */
54 PROC_MTRR
, /* whether enabled or not */
58 enum pid_directory_inos
{
77 enum pid_subdirectory_inos
{
78 PROC_PID_FD_DIR
= 0x8000, /* 0x8000-0xffff */
81 enum net_directory_inos
{
103 PROC_NET_IPX_INTERFACE
,
119 PROC_NET_AX25_BPQETHER
,
120 PROC_NET_IP_MASQ_APP
,
125 PROC_NET_STRIP_STATUS
,
126 PROC_NET_STRIP_TRACE
,
145 PROC_NET_IPFW_CHAINS
,
146 PROC_NET_IPFW_CHAIN_NAMES
,
152 enum scsi_directory_inos
{
153 PROC_SCSI_SCSI
= 256,
168 PROC_SCSI_GENERIC_NCR5380
,
187 PROC_SCSI_NCR53C406A
,
209 PROC_SCSI_SCSI_DEBUG
,
210 PROC_SCSI_NOT_PRESENT
,
211 PROC_SCSI_FILE
, /* I'm assuming here that we */
212 PROC_SCSI_LAST
= (PROC_SCSI_FILE
+ 16) /* won't ever see more than */
213 }; /* 16 HBAs in one machine */
215 enum mca_directory_inos
{
216 PROC_MCA_MACHINE
= (PROC_SCSI_LAST
+1),
220 PROC_MCA_SLOT
, /* the 8 adapter slots */
221 PROC_MCA_LAST
= (PROC_MCA_SLOT
+ 8)
224 enum bus_directory_inos
{
225 PROC_BUS_PCI
= PROC_MCA_LAST
,
226 PROC_BUS_PCI_DEVICES
,
228 PROC_BUS_ZORRO_DEVICES
,
232 enum fs_directory_inos
{
233 PROC_FS_CODA
= PROC_BUS_LAST
,
237 enum fs_coda_directory_inos
{
238 PROC_VFS_STATS
= PROC_FS_LAST
,
240 PROC_PERMISSION_STATS
,
241 PROC_CACHE_INV_STATS
,
245 /* Finally, the dynamically allocatable proc entries are reserved: */
247 #define PROC_DYNAMIC_FIRST 4096
248 #define PROC_NDYNAMIC 4096
249 #define PROC_OPENPROM_FIRST (PROC_DYNAMIC_FIRST+PROC_NDYNAMIC)
250 #define PROC_OPENPROM PROC_OPENPROM_FIRST
251 #define PROC_NOPENPROM 4096
252 #define PROC_OPENPROMD_FIRST (PROC_OPENPROM_FIRST+PROC_NOPENPROM)
253 #define PROC_NOPENPROMD 4096
255 #define PROC_SUPER_MAGIC 0x9fa0
258 * This is not completely implemented yet. The idea is to
259 * create an in-memory tree (like the actual /proc filesystem
260 * tree) of these proc_dir_entries, so that we can dynamically
261 * add new files to /proc.
263 * The "next" pointer creates a linked list of one /proc directory,
264 * while parent/subdir create the directory structure (every
265 * /proc file has a parent, but "subdir" is NULL for all
266 * non-directory entries).
268 * "get_info" is called at "read", while "fill_inode" is used to
269 * fill in file type/protection/owner information specific to the
270 * particular /proc file.
272 struct proc_dir_entry
{
273 unsigned short low_ino
;
274 unsigned short namelen
;
281 struct inode_operations
* ops
;
282 int (*get_info
)(char *, char **, off_t
, int, int);
283 void (*fill_inode
)(struct inode
*, int);
284 struct proc_dir_entry
*next
, *parent
, *subdir
;
286 int (*read_proc
)(char *page
, char **start
, off_t off
,
287 int count
, int *eof
, void *data
);
288 int (*write_proc
)(struct file
*file
, const char *buffer
,
289 unsigned long count
, void *data
);
290 int (*readlink_proc
)(struct proc_dir_entry
*de
, char *page
);
291 unsigned int count
; /* use count */
292 int deleted
; /* delete flag */
295 typedef int (read_proc_t
)(char *page
, char **start
, off_t off
,
296 int count
, int *eof
, void *data
);
297 typedef int (write_proc_t
)(struct file
*file
, const char *buffer
,
298 unsigned long count
, void *data
);
300 extern int (* dispatch_scsi_info_ptr
) (int ino
, char *buffer
, char **start
,
301 off_t offset
, int length
, int inout
);
303 #ifdef CONFIG_PROC_FS
305 extern struct proc_dir_entry proc_root
;
306 extern struct proc_dir_entry proc_root_fs
;
307 extern struct proc_dir_entry
*proc_net
;
308 extern struct proc_dir_entry
*proc_scsi
;
309 extern struct proc_dir_entry proc_sys
;
310 extern struct proc_dir_entry proc_openprom
;
311 extern struct proc_dir_entry proc_pid
;
312 extern struct proc_dir_entry proc_pid_fd
;
313 extern struct proc_dir_entry proc_mca
;
314 extern struct proc_dir_entry
*proc_bus
;
316 extern struct inode_operations proc_scsi_inode_operations
;
318 extern void proc_root_init(void);
319 extern void proc_base_init(void);
321 extern int proc_register(struct proc_dir_entry
*, struct proc_dir_entry
*);
322 extern int proc_unregister(struct proc_dir_entry
*, int);
324 static inline int proc_net_register(struct proc_dir_entry
* x
)
326 return proc_register(proc_net
, x
);
329 static inline int proc_net_unregister(int x
)
331 return proc_unregister(proc_net
, x
);
334 static inline int proc_scsi_register(struct proc_dir_entry
*driver
,
335 struct proc_dir_entry
*x
)
337 x
->ops
= &proc_scsi_inode_operations
;
338 if(x
->low_ino
< PROC_SCSI_FILE
){
339 return(proc_register(proc_scsi
, x
));
341 return(proc_register(driver
, x
));
345 static inline int proc_scsi_unregister(struct proc_dir_entry
*driver
, int x
)
347 extern void scsi_init_free(char *ptr
, unsigned int size
);
349 if(x
< PROC_SCSI_FILE
)
350 return(proc_unregister(proc_scsi
, x
));
352 struct proc_dir_entry
**p
= &driver
->subdir
, *dp
;
355 while ((dp
= *p
) != NULL
) {
356 if (dp
->low_ino
== x
)
360 ret
= proc_unregister(driver
, x
);
361 scsi_init_free((char *) dp
, sizeof(struct proc_dir_entry
) + 4);
366 extern struct dentry_operations proc_dentry_operations
;
367 extern struct super_block
*proc_read_super(struct super_block
*,void *,int);
368 extern int init_proc_fs(void);
369 extern struct inode
* proc_get_inode(struct super_block
*, int, struct proc_dir_entry
*);
370 extern int proc_statfs(struct super_block
*, struct statfs
*, int);
371 extern void proc_read_inode(struct inode
*);
372 extern void proc_write_inode(struct inode
*);
373 extern int proc_permission(struct inode
*, int);
375 extern int proc_match(int, const char *,struct proc_dir_entry
*);
378 * These are generic /proc routines that use the internal
379 * "struct proc_dir_entry" tree to traverse the filesystem.
381 * The /proc root directory has extended versions to take care
382 * of the /proc/<pid> subdirectories.
384 extern int proc_readdir(struct file
*, void *, filldir_t
);
385 extern int proc_lookup(struct inode
*, struct dentry
*);
387 struct openpromfs_dev
{
388 struct openpromfs_dev
*next
;
395 extern struct inode_operations
*
396 proc_openprom_register(int (*readdir
)(struct file
*, void *, filldir_t
),
397 int (*lookup
)(struct inode
*, struct dentry
*),
398 void (*use
)(struct inode
*, int),
399 struct openpromfs_dev
***);
400 extern void proc_openprom_deregister(void);
401 extern void (*proc_openprom_use
)(struct inode
*,int);
402 extern int proc_openprom_regdev(struct openpromfs_dev
*);
403 extern int proc_openprom_unregdev(struct openpromfs_dev
*);
405 extern struct inode_operations proc_dir_inode_operations
;
406 extern struct inode_operations proc_file_inode_operations
;
407 extern struct inode_operations proc_net_inode_operations
;
408 extern struct inode_operations proc_netdir_inode_operations
;
409 extern struct inode_operations proc_openprom_inode_operations
;
410 extern struct inode_operations proc_mem_inode_operations
;
411 extern struct inode_operations proc_sys_inode_operations
;
412 extern struct inode_operations proc_array_inode_operations
;
413 extern struct inode_operations proc_arraylong_inode_operations
;
414 extern struct inode_operations proc_kcore_inode_operations
;
415 extern struct inode_operations proc_profile_inode_operations
;
416 extern struct inode_operations proc_kmsg_inode_operations
;
417 extern struct inode_operations proc_link_inode_operations
;
418 extern struct inode_operations proc_fd_inode_operations
;
420 extern struct inode_operations proc_ringbuf_inode_operations
;
422 extern struct inode_operations proc_omirr_inode_operations
;
423 extern struct inode_operations proc_ppc_htab_inode_operations
;
428 struct proc_dir_entry
*create_proc_entry(const char *name
, mode_t mode
,
429 struct proc_dir_entry
*parent
);
430 void remove_proc_entry(const char *name
, struct proc_dir_entry
*parent
);
435 extern void proc_tty_init(void);
436 extern void proc_tty_register_driver(struct tty_driver
*driver
);
437 extern void proc_tty_unregister_driver(struct tty_driver
*driver
);
442 extern void proc_device_tree_init(void);
446 extern inline int proc_register(struct proc_dir_entry
*a
, struct proc_dir_entry
*b
) {};
447 extern inline int proc_unregister(struct proc_dir_entry
*a
, int b
) {};
448 extern inline int proc_net_register(struct proc_dir_entry
*a
) {};
449 extern inline int proc_net_unregister(int x
) {};
450 extern inline int proc_scsi_register(struct proc_dir_entry
*b
, struct proc_dir_entry
*c
) {};
451 extern inline int proc_scsi_unregister(struct proc_dir_entry
*a
, int x
);
453 extern inline struct proc_dir_entry
*create_proc_entry(const char *name
, mode_t mode
,
454 struct proc_dir_entry
*parent
)
459 extern inline void remove_proc_entry(const char *name
, struct proc_dir_entry
*parent
) {};
461 extern inline void proc_tty_register_driver(struct tty_driver
*driver
) {};
462 extern inline void proc_tty_unregister_driver(struct tty_driver
*driver
) {};
466 #endif /* _LINUX_PROC_FS_H */