Re: assertion PED_LE64_TO_CPU (gpt-AlternateLBA) = disk-dev-length failed

2008-11-11 Thread Joel Granados
Hey list:

This message seems ok to me. While I look at the patch I ask myself if it would 
not be better a PED_EXCEPTION_ERROR instead of the warning.  And, moreover, 
what occurs if the user selects ignore as apposed to cancel?

Additionally a test case here would be *great* but how do you actually make the 
gpt table point to a point that is farther away than the device.  .  maybe 
creating a label in a device with X size, then copying the first blocks to a 
device that is smaller than the other. and then executing some parted command.

Regards
- Petr Uzel [EMAIL PROTECTED] wrote:

 On Tue, Aug 26, 2008 at 12:27:21PM -0600, Bjorn Helgaas wrote:
   Yes, that is probably the root of the problem.
   The assertion is Parted's way of warning you that your
   disk/partition table is corrupted in a surprising/unusual way.
   Can you suggest a better way to handle this sort of failure?
  
  My preference would be:
  
- Since there's a valid GPT at the beginning of the image, and
 only
  the secondary copy is missing, warn that the secondary copy is
  missing or corrupted and continue.
 
 What about this fix? Just a proposal...
 
 From c44a42e6a15388bf87de873fbca07796c0139b69 Mon Sep 17 00:00:00
 2001
 From: Petr Uzel [EMAIL PROTECTED]
 Date: Wed, 5 Nov 2008 10:17:07 +0100
 Subject: [PATCH] print warning instead of crash on corrupted GPT
 
 ---
  libparted/labels/gpt.c |   14 --
  1 files changed, 12 insertions(+), 2 deletions(-)
 
 diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
 index 13d2e88..c20d729 100644
 --- a/libparted/labels/gpt.c
 +++ b/libparted/labels/gpt.c
 @@ -824,8 +824,18 @@ gpt_read (PedDisk * disk)
   goto error;
  
   if (_read_header (disk-dev, gpt, 1)) {
 - PED_ASSERT ((PedSector) PED_LE64_TO_CPU (gpt-AlternateLBA)
 - = disk-dev-length - 1, goto error_free_gpt);
 + if ((PedSector) PED_LE64_TO_CPU (gpt-AlternateLBA)
 +  disk-dev-length - 1) {
 + if (ped_exception_throw (
 + PED_EXCEPTION_WARNING,
 + PED_EXCEPTION_IGNORE_CANCEL,
 + _(The primary GPT table states that the backup GPT table is 
 +   located at the position that is beyond the end of the disk. 
 +   This means that the GPT structure is corrupted.))
 + == PED_EXCEPTION_CANCEL)
 + goto error_free_gpt;
 + }
 +
   if ((PedSector) PED_LE64_TO_CPU (gpt-AlternateLBA)
disk-dev-length - 1) {
   char* zeros = ped_malloc (pth_get_size (disk-dev));
 -- 
 1.6.0.2
 
 
 -- 
 Best regards / s pozdravem
 
 Petr Uzel, Packages maintainer
 -
 SUSE LINUX, s.r.o.  e-mail: [EMAIL PROTECTED]
 Lihovarská 1060/12  tel: +420 284 028 964
 190 00 Prague 9 fax: +420 284 028 951
 Czech Republic  http://www.suse.cz
 
 
 ___
 bug-parted mailing list
 bug-parted@gnu.org
 http://lists.gnu.org/mailman/listinfo/bug-parted

-- 
Joel Andres Granados
Red Hat / Brno Czech Republic


___
bug-parted mailing list
bug-parted@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-parted


Re: assertion PED_LE64_TO_CPU (gpt-AlternateLBA) = disk-dev-length failed

2008-11-05 Thread Petr Uzel
On Tue, Aug 26, 2008 at 12:27:21PM -0600, Bjorn Helgaas wrote:
  Yes, that is probably the root of the problem.
  The assertion is Parted's way of warning you that your
  disk/partition table is corrupted in a surprising/unusual way.
  Can you suggest a better way to handle this sort of failure?
 
 My preference would be:
 
   - Since there's a valid GPT at the beginning of the image, and only
 the secondary copy is missing, warn that the secondary copy is
 missing or corrupted and continue.

What about this fix? Just a proposal...

From c44a42e6a15388bf87de873fbca07796c0139b69 Mon Sep 17 00:00:00 2001
From: Petr Uzel [EMAIL PROTECTED]
Date: Wed, 5 Nov 2008 10:17:07 +0100
Subject: [PATCH] print warning instead of crash on corrupted GPT

---
 libparted/labels/gpt.c |   14 --
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 13d2e88..c20d729 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -824,8 +824,18 @@ gpt_read (PedDisk * disk)
goto error;
 
if (_read_header (disk-dev, gpt, 1)) {
-   PED_ASSERT ((PedSector) PED_LE64_TO_CPU (gpt-AlternateLBA)
-   = disk-dev-length - 1, goto error_free_gpt);
+   if ((PedSector) PED_LE64_TO_CPU (gpt-AlternateLBA)
+disk-dev-length - 1) {
+   if (ped_exception_throw (
+   PED_EXCEPTION_WARNING,
+   PED_EXCEPTION_IGNORE_CANCEL,
+   _(The primary GPT table states that the backup GPT table is 
+ located at the position that is beyond the end of the disk. 
+ This means that the GPT structure is corrupted.))
+   == PED_EXCEPTION_CANCEL)
+   goto error_free_gpt;
+   }
+
if ((PedSector) PED_LE64_TO_CPU (gpt-AlternateLBA)
 disk-dev-length - 1) {
char* zeros = ped_malloc (pth_get_size (disk-dev));
-- 
1.6.0.2


-- 
Best regards / s pozdravem

Petr Uzel, Packages maintainer
-
SUSE LINUX, s.r.o.  e-mail: [EMAIL PROTECTED]
Lihovarská 1060/12  tel: +420 284 028 964
190 00 Prague 9 fax: +420 284 028 951
Czech Republic  http://www.suse.cz


___
bug-parted mailing list
bug-parted@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-parted


Re: assertion PED_LE64_TO_CPU (gpt-AlternateLBA) = disk-dev-length failed

2008-08-26 Thread Jim Meyering
Bjorn Helgaas [EMAIL PROTECTED] wrote:

 [I tried to submit this via Trac, but it said 500 Internal Server Error
 (Submission rejected as potential spam)].

 I also tried to debug this with gdb, but the parted I built complains
 like this:

Sometimes it's easier to debug if you configure like this:

./configure --enable-debug --disable-shared CFLAGS=-g

   $ /usr/local/sbin/parted ../rhel5.2-image
   /usr/local/sbin/parted: error while loading shared libraries: 
 libparted-1.8.so.8: cannot open shared object file: No such file or directory

 ... I used dd to copy the first 5GB of /dev/sda to the file rhel5.2-image.

 The GPT scheme keeps a secondary copy of the partition table at the
 end of the disk.  My rhel5.2-image file is obviously missing that,
 since it only contains the first 5GB of the disk image.  That might
 explain this assertion failure.

Yes, that is probably the root of the problem.
The assertion is Parted's way of warning you that your
disk/partition table is corrupted in a surprising/unusual way.
Can you suggest a better way to handle this sort of failure?

 But I hope parted can handle this situation more gracefully.

...
 ...

 Assertion (last_usable = disk-dev-length) at gpt.c:689 in function
 _parse_header() failed.

 Ignore/Cancel? i
 Error: Can't have a partition outside the disk!
 Error: Can't have a partition outside the disk!


___
bug-parted mailing list
bug-parted@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-parted