public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: Greg KH <greg@kroah.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: sysfs: spit a warning to users when they try to create a duplicate sysfs file
Date: Sat, 15 Sep 2007 14:44:42 +0200	[thread overview]
Message-ID: <46EBD3BA.9020306@s5r6.in-berlin.de> (raw)
In-Reply-To: <20070913234118.GH10856@kroah.com>

Greg KH wrote:
> 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);
>  

As a side story:

I've got code which has checks for device_create_file != 0 but keeps
quiet if it got -EEXIST.  I rewrote it now so that it does not rely on
the driver core to skip over already existing files.  Doing this
revealed a group of old refcounting bugs. :-)  Thanks,
-- 
Stefan Richter
-=====-=-=== =--= -====
http://arcgraph.de/sr/

  parent reply	other threads:[~2007-09-15 12:45 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-13 23:37 [RFC] Some driver core and kobject minor patches Greg KH
2007-09-13 23:38 ` Driver core: remove get_bus() Greg KH
2007-09-14 11:02   ` Cornelia Huck
2007-09-14 11:27     ` Greg KH
2007-09-13 23:39 ` Driver core: remove kset_set_kset_s Greg KH
2007-09-13 23:39 ` Driver core: remove put_bus() Greg KH
2007-09-14 11:03   ` Cornelia Huck
2007-09-13 23:40 ` Driver core: remove subsys_get() Greg KH
2007-09-13 23:40 ` Driver core: remove subsys_put() Greg KH
2007-09-13 23:40 ` Driver core: remove subsys_set_kset Greg KH
2007-09-13 23:41 ` sysfs: spit a warning to users when they try to create a duplicate sysfs file Greg KH
2007-09-14 12:06   ` Cornelia Huck
2007-09-16 20:39     ` Greg KH
2007-09-15 12:44   ` Stefan Richter [this message]
2007-09-13 23:42 ` Drivers: clean up direct setting of the name of a kset Greg KH
2007-09-13 23:42 ` [RFC] Some driver core and kobject minor patches Greg KH
2007-09-13 23:43 ` cdev: remove unneeded setting of cdev names Greg KH
2007-09-13 23:43 ` kobjects: fix up improper use of the kobject name field Greg KH
2007-09-13 23:44 ` kobject: remove the static array for the name Greg KH
2007-09-14 11:25 ` [RFC] Some driver core and kobject minor patches Cornelia Huck

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=46EBD3BA.9020306@s5r6.in-berlin.de \
    --to=stefanr@s5r6.in-berlin.de \
    --cc=greg@kroah.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox