[parted-devel] [PATCH] Revert small device commits

Phillip Susi psusi at ubuntu.com
Sun Dec 30 04:59:05 UTC 2012


The following commit broke the position of the LastUsableLBA:

48f236f9: gpt: permit "mklabel gpt" on a 67-sector device

This effectively reverts that commit, as well as adjusting the subsequent
commits to instead use 68 sectors as the minimum length, since there
appears to be other parted code that can not cope with a partition table
without room for at least a 1 sector partition, and creating a partition
table without room for any partitions is silly anyhow.
---
 libparted/labels/gpt.c                        |    8 ++++----
 tests/t0203-gpt-create-on-min-sized-device.sh |    7 +++----
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 490de70..eaf14b5 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -506,16 +506,16 @@ gpt_alloc (const PedDevice *dev)
     goto error;
 
   data_start = 2 + GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / dev->sector_size;
-  data_end = dev->length - 1
+  data_end = dev->length - 2
     - GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / dev->sector_size;
 
-  /* If the device is too small to accommodate GPT headers, reject it.  */
+  /* If the device is too small to accommodate GPT headers and one data
+     sector, reject it.  */
   if (data_end < data_start)
     {
       ped_exception_throw (PED_EXCEPTION_ERROR,
 			   PED_EXCEPTION_OK,
-			   _("device is so small it cannot even"
-			     " accommodate GPT headers"));
+			   _("device is too small for GPT"));
       goto error_free_disk;
     }
 
diff --git a/tests/t0203-gpt-create-on-min-sized-device.sh b/tests/t0203-gpt-create-on-min-sized-device.sh
index 4cec64c..a946883 100644
--- a/tests/t0203-gpt-create-on-min-sized-device.sh
+++ b/tests/t0203-gpt-create-on-min-sized-device.sh
@@ -24,7 +24,7 @@ dev=loop-file
 ss=$sector_size_
 
 # Create the smallest file that can accommodate a GPT partition table.
-dd if=/dev/null of=$dev bs=$ss seek=67 || framework_failure
+dd if=/dev/null of=$dev bs=$ss seek=68 || framework_failure
 
 # create a GPT partition table
 parted -s $dev mklabel gpt > out 2>&1 || fail=1
@@ -34,10 +34,9 @@ compare /dev/null out || fail=1
 # Create a file that is 1 sector smaller, and require failure,
 # *with* a diagnostic.
 rm -f $dev
-dd if=/dev/null of=$dev bs=$ss seek=66 || framework_failure
+dd if=/dev/null of=$dev bs=$ss seek=67 || framework_failure
 
-echo Error: device is so small it cannot even accommodate GPT headers \
-  > exp || framework_failure
+echo Error: device is too small for GPT > exp || framework_failure
 
 # Try to create a GPT partition table in too little space.  This must fail.
 parted -s $dev mklabel gpt > out 2>&1 && fail=1
-- 
1.7.10.4




More information about the parted-devel mailing list