Support for GPT
[cc to John, he might be interested in this]
Hi,
Here is a patch which adds support for GPT and it also fixes building GRUB. I will commit this patch on Friday if there are no serious concerns (I don't expect any).
The most important change is the one to partmap/pc.c. GPT uses some dummy MBR to make sure some partitioning programs don't overwrite the GPT. Even when this happens, it can restore a backup. But this change hopefully prevents GRUB from installing on such partition and overwriting the partition data (which is directly after the MBR).
The next step would be figuring out how booting works on such box. I assume we full need support for EFI to do that.
A bit more important is the change of my email address. At some time my old email ([email protected]) address will expire, I am not studying there anymore. I am still reachable on that address, but please remove that address from your address book. All of my other addresses still work.
Thanks,
Marco
2005-11-30 Marco Gerards <[email protected]>
* conf/common.rmk (grub_modules_init.lst): Use -printf "%P\n"' and cd' to make sure the filename is not prefixed with a directory name.
(pkgdata_MODULES): Add `gpt.mod'.
(gpt_mod_SOURCES): New variable.
(gpt_mod_CFLAGS): Likewise.
(gpt_mod_LDFLAGS): Likewise.
* conf/i386-pc.rmk (grub_emu_SOURCES): Add `partmap/gpt.c'.
* include/grub/pc_partition.h (GRUB_PC_PARTITION_TYPE_GPT_DISK):
New macro.
* partmap/gpt.c: New file.
* partmap/pc.c (pc_partition_map_iterate): Don't continue when a GPT partition map is detected.
Index: conf/common.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/common.rmk,v
retrieving revision 1.2
common.rmk +8 -4
@@ -6,7 +6,7 @@ grub_script.tab.c grub_script.tab.h: nor # For grub-emu. grub_modules_init.lst: geninit.sh - (find $(srcdir) -name '*.c' | xargs grep GRUB_MOD_INIT) > $@ + (cd $(srcdir); find . -name '*.c' -printf "%P\n" | xargs grep GRUB_MOD_INIT) > $@ grub_modules_init.h: $(filter-out grub_emu_init.c,$(grub_emu_SOURCES)) geninitheader.sh grub_modules_init.lst sh $(srcdir)/geninitheader.sh > $@
@@ -75,10 +75,9 @@ affs_mod_LDFLAGS = $(COMMON_LDFLAGS) sfs_mod_SOURCES = fs/sfs.c sfs_mod_CFLAGS = $(COMMON_CFLAGS) sfs_mod_LDFLAGS = $(COMMON_LDFLAGS) - -# Partiton maps. -pkgdata_MODULES += amiga.mod apple.mod pc.mod sun.mod acorn.mod +# Partition maps. +pkgdata_MODULES += amiga.mod apple.mod pc.mod sun.mod acorn.mod gpt.mod # For amiga.mod amiga_mod_SOURCES = partmap/amiga.c
@@ -104,6 +103,11 @@ sun_mod_LDFLAGS = $(COMMON_LDFLAGS) acorn_mod_SOURCES = partmap/acorn.c acorn_mod_CFLAGS = $(COMMON_CFLAGS) acorn_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For gpt.mod +gpt_mod_SOURCES = partmap/gpt.c +gpt_mod_CFLAGS = $(COMMON_CFLAGS) +gpt_mod_LDFLAGS = $(COMMON_LDFLAGS) # Commands.
Index: conf/i386-pc.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/i386-pc.rmk,v
retrieving revision 1.55
i386-pc.rmk +1 -1
@@ -95,7 +95,7 @@ grub_emu_SOURCES = commands/boot.c comma normal/completion.c normal/context.c normal/main.c \ normal/menu.c normal/menu_entry.c normal/misc.c normal/script.c \ partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \ - partmap/acorn.c \ + partmap/acorn.c partmap/gpt.c \ util/console.c util/grub-emu.c util/misc.c \ util/i386/pc/biosdisk.c util/i386/pc/getroot.c \ util/i386/pc/misc.c grub_emu_init.c
Index: include/grub/pc_partition.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/pc_partition.h,v retrieving revision 1.1
grub/pc_partition.h +1 -0
@@ -49,6 +49,7 @@#define GRUB_PC_PARTITION_TYPE_FREEBSD 0xa5#define GRUB_PC_PARTITION_TYPE_OPENBSD 0xa6#define GRUB_PC_PARTITION_TYPE_NETBSD 0xa9 +#define GRUB_PC_PARTITION_TYPE_GPT_DISK 0xee#define GRUB_PC_PARTITION_TYPE_LINUX_RAID 0xfd/* Constants for BSD disk label. */
Index: partmap/gpt.c
===================================================================
RCS file: partmap/gpt.c
gpt.c new file +227 -0
227 lines not on this page · raw message
Index: partmap/pc.c
===================================================================
RCS file: /cvsroot/grub/grub2/partmap/pc.c,v
retrieving revision 1.6
pc.c +4 -0
@@ -140,6 +140,10 @@ pc_partition_map_iterate (grub_disk_t di"partition %d: flag 0x%x, type 0x%x, start 0x%lx, len 0x%lx\n" , p.index, e->flag, pcdata.dos_type, p.start, p.len); +/* If this is a GPT partition, this MBR is just a dummy. */ +if (e->type ==GRUB_PC_PARTITION_TYPE_GPT_DISK && p.index ==0 ) +return grub_error (GRUB_ERR_BAD_PART_TABLE ,"dummy mbr" ); +/* If this partition is a normal one, call the hook. */ if (!grub_pc_partition_is_empty (e->type) && !grub_pc_partition_is_extended (e->type))
Quoted 5 lines · Marco Gerards
A bit more important is the change of my email address. At some time my old email ([email protected]) address will expire, I am not studying there anymore. I am still reachable on that address, but please remove that address from your address book. All of my other addresses still work.
How about using gnu.org? :)
Okuji
Quoted 8 lines · Yoshinori K. Okuji
Quoted 5 lines · Marco Gerards
A bit more important is the change of my email address. At some time my old email ([email protected]) address will expire, I am not studying there anymore. I am still reachable on that address, but please remove that address from your address book. All of my other addresses still work.
How about using gnu.org? :)
It's a forward address that always works, unless gnu.org has problems again. :-)
--
Marco