source: GPL/include/linux/proc_fs.h@ 18

Last change on this file since 18 was 18, checked in by vladest, 20 years ago

initial import

File size: 7.8 KB
Line 
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
21enum {
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
52typedef int (read_proc_t)(char *page, char **start, off_t off,
53 int count, int *eof, void *data);
54typedef int (write_proc_t)(struct file *file, const char *buffer,
55 unsigned long count, void *data);
56typedef int (get_info_t)(char *, char **, off_t, int, int);
57
58struct 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
87extern struct proc_dir_entry proc_root;
88extern struct proc_dir_entry *proc_root_fs;
89extern struct proc_dir_entry *proc_net;
90extern struct proc_dir_entry proc_sys;
91extern struct proc_dir_entry proc_openprom;
92extern struct proc_dir_entry *proc_mca;
93extern struct proc_dir_entry *proc_bus;
94extern struct proc_dir_entry *proc_root_driver;
95extern struct proc_dir_entry proc_root_kcore;
96
97extern void proc_root_init(void);
98extern void proc_misc_init(void);
99
100struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry);
101void proc_pid_delete_inode(struct inode *inode);
102int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir);
103
104extern int proc_register(struct proc_dir_entry *, struct proc_dir_entry *);
105extern int proc_unregister(struct proc_dir_entry *, int);
106
107extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
108 struct proc_dir_entry *parent);
109extern 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 */
115struct proc_dir_entry *proc_driver_find (const char *module_name);
116
117
118/*
119 * remove /proc/driver/$module_name, and all its contents
120 */
121int proc_driver_unregister(const char *module_name);
122
123
124/*
125 * create driver-specific playground directory, /proc/driver/$module_name
126 */
127int proc_driver_register(const char *module_name);
128
129extern struct super_block *proc_super_blocks;
130extern struct dentry_operations proc_dentry_operations;
131extern struct super_block *proc_read_super(struct super_block *,void *,int);
132extern int init_proc_fs(void);
133extern struct inode * proc_get_inode(struct super_block *, int, struct proc_dir_entry *);
134extern int proc_statfs(struct super_block *, struct statfs *, int);
135extern void proc_read_inode(struct inode *);
136extern void proc_write_inode(struct inode *);
137
138extern 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 */
147extern int proc_readdir(struct file *, void *, filldir_t);
148extern struct dentry *proc_lookup(struct inode *, struct dentry *);
149
150struct 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};
158extern struct inode_operations *
159proc_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 ***);
163extern void proc_openprom_deregister(void);
164extern void (*proc_openprom_use)(struct inode *,int);
165extern int proc_openprom_regdev(struct openpromfs_dev *);
166extern int proc_openprom_unregdev(struct openpromfs_dev *);
167
168extern struct inode_operations proc_dir_inode_operations;
169extern struct inode_operations proc_file_inode_operations;
170extern struct inode_operations proc_openprom_inode_operations;
171extern struct inode_operations proc_sys_inode_operations;
172extern struct inode_operations proc_kcore_inode_operations;
173extern struct inode_operations proc_profile_inode_operations;
174extern struct inode_operations proc_kmsg_inode_operations;
175#if CONFIG_AP1000
176extern struct inode_operations proc_ringbuf_inode_operations;
177#endif
178extern struct inode_operations proc_omirr_inode_operations;
179extern struct inode_operations proc_ppc_htab_inode_operations;
180
181/*
182 * proc_tty.c
183 */
184extern void proc_tty_init(void);
185extern void proc_tty_register_driver(struct tty_driver *driver);
186extern void proc_tty_unregister_driver(struct tty_driver *driver);
187
188/*
189 * proc_devtree.c
190 */
191extern void proc_device_tree_init(void);
192
193struct 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);
196struct proc_dir_entry *create_proc_info_entry(const char *name,
197 mode_t mode, struct proc_dir_entry *base, get_info_t *get_info);
198struct proc_dir_entry *proc_net_create(const char *name);
199void proc_net_remove(const char *name);
200
201#else
202
203extern inline int proc_register(struct proc_dir_entry *a, struct proc_dir_entry *b) { return 0; }
204extern inline int proc_unregister(struct proc_dir_entry *a, int b) { return 0; }
205extern inline struct proc_dir_entry *proc_net_create(const char *name, mode_t mode,
206 get_info_t *get_info) {return NULL;}
207extern inline void proc_net_remove(const char *name) {}
208
209extern inline struct proc_dir_entry *create_proc_entry(const char *name,
210 mode_t mode, struct proc_dir_entry *parent) { return NULL; }
211
212extern inline void remove_proc_entry(const char *name, struct proc_dir_entry *parent) {};
213
214extern inline void proc_tty_register_driver(struct tty_driver *driver) {};
215extern inline void proc_tty_unregister_driver(struct tty_driver *driver) {};
216
217struct 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);
220struct proc_dir_entry *create_proc_info_entry(const char *name,
221 mode_t mode, struct proc_dir_entry *base, get_info_t *get_info);
222struct proc_dir_entry *proc_net_create(const char *name);
223void proc_net_remove(const char *name);
224
225extern struct proc_dir_entry proc_root;
226
227#endif /* CONFIG_PROC_FS */
228
229#endif /* _LINUX_PROC_FS_H */
Note: See TracBrowser for help on using the repository browser.