struct list progress;
unsigned int n_progress;
+
+ struct plugin_option **plugins;
+ unsigned int n_plugins;
};
static int mount_device(struct discover_device *dev);
return handler->devices[index];
}
+/**
+ * device_handler_get_plugin_count - Get the count of current handler plugins.
+ */
+int device_handler_get_plugin_count(const struct device_handler *handler)
+{
+ return handler->n_plugins;
+}
+
+/**
+ * discover_handler_get_plugin - Get a handler plugin by index.
+ */
+const struct plugin_option *device_handler_get_plugin(
+ const struct device_handler *handler, unsigned int index)
+{
+ if (index >= handler->n_plugins) {
+ assert(0 && "bad index");
+ return NULL;
+ }
+
+ return handler->plugins[index];
+}
+
struct network *device_handler_get_network(
const struct device_handler *handler)
{
handler->ramdisks = NULL;
handler->n_ramdisks = 0;
+ /* drop any known plugins */
+ for (i = 0; i < handler->n_plugins; i++)
+ talloc_free(handler->plugins[i]);
+ talloc_free(handler->plugins);
+ handler->plugins = NULL;
+ handler->n_plugins = 0;
+
+ discover_server_notify_plugins_remove(handler->server);
+
device_handler_reinit_sources(handler);
}
}
}
+static void device_handler_plugin_scan_device(struct device_handler *handler,
+ struct discover_device *dev)
+{
+ int rc;
+
+ pb_debug("Scanning %s for plugin files\n", dev->device->id);
+
+ rc = process_run_simple(handler, pb_system_apps.pb_plugin,
+ "scan", dev->mount_path,
+ NULL);
+ if (rc)
+ pb_log("Error from pb-plugin scan %s\n",
+ dev->mount_path);
+}
+
void device_handler_status_download_remove(struct device_handler *handler,
struct process_info *procinfo)
{
status.type = STATUS_INFO;
status.message = talloc_asprintf(handler,
- _("Booting in %d sec: %s"), sec, opt->option->name);
+ _("Booting in %d sec: [%s] %s"), sec,
+ opt->device->device->id, opt->option->name);
status.backlog = false;
device_handler_status(handler, &status);
device_handler_discover_context_commit(handler, ctx);
process_boot_option_queue(handler);
+
+ /* Check this device for pb-plugins */
+ device_handler_plugin_scan_device(handler, dev);
out:
talloc_unlink(handler, ctx);
}
}
+void device_handler_add_plugin_option(struct device_handler *handler,
+ struct plugin_option *opt)
+{
+ struct plugin_option *tmp;
+ unsigned int i;
+
+ for (i = 0; i < handler->n_plugins; i++) {
+ tmp = handler->plugins[i];
+ /* If both id and version match, ignore */
+ if (strncmp(opt->id, tmp->id, strlen(opt->id)) == 0 &&
+ strncmp(opt->version, tmp->version,
+ strlen(opt->version) == 0)) {
+ pb_log("discover: Plugin '%s' already exists, ignoring\n",
+ opt->id);
+ return;
+ }
+ }
+
+ handler->plugins = talloc_realloc(handler, handler->plugins,
+ struct plugin_option *, handler->n_plugins + 1);
+ if (!handler->plugins) {
+ pb_log("Failed to allocate memory for new plugin\n");
+ handler->n_plugins = 0;
+ return;
+ }
+
+ handler->plugins[handler->n_plugins++] = opt;
+ discover_server_notify_plugin_option_add(handler->server, opt);
+}
+
static void device_handler_update_lang(const char *lang)
{
const char *cur_lang;
static int device_handler_init_sources(struct device_handler *handler)
{
/* init our device sources: udev, network and user events */
- handler->udev = udev_init(handler, handler->waitset);
- if (!handler->udev)
- return -1;
-
handler->network = network_init(handler, handler->waitset,
handler->dry_run);
if (!handler->network)
return -1;
+ handler->udev = udev_init(handler, handler->waitset);
+ if (!handler->udev)
+ return -1;
+
handler->user_event = user_event_init(handler, handler->waitset);
if (!handler->user_event)
return -1;
system_info_reinit();
- udev_reinit(handler->udev);
-
network_shutdown(handler->network);
handler->network = network_init(handler, handler->waitset,
handler->dry_run);
+
+ udev_reinit(handler->udev);
}
static inline const char *get_device_path(struct discover_device *dev)