[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GPT probe: signature vs checksum

From: Andrew Clausen
Subject: Re: GPT probe: signature vs checksum
Date: Sat, 1 Dec 2001 07:08:11 +1100
User-agent: Mutt/1.3.17i

On Fri, Nov 30, 2001 at 06:42:54AM -0600, address@hidden wrote:
> Then they're going to add the PMBR test too.  Yes, it's heavyweight for
> probe,

And also too demanding.  i.e. it will reject corrupted, or plain
broken GPT tables (created with a buggy tool), even when it might
make sense to let the user to recover it.

You should be able to detect broken gpt tables, AS LONG AS it never
confuses a real MSDOS with a broken GPT.

> but I want to follow the spec (or work w/ Intel to change it like we
> did the pmbr test).

Why?  I guess "following the spec" is always going to be a religious
issue, but I always prefer "what works best".

Can I contribute somehow to the spec?

> If there are no sigs on the primary (or more generally, if anything about
> the primary is wrong), we test the alternate.  If the alternate turns out
> bad also, then something really doesn't want this disk to be gpt.

My new gpt_probe():

static int
gpt_probe(const PedDevice * dev)
        GuidPartitionTableHeader_t gpt;
        LegacyMBR_t legacy_mbr;
        int gpt_sig_found = 0;

        PED_ASSERT (dev != NULL, return 0);

        if (gpt_read_header(dev, 0, &gpt)) {
                if (gpt->Signature == GPT_HEADER_SIGNATURE)
                        gpt_sig_found = 1;
        if (gpt_read_header(dev, dev->length - 1, &gpt)) {
                if (gpt->Signature == GPT_HEADER_SIGNATURE)
                        gpt_sig_found = 1;
        if (!gpt_sig_found)
                return 0;

        if (ped_device_read(dev, legacyMbr, 0, 1)) {
                if (!pmbr_is_valid (&legacyMbr)) {
                        int ex_status = ped_exception_throw (
                        _("%s contains GPT signatures, indicating that it has "
                          "a GPT table.  However, it does not have a valid "
                          "fake msdos partition table, as it should.  Perhaps "
                          "it was corrupted - possibly by a program that "
                          "doesn't understand GPT partition tables.  Or "
                          "perhaps you deleted the GPT table, and are now "
                          "using an msdos partition table.  Is this a GPT "
                          "partition table?"),
                        if (ex_status != PED_EXCEPTION_YES)
                                return 0;

        return 1;

Nice and simple, and should deal with all cases cleanly (eg: bad first
sector, pmbr changed).  Why can't that go in the spec?

i.e. define GPT present (possibly corrupt) vs GPT valid.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]