2008-02-19 Robert Millan <rmh@aybabtu.com>
* partmap/gpt.c: Include `<grub/gpt_partition.h>'. (grub_gpt_partition_type_empty): Redefine with macro from `<grub/gpt_partition.h>'. (gpt_partition_map_iterate): Adjust partition type comparison. Export `entry' as partmap-specific `part.data' struct. (grub_gpt_header, grub_gpt_partentry): Move from here ... * include/grub/gpt_partition.h (grub_gpt_header) (grub_gpt_partentry): ... to here (new file). * util/i386/pc/grub-setup.c: Include `<grub/gpt_partition.h>'. (grub_gpt_partition_type_bios_boot): New const variable, defined with macro from `<grub/gpt_partition.h>'. (setup): Replace `first_start' with `embed_region', which keeps track of the embed region (and is partmap-agnostic). Replace find_first_partition_start() with find_usable_region(), which finds a usable region for embedding using partmap-specific knowledge (supports PC/MSDOS and GPT). Fix all assumptions that the embed region start at sector 1, using `embed_region.start' from now on. Similarly, use `embed_region.end' rather than `first_start' to calculate available size. In grub_util_info() message, replace "into after the MBR" with an indication of the specific sector our embed region starts at.
This commit is contained in:
parent
66cb40f6c1
commit
b93bdb0f6d
3 changed files with 72 additions and 50 deletions
|
@ -1,7 +1,7 @@
|
|||
/* gpt.c - Read GUID Partition Tables (GPT). */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2002,2005,2006,2007 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2002,2005,2006,2007,2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -23,41 +23,14 @@
|
|||
#include <grub/partition.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/pc_partition.h>
|
||||
|
||||
struct grub_gpt_header
|
||||
{
|
||||
grub_uint8_t magic[8];
|
||||
grub_uint32_t version;
|
||||
grub_uint32_t headersize;
|
||||
grub_uint32_t crc32;
|
||||
grub_uint32_t unused1;
|
||||
grub_uint64_t primary;
|
||||
grub_uint64_t backup;
|
||||
grub_uint64_t start;
|
||||
grub_uint64_t end;
|
||||
grub_uint8_t guid[16];
|
||||
grub_uint64_t partitions;
|
||||
grub_uint32_t maxpart;
|
||||
grub_uint32_t partentry_size;
|
||||
grub_uint32_t partentry_crc32;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct grub_gpt_partentry
|
||||
{
|
||||
grub_uint8_t type[16];
|
||||
grub_uint8_t guid[16];
|
||||
grub_uint64_t start;
|
||||
grub_uint64_t end;
|
||||
grub_uint8_t attrib;
|
||||
char name[72];
|
||||
} __attribute__ ((packed));
|
||||
#include <grub/gpt_partition.h>
|
||||
|
||||
static grub_uint8_t grub_gpt_magic[8] =
|
||||
{
|
||||
45, 46, 49, 20, 50, 41, 52, 54
|
||||
};
|
||||
|
||||
static grub_uint8_t grub_gpt_partition_type_empty[16] = { 0 };
|
||||
static const grub_gpt_part_type_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY;
|
||||
|
||||
static struct grub_partition_map grub_gpt_partition_map;
|
||||
|
||||
|
@ -114,7 +87,7 @@ gpt_partition_map_iterate (grub_disk_t disk,
|
|||
sizeof (entry), (char *) &entry))
|
||||
return grub_errno;
|
||||
|
||||
if (grub_memcmp (grub_gpt_partition_type_empty, entry.type,
|
||||
if (grub_memcmp (&grub_gpt_partition_type_empty, &entry.type,
|
||||
sizeof (grub_gpt_partition_type_empty)))
|
||||
{
|
||||
/* Calculate the first block and the size of the partition. */
|
||||
|
@ -124,6 +97,7 @@ gpt_partition_map_iterate (grub_disk_t disk,
|
|||
part.offset = entries;
|
||||
part.index = partno;
|
||||
part.partmap = &grub_gpt_partition_map;
|
||||
part.data = &entry;
|
||||
|
||||
grub_dprintf ("gpt", "GPT entry %d: start=%lld, length=%lld\n",
|
||||
partno, part.start, part.len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue