X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=fs%2Fsysfs%2Fsymlink.c;h=7b9c5bfde920fb1ea30af8f81d4313f84bf981ec;hb=dd397a6d1ae125686d97a20f983778c331093206;hp=d2eac3ceed5f31cf9735a68ecc69dc4a6c6771ed;hpb=ca94f26d2b2ee8ad76be617b35f846444fedc07b;p=linux-2.6-omap-h63xx.git diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c index d2eac3ceed5..7b9c5bfde92 100644 --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c @@ -3,9 +3,11 @@ */ #include +#include #include #include #include +#include #include "sysfs.h" @@ -82,10 +84,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)) @@ -170,7 +181,7 @@ static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *co free_page((unsigned long)page); } -struct inode_operations sysfs_symlink_inode_operations = { +const struct inode_operations sysfs_symlink_inode_operations = { .readlink = generic_readlink, .follow_link = sysfs_follow_link, .put_link = sysfs_put_link,