fs/debugfs: add get/set for atomic_long types
PATCH 1/1 fs/debugfs: add get/set for atomic_long types
debugfs currently can not create attributes that set/get atomic_long_t values.
This patch adds support for this through a newdebugfs_create_atomic_long_t() function.
--- fs/debugfs/file.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/debugfs.h | 2 ++ 2 files changed, 47 insertions(+)
fs/debugfs/file.c +45 -0
@@ -446,6 +446,51 @@ struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode, }EXPORT_SYMBOL_GPL (debugfs_create_atomic_t); +static int debugfs_atomic_long_t_set (void *data,u64 val) +{ +atomic_long_set ((atomic_long_t *)data, val); +return 0 ; +} +static int debugfs_atomic_long_t_get (void *data,u64 *val) +{ + *val =atomic_long_read ((atomic_long_t *)data); +return 0 ; +} +DEFINE_SIMPLE_ATTRIBUTE (fops_atomic_long_t, debugfs_atomic_long_t_get, + debugfs_atomic_long_t_set,"%lld\n" ); +DEFINE_SIMPLE_ATTRIBUTE (fops_atomic_long_t_ro, debugfs_atomic_long_t_get, +NULL ,"%lld\n" ); +DEFINE_SIMPLE_ATTRIBUTE (fops_atomic_long_t_wo,NULL , debugfs_atomic_long_t_set, +"%lld\n" ); + +/** +* debugfs_create_atomic_long_t - create a debugfs file that is used to read and +* write an atomic_long_t value +* @name: a pointer to a string containing the name of the file to create. +* @mode: the permission that the file should have +* @parent: a pointer to the parent dentry for this file. This should be a +* directory dentry if set. If this parameter is %NULL, then the +* file will be created in the root of the debugfs filesystem. +* @value: a pointer to the variable that the file should read to and write +* from. +*/ +struct dentry *debugfs_create_atomic_long_t (const char *name,umode_t mode, +struct dentry *parent,atomic_long_t *value) +{ +/* if there are no write bits set, make read only */ +if (!(mode &S_IWUGO )) +return debugfs_create_file (name, mode, parent, value, + &fops_atomic_long_t_ro); +/* if there are no read bits set, make write only */ +if (!(mode &S_IRUGO )) +return debugfs_create_file (name, mode, parent, value, + &fops_atomic_long_t_wo); + +return debugfs_create_file (name, mode, parent, value, + &fops_atomic_long_t); +} +EXPORT_SYMBOL_GPL (debugfs_create_atomic_long_t); +static ssize_t read_file_bool (struct file *file,char __user *user_buf,size_t count,loff_t *ppos) {
include/linux/debugfs.h +2 -0
@@ -81,6 +81,8 @@ struct dentry *debugfs_create_size_t(const char *name, umode_t mode, struct dentry *parent, size_t *value);struct dentry *debugfs_create_atomic_t (const char *name,umode_t mode,struct dentry *parent,atomic_t *value); +struct dentry *debugfs_create_atomic_long_t (const char *name,umode_t mode, +struct dentry *parent,atomic_long_t *value);struct dentry *debugfs_create_bool (const char *name,umode_t mode,struct dentry *parent,u32 *value);
Signature · 1 line
1.7.9.5
Greg KH
maintainerQuoted 11 lines · Ganesh Mahendran
debugfs currently can not create attributes that set/get
atomic_long_tvalues.This patch adds support for this through a new
debugfs_create_atomic_long_t()function.Signed-off-by Ganesh Mahendran <[email protected]>--- fs/debugfs/file.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/debugfs.h | 2 ++ 2 files changed, 47 insertions(+)
Do you have kernel code that depends on this?
It's the middle of the merge window, so this will have to wait until after 3.19-rc1, ok?
thanks,
greg k-h
Hello Greg:
2014-12-11 22:45 GMT+08:00 Greg KH <[email protected]>:
Quoted 7 lines · Ganesh Mahendran
Quoted 6 lines
debugfs currently can not create attributes that set/get
atomic_long_tvalues.This patch adds support for this through a new
debugfs_create_atomic_long_t()function.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Ganesh Mahendran <[email protected]>--- fs/debugfs/file.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/debugfs.h | 2 ++ 2 files changed, 47 insertions(+)Do you have kernel code that depends on this?
Currently there is no code that is depending on this.
I found there is not a debugfs API to get/set atomic_long_t when I was debuging mm/zsmalloc. So I sent this patch.
Quoted 3 lines
It's the middle of the merge window, so this will have to wait until after 3.19-rc1, ok?
It is OK. It is not an urgent patch.
Thanks so much!
Quoted 4 lines
thanks,
greg k-h
Greg KH
maintainerQuoted 11 lines · Ganesh Mahendran
debugfs currently can not create attributes that set/get
atomic_long_tvalues.This patch adds support for this through a new
debugfs_create_atomic_long_t()function.Signed-off-by Ganesh Mahendran <[email protected]>--- fs/debugfs/file.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/debugfs.h | 2 ++ 2 files changed, 47 insertions(+)
I want to see the patch that uses this before I can accept this.
thanks,
greg k-h