]> git.ozlabs.org Git - petitboot/blobdiff - discover/device-handler.c
discover: Allow devices with no device_path
[petitboot] / discover / device-handler.c
index 9e4c5bb228ebb285b9a905198e69f930e862d8e4..23961249ff595b857b327a34f025e31c64a97d1d 100644 (file)
@@ -75,6 +75,7 @@ static void boot_option_finalise(struct discover_boot_option *opt)
        assert(!opt->option->boot_image_file);
        assert(!opt->option->initrd_file);
        assert(!opt->option->icon_file);
+       assert(!opt->option->device_id);
 
        if (opt->boot_image)
                opt->option->boot_image_file = opt->boot_image->url->full;
@@ -82,6 +83,8 @@ static void boot_option_finalise(struct discover_boot_option *opt)
                opt->option->initrd_file = opt->initrd->url->full;
        if (opt->icon)
                opt->option->icon_file = opt->icon->url->full;
+
+       opt->option->device_id = opt->device->device->id;
 }
 
 static void process_boot_option_queue(struct device_handler *handler)
@@ -171,7 +174,7 @@ void discover_context_add_boot_option(struct discover_context *ctx,
                struct discover_boot_option *boot_option)
 {
        boot_option->source = ctx->parser;
-       list_add(&ctx->boot_options, &boot_option->list);
+       list_add_tail(&ctx->boot_options, &boot_option->list);
        talloc_steal(ctx, boot_option);
 }
 
@@ -232,6 +235,9 @@ static int mount_device(struct discover_device *dev)
 {
        const char *argv[6];
 
+       if (!dev->device_path)
+               return -1;
+
        if (!dev->mount_path)
                dev->mount_path = join_paths(dev, mount_base(),
                                                dev->device_path);
@@ -573,7 +579,7 @@ void device_handler_destroy(struct device_handler *handler)
 
 static int device_match_path(struct discover_device *dev, const char *path)
 {
-       return !strcmp(dev->device_path, path);
+       return dev->device_path && !strcmp(dev->device_path, path);
 }
 
 static int device_match_uuid(struct discover_device *dev, const char *uuid)