From 7ca7f595e4cef589db852394687a6ca0c2925fa7 Mon Sep 17 00:00:00 2001 From: Jim Meyering 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