proc_fs.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * The proc filesystem constants/structures
  4. */
  5. #ifndef _LINUX_PROC_FS_H
  6. #define _LINUX_PROC_FS_H
  7. #include <linux/types.h>
  8. #include <linux/fs.h>
  9. struct proc_dir_entry;
  10. struct seq_operations;
  11. #ifdef CONFIG_PROC_FS
  12. extern void proc_root_init(void);
  13. extern void proc_flush_task(struct task_struct *);
  14. extern struct proc_dir_entry *proc_symlink(const char *,
  15. struct proc_dir_entry *, const char *);
  16. extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *);
  17. extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t,
  18. struct proc_dir_entry *, void *);
  19. extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t,
  20. struct proc_dir_entry *);
  21. struct proc_dir_entry *proc_create_mount_point(const char *name);
  22. struct proc_dir_entry *proc_create_seq_data(const char *name, umode_t mode,
  23. struct proc_dir_entry *parent, const struct seq_operations *ops,
  24. void *data);
  25. #define proc_create_seq(name, mode, parent, ops) \
  26. proc_create_seq_data(name, mode, parent, ops, NULL)
  27. extern struct proc_dir_entry *proc_create_data(const char *, umode_t,
  28. struct proc_dir_entry *,
  29. const struct file_operations *,
  30. void *);
  31. struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops);
  32. extern void proc_set_size(struct proc_dir_entry *, loff_t);
  33. extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
  34. extern void *PDE_DATA(const struct inode *);
  35. extern void *proc_get_parent_data(const struct inode *);
  36. extern void proc_remove(struct proc_dir_entry *);
  37. extern void remove_proc_entry(const char *, struct proc_dir_entry *);
  38. extern int remove_proc_subtree(const char *, struct proc_dir_entry *);
  39. #else /* CONFIG_PROC_FS */
  40. static inline void proc_root_init(void)
  41. {
  42. }
  43. static inline void proc_flush_task(struct task_struct *task)
  44. {
  45. }
  46. static inline struct proc_dir_entry *proc_symlink(const char *name,
  47. struct proc_dir_entry *parent,const char *dest) { return NULL;}
  48. static inline struct proc_dir_entry *proc_mkdir(const char *name,
  49. struct proc_dir_entry *parent) {return NULL;}
  50. static inline struct proc_dir_entry *proc_create_mount_point(const char *name) { return NULL; }
  51. static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
  52. umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
  53. static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
  54. umode_t mode, struct proc_dir_entry *parent) { return NULL; }
  55. #define proc_create_seq_data(name, mode, parent, ops, data) ({NULL;})
  56. #define proc_create_seq(name, mode, parent, ops) ({NULL;})
  57. #define proc_create(name, mode, parent, proc_fops) ({NULL;})
  58. #define proc_create_data(name, mode, parent, proc_fops, data) ({NULL;})
  59. static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
  60. static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
  61. static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;}
  62. static inline void *proc_get_parent_data(const struct inode *inode) { BUG(); return NULL; }
  63. static inline void proc_remove(struct proc_dir_entry *de) {}
  64. #define remove_proc_entry(name, parent) do {} while (0)
  65. static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) { return 0; }
  66. #endif /* CONFIG_PROC_FS */
  67. struct net;
  68. static inline struct proc_dir_entry *proc_net_mkdir(
  69. struct net *net, const char *name, struct proc_dir_entry *parent)
  70. {
  71. return proc_mkdir_data(name, 0, parent, net);
  72. }
  73. struct ns_common;
  74. int open_related_ns(struct ns_common *ns,
  75. struct ns_common *(*get_ns)(struct ns_common *ns));
  76. /* get the associated pid namespace for a file in procfs */
  77. static inline struct pid_namespace *proc_pid_ns(struct inode *inode)
  78. {
  79. return inode->i_sb->s_fs_info;
  80. }
  81. #endif /* _LINUX_PROC_FS_H */