From patchwork Thu Jun 15 04:54:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 776111 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wpB4w1ndgz9sCX for ; Thu, 15 Jun 2017 14:54:56 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="jIFfDI2J"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wpB4w0cnnzDqLX for ; Thu, 15 Jun 2017 14:54:56 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="jIFfDI2J"; dkim-atps=neutral X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Received: from mendozajonas.com (mendozajonas.com [188.166.185.233]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3wpB4g1dKPzDqL8 for ; Thu, 15 Jun 2017 14:54:43 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="jIFfDI2J"; dkim-atps=neutral Received: from v4.ozlabs.ibm.com (unknown [122.99.82.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: sam@mendozajonas.com) by mendozajonas.com (Postfix) with ESMTPSA id 711961441AC; Thu, 15 Jun 2017 12:54:39 +0800 (SGT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mendozajonas.com; s=mail; t=1497502479; bh=9+padsuUDnsePiI8y3yGu8P36KSSHyuxk+aeQIfwtoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jIFfDI2J6SoMooPcvXuvzSxq0+BHfNoORPnVQpojiavwx6ojMN6g0cF1eTIC7Zt9M 8vN/ubwSGfW8vo+10mKxtspx8xLrVdqb9uBvv6cqu6f3LKlt+V4Rt5PdqBMP4DWfI5 YljnFFFjDzvUJAju84hYyAsVJ49J4tY7q6A6ZJGM= From: Samuel Mendoza-Jonas To: petitboot@lists.ozlabs.org Subject: [PATCH 2/4] discover/devmapper: Add prefix to devmapper device names Date: Thu, 15 Jun 2017 14:54:29 +1000 Message-Id: <20170615045431.29572-3-sam@mendozajonas.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170615045431.29572-1-sam@mendozajonas.com> References: <20170615045431.29572-1-sam@mendozajonas.com> X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Mendoza-Jonas MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" 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 --- discover/devmapper.c | 15 +++++++++------ 1 file 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;