blob: e518352137e796127b4fa5eb7898fe67225e9d13 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * The proc filesystem constants/structures
4 */
David Howells59d80532013-04-11 13:34:43 +01005#ifndef _LINUX_PROC_FS_H
6#define _LINUX_PROC_FS_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07007
David Howells59d80532013-04-11 13:34:43 +01008#include <linux/types.h>
9#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
David Howells59d80532013-04-11 13:34:43 +010011struct proc_dir_entry;
Christoph Hellwig3f3942a2018-05-15 15:57:23 +020012struct seq_file;
Christoph Hellwigfddda2b2018-04-13 19:44:18 +020013struct seq_operations;
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#ifdef CONFIG_PROC_FS
16
Linus Torvalds1da177e2005-04-16 15:20:36 -070017extern void proc_root_init(void);
David Howells59d80532013-04-11 13:34:43 +010018extern void proc_flush_task(struct task_struct *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Linus Torvalds1da177e2005-04-16 15:20:36 -070020extern struct proc_dir_entry *proc_symlink(const char *,
21 struct proc_dir_entry *, const char *);
David Howells59d80532013-04-11 13:34:43 +010022extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *);
David Howells270b5ac2013-04-12 02:48:30 +010023extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t,
24 struct proc_dir_entry *, void *);
David Howells59d80532013-04-11 13:34:43 +010025extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t,
26 struct proc_dir_entry *);
Seth Forsheef97df702016-11-14 11:12:56 +000027struct proc_dir_entry *proc_create_mount_point(const char *name);
Christoph Hellwigfddda2b2018-04-13 19:44:18 +020028
Christoph Hellwig44414d82018-04-24 17:05:17 +020029struct proc_dir_entry *proc_create_seq_private(const char *name, umode_t mode,
Christoph Hellwigfddda2b2018-04-13 19:44:18 +020030 struct proc_dir_entry *parent, const struct seq_operations *ops,
Christoph Hellwig44414d82018-04-24 17:05:17 +020031 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)
Christoph Hellwigfddda2b2018-04-13 19:44:18 +020034#define proc_create_seq(name, mode, parent, ops) \
Christoph Hellwig44414d82018-04-24 17:05:17 +020035 proc_create_seq_private(name, mode, parent, ops, 0, NULL)
Christoph Hellwig3f3942a2018-05-15 15:57:23 +020036struct 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)
David Howells59d80532013-04-11 13:34:43 +010041
42extern struct proc_dir_entry *proc_create_data(const char *, umode_t,
43 struct proc_dir_entry *,
44 const struct file_operations *,
45 void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Alexey Dobriyan855d9762017-09-08 16:13:38 -070047struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops);
David Howells271a15e2013-04-12 00:38:51 +010048extern void proc_set_size(struct proc_dir_entry *, loff_t);
49extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
David Howellsc30480b2013-04-12 18:03:36 +010050extern void *PDE_DATA(const struct inode *);
David Howells4a520d22013-04-12 14:06:01 +010051extern void *proc_get_parent_data(const struct inode *);
David Howells59d80532013-04-11 13:34:43 +010052extern void proc_remove(struct proc_dir_entry *);
53extern void remove_proc_entry(const char *, struct proc_dir_entry *);
54extern int remove_proc_subtree(const char *, struct proc_dir_entry *);
55
Christoph Hellwigc3506372018-04-10 19:42:55 +020056struct 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)
Christoph Hellwig3617d942018-04-13 20:38:35 +020061struct 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);
Christoph Hellwigc3506372018-04-10 19:42:55 +020064
David Howells59d80532013-04-11 13:34:43 +010065#else /* CONFIG_PROC_FS */
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Andrew Morton647f0102014-06-04 16:12:20 -070067static inline void proc_root_init(void)
68{
69}
70
Pavel Emelyanov60347f62007-10-18 23:40:03 -070071static inline void proc_flush_task(struct task_struct *task)
72{
73}
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
Linus Torvalds1da177e2005-04-16 15:20:36 -070075static inline struct proc_dir_entry *proc_symlink(const char *name,
David Howells59d80532013-04-11 13:34:43 +010076 struct proc_dir_entry *parent,const char *dest) { return NULL;}
Linus Torvalds1da177e2005-04-16 15:20:36 -070077static inline struct proc_dir_entry *proc_mkdir(const char *name,
78 struct proc_dir_entry *parent) {return NULL;}
Seth Forsheef97df702016-11-14 11:12:56 +000079static inline struct proc_dir_entry *proc_create_mount_point(const char *name) { return NULL; }
David Howells270b5ac2013-04-12 02:48:30 +010080static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
81 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
Randy Dunlapf12a20fc2011-05-17 15:44:12 -070082static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
Al Virod161a132011-07-24 03:36:29 -040083 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
Christoph Hellwig3f3942a2018-05-15 15:57:23 +020084#define proc_create_seq_private(name, mode, parent, ops, size, data) ({NULL;})
Christoph Hellwigfddda2b2018-04-13 19:44:18 +020085#define proc_create_seq_data(name, mode, parent, ops, data) ({NULL;})
86#define proc_create_seq(name, mode, parent, ops) ({NULL;})
Christoph Hellwig3f3942a2018-05-15 15:57:23 +020087#define proc_create_single(name, mode, parent, show) ({NULL;})
88#define proc_create_single_data(name, mode, parent, show, data) ({NULL;})
David Howells59d80532013-04-11 13:34:43 +010089#define proc_create(name, mode, parent, proc_fops) ({NULL;})
90#define proc_create_data(name, mode, parent, proc_fops, data) ({NULL;})
91
David Howells271a15e2013-04-12 00:38:51 +010092static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
93static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
David Howellsc30480b2013-04-12 18:03:36 +010094static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;}
David Howells59d80532013-04-11 13:34:43 +010095static inline void *proc_get_parent_data(const struct inode *inode) { BUG(); return NULL; }
96
97static inline void proc_remove(struct proc_dir_entry *de) {}
98#define remove_proc_entry(name, parent) do {} while (0)
99static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
Christoph Hellwigc3506372018-04-10 19:42:55 +0200101#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;})
Christoph Hellwig3617d942018-04-13 20:38:35 +0200103#define proc_create_net_single(name, mode, parent, show, data) ({NULL;})
Christoph Hellwigc3506372018-04-10 19:42:55 +0200104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105#endif /* CONFIG_PROC_FS */
106
Jeff Laytonf7790022014-09-12 16:40:20 -0400107struct net;
108
David Howells270b5ac2013-04-12 02:48:30 +0100109static 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
Andrey Vaginc62cce22016-10-24 18:29:13 -0700115struct ns_common;
116int open_related_ns(struct ns_common *ns,
117 struct ns_common *(*get_ns)(struct ns_common *ns));
118
Christoph Hellwig76f668b2018-05-16 07:19:01 +0200119/* get the associated pid namespace for a file in procfs */
120static inline struct pid_namespace *proc_pid_ns(struct inode *inode)
121{
122 return inode->i_sb->s_fs_info;
123}
124
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125#endif /* _LINUX_PROC_FS_H */