From patchwork Tue May 31 23:16:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 9145795 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5C27A60752 for ; Tue, 31 May 2016 23:21:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F8D0263DC for ; Tue, 31 May 2016 23:21:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 447662666A; Tue, 31 May 2016 23:21:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 01255263DC for ; Tue, 31 May 2016 23:21:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u4VNHUEE027643; Tue, 31 May 2016 19:17:30 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u4VNH3dL026269 for ; Tue, 31 May 2016 19:17:03 -0400 Received: from redhat.com (octiron.msp.redhat.com [10.15.80.209]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id u4VNH2er021400; Tue, 31 May 2016 19:17:02 -0400 Received: by redhat.com (sSMTP sendmail emulation); Tue, 31 May 2016 18:17:02 -0500 From: "Benjamin Marzinski" To: device-mapper development Date: Tue, 31 May 2016 18:16:50 -0500 Message-Id: <1464736610-20027-8-git-send-email-bmarzins@redhat.com> In-Reply-To: <1464736610-20027-1-git-send-email-bmarzins@redhat.com> References: <1464736610-20027-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: dm-devel@redhat.com Cc: Christophe Varoqui Subject: [dm-devel] [PATCH 7/7] kpartx: fix dos partition rollover error X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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-Virus-Scanned: ClamAV using ClamSMTP dos partitions are limited to 2^32 sectors. However these do not have to be 512 byte sectors, which is what device-mapper tables use. kpartx stores the dos sectors in a 32 uint. This means that on a 4k sector size device with large enough partitions, when kpartx multiplies the dos sector count by the sector size multiplier, it can rollover before it gets stored in 64 bit slice sector count. This patch just changes the multiplier to a 64 bit uint to match the slice sector count, and avoid the rollover. Signed-off-by: Benjamin Marzinski --- kpartx/dos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpartx/dos.c b/kpartx/dos.c index 90ad3bd..f252d0a 100644 --- a/kpartx/dos.c +++ b/kpartx/dos.c @@ -79,7 +79,7 @@ read_dos_pt(int fd, struct slice all, struct slice *sp, int ns) { unsigned long offset = all.start; int i, n=4; unsigned char *bp; - int sector_size_mul = get_sector_size(fd)/512; + uint64_t sector_size_mul = get_sector_size(fd)/512; bp = (unsigned char *)getblock(fd, offset); if (bp == NULL)