On Thu, Feb 14, 2013 at 11:44:30PM +0100, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
> +#define MBR_OSTYPE_EFI_GPT   0xee
> +
> +static inline int pmbr_part_valid(const uint8_t *buf)
> +{
> +     if (buf[MBR_PART_sys_ind] == MBR_OSTYPE_EFI_GPT &&
> +             get_unaligned_le32(&buf[MBR_PART_start_sect]) == 1UL) {
> +             return 1;
> +     }
> +
> +     return 0;
> +}
> +
> +/**
> + * is_pmbr_valid(): test Protective MBR for validity
> + * @mbr: pointer to a legacy mbr structure
> + *
> + * Description: Returns 1 if PMBR is valid, 0 otherwise.
> + * Validity depends on two things:
> + *  1) MSDOS signature is in the last two bytes of the MBR
> + *  2) One partition of type 0xEE is found
> + */
> +static int is_gpt_valid(const uint8_t *buf)
> +{
> +     int i;
> +
> +     if (get_unaligned_le16(&buf[BS_55AA]) != 0xAA55)
> +             return 0;
> +
> +     if (strncmp(&buf[512], "EFI PART", 8))
> +             return 0;
> +
> +     buf += MBR_Table;
> +
> +     for (i = 0; i < 4; i++, buf += MBR_partition_size) {
> +             if (pmbr_part_valid(buf))
> +                     return 1;
> +     }
> +     return 0;
> +}


ACK, this is what I meant.

Thanks,
Johannes

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to