1 #ifndef _LINUX_PROC_FS_H
2 #define _LINUX_PROC_FS_H
4 #include <linux/slab.h>
6 #include <linux/spinlock.h>
7 #include <linux/magic.h>
8 #include <asm/atomic.h>
14 * The proc filesystem constants/structures
18 * Offset of the first process in the /proc root directory..
20 #define FIRST_PROCESS_ENTRY 256
22 /* Worst case buffer size needed for holding an integer. */
23 #define PROC_NUMBUF 13
26 * We always define these enumerators
34 * This is not completely implemented yet. The idea is to
35 * create an in-memory tree (like the actual /proc filesystem
36 * tree) of these proc_dir_entries, so that we can dynamically
37 * add new files to /proc.
39 * The "next" pointer creates a linked list of one /proc directory,
40 * while parent/subdir create the directory structure (every
41 * /proc file has a parent, but "subdir" is NULL for all
42 * non-directory entries).
44 * "get_info" is called at "read", while "owner" is used to protect module
45 * from unloading while proc_dir_entry is in use
48 typedef int (read_proc_t
)(char *page
, char **start
, off_t off
,
49 int count
, int *eof
, void *data
);
50 typedef int (write_proc_t
)(struct file
*file
, const char __user
*buffer
,
51 unsigned long count
, void *data
);
52 typedef int (get_info_t
)(char *, char **, off_t
, int);
53 <<<<<<< HEAD
:include
/linux
/proc_fs
.h
54 typedef struct proc_dir_entry
*(shadow_proc_t
)(struct task_struct
*task
,
55 struct proc_dir_entry
*pde
);
57 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:include
/linux
/proc_fs
.h
59 struct proc_dir_entry
{
61 unsigned short namelen
;
68 const struct inode_operations
*proc_iops
;
70 * NULL ->proc_fops means "PDE is going away RSN" or
71 * "PDE is just created". In either case, e.g. ->read_proc won't be
72 * called because it's too late or too early, respectively.
74 * If you're allocating ->proc_fops dynamically, save a pointer
77 const struct file_operations
*proc_fops
;
80 struct proc_dir_entry
*next
, *parent
, *subdir
;
82 read_proc_t
*read_proc
;
83 write_proc_t
*write_proc
;
84 atomic_t count
; /* use count */
85 int pde_users
; /* number of callers into module in progress */
86 spinlock_t pde_unload_lock
; /* proc_fops checks and pde_users bumps */
87 struct completion
*pde_unload_completion
;
88 <<<<<<< HEAD
:include
/linux
/proc_fs
.h
89 shadow_proc_t
*shadow_proc
;
91 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:include
/linux
/proc_fs
.h
95 struct kcore_list
*next
;
101 struct list_head list
;
102 unsigned long long paddr
;
103 unsigned long long size
;
107 #ifdef CONFIG_PROC_FS
109 extern struct proc_dir_entry proc_root
;
110 extern struct proc_dir_entry
*proc_root_fs
;
111 extern struct proc_dir_entry
*proc_bus
;
112 extern struct proc_dir_entry
*proc_root_driver
;
113 extern struct proc_dir_entry
*proc_root_kcore
;
115 extern spinlock_t proc_subdir_lock
;
117 extern void proc_root_init(void);
118 extern void proc_misc_init(void);
122 void proc_flush_task(struct task_struct
*task
);
123 struct dentry
*proc_pid_lookup(struct inode
*dir
, struct dentry
* dentry
, struct nameidata
*);
124 int proc_pid_readdir(struct file
* filp
, void * dirent
, filldir_t filldir
);
125 unsigned long task_vsize(struct mm_struct
*);
126 int task_statm(struct mm_struct
*, int *, int *, int *, int *);
127 void task_mem(struct seq_file
*, struct mm_struct
*);
128 void clear_refs_smap(struct mm_struct
*mm
);
130 struct proc_dir_entry
*de_get(struct proc_dir_entry
*de
);
131 void de_put(struct proc_dir_entry
*de
);
133 extern struct proc_dir_entry
*create_proc_entry(const char *name
, mode_t mode
,
134 struct proc_dir_entry
*parent
);
135 struct proc_dir_entry
*proc_create(const char *name
, mode_t mode
,
136 struct proc_dir_entry
*parent
,
137 const struct file_operations
*proc_fops
);
138 extern void remove_proc_entry(const char *name
, struct proc_dir_entry
*parent
);
140 extern struct vfsmount
*proc_mnt
;
141 struct pid_namespace
;
142 extern int proc_fill_super(struct super_block
*);
143 extern struct inode
*proc_get_inode(struct super_block
*, unsigned int, struct proc_dir_entry
*);
146 * These are generic /proc routines that use the internal
147 * "struct proc_dir_entry" tree to traverse the filesystem.
149 * The /proc root directory has extended versions to take care
150 * of the /proc/<pid> subdirectories.
152 extern int proc_readdir(struct file
*, void *, filldir_t
);
153 extern struct dentry
*proc_lookup(struct inode
*, struct dentry
*, struct nameidata
*);
155 extern const struct file_operations proc_kcore_operations
;
156 extern const struct file_operations proc_kmsg_operations
;
157 extern const struct file_operations ppc_htab_operations
;
159 extern int pid_ns_prepare_proc(struct pid_namespace
*ns
);
160 extern void pid_ns_release_proc(struct pid_namespace
*ns
);
166 extern void proc_tty_init(void);
167 extern void proc_tty_register_driver(struct tty_driver
*driver
);
168 extern void proc_tty_unregister_driver(struct tty_driver
*driver
);
173 #ifdef CONFIG_PROC_DEVICETREE
176 extern void proc_device_tree_init(void);
177 extern void proc_device_tree_add_node(struct device_node
*, struct proc_dir_entry
*);
178 extern void proc_device_tree_add_prop(struct proc_dir_entry
*pde
, struct property
*prop
);
179 extern void proc_device_tree_remove_prop(struct proc_dir_entry
*pde
,
180 struct property
*prop
);
181 extern void proc_device_tree_update_prop(struct proc_dir_entry
*pde
,
182 struct property
*newprop
,
183 struct property
*oldprop
);
184 #endif /* CONFIG_PROC_DEVICETREE */
186 extern struct proc_dir_entry
*proc_symlink(const char *,
187 struct proc_dir_entry
*, const char *);
188 extern struct proc_dir_entry
*proc_mkdir(const char *,struct proc_dir_entry
*);
189 extern struct proc_dir_entry
*proc_mkdir_mode(const char *name
, mode_t mode
,
190 struct proc_dir_entry
*parent
);
192 static inline struct proc_dir_entry
*create_proc_read_entry(const char *name
,
193 mode_t mode
, struct proc_dir_entry
*base
,
194 read_proc_t
*read_proc
, void * data
)
196 struct proc_dir_entry
*res
=create_proc_entry(name
,mode
,base
);
198 res
->read_proc
=read_proc
;
204 static inline struct proc_dir_entry
*create_proc_info_entry(const char *name
,
205 mode_t mode
, struct proc_dir_entry
*base
, get_info_t
*get_info
)
207 struct proc_dir_entry
*res
=create_proc_entry(name
,mode
,base
);
208 if (res
) res
->get_info
=get_info
;
212 extern struct proc_dir_entry
*proc_net_fops_create(struct net
*net
,
213 const char *name
, mode_t mode
, const struct file_operations
*fops
);
214 extern void proc_net_remove(struct net
*net
, const char *name
);
215 extern struct proc_dir_entry
*proc_net_mkdir(struct net
*net
, const char *name
,
216 struct proc_dir_entry
*parent
);
220 #define proc_root_driver NULL
221 #define proc_bus NULL
223 #define proc_net_fops_create(net, name, mode, fops) ({ (void)(mode), NULL; })
224 static inline void proc_net_remove(struct net
*net
, const char *name
) {}
226 static inline void proc_flush_task(struct task_struct
*task
)
230 static inline struct proc_dir_entry
*create_proc_entry(const char *name
,
231 mode_t mode
, struct proc_dir_entry
*parent
) { return NULL
; }
232 static inline struct proc_dir_entry
*proc_create(const char *name
,
233 mode_t mode
, struct proc_dir_entry
*parent
,
234 const struct file_operations
*proc_fops
)
238 #define remove_proc_entry(name, parent) do {} while (0)
240 static inline struct proc_dir_entry
*proc_symlink(const char *name
,
241 struct proc_dir_entry
*parent
,const char *dest
) {return NULL
;}
242 static inline struct proc_dir_entry
*proc_mkdir(const char *name
,
243 struct proc_dir_entry
*parent
) {return NULL
;}
245 static inline struct proc_dir_entry
*create_proc_read_entry(const char *name
,
246 mode_t mode
, struct proc_dir_entry
*base
,
247 read_proc_t
*read_proc
, void * data
) { return NULL
; }
248 static inline struct proc_dir_entry
*create_proc_info_entry(const char *name
,
249 mode_t mode
, struct proc_dir_entry
*base
, get_info_t
*get_info
)
253 static inline void proc_tty_register_driver(struct tty_driver
*driver
) {};
254 static inline void proc_tty_unregister_driver(struct tty_driver
*driver
) {};
256 extern struct proc_dir_entry proc_root
;
258 static inline int pid_ns_prepare_proc(struct pid_namespace
*ns
)
263 static inline void pid_ns_release_proc(struct pid_namespace
*ns
)
267 #endif /* CONFIG_PROC_FS */
269 #if !defined(CONFIG_PROC_KCORE)
270 static inline void kclist_add(struct kcore_list
*new, void *addr
, size_t size
)
274 extern void kclist_add(struct kcore_list
*, void *, size_t);
278 int (*proc_get_link
)(struct inode
*, struct path
*);
279 int (*proc_read
)(struct task_struct
*task
, char *page
);
280 int (*proc_show
)(struct seq_file
*m
,
281 struct pid_namespace
*ns
, struct pid
*pid
,
282 struct task_struct
*task
);
289 struct proc_dir_entry
*pde
;
290 struct inode vfs_inode
;
293 static inline struct proc_inode
*PROC_I(const struct inode
*inode
)
295 return container_of(inode
, struct proc_inode
, vfs_inode
);
298 static inline struct proc_dir_entry
*PDE(const struct inode
*inode
)
300 return PROC_I(inode
)->pde
;
303 static inline struct net
*PDE_NET(struct proc_dir_entry
*pde
)
305 return pde
->parent
->data
;
308 struct net
*get_proc_net(const struct inode
*inode
);
310 struct proc_maps_private
{
312 struct task_struct
*task
;
314 struct vm_area_struct
*tail_vma
;
318 #endif /* _LINUX_PROC_FS_H */