/* generate hotplug event for each device in this branch */ void devinfo_remove_branch (gchar *devfs_path, HalDevice *d) { GSList *i; GSList *children; HalDevice *child; char *child_devfs_path; if (d == NULL) { d = hal_device_store_match_key_value_string (hald_get_gdl (), "solaris.devfs_path", devfs_path); if (d == NULL) return; } HAL_INFO (("remove_branch: %s %s\n", devfs_path, hal_device_get_udi (d))); /* first remove children */ children = hal_device_store_match_multiple_key_value_string (hald_get_gdl(), "info.parent", hal_device_get_udi (d)); for (i = children; i != NULL; i = g_slist_next (i)) { child = HAL_DEVICE (i->data); HAL_INFO (("remove_branch: child %s\n", hal_device_get_udi (child))); devinfo_remove_branch ((gchar *)hal_device_property_get_string (child, "solaris.devfs_path"), child); } g_slist_free (children); HAL_INFO (("remove_branch: done with children")); /* then remove self */ HAL_INFO (("remove_branch: queueing %s", devfs_path)); devinfo_remove_enqueue (devfs_path, NULL); }
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)); goto out; } /* 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>")); goto out; } } /* 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)); goto out; } /* 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); return; out: g_object_unref (hotplug_event->d); hotplug_event_end ((void *) hotplug_event); return; }
static void drvctl_lofi_add(gchar *devfs_path, gchar *name) { di_node_t node; const char *parent_udi; HalDevice *d, *parent; HAL_INFO (("lofi_add: %s %s", name, devfs_path)); if ((d = hal_device_store_match_key_value_string (hald_get_gdl (), "solaris.devfs_path", devfs_path)) == NULL) { HAL_INFO (("device not found in GDL %s", devfs_path)); return; } parent_udi = hal_device_property_get_string (d, "info.parent"); if ((parent_udi == NULL) || (strlen(parent_udi) == 0)) { HAL_INFO (("parent not found in GDL %s", parent_udi)); return; } if ((parent = hal_device_store_match_key_value_string (hald_get_gdl (), "info.udi", parent_udi)) == NULL) { HAL_INFO (("parent not found in GDL %s", parent_udi)); return; } if ((node = di_init (devfs_path, DINFOCPYALL)) == DI_NODE_NIL) { HAL_INFO (("device not found in devinfo %s", devfs_path)); return; } HAL_INFO (("device %s parent %s", hal_device_get_udi (d), parent_udi)); devinfo_lofi_add_major (parent, node, devfs_path, NULL, TRUE, d); di_fini (node); hotplug_event_process_queue (); }
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); } }
void hal_device_store_match_key_value_string_async (HalDeviceStore *store, const char *key, const char *value, HalDeviceStoreAsyncCallback callback, gpointer user_data, int timeout) { HalDevice *device; AsyncMatchInfo *info; /* First check to see if it's already there */ device = hal_device_store_match_key_value_string (store, key, value); if (device != NULL || timeout == 0) { callback (store, device, user_data); return; } info = g_new0 (AsyncMatchInfo, 1); info->store = g_object_ref (store); info->key = g_strdup (key); info->value = g_strdup (value); info->callback = callback; info->user_data = user_data; info->prop_signal_id = g_signal_connect (store, "device_property_changed", G_CALLBACK (match_device_async), info); info->store_signal_id = g_signal_connect (store, "store_changed", G_CALLBACK (store_changed), info); info->timeout_id = g_timeout_add (timeout, match_device_async_timeout, info); }
static void drvctl_dev_add(gchar *name) { HalDevice *parent, *d; gchar pdevnode[512]; if (drvctl_find_parent (name, pdevnode) == FALSE) { HAL_INFO (("dev_add: name=%s orphan", name)); parent = NULL; } else { parent = hal_device_store_match_key_value_string ( hald_get_gdl(), "netbsd.device", pdevnode); if (parent == NULL) HAL_INFO (("dev_add: name=%s but netbsd.device=%s not found",name, pdevnode)); } d = devinfo_add_node (parent, name); if (d == NULL) HAL_WARNING (("dev_add: couldn't add %s node (parent=%p)", name, parent)); hotplug_event_process_queue (); }