1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * The proc filesystem constants/structures
4 */
5 #ifndef _LINUX_PROC_FS_H
6 #define _LINUX_PROC_FS_H
7
8 #include <linux/types.h>
9 #include <linux/fs.h>
10
11 struct proc_dir_entry;
12
13 #ifdef CONFIG_PROC_FS
14
15 extern void proc_root_init(void);
16 extern void proc_flush_task(struct task_struct *);
17
18 extern struct proc_dir_entry *proc_symlink(const char *,
19 struct proc_dir_entry *, const char *);
20 extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *);
21 extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t,
22 struct proc_dir_entry *, void *);
23 extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t,
24 struct proc_dir_entry *);
25 struct proc_dir_entry *proc_create_mount_point(const char *name);
26
27 extern struct proc_dir_entry *proc_create_data(const char *, umode_t,
28 struct proc_dir_entry *,
29 const struct file_operations *,
30 void *);
31
32 struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops);
33 extern void proc_set_size(struct proc_dir_entry *, loff_t);
34 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
35 extern void *PDE_DATA(const struct inode *);
36 extern void *proc_get_parent_data(const struct inode *);
37 extern void proc_remove(struct proc_dir_entry *);
38 extern void remove_proc_entry(const char *, struct proc_dir_entry *);
39 extern int remove_proc_subtree(const char *, struct proc_dir_entry *);
40
41 #else /* CONFIG_PROC_FS */
42
proc_root_init(void)43 static inline void proc_root_init(void)
44 {
45 }
46
proc_flush_task(struct task_struct * task)47 static inline void proc_flush_task(struct task_struct *task)
48 {
49 }
50
proc_symlink(const char * name,struct proc_dir_entry * parent,const char * dest)51 static inline struct proc_dir_entry *proc_symlink(const char *name,
52 struct proc_dir_entry *parent,const char *dest) { return NULL;}
proc_mkdir(const char * name,struct proc_dir_entry * parent)53 static inline struct proc_dir_entry *proc_mkdir(const char *name,
54 struct proc_dir_entry *parent) {return NULL;}
proc_create_mount_point(const char * name)55 static inline struct proc_dir_entry *proc_create_mount_point(const char *name) { return NULL; }
proc_mkdir_data(const char * name,umode_t mode,struct proc_dir_entry * parent,void * data)56 static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
57 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
proc_mkdir_mode(const char * name,umode_t mode,struct proc_dir_entry * parent)58 static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
59 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
60 #define proc_create(name, mode, parent, proc_fops) ({NULL;})
61 #define proc_create_data(name, mode, parent, proc_fops, data) ({NULL;})
62
proc_set_size(struct proc_dir_entry * de,loff_t size)63 static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
proc_set_user(struct proc_dir_entry * de,kuid_t uid,kgid_t gid)64 static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
PDE_DATA(const struct inode * inode)65 static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;}
proc_get_parent_data(const struct inode * inode)66 static inline void *proc_get_parent_data(const struct inode *inode) { BUG(); return NULL; }
67
proc_remove(struct proc_dir_entry * de)68 static inline void proc_remove(struct proc_dir_entry *de) {}
69 #define remove_proc_entry(name, parent) do {} while (0)
remove_proc_subtree(const char * name,struct proc_dir_entry * parent)70 static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) { return 0; }
71
72 #endif /* CONFIG_PROC_FS */
73
74 #ifdef CONFIG_PROC_UID
75 extern void proc_register_uid(kuid_t uid);
76 #else
proc_register_uid(kuid_t uid)77 static inline void proc_register_uid(kuid_t uid) {}
78 #endif
79
80 struct net;
81
proc_net_mkdir(struct net * net,const char * name,struct proc_dir_entry * parent)82 static inline struct proc_dir_entry *proc_net_mkdir(
83 struct net *net, const char *name, struct proc_dir_entry *parent)
84 {
85 return proc_mkdir_data(name, 0, parent, net);
86 }
87
88 struct ns_common;
89 int open_related_ns(struct ns_common *ns,
90 struct ns_common *(*get_ns)(struct ns_common *ns));
91
92 #endif /* _LINUX_PROC_FS_H */
93