blob: 314713a4881758adb1c621aca4894b7be3d8c34e [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 Hellwigfddda2b2018-04-13 19:44:18 +020012struct seq_operations;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#ifdef CONFIG_PROC_FS
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016extern void proc_root_init(void);
David Howells59d80532013-04-11 13:34:43 +010017extern void proc_flush_task(struct task_struct *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
Linus Torvalds1da177e2005-04-16 15:20:36 -070019extern struct proc_dir_entry *proc_symlink(const char *,
20 struct proc_dir_entry *, const char *);
David Howells59d80532013-04-11 13:34:43 +010021extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *);
David Howells270b5ac2013-04-12 02:48:30 +010022extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t,
23 struct proc_dir_entry *, void *);
David Howells59d80532013-04-11 13:34:43 +010024extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t,
25 struct proc_dir_entry *);
Seth Forsheef97df702016-11-14 11:12:56 +000026struct proc_dir_entry *proc_create_mount_point(const char *name);
Christoph Hellwigfddda2b2018-04-13 19:44:18 +020027
Christoph Hellwig44414d82018-04-24 17:05:17 +020028struct proc_dir_entry *proc_create_seq_private(const char *name, umode_t mode,
Christoph Hellwigfddda2b2018-04-13 19:44:18 +020029 struct proc_dir_entry *parent, const struct seq_operations *ops,
Christoph Hellwig44414d82018-04-24 17:05:17 +020030 unsigned int state_size, void *data);
31#define proc_create_seq_data(name, mode, parent, ops, data) \
32 proc_create_seq_private(name, mode, parent, ops, 0, data)
Christoph Hellwigfddda2b2018-04-13 19:44:18 +020033#define proc_create_seq(name, mode, parent, ops) \
Christoph Hellwig44414d82018-04-24 17:05:17 +020034 proc_create_seq_private(name, mode, parent, ops, 0, NULL)
David Howells59d80532013-04-11 13:34:43 +010035
36extern struct proc_dir_entry *proc_create_data(const char *, umode_t,
37 struct proc_dir_entry *,
38 const struct file_operations *,
39 void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Alexey Dobriyan855d9762017-09-08 16:13:38 -070041struct 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 +010042extern void proc_set_size(struct proc_dir_entry *, loff_t);
43extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
David Howellsc30480b2013-04-12 18:03:36 +010044extern void *PDE_DATA(const struct inode *);
David Howells4a520d22013-04-12 14:06:01 +010045extern void *proc_get_parent_data(const struct inode *);
David Howells59d80532013-04-11 13:34:43 +010046extern void proc_remove(struct proc_dir_entry *);
47extern void remove_proc_entry(const char *, struct proc_dir_entry *);
48extern int remove_proc_subtree(const char *, struct proc_dir_entry *);
49
50#else /* CONFIG_PROC_FS */
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
Andrew Morton647f0102014-06-04 16:12:20 -070052static inline void proc_root_init(void)
53{
54}
55
Pavel Emelyanov60347f62007-10-18 23:40:03 -070056static inline void proc_flush_task(struct task_struct *task)
57{
58}
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
Linus Torvalds1da177e2005-04-16 15:20:36 -070060static inline struct proc_dir_entry *proc_symlink(const char *name,
David Howells59d80532013-04-11 13:34:43 +010061 struct proc_dir_entry *parent,const char *dest) { return NULL;}
Linus Torvalds1da177e2005-04-16 15:20:36 -070062static inline struct proc_dir_entry *proc_mkdir(const char *name,
63 struct proc_dir_entry *parent) {return NULL;}
Seth Forsheef97df702016-11-14 11:12:56 +000064static inline struct proc_dir_entry *proc_create_mount_point(const char *name) { return NULL; }
David Howells270b5ac2013-04-12 02:48:30 +010065static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
66 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
Randy Dunlapf12a20f2011-05-17 15:44:12 -070067static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
Al Virod161a132011-07-24 03:36:29 -040068 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
Christoph Hellwig44414d82018-04-24 17:05:17 +020069#define proc_create_seq_private(name, mode, parent, ops, 0, data) ({NULL;})
Christoph Hellwigfddda2b2018-04-13 19:44:18 +020070#define proc_create_seq_data(name, mode, parent, ops, data) ({NULL;})
71#define proc_create_seq(name, mode, parent, ops) ({NULL;})
David Howells59d80532013-04-11 13:34:43 +010072#define proc_create(name, mode, parent, proc_fops) ({NULL;})
73#define proc_create_data(name, mode, parent, proc_fops, data) ({NULL;})
74
David Howells271a15e2013-04-12 00:38:51 +010075static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
76static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
David Howellsc30480b2013-04-12 18:03:36 +010077static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;}
David Howells59d80532013-04-11 13:34:43 +010078static inline void *proc_get_parent_data(const struct inode *inode) { BUG(); return NULL; }
79
80static inline void proc_remove(struct proc_dir_entry *de) {}
81#define remove_proc_entry(name, parent) do {} while (0)
82static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
Linus Torvalds1da177e2005-04-16 15:20:36 -070084#endif /* CONFIG_PROC_FS */
85
Jeff Laytonf7790022014-09-12 16:40:20 -040086struct net;
87
David Howells270b5ac2013-04-12 02:48:30 +010088static inline struct proc_dir_entry *proc_net_mkdir(
89 struct net *net, const char *name, struct proc_dir_entry *parent)
90{
91 return proc_mkdir_data(name, 0, parent, net);
92}
93
Andrey Vaginc62cce22016-10-24 18:29:13 -070094struct ns_common;
95int open_related_ns(struct ns_common *ns,
96 struct ns_common *(*get_ns)(struct ns_common *ns));
97
Christoph Hellwig76f668b2018-05-16 07:19:01 +020098/* get the associated pid namespace for a file in procfs */
99static inline struct pid_namespace *proc_pid_ns(struct inode *inode)
100{
101 return inode->i_sb->s_fs_info;
102}
103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104#endif /* _LINUX_PROC_FS_H */