From 48f236f9cf1bbcd4c9cc29ebaecee7ed189580e3 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 12 Sep 2012 10:01:53 +0200 Subject: [PATCH 23/89] 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.8.5.3