blob: 928ef9e4d912513bcee0b366f4cf781d534d55cd [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;
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#ifdef CONFIG_PROC_FS
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015extern void proc_root_init(void);
David Howells59d80532013-04-11 13:34:43 +010016extern void proc_flush_task(struct task_struct *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Linus Torvalds1da177e2005-04-16 15:20:36 -070018extern struct proc_dir_entry *proc_symlink(const char *,
19 struct proc_dir_entry *, const char *);
David Howells59d80532013-04-11 13:34:43 +010020extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *);
David Howells270b5ac2013-04-12 02:48:30 +010021extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t,
22 struct proc_dir_entry *, void *);
David Howells59d80532013-04-11 13:34:43 +010023extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t,
24 struct proc_dir_entry *);
Seth Forsheef97df702016-11-14 11:12:56 +000025struct proc_dir_entry *proc_create_mount_point(const char *name);
David Howells59d80532013-04-11 13:34:43 +010026
27extern struct proc_dir_entry *proc_create_data(const char *, umode_t,
28 struct proc_dir_entry *,
29 const struct file_operations *,
30 void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Alexey Dobriyan855d9762017-09-08 16:13:38 -070032struct 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 +010033extern void proc_set_size(struct proc_dir_entry *, loff_t);
34extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
David Howellsc30480b2013-04-12 18:03:36 +010035extern void *PDE_DATA(const struct inode *);
David Howells4a520d22013-04-12 14:06:01 +010036extern void *proc_get_parent_data(const struct inode *);
David Howells59d80532013-04-11 13:34:43 +010037extern void proc_remove(struct proc_dir_entry *);
38extern void remove_proc_entry(const char *, struct proc_dir_entry *);
39extern int remove_proc_subtree(const char *, struct proc_dir_entry *);
40
41#else /* CONFIG_PROC_FS */
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
Andrew Morton647f0102014-06-04 16:12:20 -070043static inline void proc_root_init(void)
44{
45}
46
Pavel Emelyanov60347f62007-10-18 23:40:03 -070047static inline void proc_flush_task(struct task_struct *task)
48{
49}
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Linus Torvalds1da177e2005-04-16 15:20:36 -070051static inline struct proc_dir_entry *proc_symlink(const char *name,
David Howells59d80532013-04-11 13:34:43 +010052 struct proc_dir_entry *parent,const char *dest) { return NULL;}
Linus Torvalds1da177e2005-04-16 15:20:36 -070053static inline struct proc_dir_entry *proc_mkdir(const char *name,
54 struct proc_dir_entry *parent) {return NULL;}
Seth Forsheef97df702016-11-14 11:12:56 +000055static inline struct proc_dir_entry *proc_create_mount_point(const char *name) { return NULL; }
David Howells270b5ac2013-04-12 02:48:30 +010056static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
57 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
Randy Dunlapf12a20fc2011-05-17 15:44:12 -070058static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
Al Virod161a132011-07-24 03:36:29 -040059 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
David Howells59d80532013-04-11 13:34:43 +010060#define proc_create(name, mode, parent, proc_fops) ({NULL;})
61#define proc_create_data(name, mode, parent, proc_fops, data) ({NULL;})
62
David Howells271a15e2013-04-12 00:38:51 +010063static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
64static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
David Howellsc30480b2013-04-12 18:03:36 +010065static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;}
David Howells59d80532013-04-11 13:34:43 +010066static inline void *proc_get_parent_data(const struct inode *inode) { BUG(); return NULL; }
67
68static inline void proc_remove(struct proc_dir_entry *de) {}
69#define remove_proc_entry(name, parent) do {} while (0)
70static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Linus Torvalds1da177e2005-04-16 15:20:36 -070072#endif /* CONFIG_PROC_FS */
73
Jeff Laytonf7790022014-09-12 16:40:20 -040074struct net;
75
David Howells270b5ac2013-04-12 02:48:30 +010076static inline struct proc_dir_entry *proc_net_mkdir(
77 struct net *net, const char *name, struct proc_dir_entry *parent)
78{
79 return proc_mkdir_data(name, 0, parent, net);
80}
81
Andrey Vaginc62cce22016-10-24 18:29:13 -070082struct ns_common;
83int open_related_ns(struct ns_common *ns,
84 struct ns_common *(*get_ns)(struct ns_common *ns));
85
Linus Torvalds1da177e2005-04-16 15:20:36 -070086#endif /* _LINUX_PROC_FS_H */