path: root/include/linux/proc_fs.h
diff options
authorMuchun Song <>2022-01-21 22:14:20 -0800
committerLinus Torvalds <>2022-01-22 08:33:37 +0200
commit6dfbbae14a7b961f41d80a106e1ab60e86d061c5 (patch)
tree487d7ecefb4ad5b67b697fd7f99567a795c23455 /include/linux/proc_fs.h
parenta37265995c867a4e413761d846cef0445b08d6d5 (diff)
fs: proc: store PDE()->data into inode->i_private
PDE_DATA(inode) is introduced to get user private data and hide the layout of struct proc_dir_entry. The inode->i_private is used to do the same thing as well. Save a copy of user private data to inode-> i_private when proc inode is allocated. This means the user also can get their private data by inode->i_private. Introduce pde_data() to wrap inode->i_private so that we can remove PDE_DATA() from fs/proc/generic.c and make PTE_DATE() as a wrapper of pde_data(). It will be easier if we decide to remove PDE_DATE() in the future. Link: Signed-off-by: Muchun Song <> Acked-by: Christian Brauner <> Cc: Alexey Dobriyan <> Cc: Alexey Gladkov <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'include/linux/proc_fs.h')
1 files changed, 12 insertions, 1 deletions
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 01b9268451a8..b6e7005cc1b2 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -110,7 +110,18 @@ extern struct proc_dir_entry *proc_create_data(const char *, umode_t,
struct proc_dir_entry *proc_create(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct proc_ops *proc_ops);
extern void proc_set_size(struct proc_dir_entry *, loff_t);
extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
-extern void *PDE_DATA(const struct inode *);
+ * Obtain the private data passed by user through proc_create_data() or
+ * related.
+ */
+static inline void *pde_data(const struct inode *inode)
+ return inode->i_private;
+#define PDE_DATA(i) pde_data(i)
extern void *proc_get_parent_data(const struct inode *);
extern void proc_remove(struct proc_dir_entry *);
extern void remove_proc_entry(const char *, struct proc_dir_entry *);