blob: 2529b871f379b15d62f0151c6ee875683ad872ae [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
56#else /* CONFIG_PROC_FS */
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Andrew Morton647f0102014-06-04 16:12:20 -070058static inline void proc_root_init(void)
59{
60}
61
Pavel Emelyanov60347f62007-10-18 23:40:03 -070062static inline void proc_flush_task(struct task_struct *task)
63{
64}
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
Linus Torvalds1da177e2005-04-16 15:20:36 -070066static inline struct proc_dir_entry *proc_symlink(const char *name,
David Howells59d80532013-04-11 13:34:43 +010067 struct proc_dir_entry *parent,const char *dest) { return NULL;}
Linus Torvalds1da177e2005-04-16 15:20:36 -070068static inline struct proc_dir_entry *proc_mkdir(const char *name,
69 struct proc_dir_entry *parent) {return NULL;}
Seth Forsheef97df702016-11-14 11:12:56 +000070static inline struct proc_dir_entry *proc_create_mount_point(const char *name) { return NULL; }
David Howells270b5ac2013-04-12 02:48:30 +010071static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
72 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
Randy Dunlapf12a20f2011-05-17 15:44:12 -070073static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
Al Virod161a132011-07-24 03:36:29 -040074 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
Christoph Hellwig3f3942a2018-05-15 15:57:23 +020075#define proc_create_seq_private(name, mode, parent, ops, size, data) ({NULL;})
Christoph Hellwigfddda2b2018-04-13 19:44:18 +020076#define proc_create_seq_data(name, mode, parent, ops, data) ({NULL;})
77#define proc_create_seq(name, mode, parent, ops) ({NULL;})
Christoph Hellwig3f3942a2018-05-15 15:57:23 +020078#define proc_create_single(name, mode, parent, show) ({NULL;})
79#define proc_create_single_data(name, mode, parent, show, data) ({NULL;})
David Howells59d80532013-04-11 13:34:43 +010080#define proc_create(name, mode, parent, proc_fops) ({NULL;})
81#define proc_create_data(name, mode, parent, proc_fops, data) ({NULL;})
82
David Howells271a15e2013-04-12 00:38:51 +010083static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
84static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
David Howellsc30480b2013-04-12 18:03:36 +010085static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;}
David Howells59d80532013-04-11 13:34:43 +010086static inline void *proc_get_parent_data(const struct inode *inode) { BUG(); return NULL; }
87
88static inline void proc_remove(struct proc_dir_entry *de) {}
89#define remove_proc_entry(name, parent) do {} while (0)
90static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
Linus Torvalds1da177e2005-04-16 15:20:36 -070092#endif /* CONFIG_PROC_FS */
93
Jeff Laytonf7790022014-09-12 16:40:20 -040094struct net;
95
David Howells270b5ac2013-04-12 02:48:30 +010096static inline struct proc_dir_entry *proc_net_mkdir(
97 struct net *net, const char *name, struct proc_dir_entry *parent)
98{
99 return proc_mkdir_data(name, 0, parent, net);
100}
101
Andrey Vaginc62cce22016-10-24 18:29:13 -0700102struct ns_common;
103int open_related_ns(struct ns_common *ns,
104 struct ns_common *(*get_ns)(struct ns_common *ns));
105
Christoph Hellwig76f668b2018-05-16 07:19:01 +0200106/* get the associated pid namespace for a file in procfs */
107static inline struct pid_namespace *proc_pid_ns(struct inode *inode)
108{
109 return inode->i_sb->s_fs_info;
110}
111
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112#endif /* _LINUX_PROC_FS_H */