From: Greg Kroah-Hartman Date: Tue, 9 Apr 2002 19:14:34 +0000 (-0700) Subject: SYSFS: allow sysfs_create_link to create symlinks in the root of sysfs X-Git-Tag: v2.6.19-rc1~1078^2~39 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ceeee1fb2897651b434547eb26d93e6d2ff5a1a5;p=linux-2.6 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 --- diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c index d2eac3ceed..f50e3cc2de 100644 --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c @@ -3,6 +3,7 @@ */ #include +#include #include #include #include @@ -82,10 +83,19 @@ exit1: */ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name) { - struct dentry * dentry = kobj->dentry; + struct dentry *dentry = NULL; int error = -EEXIST; - BUG_ON(!kobj || !kobj->dentry || !name); + BUG_ON(!name); + + if (!kobj) { + if (sysfs_mount && sysfs_mount->mnt_sb) + dentry = sysfs_mount->mnt_sb->s_root; + } else + dentry = kobj->dentry; + + if (!dentry) + return -EFAULT; mutex_lock(&dentry->d_inode->i_mutex); if (!sysfs_dirent_exist(dentry->d_fsdata, name))