blob: f368a896a8cb825b651363df21136ae3dd54acd5 [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
28struct proc_dir_entry *proc_create_seq_data(const char *name, umode_t mode,
29 struct proc_dir_entry *parent, const struct seq_operations *ops,
30 void *data);
31#define proc_create_seq(name, mode, parent, ops) \
32 proc_create_seq_data(name, mode, parent, ops, NULL)
David Howells59d80532013-04-11 13:34:43 +010033
34extern struct proc_dir_entry *proc_create_data(const char *, umode_t,
35 struct proc_dir_entry *,
36 const struct file_operations *,
37 void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Alexey Dobriyan855d9762017-09-08 16:13:38 -070039struct 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 +010040extern void proc_set_size(struct proc_dir_entry *, loff_t);
41extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
David Howellsc30480b2013-04-12 18:03:36 +010042extern void *PDE_DATA(const struct inode *);
David Howells4a520d22013-04-12 14:06:01 +010043extern void *proc_get_parent_data(const struct inode *);
David Howells59d80532013-04-11 13:34:43 +010044extern void proc_remove(struct proc_dir_entry *);
45extern void remove_proc_entry(const char *, struct proc_dir_entry *);
46extern int remove_proc_subtree(const char *, struct proc_dir_entry *);
47
48#else /* CONFIG_PROC_FS */
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Andrew Morton647f0102014-06-04 16:12:20 -070050static inline void proc_root_init(void)
51{
52}
53
Pavel Emelyanov60347f62007-10-18 23:40:03 -070054static inline void proc_flush_task(struct task_struct *task)
55{
56}
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Linus Torvalds1da177e2005-04-16 15:20:36 -070058static inline struct proc_dir_entry *proc_symlink(const char *name,
David Howells59d80532013-04-11 13:34:43 +010059 struct proc_dir_entry *parent,const char *dest) { return NULL;}
Linus Torvalds1da177e2005-04-16 15:20:36 -070060static inline struct proc_dir_entry *proc_mkdir(const char *name,
61 struct proc_dir_entry *parent) {return NULL;}
Seth Forsheef97df702016-11-14 11:12:56 +000062static inline struct proc_dir_entry *proc_create_mount_point(const char *name) { return NULL; }
David Howells270b5ac2013-04-12 02:48:30 +010063static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
64 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
Randy Dunlapf12a20f2011-05-17 15:44:12 -070065static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
Al Virod161a132011-07-24 03:36:29 -040066 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
Christoph Hellwigfddda2b2018-04-13 19:44:18 +020067#define proc_create_seq_data(name, mode, parent, ops, data) ({NULL;})
68#define proc_create_seq(name, mode, parent, ops) ({NULL;})
David Howells59d80532013-04-11 13:34:43 +010069#define proc_create(name, mode, parent, proc_fops) ({NULL;})
70#define proc_create_data(name, mode, parent, proc_fops, data) ({NULL;})
71
David Howells271a15e2013-04-12 00:38:51 +010072static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
73static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
David Howellsc30480b2013-04-12 18:03:36 +010074static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;}
David Howells59d80532013-04-11 13:34:43 +010075static inline void *proc_get_parent_data(const struct inode *inode) { BUG(); return NULL; }
76
77static inline void proc_remove(struct proc_dir_entry *de) {}
78#define remove_proc_entry(name, parent) do {} while (0)
79static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Linus Torvalds1da177e2005-04-16 15:20:36 -070081#endif /* CONFIG_PROC_FS */
82
Jeff Laytonf7790022014-09-12 16:40:20 -040083struct net;
84
David Howells270b5ac2013-04-12 02:48:30 +010085static inline struct proc_dir_entry *proc_net_mkdir(
86 struct net *net, const char *name, struct proc_dir_entry *parent)
87{
88 return proc_mkdir_data(name, 0, parent, net);
89}
90
Andrey Vaginc62cce22016-10-24 18:29:13 -070091struct ns_common;
92int open_related_ns(struct ns_common *ns,
93 struct ns_common *(*get_ns)(struct ns_common *ns));
94
Christoph Hellwig76f668b2018-05-16 07:19:01 +020095/* get the associated pid namespace for a file in procfs */
96static inline struct pid_namespace *proc_pid_ns(struct inode *inode)
97{
98 return inode->i_sb->s_fs_info;
99}
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101#endif /* _LINUX_PROC_FS_H */