blob: 9dcde9644253b06dce7548fca3250e081d939308 [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)
61
David Howells59d80532013-04-11 13:34:43 +010062#else /* CONFIG_PROC_FS */
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
Andrew Morton647f0102014-06-04 16:12:20 -070064static inline void proc_root_init(void)
65{
66}
67
Pavel Emelyanov60347f62007-10-18 23:40:03 -070068static inline void proc_flush_task(struct task_struct *task)
69{
70}
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Linus Torvalds1da177e2005-04-16 15:20:36 -070072static inline struct proc_dir_entry *proc_symlink(const char *name,
David Howells59d80532013-04-11 13:34:43 +010073 struct proc_dir_entry *parent,const char *dest) { return NULL;}
Linus Torvalds1da177e2005-04-16 15:20:36 -070074static inline struct proc_dir_entry *proc_mkdir(const char *name,
75 struct proc_dir_entry *parent) {return NULL;}
Seth Forsheef97df702016-11-14 11:12:56 +000076static inline struct proc_dir_entry *proc_create_mount_point(const char *name) { return NULL; }
David Howells270b5ac2013-04-12 02:48:30 +010077static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
78 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
Randy Dunlapf12a20f2011-05-17 15:44:12 -070079static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
Al Virod161a132011-07-24 03:36:29 -040080 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
Christoph Hellwig3f3942a2018-05-15 15:57:23 +020081#define proc_create_seq_private(name, mode, parent, ops, size, data) ({NULL;})
Christoph Hellwigfddda2b2018-04-13 19:44:18 +020082#define proc_create_seq_data(name, mode, parent, ops, data) ({NULL;})
83#define proc_create_seq(name, mode, parent, ops) ({NULL;})
Christoph Hellwig3f3942a2018-05-15 15:57:23 +020084#define proc_create_single(name, mode, parent, show) ({NULL;})
85#define proc_create_single_data(name, mode, parent, show, data) ({NULL;})
David Howells59d80532013-04-11 13:34:43 +010086#define proc_create(name, mode, parent, proc_fops) ({NULL;})
87#define proc_create_data(name, mode, parent, proc_fops, data) ({NULL;})
88
David Howells271a15e2013-04-12 00:38:51 +010089static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
90static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
David Howellsc30480b2013-04-12 18:03:36 +010091static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;}
David Howells59d80532013-04-11 13:34:43 +010092static inline void *proc_get_parent_data(const struct inode *inode) { BUG(); return NULL; }
93
94static inline void proc_remove(struct proc_dir_entry *de) {}
95#define remove_proc_entry(name, parent) do {} while (0)
96static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
Christoph Hellwigc3506372018-04-10 19:42:55 +020098#define proc_create_net_data(name, mode, parent, ops, state_size, data) ({NULL;})
99#define proc_create_net(name, mode, parent, state_size, ops) ({NULL;})
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101#endif /* CONFIG_PROC_FS */
102
Jeff Laytonf7790022014-09-12 16:40:20 -0400103struct net;
104
David Howells270b5ac2013-04-12 02:48:30 +0100105static inline struct proc_dir_entry *proc_net_mkdir(
106 struct net *net, const char *name, struct proc_dir_entry *parent)
107{
108 return proc_mkdir_data(name, 0, parent, net);
109}
110
Andrey Vaginc62cce22016-10-24 18:29:13 -0700111struct ns_common;
112int open_related_ns(struct ns_common *ns,
113 struct ns_common *(*get_ns)(struct ns_common *ns));
114
Christoph Hellwig76f668b2018-05-16 07:19:01 +0200115/* get the associated pid namespace for a file in procfs */
116static inline struct pid_namespace *proc_pid_ns(struct inode *inode)
117{
118 return inode->i_sb->s_fs_info;
119}
120
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121#endif /* _LINUX_PROC_FS_H */