From patchwork Fri Feb 23 14:49:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard X-Patchwork-Id: 1903338 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=c2aAzT11; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4ThCf46NKfz23d2 for ; Sat, 24 Feb 2024 01:52:12 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type:List-Help: Reply-To:List-Archive:List-Unsubscribe:List-Subscribe:From:List-Post:List-Id: Message-ID:MIME-Version:Date:Subject:To:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=xeGl7QvIi7kJg7z+TYchh4ecOYGkjIgEWioID0Xy1W0=; b=c2aAzT1116MfEViU9BBXn2/IsZ jzgmHJ/1xTXRulm5DvmO8kjGdshGFsAEq+oGiG5y0HZupO6/wgyz+jGfnNDZ1SwotTNO0FDKVT1bA toWgXp+AoX5bJn7gMTSs5AzFu8Dudgky1TbP39kLkTLd6DxbB6R5Ins+vangl9I0aR/ixcNjjBZL7 XIxbhX+sAaeOCQQbv5cVUEoEFLDS3+YcMp1avYUcsgKvufJqVLBS3H8zbX1pxmskRq41BTSttvJ5X okOsMLbAT7YjabBLXjJ842+pdBCmVEBggXHrXYbUSnmTVrAlJnN3dAiIyswn1AlE63b5K+TxzrR35 F2cWUAHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdWsO-00000009qt7-0iLY; Fri, 23 Feb 2024 14:50:12 +0000 To: openwrt-devel@lists.openwrt.org Subject: [PATCH firmware-utils] ptgen: fix limitation for active partition in GPT Date: Fri, 23 Feb 2024 15:49:07 +0100 MIME-Version: 1.0 Message-ID: List-Id: OpenWrt Development List List-Post: X-Patchwork-Original-From: Thomas Richard via openwrt-devel From: Thomas Richard Precedence: list X-Mailman-Version: 2.1.34 X-BeenThere: openwrt-devel@lists.openwrt.org List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Thomas Richard List-Help: Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software. In GPT there is no reason to limit the active partition number to 4. This limitation is only for MBR, as it corresponds to the maximum number of primary partitions. Signed-off-by: Thomas Richard --- src/ptgen.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ptgen.c b/src/ptgen.c index b231c28..c7d6bc0 100644 --- a/src/ptgen.c +++ b/src/ptgen.c @@ -569,7 +569,7 @@ fail: static void usage(char *prog) { fprintf(stderr, "Usage: %s [-v] [-n] [-g] -h -s -o \n" - " [-a 0..4] [-l ] [-G ]\n" + " [-a ] [-l ] [-G ]\n" " [[-t | -T ] [-r] [-N ] -p [@]...] \n", prog); exit(EXIT_FAILURE); } @@ -668,8 +668,6 @@ int main (int argc, char **argv) break; case 'a': active = (int)strtoul(optarg, NULL, 0); - if ((active < 0) || (active > 4)) - active = 0; break; case 'l': kb_align = (int)strtoul(optarg, NULL, 0) * 2; @@ -700,6 +698,11 @@ int main (int argc, char **argv) if (argc || (!use_guid_partition_table && ((heads <= 0) || (sectors <= 0))) || !filename) usage(argv[0]); + if ((use_guid_partition_table && active > GPT_ENTRY_MAX) || + (!use_guid_partition_table && active > MBR_ENTRY_MAX) || + active < 0) + active = 0; + if (use_guid_partition_table) { heads = 254; sectors = 63;