diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2002-04-09 15:14:34 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-26 00:08:36 -0400 |
commit | ceeee1fb2897651b434547eb26d93e6d2ff5a1a5 (patch) | |
tree | d841561babe6538e463069870166524c58e25014 /fs | |
parent | 6468b3afa7bcd9b0abc5997e5330d78f0bb6626a (diff) |
SYSFS: allow sysfs_create_link to create symlinks in the root of sysfs
This is needed to make the compatible link for /sys/block in the future.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/sysfs/symlink.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c index d2eac3ceed5f..f50e3cc2ded8 100644 --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c | |||
@@ -3,6 +3,7 @@ | |||
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <linux/fs.h> | 5 | #include <linux/fs.h> |
6 | #include <linux/mount.h> | ||
6 | #include <linux/module.h> | 7 | #include <linux/module.h> |
7 | #include <linux/kobject.h> | 8 | #include <linux/kobject.h> |
8 | #include <linux/namei.h> | 9 | #include <linux/namei.h> |
@@ -82,10 +83,19 @@ exit1: | |||
82 | */ | 83 | */ |
83 | int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name) | 84 | int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name) |
84 | { | 85 | { |
85 | struct dentry * dentry = kobj->dentry; | 86 | struct dentry *dentry = NULL; |
86 | int error = -EEXIST; | 87 | int error = -EEXIST; |
87 | 88 | ||
88 | BUG_ON(!kobj || !kobj->dentry || !name); | 89 | BUG_ON(!name); |
90 | |||
91 | if (!kobj) { | ||
92 | if (sysfs_mount && sysfs_mount->mnt_sb) | ||
93 | dentry = sysfs_mount->mnt_sb->s_root; | ||
94 | } else | ||
95 | dentry = kobj->dentry; | ||
96 | |||
97 | if (!dentry) | ||
98 | return -EFAULT; | ||
89 | 99 | ||
90 | mutex_lock(&dentry->d_inode->i_mutex); | 100 | mutex_lock(&dentry->d_inode->i_mutex); |
91 | if (!sysfs_dirent_exist(dentry->d_fsdata, name)) | 101 | if (!sysfs_dirent_exist(dentry->d_fsdata, name)) |