public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] sysfs rename dir problem
@ 2004-05-23 19:50 John Zielinski
  0 siblings, 0 replies; only message in thread
From: John Zielinski @ 2004-05-23 19:50 UTC (permalink / raw)
  To: linux-kernel

[-- 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);	
 }
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-05-23 19:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-23 19:50 [RFC] sysfs rename dir problem John Zielinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox