|
@@ -15,6 +15,7 @@
|
|
#include "sysfs.h"
|
|
#include "sysfs.h"
|
|
|
|
|
|
DEFINE_MUTEX(sysfs_mutex);
|
|
DEFINE_MUTEX(sysfs_mutex);
|
|
|
|
+DEFINE_MUTEX(sysfs_rename_mutex);
|
|
spinlock_t sysfs_assoc_lock = SPIN_LOCK_UNLOCKED;
|
|
spinlock_t sysfs_assoc_lock = SPIN_LOCK_UNLOCKED;
|
|
|
|
|
|
static spinlock_t sysfs_ino_lock = SPIN_LOCK_UNLOCKED;
|
|
static spinlock_t sysfs_ino_lock = SPIN_LOCK_UNLOCKED;
|
|
@@ -82,7 +83,7 @@ static void sysfs_unlink_sibling(struct sysfs_dirent *sd)
|
|
* down from there looking up dentry for each step.
|
|
* down from there looking up dentry for each step.
|
|
*
|
|
*
|
|
* LOCKING:
|
|
* LOCKING:
|
|
- * Kernel thread context (may sleep)
|
|
|
|
|
|
+ * mutex_lock(sysfs_rename_mutex)
|
|
*
|
|
*
|
|
* RETURNS:
|
|
* RETURNS:
|
|
* Pointer to found dentry on success, ERR_PTR() value on error.
|
|
* Pointer to found dentry on success, ERR_PTR() value on error.
|
|
@@ -858,6 +859,8 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
|
|
const char *dup_name = NULL;
|
|
const char *dup_name = NULL;
|
|
int error;
|
|
int error;
|
|
|
|
|
|
|
|
+ mutex_lock(&sysfs_rename_mutex);
|
|
|
|
+
|
|
/* get the original dentry */
|
|
/* get the original dentry */
|
|
sd = kobj->sd;
|
|
sd = kobj->sd;
|
|
old_dentry = sysfs_get_dentry(sd);
|
|
old_dentry = sysfs_get_dentry(sd);
|
|
@@ -915,6 +918,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
|
|
kfree(dup_name);
|
|
kfree(dup_name);
|
|
dput(old_dentry);
|
|
dput(old_dentry);
|
|
dput(new_dentry);
|
|
dput(new_dentry);
|
|
|
|
+ mutex_unlock(&sysfs_rename_mutex);
|
|
return error;
|
|
return error;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -926,6 +930,7 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj)
|
|
struct dentry *old_dentry = NULL, *new_dentry = NULL;
|
|
struct dentry *old_dentry = NULL, *new_dentry = NULL;
|
|
int error;
|
|
int error;
|
|
|
|
|
|
|
|
+ mutex_lock(&sysfs_rename_mutex);
|
|
BUG_ON(!sd->s_parent);
|
|
BUG_ON(!sd->s_parent);
|
|
new_parent_sd = new_parent_kobj->sd ? new_parent_kobj->sd : &sysfs_root;
|
|
new_parent_sd = new_parent_kobj->sd ? new_parent_kobj->sd : &sysfs_root;
|
|
|
|
|
|
@@ -982,6 +987,7 @@ again:
|
|
dput(new_parent);
|
|
dput(new_parent);
|
|
dput(old_dentry);
|
|
dput(old_dentry);
|
|
dput(new_dentry);
|
|
dput(new_dentry);
|
|
|
|
+ mutex_unlock(&sysfs_rename_mutex);
|
|
return error;
|
|
return error;
|
|
}
|
|
}
|
|
|
|
|