blob: de3f442b7ab622c4042e909cec5c82c1d69b7a19 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * The proc filesystem constants/structures
3 */
David Howells59d80532013-04-11 13:34:43 +01004#ifndef _LINUX_PROC_FS_H
5#define _LINUX_PROC_FS_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
David Howells59d80532013-04-11 13:34:43 +01007#include <linux/types.h>
8#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
David Howells59d80532013-04-11 13:34:43 +010010struct proc_dir_entry;
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#ifdef CONFIG_PROC_FS
13
Linus Torvalds1da177e2005-04-16 15:20:36 -070014extern void proc_root_init(void);
David Howells59d80532013-04-11 13:34:43 +010015extern void proc_flush_task(struct task_struct *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Linus Torvalds1da177e2005-04-16 15:20:36 -070017extern struct proc_dir_entry *proc_symlink(const char *,
18 struct proc_dir_entry *, const char *);
David Howells59d80532013-04-11 13:34:43 +010019extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *);
David Howells270b5ac2013-04-12 02:48:30 +010020extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t,
21 struct proc_dir_entry *, void *);
David Howells59d80532013-04-11 13:34:43 +010022extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t,
23 struct proc_dir_entry *);
24
25extern struct proc_dir_entry *proc_create_data(const char *, umode_t,
26 struct proc_dir_entry *,
27 const struct file_operations *,
28 void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
David Howells59d80532013-04-11 13:34:43 +010030static inline struct proc_dir_entry *proc_create(
31 const char *name, umode_t mode, struct proc_dir_entry *parent,
32 const struct file_operations *proc_fops)
Denis V. Lunev59b74352008-04-29 01:02:00 -070033{
34 return proc_create_data(name, mode, parent, proc_fops, NULL);
35}
David Howells59d80532013-04-11 13:34:43 +010036
David Howells271a15e2013-04-12 00:38:51 +010037extern void proc_set_size(struct proc_dir_entry *, loff_t);
38extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
David Howellsc30480b2013-04-12 18:03:36 +010039extern void *PDE_DATA(const struct inode *);
David Howells4a520d22013-04-12 14:06:01 +010040extern void *proc_get_parent_data(const struct inode *);
David Howells59d80532013-04-11 13:34:43 +010041extern void proc_remove(struct proc_dir_entry *);
42extern void remove_proc_entry(const char *, struct proc_dir_entry *);
43extern int remove_proc_subtree(const char *, struct proc_dir_entry *);
Christian Brauner6dc8e7c2018-11-19 00:51:56 +010044extern struct pid *tgid_pidfd_to_pid(const struct file *file);
David Howells59d80532013-04-11 13:34:43 +010045
46#else /* CONFIG_PROC_FS */
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Andrew Morton647f0102014-06-04 16:12:20 -070048static inline void proc_root_init(void)
49{
50}
51
Pavel Emelyanov60347f62007-10-18 23:40:03 -070052static inline void proc_flush_task(struct task_struct *task)
53{
54}
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Linus Torvalds1da177e2005-04-16 15:20:36 -070056static inline struct proc_dir_entry *proc_symlink(const char *name,
David Howells59d80532013-04-11 13:34:43 +010057 struct proc_dir_entry *parent,const char *dest) { return NULL;}
Linus Torvalds1da177e2005-04-16 15:20:36 -070058static inline struct proc_dir_entry *proc_mkdir(const char *name,
59 struct proc_dir_entry *parent) {return NULL;}
David Howells270b5ac2013-04-12 02:48:30 +010060static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
61 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
Randy Dunlapf12a20f2011-05-17 15:44:12 -070062static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
Al Virod161a132011-07-24 03:36:29 -040063 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
David Howells59d80532013-04-11 13:34:43 +010064#define proc_create(name, mode, parent, proc_fops) ({NULL;})
65#define proc_create_data(name, mode, parent, proc_fops, data) ({NULL;})
66
David Howells271a15e2013-04-12 00:38:51 +010067static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
68static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
David Howellsc30480b2013-04-12 18:03:36 +010069static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;}
David Howells59d80532013-04-11 13:34:43 +010070static inline void *proc_get_parent_data(const struct inode *inode) { BUG(); return NULL; }
71
72static inline void proc_remove(struct proc_dir_entry *de) {}
73#define remove_proc_entry(name, parent) do {} while (0)
74static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Christian Brauner6dc8e7c2018-11-19 00:51:56 +010076static inline struct pid *tgid_pidfd_to_pid(const struct file *file)
77{
78 return ERR_PTR(-EBADF);
79}
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081#endif /* CONFIG_PROC_FS */
82
Connor O'Brien5b3d1102017-10-16 10:30:24 -070083#ifdef CONFIG_PROC_UID
84extern void proc_register_uid(kuid_t uid);
85#else
86static inline void proc_register_uid(kuid_t uid) {}
87#endif
88
Jeff Laytonf7790022014-09-12 16:40:20 -040089struct net;
90
David Howells270b5ac2013-04-12 02:48:30 +010091static inline struct proc_dir_entry *proc_net_mkdir(
92 struct net *net, const char *name, struct proc_dir_entry *parent)
93{
94 return proc_mkdir_data(name, 0, parent, net);
95}
96
Linus Torvalds1da177e2005-04-16 15:20:36 -070097#endif /* _LINUX_PROC_FS_H */