[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] gpt: permit "mklabel gpt" on a 67-sector device
From: |
Jim Meyering |
Subject: |
[PATCH 2/2] gpt: permit "mklabel gpt" on a 67-sector device |
Date: |
Wed, 12 Sep 2012 21:03:01 +0200 |
FYI, this is mostly incidental.
Yesterday I tried to create a gpt label on a device that was
too small. I did see the expected failure (exit nonzero), but did
not expect an accompanying failure: no diagnostic.
Exploring the limits, I found fixed these issues:
>From 81faa9b3b957781871ec3ef0df6e357388f857a1 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 12 Sep 2012 20:34:48 +0200
Subject: [PATCH 1/2] tests: update t7000-scripting.sh to avoid new FP
* tests/t7000-scripting.sh: Use -34s as the endpoint, not -1s,
to avoid a spurious difference. Also, remove quoting artifacts.
---
tests/t7000-scripting.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/t7000-scripting.sh b/tests/t7000-scripting.sh
index e64814b..859acda 100755
--- a/tests/t7000-scripting.sh
+++ b/tests/t7000-scripting.sh
@@ -47,7 +47,7 @@ for mkpart in mkpart; do
dd if=/dev/zero of=testfile bs=${ss}c count=$N 2> /dev/null || fail=1
# Test the scripting mode of $mkpart.
- parted -s testfile -- mklabel gpt "$mkpart" p-name ext3 1s -1s > out 2>&1
+ parted -s testfile -- mklabel gpt "$mkpart" p-name ext3 1s -34s > out 2>&1
test $? = 1 || fail=1
# Compare the real error and the expected one
@@ -60,8 +60,8 @@ for mkpart in mkpart; do
dd if=/dev/zero of=testfile bs=${ss}c count=$N 2> /dev/null || fail=1
# Test the interactive mode of $mkpart
echo n | \
- parted ---pretend-input-tty testfile \
- "mklabel gpt '$mkpart' p-name ext3 1s -1s" > out 2>&1 && fail=1
+ parted ---pretend-input-tty -- testfile \
+ mklabel gpt $mkpart p-name ext3 1s -34s > out 2>&1 && fail=1
# We have to format the output before comparing.
# normalize the actual output
--
1.7.12.363.g53284de
>From 48f236f9cf1bbcd4c9cc29ebaecee7ed189580e3 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 12 Sep 2012 10:01:53 +0200
Subject: [PATCH 2/2] gpt: permit "mklabel gpt" on a 67-sector device
* libparted/labels/gpt.c (gpt_alloc): Correct checks in order to
allow creation of a GPT partition table on a 67-sector device.
The computation of the "data_end" sector number was one too low.
Whereas there are two sectors at the beginning of the disk (pMBR
and the GPT header sector), there is only one at the end: the
backup GPT header. That (67) is the size of the smallest GPT
partition table, allowing for *no* partition table sectors.
---
libparted/labels/gpt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 83e518f..564a889 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -501,11 +501,11 @@ gpt_alloc (const PedDevice *dev)
goto error;
data_start = 2 + GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / dev->sector_size;
- data_end = dev->length - 2
+ data_end = dev->length - 1
- GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / dev->sector_size;
/* If the device is too small to have room for data, reject it. */
- if (data_end <= data_start)
+ if (data_end < data_start)
goto error_free_disk;
disk->disk_specific = gpt_disk_data = ped_malloc (sizeof (GPTDiskData));
--
1.7.12.363.g53284de
- [PATCH 2/2] gpt: permit "mklabel gpt" on a 67-sector device,
Jim Meyering <=