aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kobject_uevent.c
diff options
context:
space:
mode:
authorCornelia Huck <cornelia.huck@de.ibm.com>2006-11-20 11:07:51 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-12-01 17:52:01 -0500
commit8a82472f86bf693b8e91ed56c9ca4f62fbbdcfa3 (patch)
tree79d148ee548f4b57e6f5a4a69cf6cdb81e7a1bf2 /lib/kobject_uevent.c
parentaf9e0765362151b27372c14d9d6dc417184182d3 (diff)
driver core: Introduce device_move(): move a device to a new parent.
Provide a function device_move() to move a device to a new parent device. Add auxilliary functions kobject_move() and sysfs_move_dir(). kobject_move() generates a new uevent of type KOBJ_MOVE, containing the previous path (DEVPATH_OLD) in addition to the usual values. For this, a new interface kobject_uevent_env() is created that allows to add further environmental data to the uevent at the kobject layer. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Acked-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib/kobject_uevent.c')
-rw-r--r--lib/kobject_uevent.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 7f20e7b857cb..a1922765ff31 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -50,18 +50,22 @@ static char *action_to_string(enum kobject_action action)
50 return "offline"; 50 return "offline";
51 case KOBJ_ONLINE: 51 case KOBJ_ONLINE:
52 return "online"; 52 return "online";
53 case KOBJ_MOVE:
54 return "move";
53 default: 55 default:
54 return NULL; 56 return NULL;
55 } 57 }
56} 58}
57 59
58/** 60/**
59 * kobject_uevent - notify userspace by ending an uevent 61 * kobject_uevent_env - send an uevent with environmental data
60 * 62 *
61 * @action: action that is happening (usually KOBJ_ADD and KOBJ_REMOVE) 63 * @action: action that is happening (usually KOBJ_MOVE)
62 * @kobj: struct kobject that the action is happening to 64 * @kobj: struct kobject that the action is happening to
65 * @envp_ext: pointer to environmental data
63 */ 66 */
64void kobject_uevent(struct kobject *kobj, enum kobject_action action) 67void kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
68 char *envp_ext[])
65{ 69{
66 char **envp; 70 char **envp;
67 char *buffer; 71 char *buffer;
@@ -76,6 +80,7 @@ void kobject_uevent(struct kobject *kobj, enum kobject_action action)
76 char *seq_buff; 80 char *seq_buff;
77 int i = 0; 81 int i = 0;
78 int retval; 82 int retval;
83 int j;
79 84
80 pr_debug("%s\n", __FUNCTION__); 85 pr_debug("%s\n", __FUNCTION__);
81 86
@@ -134,7 +139,8 @@ void kobject_uevent(struct kobject *kobj, enum kobject_action action)
134 scratch += sprintf (scratch, "DEVPATH=%s", devpath) + 1; 139 scratch += sprintf (scratch, "DEVPATH=%s", devpath) + 1;
135 envp [i++] = scratch; 140 envp [i++] = scratch;
136 scratch += sprintf(scratch, "SUBSYSTEM=%s", subsystem) + 1; 141 scratch += sprintf(scratch, "SUBSYSTEM=%s", subsystem) + 1;
137 142 for (j = 0; envp_ext && envp_ext[j]; j++)
143 envp[i++] = envp_ext[j];
138 /* just reserve the space, overwrite it after kset call has returned */ 144 /* just reserve the space, overwrite it after kset call has returned */
139 envp[i++] = seq_buff = scratch; 145 envp[i++] = seq_buff = scratch;
140 scratch += strlen("SEQNUM=18446744073709551616") + 1; 146 scratch += strlen("SEQNUM=18446744073709551616") + 1;
@@ -200,6 +206,20 @@ exit:
200 kfree(envp); 206 kfree(envp);
201 return; 207 return;
202} 208}
209
210EXPORT_SYMBOL_GPL(kobject_uevent_env);
211
212/**
213 * kobject_uevent - notify userspace by ending an uevent
214 *
215 * @action: action that is happening (usually KOBJ_ADD and KOBJ_REMOVE)
216 * @kobj: struct kobject that the action is happening to
217 */
218void kobject_uevent(struct kobject *kobj, enum kobject_action action)
219{
220 kobject_uevent_env(kobj, action, NULL);
221}
222
203EXPORT_SYMBOL_GPL(kobject_uevent); 223EXPORT_SYMBOL_GPL(kobject_uevent);
204 224
205/** 225/**