const struct kernfs_ops *ops;
struct sysfs_addrm_cxt acxt;
struct sysfs_dirent *sd;
+ loff_t size;
int rc;
if (type == SYSFS_KOBJ_ATTR) {
ops = &sysfs_file_kfops_wo;
else
ops = &sysfs_file_kfops_empty;
+
+ size = PAGE_SIZE;
} else {
struct bin_attribute *battr = (void *)attr;
ops = &sysfs_bin_kfops_wo;
else
ops = &sysfs_file_kfops_empty;
+
+ size = battr->size;
}
sd = sysfs_new_dirent(attr->name, mode, type);
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);
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;
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:
struct sysfs_elem_attr {
const struct kernfs_ops *ops;
struct sysfs_open_dirent *open;
+ loff_t size;
};
struct sysfs_inode_attrs {