1 #ifndef _LINUX_PROC_FS_H
2 #define _LINUX_PROC_FS_H
4 #include <linux/config.h>
5 #include <linux/slab.h>
7 #include <asm/atomic.h>
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
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
;
64 struct inode_operations
* proc_iops
;
65 struct file_operations
* proc_fops
;
68 struct proc_dir_entry
*next
, *parent
, *subdir
;
70 read_proc_t
*read_proc
;
71 write_proc_t
*write_proc
;
72 atomic_t count
; /* use count */
73 int deleted
; /* delete flag */
77 struct kcore_list
*next
;
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
;
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
);
134 extern void proc_device_tree_init(void);
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
);
151 res
->read_proc
=read_proc
;
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
;
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
);
176 res
->proc_fops
= fops
;
180 static inline void proc_net_remove(const char *name
)
182 remove_proc_entry(name
,proc_net
);
188 extern void kclist_add(struct kcore_list
*, void *, size_t);
189 extern struct kcore_list
*kclist_del(void *);
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
)
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
)
234 #endif /* CONFIG_PROC_FS */
237 struct task_struct
*task
;
240 int (*proc_get_link
)(struct inode
*, struct dentry
**, struct vfsmount
**);
241 int (*proc_read
)(struct task_struct
*task
, char *page
);
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 */