[RFC] sysfs rename dir problem

John Zielinski
2004-05-23T19:54:17Z

[-- Attachment #1: Type: text/plain, Size: 212 bytes --]

In the sysfs_rename_dir function if something goes wrong then the
directory name would no longer match the internal kobj name. Here's a
patch I made to fix that but I'm not sure if it's 100% correct.

John

[-- Attachment #2: sysfs_rename_fix --]
[-- Type: text/plain, Size: 585 bytes --]

diff -urNX dontdiff linux-2.6.6/fs/sysfs/dir.c linux/fs/sysfs/dir.c
--- linux-2.6.6/fs/sysfs/dir.c 2004-05-09 22:32:28.000000000 -0400
+++ linux/fs/sysfs/dir.c 2004-05-23 15:16:40.000000000 -0400
@@ -169,8 +169,14 @@
down(&parent->d_inode->i_sem);

new_dentry = sysfs_get_dentry(parent, new_name);
- d_move(kobj->dentry, new_dentry);
- kobject_set_name(kobj,new_name);
+ if (!IS_ERR(new_dentry)) {
+ if (kobject_set_name(kobj,new_name))
+ d_move(kobj->dentry, new_dentry);
+ else {
+ d_delete(new_dentry);
+ dput(new_dentry);
+ }
+ }
up(&parent->d_inode->i_sem);
}