diff options
Diffstat (limited to 'lib/kobject_uevent.c')
-rw-r--r-- | lib/kobject_uevent.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index 5886147252d0..5a402e2982af 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c | |||
@@ -98,7 +98,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
98 | int i = 0; | 98 | int i = 0; |
99 | int retval = 0; | 99 | int retval = 0; |
100 | 100 | ||
101 | pr_debug("%s\n", __FUNCTION__); | 101 | pr_debug("kobject: '%s' (%p): %s\n", |
102 | kobject_name(kobj), kobj, __FUNCTION__); | ||
102 | 103 | ||
103 | /* search the kset we belong to */ | 104 | /* search the kset we belong to */ |
104 | top_kobj = kobj; | 105 | top_kobj = kobj; |
@@ -106,7 +107,9 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
106 | top_kobj = top_kobj->parent; | 107 | top_kobj = top_kobj->parent; |
107 | 108 | ||
108 | if (!top_kobj->kset) { | 109 | if (!top_kobj->kset) { |
109 | pr_debug("kobject attempted to send uevent without kset!\n"); | 110 | pr_debug("kobject: '%s' (%p): %s: attempted to send uevent " |
111 | "without kset!\n", kobject_name(kobj), kobj, | ||
112 | __FUNCTION__); | ||
110 | return -EINVAL; | 113 | return -EINVAL; |
111 | } | 114 | } |
112 | 115 | ||
@@ -116,7 +119,9 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
116 | /* skip the event, if the filter returns zero. */ | 119 | /* skip the event, if the filter returns zero. */ |
117 | if (uevent_ops && uevent_ops->filter) | 120 | if (uevent_ops && uevent_ops->filter) |
118 | if (!uevent_ops->filter(kset, kobj)) { | 121 | if (!uevent_ops->filter(kset, kobj)) { |
119 | pr_debug("kobject filter function caused the event to drop!\n"); | 122 | pr_debug("kobject: '%s' (%p): %s: filter function " |
123 | "caused the event to drop!\n", | ||
124 | kobject_name(kobj), kobj, __FUNCTION__); | ||
120 | return 0; | 125 | return 0; |
121 | } | 126 | } |
122 | 127 | ||
@@ -126,7 +131,9 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
126 | else | 131 | else |
127 | subsystem = kobject_name(&kset->kobj); | 132 | subsystem = kobject_name(&kset->kobj); |
128 | if (!subsystem) { | 133 | if (!subsystem) { |
129 | pr_debug("unset subsystem caused the event to drop!\n"); | 134 | pr_debug("kobject: '%s' (%p): %s: unset subsystem caused the " |
135 | "event to drop!\n", kobject_name(kobj), kobj, | ||
136 | __FUNCTION__); | ||
130 | return 0; | 137 | return 0; |
131 | } | 138 | } |
132 | 139 | ||
@@ -166,12 +173,24 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
166 | if (uevent_ops && uevent_ops->uevent) { | 173 | if (uevent_ops && uevent_ops->uevent) { |
167 | retval = uevent_ops->uevent(kset, kobj, env); | 174 | retval = uevent_ops->uevent(kset, kobj, env); |
168 | if (retval) { | 175 | if (retval) { |
169 | pr_debug ("%s - uevent() returned %d\n", | 176 | pr_debug("kobject: '%s' (%p): %s: uevent() returned " |
170 | __FUNCTION__, retval); | 177 | "%d\n", kobject_name(kobj), kobj, |
178 | __FUNCTION__, retval); | ||
171 | goto exit; | 179 | goto exit; |
172 | } | 180 | } |
173 | } | 181 | } |
174 | 182 | ||
183 | /* | ||
184 | * Mark "add" and "remove" events in the object to ensure proper | ||
185 | * events to userspace during automatic cleanup. If the object did | ||
186 | * send an "add" event, "remove" will automatically generated by | ||
187 | * the core, if not already done by the caller. | ||
188 | */ | ||
189 | if (action == KOBJ_ADD) | ||
190 | kobj->state_add_uevent_sent = 1; | ||
191 | else if (action == KOBJ_REMOVE) | ||
192 | kobj->state_remove_uevent_sent = 1; | ||
193 | |||
175 | /* we will send an event, so request a new sequence number */ | 194 | /* we will send an event, so request a new sequence number */ |
176 | spin_lock(&sequence_lock); | 195 | spin_lock(&sequence_lock); |
177 | seq = ++uevent_seqnum; | 196 | seq = ++uevent_seqnum; |
@@ -219,11 +238,12 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
219 | retval = add_uevent_var(env, "HOME=/"); | 238 | retval = add_uevent_var(env, "HOME=/"); |
220 | if (retval) | 239 | if (retval) |
221 | goto exit; | 240 | goto exit; |
222 | retval = add_uevent_var(env, "PATH=/sbin:/bin:/usr/sbin:/usr/bin"); | 241 | retval = add_uevent_var(env, |
242 | "PATH=/sbin:/bin:/usr/sbin:/usr/bin"); | ||
223 | if (retval) | 243 | if (retval) |
224 | goto exit; | 244 | goto exit; |
225 | 245 | ||
226 | call_usermodehelper (argv[0], argv, env->envp, UMH_WAIT_EXEC); | 246 | call_usermodehelper(argv[0], argv, env->envp, UMH_WAIT_EXEC); |
227 | } | 247 | } |
228 | 248 | ||
229 | exit: | 249 | exit: |
@@ -231,7 +251,6 @@ exit: | |||
231 | kfree(env); | 251 | kfree(env); |
232 | return retval; | 252 | return retval; |
233 | } | 253 | } |
234 | |||
235 | EXPORT_SYMBOL_GPL(kobject_uevent_env); | 254 | EXPORT_SYMBOL_GPL(kobject_uevent_env); |
236 | 255 | ||
237 | /** | 256 | /** |
@@ -247,7 +266,6 @@ int kobject_uevent(struct kobject *kobj, enum kobject_action action) | |||
247 | { | 266 | { |
248 | return kobject_uevent_env(kobj, action, NULL); | 267 | return kobject_uevent_env(kobj, action, NULL); |
249 | } | 268 | } |
250 | |||
251 | EXPORT_SYMBOL_GPL(kobject_uevent); | 269 | EXPORT_SYMBOL_GPL(kobject_uevent); |
252 | 270 | ||
253 | /** | 271 | /** |