All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Zielinski <grim@undead.cc>
To: linux-kernel@vger.kernel.org
Subject: [RFC] sysfs rename dir problem
Date: Sun, 23 May 2004 15:50:43 -0400	[thread overview]
Message-ID: <40B10093.6030703@undead.cc> (raw)

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

                 reply	other threads:[~2004-05-23 19:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40B10093.6030703@undead.cc \
    --to=grim@undead.cc \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.