summaryrefslogtreecommitdiffstats
path: root/fs/sysfs/sysfs.h
diff options
context:
space:
mode:
authorOliver Neukum2006-12-20 10:52:44 +0100
committerGreg Kroah-Hartman2007-02-07 19:37:13 +0100
commit94bebf4d1b8e7719f0f3944c037a21cfd99a4af7 (patch)
tree25c6ba1836e74f608b4e434b4f0f4d5c28b11de1 /fs/sysfs/sysfs.h
parentdriver core: Change function call order in device_bind_driver(). (diff)
downloadkernel-qcow2-linux-94bebf4d1b8e7719f0f3944c037a21cfd99a4af7.tar.gz
kernel-qcow2-linux-94bebf4d1b8e7719f0f3944c037a21cfd99a4af7.tar.xz
kernel-qcow2-linux-94bebf4d1b8e7719f0f3944c037a21cfd99a4af7.zip
Driver core: fix race in sysfs between sysfs_remove_file() and read()/write()
This patch prevents a race between IO and removing a file from sysfs. It introduces a list of sysfs_buffers associated with a file at the inode. Upon removal of a file the list is walked and the buffers marked orphaned. IO to orphaned buffers fails with -ENODEV. The driver can safely free associated data structures or be unloaded. Signed-off-by: Oliver Neukum <oliver@neukum.name> Acked-by: Maneesh Soni <maneesh@in.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/sysfs.h')
-rw-r--r--fs/sysfs/sysfs.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index bd7cec295dab..39c623fdc277 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -33,6 +33,22 @@ struct sysfs_symlink {
struct kobject * target_kobj;
};
+struct sysfs_buffer {
+ struct list_head associates;
+ size_t count;
+ loff_t pos;
+ char * page;
+ struct sysfs_ops * ops;
+ struct semaphore sem;
+ int orphaned;
+ int needs_read_fill;
+ int event;
+};
+
+struct sysfs_buffer_collection {
+ struct list_head associates;
+};
+
static inline struct kobject * to_kobj(struct dentry * dentry)
{
struct sysfs_dirent * sd = dentry->d_fsdata;