summaryrefslogtreecommitdiffstats
path: root/fs/sysfs/symlink.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2002-04-09 12:14:34 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2006-09-25 21:08:36 -0700
commitceeee1fb2897651b434547eb26d93e6d2ff5a1a5 (patch)
treed841561babe6538e463069870166524c58e25014 /fs/sysfs/symlink.c
parent6468b3afa7bcd9b0abc5997e5330d78f0bb6626a (diff)
downloadtalos-obmc-linux-ceeee1fb2897651b434547eb26d93e6d2ff5a1a5.tar.gz
talos-obmc-linux-ceeee1fb2897651b434547eb26d93e6d2ff5a1a5.zip
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/sysfs/symlink.c')
-rw-r--r--fs/sysfs/symlink.c14
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 @@
*/
#include <linux/fs.h>
+#include <linux/mount.h>
#include <linux/module.h>
#include <linux/kobject.h>
#include <linux/namei.h>
@@ -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))
OpenPOWER on IntegriCloud