aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kobject.c
diff options
context:
space:
mode:
authorJean Tourrilhes <jt@hpl.hp.com>2007-03-07 13:49:30 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2007-04-27 13:57:29 -0400
commitca2f37dbc5324c7278577731033a358f1f86050a (patch)
tree5085e9826220e047c1f53070355c4f194988241f /lib/kobject.c
parent1b0b3b9980e482ab7c603430462538334f69f14a (diff)
Driver core: notify userspace of network device renames
Provide rename event for when we rename network devices. Signed-off-by: Jean Tourrilhes <jt@hpl.hp.com> Cc: 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.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index bbbfab4145e6..db1d23707eb1 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -311,13 +311,43 @@ EXPORT_SYMBOL(kobject_set_name);
311int kobject_rename(struct kobject * kobj, const char *new_name) 311int kobject_rename(struct kobject * kobj, const char *new_name)
312{ 312{
313 int error = 0; 313 int error = 0;
314 const char *devpath = NULL;
315 char *devpath_string = NULL;
316 char *envp[2];
314 317
315 kobj = kobject_get(kobj); 318 kobj = kobject_get(kobj);
316 if (!kobj) 319 if (!kobj)
317 return -EINVAL; 320 return -EINVAL;
318 if (!kobj->parent) 321 if (!kobj->parent)
319 return -EINVAL; 322 return -EINVAL;
323
324 devpath = kobject_get_path(kobj, GFP_KERNEL);
325 if (!devpath) {
326 error = -ENOMEM;
327 goto out;
328 }
329 devpath_string = kmalloc(strlen(devpath) + 15, GFP_KERNEL);
330 if (!devpath_string) {
331 error = -ENOMEM;
332 goto out;
333 }
334 sprintf(devpath_string, "DEVPATH_OLD=%s", devpath);
335 envp[0] = devpath_string;
336 envp[1] = NULL;
337 /* Note : if we want to send the new name alone, not the full path,
338 * we could probably use kobject_name(kobj); */
339
320 error = sysfs_rename_dir(kobj, kobj->parent->dentry, new_name); 340 error = sysfs_rename_dir(kobj, kobj->parent->dentry, new_name);
341
342 /* This function is mostly/only used for network interface.
343 * Some hotplug package track interfaces by their name and
344 * therefore want to know when the name is changed by the user. */
345 if (!error)
346 kobject_uevent_env(kobj, KOBJ_MOVE, envp);
347
348out:
349 kfree(devpath_string);
350 kfree(devpath);
321 kobject_put(kobj); 351 kobject_put(kobj);
322 352
323 return error; 353 return error;