Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | /* |
3 | * The proc filesystem constants/structures | |
4 | */ | |
59d8053f DH |
5 | #ifndef _LINUX_PROC_FS_H |
6 | #define _LINUX_PROC_FS_H | |
1da177e4 | 7 | |
59d8053f DH |
8 | #include <linux/types.h> |
9 | #include <linux/fs.h> | |
1da177e4 | 10 | |
59d8053f | 11 | struct proc_dir_entry; |
3f3942ac | 12 | struct seq_file; |
fddda2b7 | 13 | struct seq_operations; |
1da177e4 | 14 | |
1da177e4 LT |
15 | #ifdef CONFIG_PROC_FS |
16 | ||
1da177e4 | 17 | extern void proc_root_init(void); |
59d8053f | 18 | extern void proc_flush_task(struct task_struct *); |
1da177e4 | 19 | |
1da177e4 LT |
20 | extern struct proc_dir_entry *proc_symlink(const char *, |
21 | struct proc_dir_entry *, const char *); | |
59d8053f | 22 | extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *); |
270b5ac2 DH |
23 | extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t, |
24 | struct proc_dir_entry *, void *); | |
59d8053f DH |
25 | extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t, |
26 | struct proc_dir_entry *); | |
f97df70b | 27 | struct proc_dir_entry *proc_create_mount_point(const char *name); |
fddda2b7 | 28 | |
44414d82 | 29 | struct proc_dir_entry *proc_create_seq_private(const char *name, umode_t mode, |
fddda2b7 | 30 | struct proc_dir_entry *parent, const struct seq_operations *ops, |
44414d82 CH |
31 | unsigned int state_size, void *data); |
32 | #define proc_create_seq_data(name, mode, parent, ops, data) \ | |
33 | proc_create_seq_private(name, mode, parent, ops, 0, data) | |
fddda2b7 | 34 | #define proc_create_seq(name, mode, parent, ops) \ |
44414d82 | 35 | proc_create_seq_private(name, mode, parent, ops, 0, NULL) |
3f3942ac CH |
36 | struct proc_dir_entry *proc_create_single_data(const char *name, umode_t mode, |
37 | struct proc_dir_entry *parent, | |
38 | int (*show)(struct seq_file *, void *), void *data); | |
39 | #define proc_create_single(name, mode, parent, show) \ | |
40 | proc_create_single_data(name, mode, parent, show, NULL) | |
59d8053f DH |
41 | |
42 | extern struct proc_dir_entry *proc_create_data(const char *, umode_t, | |
43 | struct proc_dir_entry *, | |
44 | const struct file_operations *, | |
45 | void *); | |
46 | ||
855d9765 | 47 | struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops); |
271a15ea DH |
48 | extern void proc_set_size(struct proc_dir_entry *, loff_t); |
49 | extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t); | |
c30480b9 | 50 | extern void *PDE_DATA(const struct inode *); |
4a520d27 | 51 | extern void *proc_get_parent_data(const struct inode *); |
59d8053f DH |
52 | extern void proc_remove(struct proc_dir_entry *); |
53 | extern void remove_proc_entry(const char *, struct proc_dir_entry *); | |
54 | extern int remove_proc_subtree(const char *, struct proc_dir_entry *); | |
55 | ||
c3506372 CH |
56 | struct proc_dir_entry *proc_create_net_data(const char *name, umode_t mode, |
57 | struct proc_dir_entry *parent, const struct seq_operations *ops, | |
58 | unsigned int state_size, void *data); | |
59 | #define proc_create_net(name, mode, parent, state_size, ops) \ | |
60 | proc_create_net_data(name, mode, parent, state_size, ops, NULL) | |
3617d949 CH |
61 | struct proc_dir_entry *proc_create_net_single(const char *name, umode_t mode, |
62 | struct proc_dir_entry *parent, | |
63 | int (*show)(struct seq_file *, void *), void *data); | |
c3506372 | 64 | |
59d8053f | 65 | #else /* CONFIG_PROC_FS */ |
1da177e4 | 66 | |
647f010b AM |
67 | static inline void proc_root_init(void) |
68 | { | |
69 | } | |
70 | ||
60347f67 PE |
71 | static inline void proc_flush_task(struct task_struct *task) |
72 | { | |
73 | } | |
1da177e4 | 74 | |
1da177e4 | 75 | static inline struct proc_dir_entry *proc_symlink(const char *name, |
59d8053f | 76 | struct proc_dir_entry *parent,const char *dest) { return NULL;} |
1da177e4 LT |
77 | static inline struct proc_dir_entry *proc_mkdir(const char *name, |
78 | struct proc_dir_entry *parent) {return NULL;} | |
f97df70b | 79 | static inline struct proc_dir_entry *proc_create_mount_point(const char *name) { return NULL; } |
270b5ac2 DH |
80 | static inline struct proc_dir_entry *proc_mkdir_data(const char *name, |
81 | umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; } | |
f12a20fc | 82 | static inline struct proc_dir_entry *proc_mkdir_mode(const char *name, |
d161a13f | 83 | umode_t mode, struct proc_dir_entry *parent) { return NULL; } |
3f3942ac | 84 | #define proc_create_seq_private(name, mode, parent, ops, size, data) ({NULL;}) |
fddda2b7 CH |
85 | #define proc_create_seq_data(name, mode, parent, ops, data) ({NULL;}) |
86 | #define proc_create_seq(name, mode, parent, ops) ({NULL;}) | |
3f3942ac CH |
87 | #define proc_create_single(name, mode, parent, show) ({NULL;}) |
88 | #define proc_create_single_data(name, mode, parent, show, data) ({NULL;}) | |
59d8053f DH |
89 | #define proc_create(name, mode, parent, proc_fops) ({NULL;}) |
90 | #define proc_create_data(name, mode, parent, proc_fops, data) ({NULL;}) | |
91 | ||
271a15ea DH |
92 | static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {} |
93 | static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {} | |
c30480b9 | 94 | static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;} |
59d8053f | 95 | static inline void *proc_get_parent_data(const struct inode *inode) { BUG(); return NULL; } |
1da177e4 | 96 | |
59d8053f DH |
97 | static inline void proc_remove(struct proc_dir_entry *de) {} |
98 | #define remove_proc_entry(name, parent) do {} while (0) | |
99 | static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) { return 0; } | |
9043476f | 100 | |
c3506372 CH |
101 | #define proc_create_net_data(name, mode, parent, ops, state_size, data) ({NULL;}) |
102 | #define proc_create_net(name, mode, parent, state_size, ops) ({NULL;}) | |
3617d949 | 103 | #define proc_create_net_single(name, mode, parent, show, data) ({NULL;}) |
c3506372 | 104 | |
59d8053f | 105 | #endif /* CONFIG_PROC_FS */ |
1da177e4 | 106 | |
f7790029 JL |
107 | struct net; |
108 | ||
270b5ac2 DH |
109 | static inline struct proc_dir_entry *proc_net_mkdir( |
110 | struct net *net, const char *name, struct proc_dir_entry *parent) | |
111 | { | |
112 | return proc_mkdir_data(name, 0, parent, net); | |
113 | } | |
114 | ||
c62cce2c AV |
115 | struct ns_common; |
116 | int open_related_ns(struct ns_common *ns, | |
117 | struct ns_common *(*get_ns)(struct ns_common *ns)); | |
118 | ||
76f668be CH |
119 | /* get the associated pid namespace for a file in procfs */ |
120 | static inline struct pid_namespace *proc_pid_ns(struct inode *inode) | |
121 | { | |
122 | return inode->i_sb->s_fs_info; | |
123 | } | |
124 | ||
1da177e4 | 125 | #endif /* _LINUX_PROC_FS_H */ |