I actually wrote this patch back in April 2007 when I was trying to
get Parted to parse EFI GPT labels written by OpenSolaris ZFS. As you
can tell from the change description, Parted was messing up my
partitions.
- Linux was seeing my partitions as being a different size than
OpenSolaris was, and Parted was a bit too eager to "fix" things.
- Parted was computing the CRC differently than OpenSolaris was
(though I fixed this in another change last year), and again Parted
was a bit too eager to "fix" it.
I haven't touched Parted since then, but I've been wanting to get this
off my plate.
Thanks!
Matthew
From c1e6d20c2c143ed80a6c3af6a107b3f34b4f071c Mon Sep 17 00:00:00 2001
From: Matthew S. Harris <[EMAIL PROTECTED]>
Date: Tue, 18 Nov 2008 20:57:54 -0800
Subject: [PATCH] Be more conservative about modifying the disk.
* libparted/labels/gpt.c (gpt_read): When the backup GPT table isn't
at the end of the disk, allow (and default to) ignoring the problem.
If another OS sees the disk as smaller, we don't want to break them by
moving things around.
* libparted/labels/gpt.c (gpt_read): If the primary GPT table appears
corrupt, the default behavior (when the user presses Ctrl-C, for
example) should be to cancel rather than to overwrite the primary GPT
table.
---
libparted/labels/gpt.c | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 13d2e88..e8b3434 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -832,20 +832,19 @@ gpt_read (PedDisk * disk)
#ifndef DISCOVER_ONLY
if (ped_exception_throw (
- PED_EXCEPTION_ERROR,
+ PED_EXCEPTION_WARNING,
PED_EXCEPTION_FIX | PED_EXCEPTION_CANCEL,
_("The backup GPT table is not at the end of the disk, as it "
"should be. This might mean that another operating system "
"believes the disk is smaller. Fix, by moving the backup "
"to the end (and removing the old backup)?"))
- == PED_EXCEPTION_CANCEL)
- goto error_free_gpt;
-
- write_back = 1;
- memset (zeros, 0, disk->dev->sector_size);
- ped_device_write (disk->dev, zeros,
- PED_LE64_TO_CPU (gpt->AlternateLBA),
- 1);
+ == PED_EXCEPTION_FIX) {
+ write_back = 1;
+ memset (zeros, 0, disk->dev->sector_size);
+ ped_device_write (disk->dev, zeros,
+ PED_LE64_TO_CPU
(gpt->AlternateLBA),
+ 1);
+ }
#endif /* !DISCOVER_ONLY */
}
} else { /* primary GPT *not* ok */
@@ -868,10 +867,10 @@ gpt_read (PedDisk * disk)
if (alternate_ok) {
if (ped_exception_throw (
PED_EXCEPTION_ERROR,
- PED_EXCEPTION_OK_CANCEL,
+ PED_EXCEPTION_FIX | PED_EXCEPTION_CANCEL,
_("The primary GPT table is corrupt, but the "
"backup appears OK, so that will be used."))
- == PED_EXCEPTION_CANCEL)
+ != PED_EXCEPTION_FIX)
goto error_free_gpt;
} else {
ped_exception_throw (
--
1.5.6.3
_______________________________________________
parted-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/parted-devel