[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/9] gpt: Revert small device commits
From: |
Phillip Susi |
Subject: |
[PATCH 3/9] gpt: Revert small device commits |
Date: |
Sun, 30 Jun 2013 23:11:55 -0400 |
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.1.2
- [PATCH 1/9] parted: fix EOF and ctrl-c handling, Phillip Susi, 2013/06/30
- [PATCH 2/9] tests: t6003-dm-hide: don't hang on exception, Phillip Susi, 2013/06/30
- [PATCH 3/9] gpt: Revert small device commits,
Phillip Susi <=
- [PATCH 5/9] libparted: handle logical partitions starting immediately after the EBR, Phillip Susi, 2013/06/30
- [PATCH 4/9] libparted: set dmraid partition uuid, Phillip Susi, 2013/06/30
- [PATCH 9/9] Revert "linux-commit: do not unnecessarily open partition device nodes", Phillip Susi, 2013/06/30
- [PATCH 6/9] libparted: fix gpt end of disk handling, Phillip Susi, 2013/06/30
- [PATCH 7/9] parted: don't reload partition table on every command, Phillip Susi, 2013/06/30
- [PATCH 8/9] libparted: allow some common errors to be ignored, Phillip Susi, 2013/06/30