summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-10-24 15:49:07 (GMT)
committerPawel Osmialowski <p.osmialowsk@mcdsrvbld02.digital.local>2015-03-27 13:37:26 (GMT)
commitd8bb3a9808c30656b62e193ef443adb85dc6603d (patch)
tree9d655dcc8884db32421b66ecff02e232020a74cb
parent2338f3cf7b0b08fde3877a3092ccebaf05551a84 (diff)
downloadlinux-3.10-d8bb3a9808c30656b62e193ef443adb85dc6603d.zip
linux-3.10-d8bb3a9808c30656b62e193ef443adb85dc6603d.tar.gz
linux-3.10-d8bb3a9808c30656b62e193ef443adb85dc6603d.tar.bz2
sysfs: merge sysfs_elem_bin_attr into sysfs_elem_attr
3124eb1679 ("sysfs: merge regular and bin file handling") folded bin file handling into regular file handling. Among other things, bin file now shares the same open path including sysfs_open_dirent association using sysfs_dirent->s_attr.open. This is buggy because ->s_bin_attr lives in the same union and doesn't have the field. This bug doesn't trigger because sysfs_elem_bin_attr doesn't have an active field at the conflicting position. It does have a field "buffers" but it isn't used anymore. This patch collapses sysfs_elem_bin_attr into sysfs_elem_attr so that the bin_attr is accessed through ->s_attr.bin_attr which lives with ->s_attr.attr in an anonymous union. The code paths already assume bin_attr contains attr as the first element, so this doesn't add any more assumptions while making it explicit that the two types are handled together. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/sysfs/file.c8
-rw-r--r--fs/sysfs/inode.c2
-rw-r--r--fs/sysfs/sysfs.h11
3 files changed, 9 insertions, 12 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 6f05e3e..9dfce06 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -155,7 +155,7 @@ static ssize_t sysfs_bin_read(struct file *file, char __user *userbuf,
size_t bytes, loff_t *off)
{
struct sysfs_open_file *of = sysfs_of(file);
- struct bin_attribute *battr = of->sd->s_bin_attr.bin_attr;
+ struct bin_attribute *battr = of->sd->s_attr.bin_attr;
struct kobject *kobj = of->sd->s_parent->s_dir.kobj;
int size = file_inode(file)->i_size;
int count = min_t(size_t, bytes, PAGE_SIZE);
@@ -237,7 +237,7 @@ static int flush_write_buffer(struct sysfs_open_file *of, char *buf, loff_t off,
}
if (sysfs_is_bin(of->sd)) {
- struct bin_attribute *battr = of->sd->s_bin_attr.bin_attr;
+ struct bin_attribute *battr = of->sd->s_attr.bin_attr;
rc = -EIO;
if (battr->write)
@@ -468,7 +468,7 @@ static const struct vm_operations_struct sysfs_bin_vm_ops = {
static int sysfs_bin_mmap(struct file *file, struct vm_area_struct *vma)
{
struct sysfs_open_file *of = sysfs_of(file);
- struct bin_attribute *battr = of->sd->s_bin_attr.bin_attr;
+ struct bin_attribute *battr = of->sd->s_attr.bin_attr;
struct kobject *kobj = of->sd->s_parent->s_dir.kobj;
int rc;
@@ -620,7 +620,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
return -ENODEV;
if (sysfs_is_bin(attr_sd)) {
- struct bin_attribute *battr = attr_sd->s_bin_attr.bin_attr;
+ struct bin_attribute *battr = attr_sd->s_attr.bin_attr;
has_read = battr->read || battr->mmap;
has_write = battr->write || battr->mmap;
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index edef1f4..5f7e2af 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -275,7 +275,7 @@ static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
inode->i_fop = &sysfs_file_operations;
break;
case SYSFS_KOBJ_BIN_ATTR:
- bin_attr = sd->s_bin_attr.bin_attr;
+ bin_attr = sd->s_attr.bin_attr;
inode->i_size = bin_attr->size;
inode->i_fop = &sysfs_bin_operations;
break;
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 3875086..2cb9ee6 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -29,15 +29,13 @@ struct sysfs_elem_symlink {
};
struct sysfs_elem_attr {
- struct attribute *attr;
+ union {
+ struct attribute *attr;
+ struct bin_attribute *bin_attr;
+ };
struct sysfs_open_dirent *open;
};
-struct sysfs_elem_bin_attr {
- struct bin_attribute *bin_attr;
- struct hlist_head buffers;
-};
-
struct sysfs_inode_attrs {
struct iattr ia_iattr;
void *ia_secdata;
@@ -74,7 +72,6 @@ struct sysfs_dirent {
struct sysfs_elem_dir s_dir;
struct sysfs_elem_symlink s_symlink;
struct sysfs_elem_attr s_attr;
- struct sysfs_elem_bin_attr s_bin_attr;
};
unsigned short s_flags;