airo: Use remove_proc_subtree()
[deliverable/linux.git] / include / linux / proc_fs.h
CommitLineData
1da177e4
LT
1#ifndef _LINUX_PROC_FS_H
2#define _LINUX_PROC_FS_H
3
1da177e4
LT
4#include <linux/slab.h>
5#include <linux/fs.h>
64a07bd8 6#include <linux/spinlock.h>
e18fa700 7#include <linux/magic.h>
60063497 8#include <linux/atomic.h>
0bb80f24 9#include <linux/proc_ns.h>
1da177e4 10
457c4cbc 11struct net;
786d7e16 12struct completion;
57d3c64f
BN
13struct mm_struct;
14
1da177e4
LT
15/*
16 * The proc filesystem constants/structures
17 */
18
19/*
20 * Offset of the first process in the /proc root directory..
21 */
22#define FIRST_PROCESS_ENTRY 256
23
f248dcb3
MM
24/* Worst case buffer size needed for holding an integer. */
25#define PROC_NUMBUF 13
1da177e4 26
1da177e4
LT
27/*
28 * This is not completely implemented yet. The idea is to
29 * create an in-memory tree (like the actual /proc filesystem
30 * tree) of these proc_dir_entries, so that we can dynamically
31 * add new files to /proc.
32 *
33 * The "next" pointer creates a linked list of one /proc directory,
34 * while parent/subdir create the directory structure (every
35 * /proc file has a parent, but "subdir" is NULL for all
36 * non-directory entries).
1da177e4
LT
37 */
38
1da177e4
LT
39struct proc_dir_entry {
40 unsigned int low_ino;
d161a13f 41 umode_t mode;
1da177e4 42 nlink_t nlink;
dcb0f222
EB
43 kuid_t uid;
44 kgid_t gid;
22e6c1b3 45 loff_t size;
c5ef1c42
AV
46 const struct inode_operations *proc_iops;
47 const struct file_operations *proc_fops;
1da177e4
LT
48 struct proc_dir_entry *next, *parent, *subdir;
49 void *data;
1da177e4 50 atomic_t count; /* use count */
05c0ae21 51 atomic_t in_use; /* number of callers into module in progress; */
866ad9a7 52 /* negative -> it's going away RSN */
786d7e16 53 struct completion *pde_unload_completion;
881adb85 54 struct list_head pde_openers; /* who did ->open, but not ->release */
09570f91
DH
55 spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */
56 u8 namelen;
57 char name[];
1da177e4
LT
58};
59
1da177e4
LT
60#ifdef CONFIG_PROC_FS
61
1da177e4 62extern void proc_root_init(void);
1da177e4 63
48e6484d 64void proc_flush_task(struct task_struct *task);
7695650a 65
d161a13f 66struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
2d3a4e36 67 struct proc_dir_entry *parent,
59b74351
DL
68 const struct file_operations *proc_fops,
69 void *data);
1da177e4 70extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
8ce584c7 71extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent);
1da177e4 72
1da177e4
LT
73extern struct proc_dir_entry *proc_symlink(const char *,
74 struct proc_dir_entry *, const char *);
75extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *);
270b5ac2
DH
76extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t,
77 struct proc_dir_entry *, void *);
d161a13f 78extern struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode,
1da177e4
LT
79 struct proc_dir_entry *parent);
80
d161a13f 81static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
59b74351
DL
82 struct proc_dir_entry *parent, const struct file_operations *proc_fops)
83{
84 return proc_create_data(name, mode, parent, proc_fops, NULL);
85}
1da177e4 86
271a15ea
DH
87extern void proc_set_size(struct proc_dir_entry *, loff_t);
88extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
1da177e4
LT
89#else
90
60347f67
PE
91static inline void proc_flush_task(struct task_struct *task)
92{
93}
1da177e4 94
4fc1a601
G
95#define proc_create(name, mode, parent, fops) ({ (void)(mode), NULL; })
96
59b74351 97static inline struct proc_dir_entry *proc_create_data(const char *name,
d161a13f 98 umode_t mode, struct proc_dir_entry *parent,
59b74351
DL
99 const struct file_operations *proc_fops, void *data)
100{
101 return NULL;
102}
1da177e4 103#define remove_proc_entry(name, parent) do {} while (0)
8ce584c7 104#define remove_proc_subtree(name, parent) do {} while (0)
1da177e4
LT
105
106static inline struct proc_dir_entry *proc_symlink(const char *name,
107 struct proc_dir_entry *parent,const char *dest) {return NULL;}
108static inline struct proc_dir_entry *proc_mkdir(const char *name,
109 struct proc_dir_entry *parent) {return NULL;}
270b5ac2
DH
110static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
111 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
f12a20fc 112static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
d161a13f 113 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
271a15ea
DH
114static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
115static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
1da177e4 116
1da177e4
LT
117#endif /* CONFIG_PROC_FS */
118
6b4e306a 119
20cdc894 120union proc_op {
7773fbc5 121 int (*proc_get_link)(struct dentry *, struct path *);
20cdc894 122 int (*proc_read)(struct task_struct *task, char *page);
be614086
EB
123 int (*proc_show)(struct seq_file *m,
124 struct pid_namespace *ns, struct pid *pid,
125 struct task_struct *task);
20cdc894
EB
126};
127
9043476f
AV
128struct ctl_table_header;
129struct ctl_table;
130
1da177e4 131struct proc_inode {
13b41b09 132 struct pid *pid;
aed7a6c4 133 int fd;
20cdc894 134 union proc_op op;
1da177e4 135 struct proc_dir_entry *pde;
9043476f
AV
136 struct ctl_table_header *sysctl;
137 struct ctl_table *sysctl_entry;
0bb80f24 138 struct proc_ns ns;
1da177e4
LT
139 struct inode vfs_inode;
140};
141
142static inline struct proc_inode *PROC_I(const struct inode *inode)
143{
144 return container_of(inode, struct proc_inode, vfs_inode);
145}
146
147static inline struct proc_dir_entry *PDE(const struct inode *inode)
148{
149 return PROC_I(inode)->pde;
150}
151
d9dda78b
AV
152static inline void *PDE_DATA(const struct inode *inode)
153{
154 return PROC_I(inode)->pde->data;
155}
156
270b5ac2
DH
157static inline struct proc_dir_entry *proc_net_mkdir(
158 struct net *net, const char *name, struct proc_dir_entry *parent)
159{
160 return proc_mkdir_data(name, 0, parent, net);
161}
162
1da177e4 163#endif /* _LINUX_PROC_FS_H */
This page took 1.532805 seconds and 5 git commands to generate.