Skip to content

Commit

Permalink
kobject: replace '/' with '!' in name
Browse files Browse the repository at this point in the history
Some (block) devices have a '/' in the name, and need special
handling. Let's have that rule to the core, so we can remove it
from the block class.

Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Kay Sievers authored and Greg Kroah-Hartman committed Jul 22, 2008
1 parent e105b8b commit 9f25565
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/kobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,19 @@ static int kobject_add_internal(struct kobject *kobj)
static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
va_list vargs)
{
/* Free the old name, if necessary. */
kfree(kobj->name);
const char *old_name = kobj->name;
char *s;

kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
if (!kobj->name)
return -ENOMEM;

/* ewww... some of these buggers have '/' in the name ... */
s = strchr(kobj->name, '/');
if (s)
s[0] = '!';

kfree(old_name);
return 0;
}

Expand Down

0 comments on commit 9f25565

Please sign in to comment.