git.samba.org
/
sfrench
/
cifs-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'gfar' of master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc...
[sfrench/cifs-2.6.git]
/
fs
/
sysfs
/
symlink.c
diff --git
a/fs/sysfs/symlink.c
b/fs/sysfs/symlink.c
index e38d6338a20ddbdb27b9f0a0bd32c105c257d453..7b9c5bfde920fb1ea30af8f81d4313f84bf981ec 100644
(file)
--- a/
fs/sysfs/symlink.c
+++ b/
fs/sysfs/symlink.c
@@
-3,9
+3,11
@@
*/
#include <linux/fs.h>
*/
#include <linux/fs.h>
+#include <linux/mount.h>
#include <linux/module.h>
#include <linux/kobject.h>
#include <linux/namei.h>
#include <linux/module.h>
#include <linux/kobject.h>
#include <linux/namei.h>
+#include <asm/semaphore.h>
#include "sysfs.h"
#include "sysfs.h"
@@
-66,6
+68,7
@@
static int sysfs_add_link(struct dentry * parent, const char * name, struct kobj
if (!error)
return 0;
if (!error)
return 0;
+ kobject_put(target);
kfree(sl->link_name);
exit2:
kfree(sl);
kfree(sl->link_name);
exit2:
kfree(sl);
@@
-81,13
+84,23
@@
exit1:
*/
int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name)
{
*/
int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name)
{
- struct dentry * dentry = kobj->dentry;
- int error = 0;
+ struct dentry *dentry = NULL;
+ int error = -EEXIST;
+
+ BUG_ON(!name);
+
+ if (!kobj) {
+ if (sysfs_mount && sysfs_mount->mnt_sb)
+ dentry = sysfs_mount->mnt_sb->s_root;
+ } else
+ dentry = kobj->dentry;
- BUG_ON(!kobj || !kobj->dentry || !name);
+ if (!dentry)
+ return -EFAULT;
mutex_lock(&dentry->d_inode->i_mutex);
mutex_lock(&dentry->d_inode->i_mutex);
- error = sysfs_add_link(dentry, name, target);
+ if (!sysfs_dirent_exist(dentry->d_fsdata, name))
+ error = sysfs_add_link(dentry, name, target);
mutex_unlock(&dentry->d_inode->i_mutex);
return error;
}
mutex_unlock(&dentry->d_inode->i_mutex);
return error;
}
@@
-168,7
+181,7
@@
static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *co
free_page((unsigned long)page);
}
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,
.readlink = generic_readlink,
.follow_link = sysfs_follow_link,
.put_link = sysfs_put_link,