aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/debugfs.h
diff options
context:
space:
mode:
authorNicolai Stange <nicstange@gmail.com>2017-10-30 19:15:47 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-11-07 14:25:02 -0500
commit7c8d469877b16d2c1cecf101a0abb7b218db85bc (patch)
treea6d2637db3d3d721e0079fd70e9f95ede449b942 /include/linux/debugfs.h
parent2ec16150179888b81717d1d3ce84e634f4736af2 (diff)
debugfs: add support for more elaborate ->d_fsdata
Currently, the user provided fops, "real_fops", are stored directly into ->d_fsdata. In order to be able to store more per-file state and thus prepare for more granular file removal protection, wrap the real_fops into a dynamically allocated container struct, debugfs_fsdata. A struct debugfs_fsdata gets allocated at file creation and freed from the newly intoduced ->d_release(). Finally, move the implementation of debugfs_real_fops() out of the public debugfs header such that struct debugfs_fsdata's declaration can be kept private. Signed-off-by: Nicolai Stange <nicstange@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/debugfs.h')
-rw-r--r--include/linux/debugfs.h20
1 files changed, 3 insertions, 17 deletions
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h
index b93efc8feecd..cbee5f4a02a3 100644
--- a/include/linux/debugfs.h
+++ b/include/linux/debugfs.h
@@ -45,23 +45,6 @@ extern struct dentry *arch_debugfs_dir;
45 45
46extern struct srcu_struct debugfs_srcu; 46extern struct srcu_struct debugfs_srcu;
47 47
48/**
49 * debugfs_real_fops - getter for the real file operation
50 * @filp: a pointer to a struct file
51 *
52 * Must only be called under the protection established by
53 * debugfs_use_file_start().
54 */
55static inline const struct file_operations *debugfs_real_fops(const struct file *filp)
56 __must_hold(&debugfs_srcu)
57{
58 /*
59 * Neither the pointer to the struct file_operations, nor its
60 * contents ever change -- srcu_dereference() is not needed here.
61 */
62 return filp->f_path.dentry->d_fsdata;
63}
64
65#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \ 48#define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \
66static int __fops ## _open(struct inode *inode, struct file *file) \ 49static int __fops ## _open(struct inode *inode, struct file *file) \
67{ \ 50{ \
@@ -112,6 +95,9 @@ int debugfs_use_file_start(const struct dentry *dentry, int *srcu_idx)
112 95
113void debugfs_use_file_finish(int srcu_idx) __releases(&debugfs_srcu); 96void debugfs_use_file_finish(int srcu_idx) __releases(&debugfs_srcu);
114 97
98const struct file_operations *debugfs_real_fops(const struct file *filp)
99 __must_hold(&debugfs_srcu);
100
115ssize_t debugfs_attr_read(struct file *file, char __user *buf, 101ssize_t debugfs_attr_read(struct file *file, char __user *buf,
116 size_t len, loff_t *ppos); 102 size_t len, loff_t *ppos);
117ssize_t debugfs_attr_write(struct file *file, const char __user *buf, 103ssize_t debugfs_attr_write(struct file *file, const char __user *buf,