From patchwork Thu Oct 8 19:44:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 7355021 X-Patchwork-Delegate: bmarzins@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CB5199F1B9 for ; Thu, 8 Oct 2015 19:47:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 09E9B207BC for ; Thu, 8 Oct 2015 19:47:42 +0000 (UTC) Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F5B6207B9 for ; Thu, 8 Oct 2015 19:47:41 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t98Jj6g0029994; Thu, 8 Oct 2015 15:45:06 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id t98Jj5DV005783 for ; Thu, 8 Oct 2015 15:45:05 -0400 Received: from redhat.com (octiron.msp.redhat.com [10.15.80.209]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t98Jj4S5010480; Thu, 8 Oct 2015 15:45:04 -0400 Received: by redhat.com (sSMTP sendmail emulation); Thu, 08 Oct 2015 14:45:03 -0500 From: "Benjamin Marzinski" To: device-mapper development Date: Thu, 8 Oct 2015 14:44:40 -0500 Message-Id: <1444333491-16265-8-git-send-email-bmarzins@redhat.com> In-Reply-To: <1444333491-16265-1-git-send-email-bmarzins@redhat.com> References: <1444333491-16265-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: dm-devel@redhat.com Cc: Christophe Varoqui Subject: [dm-devel] [PATCH 07/18] make kpartx -d remove all partitions X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently kpartx -d only removes the partitions that have entries in the partition table. If you remove a partition from the device, and then run kpartx -d, it will not delete that partition (kpartx -u will). I don't see any value in leaving partition devices for partitions that don't even exist anymore, so this patch makes -d delete all partitions. Signed-off-by: Benjamin Marzinski Reviewed-by: Hannes Reinecke --- kpartx/kpartx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c index d69f9af..a9d4c98 100644 --- a/kpartx/kpartx.c +++ b/kpartx/kpartx.c @@ -426,7 +426,7 @@ main(int argc, char **argv){ break; case DELETE: - for (j = n-1; j >= 0; j--) { + for (j = MAXSLICES-1; j >= 0; j--) { if (safe_sprintf(partname, "%s%s%d", mapname, delim, j+1)) { fprintf(stderr, "partname too small\n"); @@ -434,7 +434,7 @@ main(int argc, char **argv){ } strip_slash(partname); - if (!slices[j].size || !dm_map_present(partname)) + if (!dm_map_present(partname)) continue; if (!dm_simplecmd(DM_DEVICE_REMOVE, partname,