Re: linux-2.6.23-git3: Many sysfs-related warnings in dmesg

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Greg KH
Date: Wednesday, October 24, 2007 - 4:52 pm

On Wed, Oct 24, 2007 at 04:43:48PM -0700, Greg KH wrote:

Can someone try this patch, and see what happens when they try to rename
an object to something that is already existing?

thanks,

greg k-h


---
 lib/kobject.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -366,6 +366,19 @@ int kobject_rename(struct kobject * kobj
 	if (!kobj->parent)
 		return -EINVAL;
 
+	/* see if this name is already in use */
+	if (kobj->kset) {
+		struct kobject *temp_kobj;
+		temp_kobj = kset_find_obj(kobj->kset, new_name);
+		if (temp_kobj) {
+			printk(KERN_WARNING "kobject '%s' can not be renamed "
+			       "to '%s' as '%s' is already in existance.\n",
+			       kobject_name(kobj), new_name, new_name);
+			kobject_put(temp_kobj);
+			return -EINVAL;
+		}
+	}
+
 	devpath = kobject_get_path(kobj, GFP_KERNEL);
 	if (!devpath) {
 		error = -ENOMEM;
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
linux-2.6.23-git3: Many sysfs-related warnings in dmesg, Rafael J. Wysocki, (Sat Oct 13, 12:26 pm)
Re: linux-2.6.23-git3: Many sysfs-related warnings in dmesg, Rafael J. Wysocki, (Tue Oct 16, 1:04 pm)
Re: linux-2.6.23-git3: Many sysfs-related warnings in dmesg, Rafael J. Wysocki, (Tue Oct 16, 2:13 pm)
Re: linux-2.6.23-git3: Many sysfs-related warnings in dmesg, Rafael J. Wysocki, (Tue Oct 16, 4:58 pm)
Re: linux-2.6.23-git3: Many sysfs-related warnings in dmesg, Rafael J. Wysocki, (Wed Oct 17, 10:35 am)
Re: linux-2.6.23-git3: Many sysfs-related warnings in dmesg, Greg KH, (Wed Oct 24, 4:52 pm)