Merge with Linux 2.6.0-test1.
[linux-2.6/linux-mips.git] / include / linux / proc_fs.h
blob9054f5686f04bd0c7d034244566cbeef678b83d9
1 #ifndef _LINUX_PROC_FS_H
2 #define _LINUX_PROC_FS_H
4 #include <linux/config.h>
5 #include <linux/slab.h>
6 #include <linux/fs.h>
7 #include <asm/atomic.h>
9 /*
10 * The proc filesystem constants/structures
14 * Offset of the first process in the /proc root directory..
16 #define FIRST_PROCESS_ENTRY 256
20 * We always define these enumerators
23 enum {
24 PROC_ROOT_INO = 1,
27 /* Finally, the dynamically allocatable proc entries are reserved: */
29 #define PROC_DYNAMIC_FIRST 4096
30 #define PROC_NDYNAMIC 16384
32 #define PROC_SUPER_MAGIC 0x9fa0
35 * This is not completely implemented yet. The idea is to
36 * create an in-memory tree (like the actual /proc filesystem
37 * tree) of these proc_dir_entries, so that we can dynamically
38 * add new files to /proc.
40 * The "next" pointer creates a linked list of one /proc directory,
41 * while parent/subdir create the directory structure (every
42 * /proc file has a parent, but "subdir" is NULL for all
43 * non-directory entries).
45 * "get_info" is called at "read", while "owner" is used to protect module
46 * from unloading while proc_dir_entry is in use
49 typedef int (read_proc_t)(char *page, char **start, off_t off,
50 int count, int *eof, void *data);
51 typedef int (write_proc_t)(struct file *file, const char __user *buffer,
52 unsigned long count, void *data);
53 typedef int (get_info_t)(char *, char **, off_t, int);
55 struct proc_dir_entry {
56 unsigned short low_ino;
57 unsigned short namelen;
58 const char *name;
59 mode_t mode;
60 nlink_t nlink;
61 uid_t uid;
62 gid_t gid;
63 unsigned long size;
64 struct inode_operations * proc_iops;
65 struct file_operations * proc_fops;
66 get_info_t *get_info;
67 struct module *owner;
68 struct proc_dir_entry *next, *parent, *subdir;
69 void *data;
70 read_proc_t *read_proc;
71 write_proc_t *write_proc;
72 atomic_t count; /* use count */
73 int deleted; /* delete flag */
76 struct kcore_list {
77 struct kcore_list *next;
78 unsigned long addr;
79 size_t size;
82 #ifdef CONFIG_PROC_FS
84 extern struct proc_dir_entry proc_root;
85 extern struct proc_dir_entry *proc_root_fs;
86 extern struct proc_dir_entry *proc_net;
87 extern struct proc_dir_entry *proc_bus;
88 extern struct proc_dir_entry *proc_root_driver;
89 extern struct proc_dir_entry *proc_root_kcore;
91 extern void proc_root_init(void);
92 extern void proc_misc_init(void);
94 struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *);
95 struct dentry *proc_pid_unhash(struct task_struct *p);
96 void proc_pid_flush(struct dentry *proc_dentry);
97 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir);
99 extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
100 struct proc_dir_entry *parent);
101 extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
103 extern struct vfsmount *proc_mnt;
104 extern int proc_fill_super(struct super_block *,void *,int);
105 extern struct inode * proc_get_inode(struct super_block *, int, struct proc_dir_entry *);
107 extern int proc_match(int, const char *,struct proc_dir_entry *);
110 * These are generic /proc routines that use the internal
111 * "struct proc_dir_entry" tree to traverse the filesystem.
113 * The /proc root directory has extended versions to take care
114 * of the /proc/<pid> subdirectories.
116 extern int proc_readdir(struct file *, void *, filldir_t);
117 extern struct dentry *proc_lookup(struct inode *, struct dentry *, struct nameidata *);
119 extern struct file_operations proc_kcore_operations;
120 extern struct file_operations proc_kmsg_operations;
121 extern struct file_operations ppc_htab_operations;
124 * proc_tty.c
126 struct tty_driver;
127 extern void proc_tty_init(void);
128 extern void proc_tty_register_driver(struct tty_driver *driver);
129 extern void proc_tty_unregister_driver(struct tty_driver *driver);
132 * proc_devtree.c
134 extern void proc_device_tree_init(void);
137 * proc_rtas.c
139 extern void proc_rtas_init(void);
141 extern struct proc_dir_entry *proc_symlink(const char *,
142 struct proc_dir_entry *, const char *);
143 extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *);
145 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
146 mode_t mode, struct proc_dir_entry *base,
147 read_proc_t *read_proc, void * data)
149 struct proc_dir_entry *res=create_proc_entry(name,mode,base);
150 if (res) {
151 res->read_proc=read_proc;
152 res->data=data;
154 return res;
157 static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
158 mode_t mode, struct proc_dir_entry *base, get_info_t *get_info)
160 struct proc_dir_entry *res=create_proc_entry(name,mode,base);
161 if (res) res->get_info=get_info;
162 return res;
165 static inline struct proc_dir_entry *proc_net_create(const char *name,
166 mode_t mode, get_info_t *get_info)
168 return create_proc_info_entry(name,mode,proc_net,get_info);
171 static inline struct proc_dir_entry *proc_net_fops_create(const char *name,
172 mode_t mode, struct file_operations *fops)
174 struct proc_dir_entry *res = create_proc_entry(name, mode, proc_net);
175 if (res)
176 res->proc_fops = fops;
177 return res;
180 static inline void proc_net_remove(const char *name)
182 remove_proc_entry(name,proc_net);
186 * fs/proc/kcore.c
188 extern void kclist_add(struct kcore_list *, void *, size_t);
189 extern struct kcore_list *kclist_del(void *);
191 #else
193 #define proc_root_driver NULL
194 #define proc_net_fops_create(name,mode,fops) do {} while(0)
195 static inline struct proc_dir_entry *proc_net_create(const char *name, mode_t mode,
196 get_info_t *get_info) {return NULL;}
197 static inline void proc_net_remove(const char *name) {}
199 static inline struct dentry *proc_pid_unhash(struct task_struct *p) { return NULL; }
200 static inline void proc_pid_flush(struct dentry *proc_dentry) { }
202 static inline struct proc_dir_entry *create_proc_entry(const char *name,
203 mode_t mode, struct proc_dir_entry *parent) { return NULL; }
205 #define remove_proc_entry(name, parent) do {} while (0)
207 static inline struct proc_dir_entry *proc_symlink(const char *name,
208 struct proc_dir_entry *parent,char *dest) {return NULL;}
209 static inline struct proc_dir_entry *proc_mkdir(const char *name,
210 struct proc_dir_entry *parent) {return NULL;}
212 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
213 mode_t mode, struct proc_dir_entry *base,
214 int (*read_proc)(char *, char **, off_t, int, int *, void *),
215 void * data) { return NULL; }
216 static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
217 mode_t mode, struct proc_dir_entry *base, get_info_t *get_info)
218 { return NULL; }
220 struct tty_driver;
221 static inline void proc_tty_register_driver(struct tty_driver *driver) {};
222 static inline void proc_tty_unregister_driver(struct tty_driver *driver) {};
224 extern struct proc_dir_entry proc_root;
226 static inline void kclist_add(struct kcore_list *new, void *addr, size_t size)
229 static inline struct kcore_list * kclist_del(void *addr)
231 return NULL;
234 #endif /* CONFIG_PROC_FS */
236 struct proc_inode {
237 struct task_struct *task;
238 int type;
239 union {
240 int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
241 int (*proc_read)(struct task_struct *task, char *page);
242 } op;
243 struct proc_dir_entry *pde;
244 struct inode vfs_inode;
247 static inline struct proc_inode *PROC_I(const struct inode *inode)
249 return container_of(inode, struct proc_inode, vfs_inode);
252 static inline struct proc_dir_entry *PDE(const struct inode *inode)
254 return PROC_I(inode)->pde;
257 #endif /* _LINUX_PROC_FS_H */