[parted-devel] [PATCH 2/2] libparted: raised dos partition limit from 16 to 64

Jim Meyering jim at meyering.net
Wed Jan 18 13:43:17 UTC 2012


Phillip Susi wrote:

> From: Phillip Susi <psusi at cfl.rr.com>
>
> ---
>  NEWS                               |    2 ++
>  libparted/labels/dos.c             |    2 +-
>  tests/t9042-dos-partition-limit.sh |    2 +-
>  3 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/NEWS b/NEWS
> index 194903b..7584c56 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -4,6 +4,8 @@ GNU parted NEWS                                    -*- outline -*-
>
>  ** New features
>
> +  Increased limit for msdos partitions from 16 to 64
> +
>    parted has improved support for partitionable loopback devices
>
>  ** Bug fixes
> diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
> index cb90b79..f5db5b9 100644
> --- a/libparted/labels/dos.c
> +++ b/libparted/labels/dos.c
> @@ -103,7 +103,7 @@ static const char MBR_BOOT_CODE[] = {
>   * (i.e. 1022 is sometimes used to indicate "use LBA").
>   */
>  #define MAX_CHS_CYLINDER	1021
> -#define MAX_TOTAL_PART		16
> +#define MAX_TOTAL_PART		64
>
>  typedef struct _DosRawPartition		DosRawPartition;
>  typedef struct _DosRawTable		DosRawTable;
> diff --git a/tests/t9042-dos-partition-limit.sh b/tests/t9042-dos-partition-limit.sh
> index d19bfd9..3f24d4a 100644
> --- a/tests/t9042-dos-partition-limit.sh
> +++ b/tests/t9042-dos-partition-limit.sh
> @@ -26,7 +26,7 @@ grep '^#define USE_BLKID 1' "$CONFIG_HEADER" > /dev/null ||
>
>  ss=$sector_size_
>  partition_sectors=256  # sectors per partition
> -n_partitions=13        # how many partitions to create
> +n_partitions=61        # how many partitions to create
>  start=2048             # start sector for the first partition

Thanks for another fine patch.
I used this one as the impetus to fix the half-cooked
addition I made to your previous patch.  There, I hard-coded
the expected first partition dimensions with this line:

   "1:$((start-2))s:$((start-2+4098-1))s:4098s:::lba;"

That obviously has too many literals, so I have corrected it
with this:

diff --git a/tests/t9042-dos-partition-limit.sh b/tests/t9042-dos-partition-limit.sh
index 7e3e84a..91d3311 100644
--- a/tests/t9042-dos-partition-limit.sh
+++ b/tests/t9042-dos-partition-limit.sh
@@ -39,9 +39,10 @@ scsi_debug_setup_ sector_size=$ss dev_size_mb=$n_MiB > dev-name ||
 scsi_dev=$(cat dev-name)

 n=$((n_MiB * sectors_per_MiB))
+len=$((2 + partition_sectors * (3+n_partitions)))
 printf '%s\n' "BYT;" \
     "$scsi_dev:${n}s:scsi:$ss:$ss:msdos:Linux scsi_debug;" \
-    "1:$((start-2))s:$((start-2+4098-1))s:4098s:::lba;" \
+    "1:$((start-2))s:$((start-2+len-1))s:${len}s:::lba;" \
   > exp || fail=1

 parted -s $scsi_dev mklabel msdos || fail=1

But even that is still not right, since when I test with
a simulated larger sector size,
  sudo make -C tests check VERBOSE=yes TESTS=t9042-dos-partition-limit.sh \
    PARTED_SECTOR_SIZE=4096
it fails with this:

  --- exp 2012-01-18 13:39:04.966226938 +0000
  +++ out 2012-01-18 13:39:05.165232120 +0000
  @@ -1,6 +1,6 @@
   BYT;
   /dev/sdd:17664s:scsi:4096:4096:msdos:Linux scsi_debug;
  -1:2046s:18431s:16386s:::lba;
  +1:2046s:17663s:15618s:::lba;

Which means the "len=..." part must be changed to depend on $ss.
If someone wants to correct the formula above, please let me know.
Otherwise, I'll probably do it today or tomorrow.

>From e8bceafa04c3ece7f5094a3738f747956a18cb0a Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi at cfl.rr.com>
Date: Fri, 13 Jan 2012 16:21:52 -0500
Subject: [PATCH] libparted: raise dos partition limit from 16 to 64

* NEWS (Bug fixes): Mention it.
* libparted/labels/dos.c (MAX_TOTAL_PART): s/16/64/
* tests/t9042-dos-partition-limit.sh: s/13/61/ (MAX_TOTAL_PART-3)
---
 NEWS                               |    2 ++
 libparted/labels/dos.c             |    2 +-
 tests/t9042-dos-partition-limit.sh |    5 +++--
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 194903b..7584c56 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ GNU parted NEWS                                    -*- outline -*-

 ** New features

+  Increased limit for msdos partitions from 16 to 64
+
   parted has improved support for partitionable loopback devices

 ** Bug fixes
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index 3f3effe..1d3a867 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -103,7 +103,7 @@ static const char MBR_BOOT_CODE[] = {
  * (i.e. 1022 is sometimes used to indicate "use LBA").
  */
 #define MAX_CHS_CYLINDER	1021
-#define MAX_TOTAL_PART		16
+#define MAX_TOTAL_PART		64

 typedef struct _DosRawPartition		DosRawPartition;
 typedef struct _DosRawTable		DosRawTable;
diff --git a/tests/t9042-dos-partition-limit.sh b/tests/t9042-dos-partition-limit.sh
index 07e8f64..91d3311 100644
--- a/tests/t9042-dos-partition-limit.sh
+++ b/tests/t9042-dos-partition-limit.sh
@@ -26,7 +26,7 @@ grep '^#define USE_BLKID 1' "$CONFIG_HEADER" > /dev/null ||

 ss=$sector_size_
 partition_sectors=256  # sectors per partition
-n_partitions=13        # how many partitions to create
+n_partitions=61        # how many partitions to create
 start=2048             # start sector for the first partition

 n_sectors=$(($start + n_partitions * partition_sectors))
@@ -39,9 +39,10 @@ scsi_debug_setup_ sector_size=$ss dev_size_mb=$n_MiB > dev-name ||
 scsi_dev=$(cat dev-name)

 n=$((n_MiB * sectors_per_MiB))
+len=$((2 + partition_sectors * (3+n_partitions)))
 printf '%s\n' "BYT;" \
     "$scsi_dev:${n}s:scsi:$ss:$ss:msdos:Linux scsi_debug;" \
-    "1:$((start-2))s:$((start-2+4098-1))s:4098s:::lba;" \
+    "1:$((start-2))s:$((start-2+len-1))s:${len}s:::lba;" \
   > exp || fail=1

 parted -s $scsi_dev mklabel msdos || fail=1
--
1.7.9.rc1.2.gccfe4



More information about the parted-devel mailing list