aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/sysfs')
-rw-r--r--fs/sysfs/file.c6
-rw-r--r--fs/sysfs/inode.c8
-rw-r--r--fs/sysfs/sysfs.h1
3 files changed, 8 insertions, 7 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);
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 4c463dabfc6a..037a8925f56e 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -254,8 +254,6 @@ int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
254 254
255static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode) 255static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
256{ 256{
257 struct bin_attribute *bin_attr;
258
259 inode->i_private = sysfs_get(sd); 257 inode->i_private = sysfs_get(sd);
260 inode->i_mapping->a_ops = &sysfs_aops; 258 inode->i_mapping->a_ops = &sysfs_aops;
261 inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info; 259 inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info;
@@ -271,12 +269,8 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
271 inode->i_fop = &sysfs_dir_operations; 269 inode->i_fop = &sysfs_dir_operations;
272 break; 270 break;
273 case SYSFS_KOBJ_ATTR: 271 case SYSFS_KOBJ_ATTR:
274 inode->i_size = PAGE_SIZE;
275 inode->i_fop = &kernfs_file_operations;
276 break;
277 case SYSFS_KOBJ_BIN_ATTR: 272 case SYSFS_KOBJ_BIN_ATTR:
278 bin_attr = sd->priv; 273 inode->i_size = sd->s_attr.size;
279 inode->i_size = bin_attr->size;
280 inode->i_fop = &kernfs_file_operations; 274 inode->i_fop = &kernfs_file_operations;
281 break; 275 break;
282 case SYSFS_KOBJ_LINK: 276 case SYSFS_KOBJ_LINK:
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index c05e0ddd0268..d40e85e8c2ee 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -29,6 +29,7 @@ struct sysfs_elem_symlink {
29struct sysfs_elem_attr { 29struct sysfs_elem_attr {
30 const struct kernfs_ops *ops; 30 const struct kernfs_ops *ops;
31 struct sysfs_open_dirent *open; 31 struct sysfs_open_dirent *open;
32 loff_t size;
32}; 33};
33 34
34struct sysfs_inode_attrs { 35struct sysfs_inode_attrs {