Re: [PATCH firmware-utils] ptgen: fix limitation for active partition in GPT

2024-02-26 Thread Paul D

On 2024-02-23 15:49, Thomas Richard wrote:

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 


Agreed.


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH firmware-utils] ptgen: fix limitation for active partition in GPT

2024-02-23 Thread Thomas Richard via openwrt-devel
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.--- Begin Message ---
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;
-- 
2.39.2


--- End Message ---
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel