parted/0024-gpt-when-mklabel-gpt-fails-always-provide-a-diagnost.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

39 lines
1.3 KiB
Diff

From 7ca7f595e4cef589db852394687a6ca0c2925fa7 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Wed, 12 Sep 2012 10:48:33 +0200
Subject: [PATCH 24/89] gpt: when "mklabel gpt" fails, always provide a
diagnostic
* libparted/labels/gpt.c (gpt_alloc): When rejecting a device because
it is too small, give a diagnostic, as is done in every other failure
path through this function.
---
libparted/labels/gpt.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 564a889..63b30b9 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -504,9 +504,15 @@ gpt_alloc (const PedDevice *dev)
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 the device is too small to accommodate GPT headers, reject it. */
if (data_end < data_start)
- goto error_free_disk;
+ {
+ ped_exception_throw (PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_OK,
+ _("device is so small it cannot even"
+ " accommodate GPT headers"));
+ goto error_free_disk;
+ }
disk->disk_specific = gpt_disk_data = ped_malloc (sizeof (GPTDiskData));
if (!disk->disk_specific)
--
1.8.5.3