diff options
author | Tejun Heo <tj@kernel.org> | 2013-11-28 14:54:22 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-29 17:35:05 -0800 |
commit | 471bd7b78bd56c580e91e00a0f656ca922ab3b3c (patch) | |
tree | 20a7f9783fdd21f547fc75404b2cf702d8d4df27 /fs/sysfs/file.c | |
parent | f6acf8bb6a40ba3bfcf542e4c4c9e8968c8cb57a (diff) | |
download | linux-471bd7b78bd56c580e91e00a0f656ca922ab3b3c.tar.gz linux-471bd7b78bd56c580e91e00a0f656ca922ab3b3c.tar.bz2 linux-471bd7b78bd56c580e91e00a0f656ca922ab3b3c.zip |
sysfs, kernfs: add sysfs_dirent->s_attr.size
sysfs sets the size of regular files unconditionally at PAGE_SIZE and
takes the size of bin files from bin_attribute. The latter is a
pretty bad interface which forces bin_attribute users to create a
separate copy of bin_attribute for each instance of the file -
e.g. pci resource files.
Add sysfs_dirent->s_attr.size so that the size can be specified
separately. This unifies inode init paths of ATTR and BIN_ATTR
identical and allows for generic size handling for kernfs.
Unfortunately, this grows the size of sysfs_dirent by sizeof(loff_t).
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/sysfs/file.c')
-rw-r--r-- | fs/sysfs/file.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index cbebc335af8c..0b0cec8e9d8f 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c @@ -923,6 +923,7 @@ int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd, const struct kernfs_ops *ops; struct sysfs_addrm_cxt acxt; struct sysfs_dirent *sd; + loff_t size; int rc; if (type == SYSFS_KOBJ_ATTR) { @@ -943,6 +944,8 @@ int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd, ops = &sysfs_file_kfops_wo; else ops = &sysfs_file_kfops_empty; + + size = PAGE_SIZE; } else { struct bin_attribute *battr = (void *)attr; @@ -954,6 +957,8 @@ int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd, ops = &sysfs_bin_kfops_wo; else ops = &sysfs_file_kfops_empty; + + size = battr->size; } sd = sysfs_new_dirent(attr->name, mode, type); @@ -961,6 +966,7 @@ int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd, return -ENOMEM; sd->s_attr.ops = ops; + sd->s_attr.size = size; sd->s_ns = ns; sd->priv = (void *)attr; sysfs_dirent_init_lockdep(sd); |