summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2017-06-14 15:17:28 +1000
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2017-07-11 14:32:34 +1000
commitb003f5f28b2cc7f98adcee7635d44884ff4dc012 (patch)
tree5d5f98583b7396fa03c2cd5c7db6681be8a3ff07
parent4c55c0778e983c41418effecdbd96437b43a5513 (diff)
downloadtalos-petitboot-b003f5f28b2cc7f98adcee7635d44884ff4dc012.zip
talos-petitboot-b003f5f28b2cc7f98adcee7635d44884ff4dc012.tar.gz
discover/devmapper: Add prefix to devmapper device names
Add a 'pb-' prefix to all device mapper devices created by Petitboot. Beyond helping to identify Petitboot-related devices, this avoids naming collisions if we create snapshots of LVM logical volumes which also exist in /dev/mapper. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
-rw-r--r--discover/devmapper.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/discover/devmapper.c b/discover/devmapper.c
index c1a5492..2b28e0f 100644
--- a/discover/devmapper.c
+++ b/discover/devmapper.c
@@ -285,11 +285,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 +325,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 +350,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 +368,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 +383,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;
OpenPOWER on IntegriCloud