[parted-devel] [PATCH 1/4] libparted: Remove the prompt to fix the backup GPT header.

Brian C. Lane bcl at redhat.com
Sat Mar 29 03:46:16 UTC 2014


If the header is in the wrong place it will be caught by the code to
detect unused space, so remove the prompt completely. This also fixes a
comparison that would have resulted in using a PTE area that was smaller
than the default instead of the larger.

* libparted/labels/gpt.c (gpt_read): Drop the fix backup gpt table prompt.
  (_parse_header): Fix size compare for PTE area.
---
 libparted/labels/gpt.c | 27 ++-------------------------
 1 file changed, 2 insertions(+), 25 deletions(-)

diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 42b0360..26ec755 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -737,7 +737,8 @@ _parse_header (PedDisk *disk, const GuidPartitionTableHeader_t *gpt,
   last_usable_min_default = disk->dev->length - 2 -
     GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / disk->dev->sector_size;
 
-  if (last_usable_if_grown > last_usable_min_default)
+  /* Use the LARGER PTE area */
+  if (last_usable_if_grown < last_usable_min_default)
     last_usable_if_grown = last_usable_min_default;
 
   if (last_usable <= first_usable
@@ -763,7 +764,6 @@ _parse_header (PedDisk *disk, const GuidPartitionTableHeader_t *gpt,
 
       if (q == PED_EXCEPTION_FIX)
         {
-          last_usable = last_usable_if_grown;
           /* clear the old backup gpt header */
           ptt_clear_sectors (disk->dev,
                              gpt_disk_data->AlternateLBA, 1);
@@ -984,29 +984,6 @@ gpt_read (PedDisk *disk)
   if (primary_gpt && backup_gpt)
     {
       /* Both are valid.  */
-#ifndef DISCOVER_ONLY
-      PedSector gpt_disk_end = PED_LE64_TO_CPU (primary_gpt->LastUsableLBA) + 1;
-      gpt_disk_end += ((PedSector) (PED_LE32_TO_CPU (primary_gpt->NumberOfPartitionEntries)) *
-                       (PedSector) (PED_LE32_TO_CPU (primary_gpt->SizeOfPartitionEntry)) /
-                       disk->dev->sector_size);
-
-      gpt_disk_data->AlternateLBA = PED_LE64_TO_CPU (primary_gpt->AlternateLBA);
-      if (PED_LE64_TO_CPU (primary_gpt->AlternateLBA) != gpt_disk_end)
-        {
-          if (ped_exception_throw
-                  (PED_EXCEPTION_ERROR,
-                   (PED_EXCEPTION_FIX | PED_EXCEPTION_IGNORE),
-                   _("The backup GPT table is not at the end of the disk, as it "
-                     "should be.  Fix, by moving the backup to the end "
-                     "(and removing the old backup)?")) == PED_EXCEPTION_FIX)
-            {
-              ptt_clear_sectors (disk->dev,
-                                 PED_LE64_TO_CPU (primary_gpt->AlternateLBA), 1);
-              gpt_disk_data->AlternateLBA = gpt_disk_end;
-              write_back = 1;
-            }
-        }
-#endif /* !DISCOVER_ONLY */
       pth_free (backup_gpt);
       gpt = primary_gpt;
     }
-- 
1.8.5.3




More information about the parted-devel mailing list