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 <linux/atomic.h>
9 #include <linux/proc_ns.h>
16 * The proc filesystem constants/structures
20 * Offset of the first process in the /proc root directory..
22 #define FIRST_PROCESS_ENTRY 256
24 /* Worst case buffer size needed for holding an integer. */
25 #define PROC_NUMBUF 13
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.
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).
39 struct proc_dir_entry {
46 const struct inode_operations *proc_iops;
47 const struct file_operations *proc_fops;
48 struct proc_dir_entry *next, *parent, *subdir;
50 atomic_t count; /* use count */
51 atomic_t in_use; /* number of callers into module in progress; */
52 /* negative -> it's going away RSN */
53 struct completion *pde_unload_completion;
54 struct list_head pde_openers; /* who did ->open, but not ->release */
55 spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */
62 extern void proc_root_init(void);
64 void proc_flush_task(struct task_struct *task);
66 struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
67 struct proc_dir_entry *parent,
68 const struct file_operations *proc_fops,
70 extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
71 extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent);
73 extern struct proc_dir_entry *proc_symlink(const char *,
74 struct proc_dir_entry *, const char *);
75 extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *);
76 extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t,
77 struct proc_dir_entry *, void *);
78 extern struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode,
79 struct proc_dir_entry *parent);
81 static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
82 struct proc_dir_entry *parent, const struct file_operations *proc_fops)
84 return proc_create_data(name, mode, parent, proc_fops, NULL);
87 extern void proc_set_size(struct proc_dir_entry *, loff_t);
88 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
89 extern void *proc_get_parent_data(const struct inode *);
92 static inline void proc_flush_task(struct task_struct *task)
96 #define proc_create(name, mode, parent, fops) ({ (void)(mode), NULL; })
98 static inline struct proc_dir_entry *proc_create_data(const char *name,
99 umode_t mode, struct proc_dir_entry *parent,
100 const struct file_operations *proc_fops, void *data)
104 #define remove_proc_entry(name, parent) do {} while (0)
105 #define remove_proc_subtree(name, parent) do {} while (0)
107 static inline struct proc_dir_entry *proc_symlink(const char *name,
108 struct proc_dir_entry *parent,const char *dest) {return NULL;}
109 static inline struct proc_dir_entry *proc_mkdir(const char *name,
110 struct proc_dir_entry *parent) {return NULL;}
111 static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
112 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
113 static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
114 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
115 static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
116 static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
118 #endif /* CONFIG_PROC_FS */
122 int (*proc_get_link)(struct dentry *, struct path *);
123 int (*proc_read)(struct task_struct *task, char *page);
124 int (*proc_show)(struct seq_file *m,
125 struct pid_namespace *ns, struct pid *pid,
126 struct task_struct *task);
129 struct ctl_table_header;
136 struct proc_dir_entry *pde;
137 struct ctl_table_header *sysctl;
138 struct ctl_table *sysctl_entry;
140 struct inode vfs_inode;
143 static inline struct proc_inode *PROC_I(const struct inode *inode)
145 return container_of(inode, struct proc_inode, vfs_inode);
148 static inline struct proc_dir_entry *PDE(const struct inode *inode)
150 return PROC_I(inode)->pde;
153 static inline void *PDE_DATA(const struct inode *inode)
155 return PROC_I(inode)->pde->data;
158 static inline struct proc_dir_entry *proc_net_mkdir(
159 struct net *net, const char *name, struct proc_dir_entry *parent)
161 return proc_mkdir_data(name, 0, parent, net);
164 #endif /* _LINUX_PROC_FS_H */