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>
This commit is contained in:
parent
f6acf8bb6a
commit
471bd7b78b
3 changed files with 8 additions and 7 deletions
|
@ -254,8 +254,6 @@ int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
|
|||
|
||||
static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
|
||||
{
|
||||
struct bin_attribute *bin_attr;
|
||||
|
||||
inode->i_private = sysfs_get(sd);
|
||||
inode->i_mapping->a_ops = &sysfs_aops;
|
||||
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)
|
|||
inode->i_fop = &sysfs_dir_operations;
|
||||
break;
|
||||
case SYSFS_KOBJ_ATTR:
|
||||
inode->i_size = PAGE_SIZE;
|
||||
inode->i_fop = &kernfs_file_operations;
|
||||
break;
|
||||
case SYSFS_KOBJ_BIN_ATTR:
|
||||
bin_attr = sd->priv;
|
||||
inode->i_size = bin_attr->size;
|
||||
inode->i_size = sd->s_attr.size;
|
||||
inode->i_fop = &kernfs_file_operations;
|
||||
break;
|
||||
case SYSFS_KOBJ_LINK:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue