discover/grub: Use different paths to search for the BLS directory
[petitboot] / discover / devmapper.c
index c1a5492b98a6550da0de04f30be4c4df952f4c0c..d8445e62e999a7c7e9681fa7f3ce51ccf93b405e 100644 (file)
@@ -2,6 +2,7 @@
 #include <types/types.h>
 #include <log/log.h>
 #include <errno.h>
+#include <inttypes.h>
 #include <string.h>
 
 #include <sys/types.h>
@@ -231,7 +232,7 @@ static int run_create_task(const char *dm_name, const struct target *target)
        struct dm_task *task;
        uint32_t cookie;
 
-       pb_debug("%s: %lu %lu '%s' '%s'\n", __func__,
+       pb_debug("%s: %" PRIu64 " %" PRIu64 " '%s' '%s'\n", __func__,
                 target->start_sector, target->end_sector,
                 target->ttype, target->params);
 
@@ -285,11 +286,11 @@ static int create_base(struct discover_device *device)
                goto out;
        }
 
-       name = talloc_asprintf(device, "%s-base", device->device->id);
+       name = talloc_asprintf(device, "pb-%s-base", device->device->id);
        if (!name || run_create_task(name, &target))
                goto out;
 
-       device->ramdisk->base = talloc_asprintf(device, "/dev/mapper/%s-base",
+       device->ramdisk->base = talloc_asprintf(device, "/dev/mapper/pb-%s-base",
                                        device->device->id);
        if (!device->ramdisk->base) {
                pb_log("Failed to track new device /dev/mapper/%s-base\n",
@@ -325,12 +326,12 @@ static int create_origin(struct discover_device *device)
                goto out;
        }
 
-       name = talloc_asprintf(device, "%s-origin", device->device->id);
+       name = talloc_asprintf(device, "pb-%s-origin", device->device->id);
        if (!name || run_create_task(name, &target))
                goto out;
 
        device->ramdisk->origin = talloc_asprintf(device,
-                                       "/dev/mapper/%s-origin",
+                                       "/dev/mapper/pb-%s-origin",
                                        device->device->id);
        if (!device->ramdisk->origin) {
                pb_log("Failed to track new device /dev/mapper/%s-origin\n",
@@ -350,6 +351,7 @@ out:
 static int create_snapshot(struct discover_device *device)
 {
        struct target target;
+       char *name = NULL;
        int rc = -1;
 
        if (!device->ramdisk || !device->ramdisk->base ||
@@ -367,10 +369,11 @@ static int create_snapshot(struct discover_device *device)
                goto out;
        }
 
-       if (run_create_task(device->device->id, &target))
+       name = talloc_asprintf(device, "pb-%s", device->device->id);
+       if (!name || run_create_task(name, &target))
                goto out;
 
-       device->ramdisk->snapshot = talloc_asprintf(device, "/dev/mapper/%s",
+       device->ramdisk->snapshot = talloc_asprintf(device, "/dev/mapper/pb-%s",
                                                device->device->id);
        if (!device->ramdisk->snapshot) {
                pb_log("Failed to track new device /dev/mapper/%s\n",
@@ -381,6 +384,7 @@ static int create_snapshot(struct discover_device *device)
        rc = 0;
 
 out:
+       talloc_free(name);
        talloc_free(target.params);
        talloc_free(target.ttype);
        return rc;