static void hotplug_event_begin_devfs_add (HotplugEvent *hotplug_event, HalDevice *d) { HalDevice *parent; const gchar *parent_udi; void (*begin_add_func) (HalDevice *, HalDevice *, DevinfoDevHandler *, void *); if (d != NULL) { /* XXX */ HAL_ERROR (("devpath %s already present in store, ignore event", hotplug_event->un.devfs.devfs_path)); hotplug_event_end ((void *) hotplug_event); return; } /* find parent */ parent_udi = hal_device_property_get_string (hotplug_event->d, "info.parent"); if (parent_udi == NULL || strlen(parent_udi) == 0) { parent = NULL; } else { parent = hal_device_store_match_key_value_string (hald_get_gdl (), "info.udi", parent_udi); } /* only root node is allowed to be orphan */ if (parent == NULL) { if (strcmp(hotplug_event->un.devfs.devfs_path, "/") != 0) { HAL_ERROR (("Parent is NULL devfs_path=%s parent_udi=%s", hotplug_event->un.devfs.devfs_path, parent_udi ? parent_udi : "<null>")); hotplug_event_end ((void *) hotplug_event); return; } } /* children of ignored parent should be ignored */ if (parent != NULL && hal_device_property_get_bool (parent, "info.ignore")) { HAL_INFO (("parent ignored %s", parent_udi)); hotplug_event_end ((void *) hotplug_event); return; } /* custom or generic add function */ begin_add_func = hotplug_event->un.devfs.handler->hotplug_begin_add; if (begin_add_func == NULL) { begin_add_func = hotplug_event_begin_add_devinfo; } begin_add_func (hotplug_event->d, parent, hotplug_event->un.devfs.handler, (void *) hotplug_event); }
void devinfo_callouts_add_done (HalDevice *d, gpointer userdata1, gpointer userdata2) { void *end_token = (void *) userdata1; /* Move from temporary to global device store */ hal_device_store_remove (hald_get_tdl (), d); hal_device_store_add (hald_get_gdl (), d); hotplug_event_end (end_token); }
static void hotplug_event_begin_devfs_remove (HotplugEvent *hotplug_event, HalDevice *d) { if (d == NULL) { HAL_ERROR (("devpath %s not present in store, ignore event", hotplug_event->un.devfs.devfs_path)); hotplug_event_end ((void *) hotplug_event); return; } HAL_INFO (("hotplug_event_begin_devfs_remove %s", hal_device_get_udi (d))); hotplug_event_begin_remove_devinfo(d, hotplug_event->un.devfs.devfs_path, (void *) hotplug_event); }
void devinfo_callouts_remove_done (HalDevice *d, gpointer userdata1, gpointer userdata2) { void *end_token = (void *) userdata1; HAL_INFO (("Remove callouts completed udi=%s", hal_device_get_udi (d))); if (!hal_device_store_remove (hald_get_gdl (), d)) { HAL_WARNING (("Error removing device")); } g_object_unref (d); hotplug_event_end (end_token); }
static void hotplug_event_begin (HotplugEvent *hotplug_event) { switch (hotplug_event->type) { case HOTPLUG_EVENT_DEVFS: hotplug_event_begin_devfs (hotplug_event); break; default: HAL_ERROR (("Unknown hotplug event type %d", hotplug_event->type)); hotplug_event_end ((void *) hotplug_event); break; } }
void devinfo_callouts_preprobing_done (HalDevice *d, gpointer userdata1, gpointer userdata2) { void *end_token = (void *) userdata1; DevinfoDevHandler *handler = (DevinfoDevHandler *) userdata2; void (*probing_done) (HalDevice *, guint32, gint, char **, gpointer, gpointer); const gchar *prober; int prober_timeout; if (hal_device_property_get_bool (d, "info.ignore")) { HAL_INFO (("Preprobing merged info.ignore==TRUE")); /* Leave device with info.ignore==TRUE so we won't pick up children */ hal_device_property_remove (d, "info.category"); hal_device_property_remove (d, "info.capabilities"); hal_device_store_remove (hald_get_tdl (), d); hal_device_store_add (hald_get_gdl (), d); hotplug_event_end (end_token); return; } if (handler != NULL && handler->get_prober != NULL) { prober = handler->get_prober (d, &prober_timeout); } else { prober = NULL; } if (handler->probing_done != NULL) { probing_done = handler->probing_done; } else { probing_done = devinfo_callouts_probing_done; } if (prober != NULL) { /* probe the device */ HAL_INFO(("Probing udi=%s", hal_device_get_udi (d))); hald_runner_run (d, prober, NULL, prober_timeout, probing_done, (gpointer) end_token, (gpointer) handler); } else { probing_done (d, 0, 0, NULL, userdata1, userdata2); } }
static void hotplug_event_begin_devfs (HotplugEvent *hotplug_event) { HalDevice *d; HAL_INFO (("hotplug_event_begin_devfs: %s", hotplug_event->un.devfs.devfs_path)); d = hal_device_store_match_key_value_string (hald_get_gdl (), "solaris.devfs_path", hotplug_event->un.devfs.devfs_path); if (hotplug_event->action == HOTPLUG_ACTION_ADD) { hotplug_event_begin_devfs_add (hotplug_event, d); } else if (hotplug_event->action == HOTPLUG_ACTION_REMOVE) { hotplug_event_begin_devfs_remove (hotplug_event, d); } else { hotplug_event_end ((void *) hotplug_event); } }
/* This is the beginning of hotplug even handling */ void hotplug_event_begin_add_devinfo (HalDevice *d, HalDevice *parent, DevinfoDevHandler *handler, void *end_token) { HotplugEvent *hotplug_event = (HotplugEvent *)end_token; HAL_INFO(("Preprobing udi=%s", hal_device_get_udi (d))); if (parent == NULL && (strcmp(hotplug_event->un.devfs.devfs_path, "/") != 0)) { HAL_ERROR (("Parent is NULL, devfs_path=%s", hotplug_event->un.devfs.devfs_path)); goto skip; } if (parent != NULL && hal_device_property_get_bool (parent, "info.ignore")) { HAL_INFO (("Ignoring device since parent has info.ignore==TRUE")); goto skip; } if (hal_device_store_find (hald_get_tdl (), hal_device_get_udi (d)) == NULL) { /* add to TDL so preprobing callouts and prober can access it */ hal_device_store_add (hald_get_tdl (), d); } /* Process preprobe fdi files */ di_search_and_merge (d, DEVICE_INFO_TYPE_PREPROBE); /* Run preprobe callouts */ hal_util_callout_device_preprobe (d, devinfo_callouts_preprobing_done, end_token, handler); return; skip: if (hal_device_store_find (hald_get_tdl (), hal_device_get_udi (d))) hal_device_store_remove (hald_get_tdl (), d); g_object_unref (d); hotplug_event_end (end_token); return; }
void devinfo_callouts_probing_done (HalDevice *d, guint32 exit_type, gint return_code, char **error, gpointer userdata1, gpointer userdata2) { void *end_token = (void *) userdata1; /* Discard device if probing reports failure */ if (exit_type != HALD_RUN_SUCCESS || (return_code != 0)) { HAL_INFO (("Probing for %s failed %d", hal_device_get_udi (d), return_code)); hal_device_store_remove (hald_get_tdl (), d); g_object_unref (d); hotplug_event_end (end_token); return; } /* Merge properties from .fdi files */ di_search_and_merge (d, DEVICE_INFO_TYPE_INFORMATION); di_search_and_merge (d, DEVICE_INFO_TYPE_POLICY); hal_util_callout_device_add (d, devinfo_callouts_add_done, end_token, NULL); }