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 | ||
564def71 DH |
17 | typedef int (*proc_write_t)(struct file *, char *, size_t); |
18 | ||
1da177e4 | 19 | extern void proc_root_init(void); |
59d8053f | 20 | extern void proc_flush_task(struct task_struct *); |
1da177e4 | 21 | |
1da177e4 LT |
22 | extern struct proc_dir_entry *proc_symlink(const char *, |
23 | struct proc_dir_entry *, const char *); | |
59d8053f | 24 | extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *); |
270b5ac2 DH |
25 | extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t, |
26 | struct proc_dir_entry *, void *); | |
59d8053f DH |
27 | extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t, |
28 | struct proc_dir_entry *); | |
f97df70b | 29 | struct proc_dir_entry *proc_create_mount_point(const char *name); |
fddda2b7 | 30 | |
44414d82 | 31 | struct proc_dir_entry *proc_create_seq_private(const char *name, umode_t mode, |
fddda2b7 | 32 | struct proc_dir_entry *parent, const struct seq_operations *ops, |
44414d82 CH |
33 | unsigned int state_size, void *data); |
34 | #define proc_create_seq_data(name, mode, parent, ops, data) \ | |
35 | proc_create_seq_private(name, mode, parent, ops, 0, data) | |
fddda2b7 | 36 | #define proc_create_seq(name, mode, parent, ops) \ |
44414d82 | 37 | proc_create_seq_private(name, mode, parent, ops, 0, NULL) |
3f3942ac CH |
38 | struct proc_dir_entry *proc_create_single_data(const char *name, umode_t mode, |
39 | struct proc_dir_entry *parent, | |
40 | int (*show)(struct seq_file *, void *), void *data); | |
41 | #define proc_create_single(name, mode, parent, show) \ | |
42 | proc_create_single_data(name, mode, parent, show, NULL) | |
59d8053f DH |
43 | |
44 | extern struct proc_dir_entry *proc_create_data(const char *, umode_t, | |
45 | struct proc_dir_entry *, | |
46 | const struct file_operations *, | |
47 | void *); | |
48 | ||
855d9765 | 49 | 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 |
50 | extern void proc_set_size(struct proc_dir_entry *, loff_t); |
51 | extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t); | |
c30480b9 | 52 | extern void *PDE_DATA(const struct inode *); |
4a520d27 | 53 | extern void *proc_get_parent_data(const struct inode *); |
59d8053f DH |
54 | extern void proc_remove(struct proc_dir_entry *); |
55 | extern void remove_proc_entry(const char *, struct proc_dir_entry *); | |
56 | extern int remove_proc_subtree(const char *, struct proc_dir_entry *); | |
57 | ||
c3506372 CH |
58 | struct proc_dir_entry *proc_create_net_data(const char *name, umode_t mode, |
59 | struct proc_dir_entry *parent, const struct seq_operations *ops, | |
60 | unsigned int state_size, void *data); | |
9573e8f7 ML |
61 | #define proc_create_net(name, mode, parent, ops, state_size) \ |
62 | proc_create_net_data(name, mode, parent, ops, state_size, NULL) | |
3617d949 CH |
63 | struct proc_dir_entry *proc_create_net_single(const char *name, umode_t mode, |
64 | struct proc_dir_entry *parent, | |
65 | int (*show)(struct seq_file *, void *), void *data); | |
564def71 DH |
66 | struct proc_dir_entry *proc_create_net_data_write(const char *name, umode_t mode, |
67 | struct proc_dir_entry *parent, | |
68 | const struct seq_operations *ops, | |
69 | proc_write_t write, | |
70 | unsigned int state_size, void *data); | |
71 | struct proc_dir_entry *proc_create_net_single_write(const char *name, umode_t mode, | |
72 | struct proc_dir_entry *parent, | |
73 | int (*show)(struct seq_file *, void *), | |
74 | proc_write_t write, | |
75 | void *data); | |
3eb39f47 | 76 | extern struct pid *tgid_pidfd_to_pid(const struct file *file); |
c3506372 | 77 | |
68bc30bb AL |
78 | #ifdef CONFIG_PROC_PID_ARCH_STATUS |
79 | /* | |
80 | * The architecture which selects CONFIG_PROC_PID_ARCH_STATUS must | |
81 | * provide proc_pid_arch_status() definition. | |
82 | */ | |
83 | int proc_pid_arch_status(struct seq_file *m, struct pid_namespace *ns, | |
84 | struct pid *pid, struct task_struct *task); | |
85 | #endif /* CONFIG_PROC_PID_ARCH_STATUS */ | |
86 | ||
59d8053f | 87 | #else /* CONFIG_PROC_FS */ |
1da177e4 | 88 | |
647f010b AM |
89 | static inline void proc_root_init(void) |
90 | { | |
91 | } | |
92 | ||
60347f67 PE |
93 | static inline void proc_flush_task(struct task_struct *task) |
94 | { | |
95 | } | |
1da177e4 | 96 | |
1da177e4 | 97 | static inline struct proc_dir_entry *proc_symlink(const char *name, |
59d8053f | 98 | struct proc_dir_entry *parent,const char *dest) { return NULL;} |
1da177e4 LT |
99 | static inline struct proc_dir_entry *proc_mkdir(const char *name, |
100 | struct proc_dir_entry *parent) {return NULL;} | |
f97df70b | 101 | static inline struct proc_dir_entry *proc_create_mount_point(const char *name) { return NULL; } |
270b5ac2 DH |
102 | static inline struct proc_dir_entry *proc_mkdir_data(const char *name, |
103 | umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; } | |
f12a20fc | 104 | static inline struct proc_dir_entry *proc_mkdir_mode(const char *name, |
d161a13f | 105 | umode_t mode, struct proc_dir_entry *parent) { return NULL; } |
3f3942ac | 106 | #define proc_create_seq_private(name, mode, parent, ops, size, data) ({NULL;}) |
fddda2b7 CH |
107 | #define proc_create_seq_data(name, mode, parent, ops, data) ({NULL;}) |
108 | #define proc_create_seq(name, mode, parent, ops) ({NULL;}) | |
3f3942ac CH |
109 | #define proc_create_single(name, mode, parent, show) ({NULL;}) |
110 | #define proc_create_single_data(name, mode, parent, show, data) ({NULL;}) | |
59d8053f DH |
111 | #define proc_create(name, mode, parent, proc_fops) ({NULL;}) |
112 | #define proc_create_data(name, mode, parent, proc_fops, data) ({NULL;}) | |
113 | ||
271a15ea DH |
114 | static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {} |
115 | static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {} | |
c30480b9 | 116 | static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;} |
59d8053f | 117 | static inline void *proc_get_parent_data(const struct inode *inode) { BUG(); return NULL; } |
1da177e4 | 118 | |
59d8053f DH |
119 | static inline void proc_remove(struct proc_dir_entry *de) {} |
120 | #define remove_proc_entry(name, parent) do {} while (0) | |
121 | static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) { return 0; } | |
9043476f | 122 | |
c3506372 CH |
123 | #define proc_create_net_data(name, mode, parent, ops, state_size, data) ({NULL;}) |
124 | #define proc_create_net(name, mode, parent, state_size, ops) ({NULL;}) | |
3617d949 | 125 | #define proc_create_net_single(name, mode, parent, show, data) ({NULL;}) |
c3506372 | 126 | |
3eb39f47 CB |
127 | static inline struct pid *tgid_pidfd_to_pid(const struct file *file) |
128 | { | |
129 | return ERR_PTR(-EBADF); | |
130 | } | |
131 | ||
59d8053f | 132 | #endif /* CONFIG_PROC_FS */ |
1da177e4 | 133 | |
f7790029 JL |
134 | struct net; |
135 | ||
270b5ac2 DH |
136 | static inline struct proc_dir_entry *proc_net_mkdir( |
137 | struct net *net, const char *name, struct proc_dir_entry *parent) | |
138 | { | |
139 | return proc_mkdir_data(name, 0, parent, net); | |
140 | } | |
141 | ||
c62cce2c AV |
142 | struct ns_common; |
143 | int open_related_ns(struct ns_common *ns, | |
144 | struct ns_common *(*get_ns)(struct ns_common *ns)); | |
145 | ||
76f668be | 146 | /* get the associated pid namespace for a file in procfs */ |
891ae71d | 147 | static inline struct pid_namespace *proc_pid_ns(const struct inode *inode) |
76f668be CH |
148 | { |
149 | return inode->i_sb->s_fs_info; | |
150 | } | |
151 | ||
1da177e4 | 152 | #endif /* _LINUX_PROC_FS_H */ |