Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * The proc filesystem constants/structures |
| 4 | */ |
David Howells | 59d8053 | 2013-04-11 13:34:43 +0100 | [diff] [blame] | 5 | #ifndef _LINUX_PROC_FS_H |
| 6 | #define _LINUX_PROC_FS_H |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | |
David Howells | 59d8053 | 2013-04-11 13:34:43 +0100 | [diff] [blame] | 8 | #include <linux/types.h> |
| 9 | #include <linux/fs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
David Howells | 59d8053 | 2013-04-11 13:34:43 +0100 | [diff] [blame] | 11 | struct proc_dir_entry; |
Christoph Hellwig | 3f3942a | 2018-05-15 15:57:23 +0200 | [diff] [blame] | 12 | struct seq_file; |
Christoph Hellwig | fddda2b | 2018-04-13 19:44:18 +0200 | [diff] [blame] | 13 | struct seq_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #ifdef CONFIG_PROC_FS |
| 16 | |
David Howells | 564def7 | 2018-05-18 11:46:15 +0100 | [diff] [blame^] | 17 | typedef int (*proc_write_t)(struct file *, char *, size_t); |
| 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | extern void proc_root_init(void); |
David Howells | 59d8053 | 2013-04-11 13:34:43 +0100 | [diff] [blame] | 20 | extern void proc_flush_task(struct task_struct *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | extern struct proc_dir_entry *proc_symlink(const char *, |
| 23 | struct proc_dir_entry *, const char *); |
David Howells | 59d8053 | 2013-04-11 13:34:43 +0100 | [diff] [blame] | 24 | extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *); |
David Howells | 270b5ac | 2013-04-12 02:48:30 +0100 | [diff] [blame] | 25 | extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t, |
| 26 | struct proc_dir_entry *, void *); |
David Howells | 59d8053 | 2013-04-11 13:34:43 +0100 | [diff] [blame] | 27 | extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t, |
| 28 | struct proc_dir_entry *); |
Seth Forshee | f97df70 | 2016-11-14 11:12:56 +0000 | [diff] [blame] | 29 | struct proc_dir_entry *proc_create_mount_point(const char *name); |
Christoph Hellwig | fddda2b | 2018-04-13 19:44:18 +0200 | [diff] [blame] | 30 | |
Christoph Hellwig | 44414d8 | 2018-04-24 17:05:17 +0200 | [diff] [blame] | 31 | struct proc_dir_entry *proc_create_seq_private(const char *name, umode_t mode, |
Christoph Hellwig | fddda2b | 2018-04-13 19:44:18 +0200 | [diff] [blame] | 32 | struct proc_dir_entry *parent, const struct seq_operations *ops, |
Christoph Hellwig | 44414d8 | 2018-04-24 17:05:17 +0200 | [diff] [blame] | 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) |
Christoph Hellwig | fddda2b | 2018-04-13 19:44:18 +0200 | [diff] [blame] | 36 | #define proc_create_seq(name, mode, parent, ops) \ |
Christoph Hellwig | 44414d8 | 2018-04-24 17:05:17 +0200 | [diff] [blame] | 37 | proc_create_seq_private(name, mode, parent, ops, 0, NULL) |
Christoph Hellwig | 3f3942a | 2018-05-15 15:57:23 +0200 | [diff] [blame] | 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) |
David Howells | 59d8053 | 2013-04-11 13:34:43 +0100 | [diff] [blame] | 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 *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
Alexey Dobriyan | 855d976 | 2017-09-08 16:13:38 -0700 | [diff] [blame] | 49 | struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops); |
David Howells | 271a15e | 2013-04-12 00:38:51 +0100 | [diff] [blame] | 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); |
David Howells | c30480b | 2013-04-12 18:03:36 +0100 | [diff] [blame] | 52 | extern void *PDE_DATA(const struct inode *); |
David Howells | 4a520d2 | 2013-04-12 14:06:01 +0100 | [diff] [blame] | 53 | extern void *proc_get_parent_data(const struct inode *); |
David Howells | 59d8053 | 2013-04-11 13:34:43 +0100 | [diff] [blame] | 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 | |
Christoph Hellwig | c350637 | 2018-04-10 19:42:55 +0200 | [diff] [blame] | 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); |
| 61 | #define proc_create_net(name, mode, parent, state_size, ops) \ |
| 62 | proc_create_net_data(name, mode, parent, state_size, ops, NULL) |
Christoph Hellwig | 3617d94 | 2018-04-13 20:38:35 +0200 | [diff] [blame] | 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); |
David Howells | 564def7 | 2018-05-18 11:46:15 +0100 | [diff] [blame^] | 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); |
Christoph Hellwig | c350637 | 2018-04-10 19:42:55 +0200 | [diff] [blame] | 76 | |
David Howells | 59d8053 | 2013-04-11 13:34:43 +0100 | [diff] [blame] | 77 | #else /* CONFIG_PROC_FS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | |
Andrew Morton | 647f010 | 2014-06-04 16:12:20 -0700 | [diff] [blame] | 79 | static inline void proc_root_init(void) |
| 80 | { |
| 81 | } |
| 82 | |
Pavel Emelyanov | 60347f6 | 2007-10-18 23:40:03 -0700 | [diff] [blame] | 83 | static inline void proc_flush_task(struct task_struct *task) |
| 84 | { |
| 85 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | static inline struct proc_dir_entry *proc_symlink(const char *name, |
David Howells | 59d8053 | 2013-04-11 13:34:43 +0100 | [diff] [blame] | 88 | struct proc_dir_entry *parent,const char *dest) { return NULL;} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | static inline struct proc_dir_entry *proc_mkdir(const char *name, |
| 90 | struct proc_dir_entry *parent) {return NULL;} |
Seth Forshee | f97df70 | 2016-11-14 11:12:56 +0000 | [diff] [blame] | 91 | static inline struct proc_dir_entry *proc_create_mount_point(const char *name) { return NULL; } |
David Howells | 270b5ac | 2013-04-12 02:48:30 +0100 | [diff] [blame] | 92 | static inline struct proc_dir_entry *proc_mkdir_data(const char *name, |
| 93 | umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; } |
Randy Dunlap | f12a20f | 2011-05-17 15:44:12 -0700 | [diff] [blame] | 94 | static inline struct proc_dir_entry *proc_mkdir_mode(const char *name, |
Al Viro | d161a13 | 2011-07-24 03:36:29 -0400 | [diff] [blame] | 95 | umode_t mode, struct proc_dir_entry *parent) { return NULL; } |
Christoph Hellwig | 3f3942a | 2018-05-15 15:57:23 +0200 | [diff] [blame] | 96 | #define proc_create_seq_private(name, mode, parent, ops, size, data) ({NULL;}) |
Christoph Hellwig | fddda2b | 2018-04-13 19:44:18 +0200 | [diff] [blame] | 97 | #define proc_create_seq_data(name, mode, parent, ops, data) ({NULL;}) |
| 98 | #define proc_create_seq(name, mode, parent, ops) ({NULL;}) |
Christoph Hellwig | 3f3942a | 2018-05-15 15:57:23 +0200 | [diff] [blame] | 99 | #define proc_create_single(name, mode, parent, show) ({NULL;}) |
| 100 | #define proc_create_single_data(name, mode, parent, show, data) ({NULL;}) |
David Howells | 59d8053 | 2013-04-11 13:34:43 +0100 | [diff] [blame] | 101 | #define proc_create(name, mode, parent, proc_fops) ({NULL;}) |
| 102 | #define proc_create_data(name, mode, parent, proc_fops, data) ({NULL;}) |
| 103 | |
David Howells | 271a15e | 2013-04-12 00:38:51 +0100 | [diff] [blame] | 104 | static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {} |
| 105 | static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {} |
David Howells | c30480b | 2013-04-12 18:03:36 +0100 | [diff] [blame] | 106 | static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;} |
David Howells | 59d8053 | 2013-04-11 13:34:43 +0100 | [diff] [blame] | 107 | static inline void *proc_get_parent_data(const struct inode *inode) { BUG(); return NULL; } |
| 108 | |
| 109 | static inline void proc_remove(struct proc_dir_entry *de) {} |
| 110 | #define remove_proc_entry(name, parent) do {} while (0) |
| 111 | static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) { return 0; } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
Christoph Hellwig | c350637 | 2018-04-10 19:42:55 +0200 | [diff] [blame] | 113 | #define proc_create_net_data(name, mode, parent, ops, state_size, data) ({NULL;}) |
| 114 | #define proc_create_net(name, mode, parent, state_size, ops) ({NULL;}) |
Christoph Hellwig | 3617d94 | 2018-04-13 20:38:35 +0200 | [diff] [blame] | 115 | #define proc_create_net_single(name, mode, parent, show, data) ({NULL;}) |
Christoph Hellwig | c350637 | 2018-04-10 19:42:55 +0200 | [diff] [blame] | 116 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | #endif /* CONFIG_PROC_FS */ |
| 118 | |
Jeff Layton | f779002 | 2014-09-12 16:40:20 -0400 | [diff] [blame] | 119 | struct net; |
| 120 | |
David Howells | 270b5ac | 2013-04-12 02:48:30 +0100 | [diff] [blame] | 121 | static inline struct proc_dir_entry *proc_net_mkdir( |
| 122 | struct net *net, const char *name, struct proc_dir_entry *parent) |
| 123 | { |
| 124 | return proc_mkdir_data(name, 0, parent, net); |
| 125 | } |
| 126 | |
Andrey Vagin | c62cce2 | 2016-10-24 18:29:13 -0700 | [diff] [blame] | 127 | struct ns_common; |
| 128 | int open_related_ns(struct ns_common *ns, |
| 129 | struct ns_common *(*get_ns)(struct ns_common *ns)); |
| 130 | |
Christoph Hellwig | 76f668b | 2018-05-16 07:19:01 +0200 | [diff] [blame] | 131 | /* get the associated pid namespace for a file in procfs */ |
| 132 | static inline struct pid_namespace *proc_pid_ns(struct inode *inode) |
| 133 | { |
| 134 | return inode->i_sb->s_fs_info; |
| 135 | } |
| 136 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | #endif /* _LINUX_PROC_FS_H */ |