summaryrefslogtreecommitdiffstats
path: root/lib/kobject.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-05-06 22:24:04 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2008-07-22 06:54:40 +0200
commit9f255651fb41c111ee35a2ae632df8ce9bd61def (patch)
tree5afdfe266762182adc210ee5f73176dd6078e7e0 /lib/kobject.c
parentsysfs: add /sys/dev/{char,block} to lookup sysfs path by major:minor (diff)
downloadlinux-9f255651fb41c111ee35a2ae632df8ce9bd61def.tar.xz
linux-9f255651fb41c111ee35a2ae632df8ce9bd61def.zip
kobject: replace '/' with '!' in name
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>
Diffstat (limited to 'lib/kobject.c')
-rw-r--r--lib/kobject.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index dcade0543bd2..744401571ed7 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -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;
}