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>
- 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;
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",
device->device->id);
if (!device->ramdisk->base) {
pb_log("Failed to track new device /dev/mapper/%s-base\n",
- 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,
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",
device->device->id);
if (!device->ramdisk->origin) {
pb_log("Failed to track new device /dev/mapper/%s-origin\n",
static int create_snapshot(struct discover_device *device)
{
struct target target;
static int create_snapshot(struct discover_device *device)
{
struct target target;
int rc = -1;
if (!device->ramdisk || !device->ramdisk->base ||
int rc = -1;
if (!device->ramdisk || !device->ramdisk->base ||
- if (run_create_task(device->device->id, &target))
+ name = talloc_asprintf(device, "pb-%s", device->device->id);
+ if (!name || run_create_task(name, &target))
- 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",
device->device->id);
if (!device->ramdisk->snapshot) {
pb_log("Failed to track new device /dev/mapper/%s\n",
talloc_free(target.params);
talloc_free(target.ttype);
return rc;
talloc_free(target.params);
talloc_free(target.ttype);
return rc;