8273 prop != DI_PROP_NIL && count < MAX_PROP_COUNT;
8274 prop = di_prop_next(node, prop)) {
8275
8276 if (di_prop_devt(prop) != DDI_DEV_T_NONE)
8277 continue;
8278
8279 if ((x = add_property(nvl, prop)) == 0)
8280 count++;
8281 else if (x == -1) {
8282 if ((prop_name = di_prop_name(prop)) == NULL)
8283 prop_name = "";
8284 err_print(PROP_ADD_FAILED, prop_name);
8285 goto out;
8286 }
8287 }
8288 }
8289
8290 return (nvl);
8291
8292 out:
8293 if (nvl)
8294 nvlist_free(nvl);
8295
8296 if (dev_name)
8297 free(dev_name);
8298
8299 if (dev_name_lookup_err) {
8300 /*
8301 * If a lofi mount fails, the /devices node may well have
8302 * disappeared by the time we run, so let's not complain.
8303 */
8304 if (strcmp(subclass, ESC_LOFI) != 0)
8305 err_print(DEV_NAME_LOOKUP_FAILED, node_path);
8306 } else {
8307 err_print(BUILD_EVENT_ATTR_FAILED, (err) ? strerror(err) : "");
8308 }
8309 return (NULL);
8310 }
8311
8312 static void
8313 log_event(char *class, char *subclass, nvlist_t *nvl)
8347 syseventq_front = tmp;
8348 (void) mutex_unlock(&syseventq_mutex);
8349 }
8350
8351 static void
8352 process_syseventq()
8353 {
8354 (void) mutex_lock(&syseventq_mutex);
8355 while (syseventq_back != NULL) {
8356 syseventq_t *tmp = syseventq_back;
8357
8358 vprint(CHATTY_MID, "sending queued event: %s, %s\n",
8359 tmp->class, tmp->subclass);
8360
8361 log_event(tmp->class, tmp->subclass, tmp->nvl);
8362
8363 if (tmp->class != NULL)
8364 free(tmp->class);
8365 if (tmp->subclass != NULL)
8366 free(tmp->subclass);
8367 if (tmp->nvl != NULL)
8368 nvlist_free(tmp->nvl);
8369 syseventq_back = syseventq_back->next;
8370 if (syseventq_back == NULL)
8371 syseventq_front = NULL;
8372 free(tmp);
8373 }
8374 (void) mutex_unlock(&syseventq_mutex);
8375 }
8376
8377 static void
8378 build_and_enq_event(char *class, char *subclass, char *node_path,
8379 di_node_t node, char *minor)
8380 {
8381 nvlist_t *nvl;
8382
8383 vprint(CHATTY_MID, "build_and_enq_event(%s, %s, %s, 0x%8.8x)\n",
8384 class, subclass, node_path, (int)node);
8385
8386 if (node != DI_NODE_NIL)
8387 nvl = build_event_attributes(class, subclass, node_path, node,
|
8273 prop != DI_PROP_NIL && count < MAX_PROP_COUNT;
8274 prop = di_prop_next(node, prop)) {
8275
8276 if (di_prop_devt(prop) != DDI_DEV_T_NONE)
8277 continue;
8278
8279 if ((x = add_property(nvl, prop)) == 0)
8280 count++;
8281 else if (x == -1) {
8282 if ((prop_name = di_prop_name(prop)) == NULL)
8283 prop_name = "";
8284 err_print(PROP_ADD_FAILED, prop_name);
8285 goto out;
8286 }
8287 }
8288 }
8289
8290 return (nvl);
8291
8292 out:
8293 nvlist_free(nvl);
8294
8295 if (dev_name)
8296 free(dev_name);
8297
8298 if (dev_name_lookup_err) {
8299 /*
8300 * If a lofi mount fails, the /devices node may well have
8301 * disappeared by the time we run, so let's not complain.
8302 */
8303 if (strcmp(subclass, ESC_LOFI) != 0)
8304 err_print(DEV_NAME_LOOKUP_FAILED, node_path);
8305 } else {
8306 err_print(BUILD_EVENT_ATTR_FAILED, (err) ? strerror(err) : "");
8307 }
8308 return (NULL);
8309 }
8310
8311 static void
8312 log_event(char *class, char *subclass, nvlist_t *nvl)
8346 syseventq_front = tmp;
8347 (void) mutex_unlock(&syseventq_mutex);
8348 }
8349
8350 static void
8351 process_syseventq()
8352 {
8353 (void) mutex_lock(&syseventq_mutex);
8354 while (syseventq_back != NULL) {
8355 syseventq_t *tmp = syseventq_back;
8356
8357 vprint(CHATTY_MID, "sending queued event: %s, %s\n",
8358 tmp->class, tmp->subclass);
8359
8360 log_event(tmp->class, tmp->subclass, tmp->nvl);
8361
8362 if (tmp->class != NULL)
8363 free(tmp->class);
8364 if (tmp->subclass != NULL)
8365 free(tmp->subclass);
8366 nvlist_free(tmp->nvl);
8367 syseventq_back = syseventq_back->next;
8368 if (syseventq_back == NULL)
8369 syseventq_front = NULL;
8370 free(tmp);
8371 }
8372 (void) mutex_unlock(&syseventq_mutex);
8373 }
8374
8375 static void
8376 build_and_enq_event(char *class, char *subclass, char *node_path,
8377 di_node_t node, char *minor)
8378 {
8379 nvlist_t *nvl;
8380
8381 vprint(CHATTY_MID, "build_and_enq_event(%s, %s, %s, 0x%8.8x)\n",
8382 class, subclass, node_path, (int)node);
8383
8384 if (node != DI_NODE_NIL)
8385 nvl = build_event_attributes(class, subclass, node_path, node,
|