]> git.ozlabs.org Git - petitboot/blobdiff - discover/device-handler.c
docker: Add build container files
[petitboot] / discover / device-handler.c
index 4e1b3ca77fc0f447bfd0febfdf66db22c7121ed6..569e65290bd7e98cef518b078a16f76547ecb564 100644 (file)
@@ -1,4 +1,5 @@
 #include <assert.h>
+#include <inttypes.h>
 #include <stdlib.h>
 #include <stdbool.h>
 #include <unistd.h>
@@ -653,7 +654,7 @@ void device_handler_status_download(struct device_handler *handler,
                        unit++;
                }
                update = talloc_asprintf(handler,
-                               _("%u %s downloading: %.0f%% - %lu%cB"),
+                               _("%u %s downloading: %.0f%% - %" PRIu64 "%cB"),
                                handler->n_progress,
                                ngettext("item", "items", handler->n_progress),
                                (current / total) * 100, current_converted,
@@ -831,6 +832,9 @@ static enum default_priority default_option_priority(
                int boot_match = autoboot_option_priority(config, opt);
                if (boot_match > 0)
                        return boot_match;
+       } else {
+               /* If there is no specific boot order, boot any device */
+               return DEFAULT_PRIORITY_LOCAL_FIRST;
        }
 
        /* If the option didn't match any entry in the array, it is disabled */
@@ -1356,7 +1360,7 @@ static void process_url_cb(struct load_url_result *result, void *data)
 
        mac = event_get_param(event, "mac");
        char *url = talloc_asprintf(event, "file://%s", result->local);
-       event_set_param(event, "pxeconffile", url);
+       event_set_param(event, "pxeconffile-local", url);
 
        dev = discover_device_create(handler, mac, event->device);
        ctx = device_handler_discover_context_create(handler, dev);
@@ -1556,8 +1560,7 @@ void device_handler_add_plugin_option(struct device_handler *handler,
                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)) {
+                               strcmp(opt->version, tmp->version) == 0) {
                        pb_log("discover: Plugin '%s' already exists, ignoring\n",
                                        opt->id);
                        return;
@@ -1792,6 +1795,20 @@ static int mount_device(struct discover_device *dev)
        rc = try_mount(device_path, dev->mount_path, fstype,
                       MS_RDONLY | MS_SILENT, dev->ramdisk);
 
+       /* If mount fails clean up any snapshot and try again */
+       if (rc && dev->ramdisk) {
+               pb_log("couldn't mount snapshot for %s: mount failed: %s\n",
+                               device_path, strerror(errno));
+               pb_log("falling back to actual device\n");
+
+               devmapper_destroy_snapshot(dev);
+
+               device_path = get_device_path(dev);
+               pb_log("mounting device %s read-only\n", dev->device_path);
+               rc = try_mount(device_path, dev->mount_path, fstype,
+                              MS_RDONLY | MS_SILENT, dev->ramdisk);
+       }
+
        if (!rc) {
                dev->mounted = true;
                dev->mounted_rw = false;
@@ -1803,9 +1820,6 @@ static int mount_device(struct discover_device *dev)
        pb_log("couldn't mount device %s: mount failed: %s\n",
                        device_path, strerror(errno));
 
-       /* If mount fails clean up any snapshot */
-       devmapper_destroy_snapshot(dev);
-
        pb_rmdir_recursive(mount_base(), dev->mount_path);
 err_free:
        talloc_free(dev->mount_path);