parted/0057-gpt-Revert-small-device-commits.patch
Brian C. Lane 0b7af917e2 - Rebase on new upstream master commit cc382c3
- Drop patches incorporated into upstream
- Still adds the various DASD patches
2014-04-08 11:46:37 -07:00

76 lines
2.9 KiB
Diff

From 62a27ccbdaa29a825a593c9562a5cf55ff9e8db4 Mon Sep 17 00:00:00 2001
From: Phillip Susi <psusi@ubuntu.com>
Date: Sat, 29 Dec 2012 21:59:08 -0500
Subject: [PATCH 57/89] gpt: Revert small device commits
The following commit broke the position of the LastUsableLBA:
48f236f9: gpt: permit "mklabel gpt" on a 67-sector device
It introduced an off by one error, leaving LastUsableLBA pointing to
the first sector of the backup partition table instead.
This effectively reverts that commit, as well as adjusting the subsequent
commits to instead use 68 sectors as the minimum length. I believe
this is the minimum legal size as at 67 sectors, there is no valid
value for FirstUsableLBA and LastUsableLBA.
---
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 da291df..d95d9cd 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.8.5.3