]> git.ozlabs.org Git - petitboot/blobdiff - discover/device-handler.c
discover: Implement device handler boot path
[petitboot] / discover / device-handler.c
index bda724cc3badcf1ea46e6d92520b7e3c71411644..6a27f15780a5a4ae290e2ddf6d1b95f789dadb02 100644 (file)
@@ -10,7 +10,7 @@
 #include <talloc/talloc.h>
 #include <list/list.h>
 #include <log/log.h>
-#include <pb-protocol/pb-protocol.h>
+#include <types/types.h>
 #include <system/system.h>
 
 #include "device-handler.h"
@@ -19,6 +19,7 @@
 #include "parser.h"
 #include "udev.h"
 #include "paths.h"
+#include "boot.h"
 
 struct device_handler {
        struct discover_server *server;
@@ -429,3 +430,30 @@ void device_handler_destroy(struct device_handler *handler)
 {
        talloc_free(handler);
 }
+
+static struct boot_option *find_boot_option_by_id(
+               struct device_handler *handler, const char *id)
+{
+       unsigned int i;
+
+       for (i = 0; i < handler->n_devices; i++) {
+               struct device *dev = handler->devices[i];
+               struct boot_option *opt;
+
+               list_for_each_entry(&dev->boot_options, opt, list)
+                       if (!strcmp(opt->id, id))
+                               return opt;
+       }
+
+       return NULL;
+}
+
+void device_handler_boot(struct device_handler *handler,
+               struct boot_command *cmd)
+{
+       struct boot_option *opt;
+
+       opt = find_boot_option_by_id(handler, cmd->option_id);
+
+       boot(handler, opt, cmd, 0);
+}