aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/file.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-11-28 14:54:22 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-11-29 20:35:05 -0500
commit471bd7b78bd56c580e91e00a0f656ca922ab3b3c (patch)
tree20a7f9783fdd21f547fc75404b2cf702d8d4df27 /fs/sysfs/file.c
parentf6acf8bb6a40ba3bfcf542e4c4c9e8968c8cb57a (diff)
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.c6
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,
923 const struct kernfs_ops *ops; 923 const struct kernfs_ops *ops;
924 struct sysfs_addrm_cxt acxt; 924 struct sysfs_addrm_cxt acxt;
925 struct sysfs_dirent *sd; 925 struct sysfs_dirent *sd;
926 loff_t size;
926 int rc; 927 int rc;
927 928
928 if (type == SYSFS_KOBJ_ATTR) { 929 if (type == SYSFS_KOBJ_ATTR) {
@@ -943,6 +944,8 @@ int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd,
943 ops = &sysfs_file_kfops_wo; 944 ops = &sysfs_file_kfops_wo;
944 else 945 else
945 ops = &sysfs_file_kfops_empty; 946 ops = &sysfs_file_kfops_empty;
947
948 size = PAGE_SIZE;
946 } else { 949 } else {
947 struct bin_attribute *battr = (void *)attr; 950 struct bin_attribute *battr = (void *)attr;
948 951
@@ -954,6 +957,8 @@ int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd,
954 ops = &sysfs_bin_kfops_wo; 957 ops = &sysfs_bin_kfops_wo;
955 else 958 else
956 ops = &sysfs_file_kfops_empty; 959 ops = &sysfs_file_kfops_empty;
960
961 size = battr->size;
957 } 962 }
958 963
959 sd = sysfs_new_dirent(attr->name, mode, type); 964 sd = sysfs_new_dirent(attr->name, mode, type);
@@ -961,6 +966,7 @@ int sysfs_add_file_mode_ns(struct sysfs_dirent *dir_sd,
961 return -ENOMEM; 966 return -ENOMEM;
962 967
963 sd->s_attr.ops = ops; 968 sd->s_attr.ops = ops;
969 sd->s_attr.size = size;
964 sd->s_ns = ns; 970 sd->s_ns = ns;
965 sd->priv = (void *)attr; 971 sd->priv = (void *)attr;
966 sysfs_dirent_init_lockdep(sd); 972 sysfs_dirent_init_lockdep(sd);