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 20:35:05 -0500 |
commit | 471bd7b78bd56c580e91e00a0f656ca922ab3b3c (patch) | |
tree | 20a7f9783fdd21f547fc75404b2cf702d8d4df27 /fs/sysfs/inode.c | |
parent | f6acf8bb6a40ba3bfcf542e4c4c9e8968c8cb57a (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/inode.c')
-rw-r--r-- | fs/sysfs/inode.c | 8 |
1 files changed, 1 insertions, 7 deletions
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 | ||
255 | static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode) | 255 | static 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: |