sysfs: spit a warning to users when they try to create a duplicate sysfs file

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Date: Thursday, September 13, 2007 - 7:41 pm

We want to let people know when we create a duplicate sysfs file, as
they need to fix up their code.


Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 fs/sysfs/dir.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -428,8 +428,12 @@ void sysfs_addrm_start(struct sysfs_addr
  */
 int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
 {
-	if (sysfs_find_dirent(acxt->parent_sd, sd->s_name))
+	if (sysfs_find_dirent(acxt->parent_sd, sd->s_name)) {
+		printk(KERN_WARNING, "sysfs: duplicate filename '%s' "
+		       "can not be created\n", sd->s_name);
+		WARN_ON(1);
 		return -EEXIST;
+	}
 
 	sd->s_parent = sysfs_get(acxt->parent_sd);
 
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC] Some driver core and kobject minor patches, Greg KH, (Thu Sep 13, 7:37 pm)
Re: [RFC] Some driver core and kobject minor patches, Cornelia Huck, (Fri Sep 14, 7:25 am)
kobject: remove the static array for the name, Greg KH, (Thu Sep 13, 7:44 pm)
cdev: remove unneeded setting of cdev names, Greg KH, (Thu Sep 13, 7:43 pm)
sysfs: spit a warning to users when they try to create a dup..., Greg KH, (Thu Sep 13, 7:41 pm)
Driver core: remove subsys_set_kset, Greg KH, (Thu Sep 13, 7:40 pm)
Driver core: remove subsys_put(), Greg KH, (Thu Sep 13, 7:40 pm)
Driver core: remove subsys_get(), Greg KH, (Thu Sep 13, 7:40 pm)
Driver core: remove put_bus(), Greg KH, (Thu Sep 13, 7:39 pm)
Re: Driver core: remove put_bus(), Cornelia Huck, (Fri Sep 14, 7:03 am)
Driver core: remove kset_set_kset_s, Greg KH, (Thu Sep 13, 7:39 pm)
Driver core: remove get_bus(), Greg KH, (Thu Sep 13, 7:38 pm)
Re: Driver core: remove get_bus(), Cornelia Huck, (Fri Sep 14, 7:02 am)
Re: Driver core: remove get_bus(), Greg KH, (Fri Sep 14, 7:27 am)