diff options
author | Tejun Heo <htejun@gmail.com> | 2007-06-13 14:45:15 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-11 19:09:04 -0400 |
commit | 2b29ac252afff87b8465b064ca2d9740cf1f6e52 (patch) | |
tree | 9f4930db68ace50adc7c11feba12aafe34e2cdbe /fs/sysfs/sysfs.h | |
parent | aecdcedaab49ca40620dc7dd70f67ee7269a66c9 (diff) |
sysfs: reimplement symlink using sysfs_dirent tree
sysfs symlink is implemented by referencing dentry and kobject from
sysfs_dirent - symlink entry references kobject, dentry is used to
walk the tree. This complicates object lifetimes rules and is
dangerous - for example, there is no way to tell to which module the
target of a symlink belongs and referencing that kobject can make it
linger after the module is gone.
This patch reimplements symlink using only sysfs_dirent tree. sd for
a symlink points and holds reference to the target sysfs_dirent and
all walking is done using sysfs_dirent tree. Simpler and safer.
Please read the following message for more info.
http://article.gmane.org/gmane.linux.kernel/510293
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/sysfs.h')
-rw-r--r-- | fs/sysfs/sysfs.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h index 718e2e123fae..60717660ac55 100644 --- a/fs/sysfs/sysfs.h +++ b/fs/sysfs/sysfs.h | |||
@@ -3,7 +3,7 @@ struct sysfs_elem_dir { | |||
3 | }; | 3 | }; |
4 | 4 | ||
5 | struct sysfs_elem_symlink { | 5 | struct sysfs_elem_symlink { |
6 | struct kobject * target_kobj; | 6 | struct sysfs_dirent * target_sd; |
7 | }; | 7 | }; |
8 | 8 | ||
9 | struct sysfs_elem_attr { | 9 | struct sysfs_elem_attr { |
@@ -100,10 +100,11 @@ static inline struct kobject *sysfs_get_kobject(struct dentry *dentry) | |||
100 | spin_lock(&dcache_lock); | 100 | spin_lock(&dcache_lock); |
101 | if (!d_unhashed(dentry)) { | 101 | if (!d_unhashed(dentry)) { |
102 | struct sysfs_dirent * sd = dentry->d_fsdata; | 102 | struct sysfs_dirent * sd = dentry->d_fsdata; |
103 | |||
103 | if (sd->s_type & SYSFS_KOBJ_LINK) | 104 | if (sd->s_type & SYSFS_KOBJ_LINK) |
104 | kobj = kobject_get(sd->s_elem.symlink.target_kobj); | 105 | sd = sd->s_elem.symlink.target_sd; |
105 | else | 106 | |
106 | kobj = kobject_get(sd->s_elem.dir.kobj); | 107 | kobj = kobject_get(sd->s_elem.dir.kobj); |
107 | } | 108 | } |
108 | spin_unlock(&dcache_lock); | 109 | spin_unlock(&dcache_lock); |
109 | 110 | ||