Partition modules
Hi,
Here is a patch to modulize partition support. At the moment it will create pc.mod, amiga.mod and apple.mod. Loading one of these modules will give support for that specific partition map.
The names are not that clear at the moment, but that is because I plan to put the modules in directories. So you will have partmap/pc.mod, partmap/amiga.mod, but also fs/ext2.mod. But I will do this later, this patch is big enough already.
There is one new partition map that is supported, the one that is used on the amiga (RDB). If this patch is applied you can use GRUB 2 to access files on the pegasos.
Can someone please this patch on the PC for me to see if it works? I don't know when I can do that, I just tried if it compiles correctly on the PC.
If there are no problems with this patch I will commit it Sunday, but only if I am sure it works on the PC. I hope someone can comment on my patch if there is something wrong with it.
Thanks,
Marco
2004-11-17 Marco Gerards <[email protected]>
* commands/ls.c: Include <grub/partition.h> instead of <grub/machine/partition.h>.
* kern/disk.c: Likewise.
* kern/rescue.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* normal/cmdline.c: Likewise.
* kern/powerpc/ieee1275/init.c: Likewise. (grub_machine_init): Call grub_pc_partition_map_init', grub_amiga_partition_map_init' and `grub_apple_partition_map_init'.
* conf/i386-pc.rmk (kernel_img_SOURCES): Remove disk/i386/pc/partition.c'. Add kern/partition.c'. (kernel_img_HEADERS): Remove machine/partition.h'. Add partition.h' and pc_partition.h'. (grub_setup_SOURCES): Remove disk/i386/pc/partition.c'. Add kern/partition.c', partmap/amiga.c', partmap/apple.c' and partmap/pc.c'. (grub_emu_SOURCES): Likewise.
(pkgdata_MODULES): Add amiga.mod', apple.mod' and `pc.mod'. (amiga_mod_SOURCES, amiga_mod_CFLAGS, apple_mod_SOURCES) (apple_mod_CFLAGS, pc_mod_SOURCES, pc_mod_CFLAGS): New variables.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Remove disk/powerpc/ieee1275/partition.c'. Add kern/partition.c', partmap/amiga.c', partmap/apple.c' and `partmap/pc.c'. (grubof_SOURCES): Likewise.
* disk/i386/pc/partition.c: Removed.
* disk/powerpc/ieee1275/partition.c: Likewise.
* include/grub/partition.h: Removed.
* include/grub/pc_partition.h: Likewise.
* include/grub/powerpc/ieee1275/partition.h: Likewise.
* kern/partition.c: New file.
* partmap/amiga.c: Likewise.
* partmap/apple.c: Likewise.
* partmap/pc.c: Likewise.
* util/grub-emu.c: Include <grub/partition.h> instead of <grub/machine/partition.h>.
(main): Call grub_pc_partition_map_init', grub_amiga_partition_map_init' and `grub_apple_partition_map_init' and deinitialize afterwards.
* util/i386/pc/biosdisk.c: Include #include <grub/partition.h>' and include <grub/pc_partition.h>' instead of `<grub/machine/partition.h>'.
* util/i386/pc/grub-setup.c: Likewise.
Index: commands/ls.c
===================================================================
RCS file: /cvsroot/grub/grub2/commands/ls.c,v
retrieving revision 1.3
ls.c +1 -1
@@ -28,7 +28,7 @@#include <grub/disk.h> #include <grub/device.h> #include <grub/term.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> #include <grub/file.h> static const struct grub_arg_option options[] =
Index: conf/i386-pc.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/i386-pc.rmk,v
retrieving revision 1.22
i386-pc.rmk +20 -5
@@ -25,7 +25,7 @@ diskboot_img_LDFLAGS = -nostdlib -Wl,-N, kernel_img_SOURCES = kern/i386/pc/startup.S kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \ - kern/i386/dl.c kern/i386/pc/init.c disk/i386/pc/partition.c \ + kern/i386/dl.c kern/i386/pc/init.c kern/partition.c \ kern/env.c disk/i386/pc/biosdisk.c \ term/i386/pc/console.c \ symlist.c
@@ -33,7 +33,7 @@ kernel_img_HEADERS = arg.h boot.h device file.h fs.h kernel.h loader.h misc.h mm.h net.h rescue.h symbol.h \ term.h types.h machine/biosdisk.h machine/boot.h \ machine/console.h machine/init.h machine/memory.h \ - machine/loader.h machine/partition.h machine/time.h machine/vga.h + machine/loader.h partition.h pc_partition.h machine/time.h machine/vga.h kernel_img_CFLAGS = $(COMMON_CFLAGS) kernel_img_ASFLAGS = $(COMMON_ASFLAGS) kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,8200
@@ -60,14 +60,16 @@ grub_mkimage_LDFLAGS = -llzo # For grub-setup. grub_setup_SOURCES = util/i386/pc/grub-setup.c util/i386/pc/biosdisk.c \ util/misc.c util/i386/pc/getroot.c kern/device.c kern/disk.c \ - kern/err.c kern/misc.c disk/i386/pc/partition.c fs/fat.c fs/ext2.c \ + kern/err.c kern/misc.c fs/fat.c fs/ext2.c \ + kern/partition.c partmap/amiga.c partmap/apple.c partmap/pc.c \ fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c kern/file.c kern/fs.c kern/env.c fs/fshelp.c # For grub grub_emu_SOURCES = kern/main.c kern/device.c fs/fshelp.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/misc.c kern/loader.c kern/rescue.c kern/term.c \ - disk/i386/pc/partition.c kern/env.c commands/ls.c \ + kern/partition.c kern/env.c commands/ls.c partmap/amiga.c \ + partmap/pc.c partmap/apple.c \ commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c \ util/i386/pc/biosdisk.c fs/fat.c fs/ext2.c fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c fs/iso9660.c \ normal/cmdline.c normal/command.c normal/main.c normal/menu.c normal/arg.c \
@@ -80,7 +82,8 @@ genmoddep_SOURCES = util/genmoddep.c # Modules. pkgdata_MODULES = _chain.mod _linux.mod linux.mod fat.mod ufs.mod ext2.mod minix.mod \ hfs.mod jfs.mod normal.mod hello.mod vga.mod font.mod _multiboot.mod ls.mod \ - boot.mod cmp.mod cat.mod terminal.mod fshelp.mod chain.mod multiboot.mod + boot.mod cmp.mod cat.mod terminal.mod fshelp.mod chain.mod multiboot.mod \ + amiga.mod apple.mod pc.mod # For _chain.mod. _chain_mod_SOURCES = loader/i386/pc/chainloader.c
@@ -175,3 +178,15 @@ _multiboot_mod_CFLAGS = $(COMMON_CFLAGS) # For multiboot.mod. multiboot_mod_SOURCES = loader/i386/pc/multiboot_normal.c multiboot_mod_CFLAGS = $(COMMON_CFLAGS) + +# For amiga.mod +amiga_mod_SOURCES = partmap/amiga.c +amiga_mod_CFLAGS = $(COMMON_CFLAGS) + +# For apple.mod +apple_mod_SOURCES = partmap/apple.c +apple_mod_CFLAGS = $(COMMON_CFLAGS) + +# For pc.mod +pc_mod_SOURCES = partmap/pc.c +pc_mod_CFLAGS = $(COMMON_CFLAGS)
Index: conf/powerpc-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/powerpc-ieee1275.rmk,v retrieving revision 1.14
powerpc-ieee1275.rmk +5 -3
@@ -24,11 +24,11 @@ noinst_UTILITIES = genmoddep grub_emu_SOURCES = kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/misc.c kern/loader.c kern/rescue.c kern/term.c \ - disk/powerpc/ieee1275/partition.c fs/fshelp.c \ + partmap/amiga.c partmap/pc.c partmap/apple.c fs/fshelp.c \ util/i386/pc/biosdisk.c fs/fat.c fs/ext2.c fs/ufs.c fs/minix.c fs/hfs.c \ fs/jfs.c fs/iso9660.c \ normal/cmdline.c normal/command.c normal/main.c normal/menu.c \ - normal/arg.c \ + normal/arg.c kern/partition.c \ util/console.c util/grub-emu.c util/misc.c util/i386/pc/getroot.c \ kern/env.c commands/ls.c \ commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c
@@ -41,10 +41,12 @@ grubof_SOURCES = boot/powerpc/ieee1275/c kern/powerpc/ieee1275/init.c term/powerpc/ieee1275/ofconsole.c \ kern/powerpc/ieee1275/openfw.c fs/ext2.c fs/ufs.c fs/minix.c fs/hfs.c \ fs/jfs.c normal/cmdline.c normal/command.c normal/main.c normal/menu.c \ - disk/powerpc/ieee1275/ofdisk.c disk/powerpc/ieee1275/partition.c \ + disk/powerpc/ieee1275/ofdisk.c partmap/amiga.c partmap/pc.c \ + partmap/apple.c kern/partition.c \ kern/env.c normal/arg.c loader/powerpc/ieee1275/linux.c \ loader/powerpc/ieee1275/linux_normal.c commands/boot.c \ normal/powerpc/setjmp.S + grubof_HEADERS = grub/powerpc/ieee1275/ieee1275.h grubof_CFLAGS = $(COMMON_CFLAGS) -DGRUBOF grubof_ASFLAGS = $(COMMON_ASFLAGS)
Index: disk/i386/pc/partition.c
===================================================================
RCS file: disk/i386/pc/partition.c
i386/pc/partition.c deleted +0 -248
248 lines not on this page · raw message
Index: disk/powerpc/ieee1275/partition.c
===================================================================
RCS file: disk/powerpc/ieee1275/partition.c
powerpc/ieee1275/partition.c deleted +0 -120
120 lines not on this page · raw message
Index: include/grub/partition.h
===================================================================
RCS file: include/grub/partition.h
grub/partition.h new file +118 -0
118 lines not on this page · raw message
Index: include/grub/pc_partition.h
===================================================================
RCS file: include/grub/pc_partition.h
grub/pc_partition.h new file +190 -0
190 lines not on this page · raw message
Index: include/grub/i386/pc/partition.h
===================================================================
RCS file: include/grub/i386/pc/partition.h
grub/i386/pc/partition.h deleted +0 -242
242 lines not on this page · raw message
Index: include/grub/powerpc/ieee1275/partition.h
===================================================================
RCS file: include/grub/powerpc/ieee1275/partition.h
grub/powerpc/ieee1275/partition.h deleted +0 -140
140 lines not on this page · raw message
Index: kern/disk.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/disk.c,v
retrieving revision 1.8
disk.c +1 -1
@@ -21,7 +21,7 @@#include <grub/err.h> #include <grub/mm.h> #include <grub/types.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> #include <grub/misc.h> #include <grub/machine/time.h> #include <grub/file.h>
Index: kern/partition.c
===================================================================
RCS file: kern/partition.c
partition.c new file +95 -0
95 lines not on this page · raw message
Index: kern/rescue.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/rescue.c,v
retrieving revision 1.10
rescue.c +1 -1
@@ -28,7 +28,7 @@#include <grub/err.h> #include <grub/loader.h> #include <grub/dl.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> #include <grub/env.h> #define GRUB_RESCUE_BUF_SIZE 256
Index: kern/powerpc/ieee1275/init.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/init.c,v retrieving revision 1.8
powerpc/ieee1275/init.c +4 -1
@@ -22,7 +22,7 @@#include <grub/dl.h> #include <grub/disk.h> #include <grub/mm.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> #include <grub/machine/ieee1275.h> #include <grub/normal.h> #include <grub/fs.h>
@@ -78,6 +78,9 @@ grub_machine_init (void)grub_boot_init ();grub_linux_init ();grub_linux_normal_init (); +grub_pc_partition_map_init (); +grub_amiga_partition_map_init (); +grub_apple_partition_map_init ();grub_ofdisk_init (); }
Index: loader/i386/pc/chainloader.c
===================================================================
RCS file: /cvsroot/grub/grub2/loader/i386/pc/chainloader.c,v retrieving revision 1.7
i386/pc/chainloader.c +1 -1
@@ -28,7 +28,7 @@#include <grub/misc.h> #include <grub/types.h> #include <grub/machine/init.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> #include <grub/machine/memory.h> #include <grub/rescue.h> #include <grub/dl.h>
Index: normal/cmdline.c
===================================================================
RCS file: /cvsroot/grub/grub2/normal/cmdline.c,v
retrieving revision 1.8
cmdline.c +1 -1
@@ -23,7 +23,7 @@#include <grub/err.h> #include <grub/types.h> #include <grub/mm.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> #include <grub/disk.h> #include <grub/file.h> #include <grub/env.h>
Index: partmap/amiga.c
===================================================================
RCS file: partmap/amiga.c
amiga.c new file +229 -0
229 lines not on this page · raw message
Index: partmap/apple.c
===================================================================
RCS file: partmap/apple.c
apple.c new file +227 -0
227 lines not on this page · raw message
Index: partmap/pc.c
===================================================================
RCS file: partmap/pc.c
pc.c new file +293 -0
293 lines not on this page · raw message
Index: util/grub-emu.c
===================================================================
RCS file: /cvsroot/grub/grub2/util/grub-emu.c,v
retrieving revision 1.8
grub-emu.c +8 -1
@@ -34,6 +34,7 @@#include <grub/normal.h> #include <grub/util/getroot.h> #include <grub/env.h> +#include <grub/partition.h> #ifdef __NetBSD__/* NetBSD uses /boot for its boot block. */
@@ -154,6 +155,9 @@ main (int argc, char *argv[])/* XXX: This is a bit unportable. */ grub_util_biosdisk_init (args.dev_map); +grub_pc_partition_map_init (); +grub_amiga_partition_map_init (); +grub_apple_partition_map_init ();/* Initialize the default modules. */ grub_iso9660_init ();
@@ -187,6 +191,9 @@ main (int argc, char *argv[])grub_cmp_fini ();grub_cat_fini ();grub_terminal_fini (); - +grub_amiga_partition_map_fini (); +grub_pc_partition_map_fini (); +grub_apple_partition_map_fini (); +return 0 ; }
Index: util/i386/pc/biosdisk.c
===================================================================
RCS file: /cvsroot/grub/grub2/util/i386/pc/biosdisk.c,v retrieving revision 1.8
i386/pc/biosdisk.c +2 -1
@@ -20,7 +20,8 @@#include <grub/machine/biosdisk.h> #include <grub/disk.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> +#include <grub/pc_partition.h> #include <grub/types.h> #include <grub/err.h> #include <grub/util/misc.h>
Index: util/i386/pc/grub-setup.c
===================================================================
RCS file: /cvsroot/grub/grub2/util/i386/pc/grub-setup.c,v retrieving revision 1.8
i386/pc/grub-setup.c +2 -1
@@ -25,7 +25,8 @@#include <grub/disk.h> #include <grub/file.h> #include <grub/fs.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> +#include <grub/pc_partition.h> #include <grub/machine/util/biosdisk.h> #include <grub/machine/boot.h> #include <grub/machine/kernel.h>
Quoted 4 lines · Marco Gerards
Here is a patch to modulize partition support. At the moment it will create pc.mod, amiga.mod and apple.mod. Loading one of these modules will give support for that specific partition map.
Thanks Marco!
Quoted 23 lines
grub/partition.h new file +23
-0+/* Partition description. */ +struct grub_partition +{ +/* The start sector. */ +unsigned long start; + +/* The length in sector units. */ +unsigned long len; + +/* The offset of the partition table. */ +unsigned long offset; + +/* The index of this partition in the partition table. */ +int index; + +/* The DOS partition number. */ +int dos_part; + +/* The BSD partition number (a == 0). */ +int bsd_part; + +/* The DOS partition type. */ +int dos_type;
grub/partition.h line 83
Quoted 10 lines
grub/partition.h new file +10
-0+ +/* The BSD partition type. */ +int bsd_type; + +/* The offset of the extended partition. */ +unsigned long ext_offset; + +/* The type partition map. */ +grub_partition_map_t partmap; +};
I do have an objection here: members like "bsd_type" don't belong in a generic struct, but rather in grub_partition_bsd_type. I believe grub_partition should be the abstraction, i.e. what defines a partition in the general sense. start, len, and index are obviously good; offset is compensating for a DOS issue, though at least it has (irrelevant) meaning for an Apple map... but ext_offset and these dos_ and bsd_ things don't belong here IMHO.
Also, there were a number of whitespace-only lines in your patch; a simple regex should show you where.
I'm seeing a crash on both briQ and my G3, so I'm sprinkling printfs now...
-Hollis
Quoted 2 lines · Hollis Blanchard
I'm seeing a crash on both briQ and my G3, so I'm sprinkling printfs now...
This incremental patch fixes rescue mode "ls" on both systems. I guess the patch you sent works on Amiga... pffft. :)
-Hollis
apple.c 2004-11-17 22:32:41.988875816 -0600 renamed from apple.c.orig 2004-11-17 22:30:14.731262376 -0600 +3 -0
@@ -86,6 +86,8 @@ struct grub_apple_part grub_uint16_t pad[187]; }; +static struct grub_partition_map grub_apple_partition_map; + #ifndef GRUB_UTIL static grub_dl_t my_mod; #endif
@@ -119,6 +121,7 @@ apple_partition_map_iterate (grub_disk_t part.len = apart.blockcnt; part.offset = pos; part.index = partno; + part.partmap = &grub_apple_partition_map; if (hook (&part)) return grub_errno;
pc.c 2004-11-17 22:29:39.966547416 -0600 renamed from pc.c.orig 2004-11-17 22:29:24.891839120 -0600 +3 -0
@@ -25,6 +25,8 @@ #include <grub/misc.h> #include <grub/dl.h> +static struct grub_partition_map grub_pc_partition_map; + #ifndef GRUB_UTIL static grub_dl_t my_mod; #endif
@@ -97,6 +97,7 @@ pc_partition_map_iterate (grub_disk_t di p.offset = 0; p.ext_offset = 0; p.dos_part = -1; + p.partmap = &grub_pc_partition_map; while (1) {
Quoted 7 lines · Hollis Blanchard
Quoted 3 lines · Hollis Blanchard
I'm seeing a crash on both briQ and my G3, so I'm sprinkling printfs now...
This incremental patch fixes rescue mode "ls" on both systems. I guess the patch you sent works on Amiga... pffft. :)
I will fix this in my tree.
Thanks,
Marco
Quoted 7 lines · Hollis Blanchard
I do have an objection here: members like "
bsd_type" don't belong in a generic struct, but rather ingrub_partition_bsd_type. I believegrub_partitionshould be the abstraction, i.e. what defines a partition in the general sense. start, len, and index are obviously good; offset is compensating for a DOS issue, though at least it has (irrelevant) meaning for an Apple map... butext_offsetand thesedos_andbsd_things don't belong here IMHO.
Ok.
Quoted 2 lines
Also, there were a number of whitespace-only lines in your patch; a simple regex should show you where.
Ok.
Quoted 2 lines
I'm seeing a crash on both briQ and my G3, so I'm sprinkling printfs now...
Does the PC partition map work on the briQ now?
Thanks,
Marco
Quoted 7 lines · Hollis Blanchard
I do have an objection here: members like "
bsd_type" don't belong in a generic struct, but rather ingrub_partition_bsd_type. I believegrub_partitionshould be the abstraction, i.e. what defines a partition in the general sense. start, len, and index are obviously good; offset is compensating for a DOS issue, though at least it has (irrelevant) meaning for an Apple map... butext_offsetand thesedos_andbsd_things don't belong here IMHO.
I agree with you in theory... but I guess it is a bit difficult to make BSD disklabel independent, because it is sometimes used alone and it is sometimes nested in other partition types. I hope Marco will find out a good solution here.
Okuji
Quoted 9 lines · Yoshinori K. Okuji
Quoted 7 lines · Hollis Blanchard
I do have an objection here: members like "
bsd_type" don't belong in a generic struct, but rather ingrub_partition_bsd_type. I believegrub_partitionshould be the abstraction, i.e. what defines a partition in the general sense. start, len, and index are obviously good; offset is compensating for a DOS issue, though at least it has (irrelevant) meaning for an Apple map... butext_offsetand thesedos_andbsd_things don't belong here IMHO.
Quoted 4 lines
I agree with you in theory... but I guess it is a bit difficult to make BSD disklabel independent, because it is sometimes used alone and it is sometimes nested in other partition types. I hope Marco will find out a good solution here.
It should not be too hard. The extra members are only used in specific parts of the code, mainly in the i386/pc directories. Perhaps I could add a member which points to a user defined data structure. In that datastructure the extra information can be stored.
The BSD disklabel is a weird special case. Perhaps we need some kind of nested partitions or so. I don't know if that will make sense because I have no knowledge about BSD slices and how they are used.
Thanks,
Marco
Quoted 3 lines · Marco Gerards
The BSD disklabel is a weird special case. Perhaps we need some kind of nested partitions or so. I don't know if that will make sense because I have no knowledge about BSD slices and how they are used.
Take a look at this:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/disk-organization.html
Note that you can make a BSD disklabel without any PC partition, if you wish. This is not supported by GRUB legacy (except for floppies).
Okuji
Quoted 11 lines · Yoshinori K. Okuji
Quoted 3 lines · Marco Gerards
The BSD disklabel is a weird special case. Perhaps we need some kind of nested partitions or so. I don't know if that will make sense because I have no knowledge about BSD slices and how they are used.
Take a look at this:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/disk-organization.html
Note that you can make a BSD disklabel without any PC partition, if you wish. This is not supported by GRUB legacy (except for floppies).
Thanks a lot for this information.
If I understand the GRUB 2 partition code correctly, such partition is identified with only a command, right? For example: (hd0,,a). Am I right about this?
At the moment the partition (slice) type is checked to figure out if there is a BSD partition. If so, the BSD partitions are iterated. How about the apple, amiga, etc? Does it work the same? Otherwise code might be shared.
Because I do not have *BSD installed on any system I can not work on this, but it might be worthwhile to think about this and make it a todo item related to the PPC port.
Thanks,
Marco
Quoted 3 lines · Marco Gerards
Can someone please this patch on the PC for me to see if it works? I don't know when I can do that, I just tried if it compiles correctly on the PC.
Don't expect me to test it... I might be able to have time in this weekend, but no guarantee.
grub/pc_partition.h
Quoted 7 lines
Index:
include/grub/pc_partition.h
===================================================================
RCS file:include/grub/pc_partition.h
diff -Ninclude/grub/pc_partition.hgrub/pc_partition.h new file +0
-0@@ -0,0 +1,190 @@
[snip]
The macros defined in this header should use different names, because GRUB_PARTITION_FOO is too generic. Maybe GRUB_PC_PARTITION_FOO?
The other parts look good for me.
Thanks,
Okuji
Quoted 7 lines · Yoshinori K. Okuji
Quoted 3 lines · Marco Gerards
Can someone please this patch on the PC for me to see if it works? I don't know when I can do that, I just tried if it compiles correctly on the PC.
Don't expect me to test it... I might be able to have time in this weekend, but no guarantee.
Ok, otherwise I will just have to wait until I have a PC available.
Quoted 11 lines
grub/pc_partition.h
Quoted 7 lines
Index:
include/grub/pc_partition.h
===================================================================
RCS file:include/grub/pc_partition.h
diff -Ninclude/grub/pc_partition.hgrub/pc_partition.h new file +0
-0@@ -0,0 +1,190 @@[snip]
The macros defined in this header should use different names, because
GRUB_PARTITION_FOOis too generic. MaybeGRUB_PC_PARTITION_FOO?
Sure. I will make the change.
Thanks.
Marco
Quoted 2 lines · Marco Gerards
If there are no problems with this patch I will commit it Sunday, but only if I am sure it works on the PC.
I have tried it on 2 PCs and can confirm that it works, with PC partitions, after Hollis's changes are applied.
Signature · 2 lines
Member AFFS, WYLUG, SWP (UK), ANL, RESPECT, Leeds SA, Leeds Anti-war coalition No to software patents! Victory to the iraqi resistance!
Quoted 7 lines · Timothy Baldwin
Quoted 2 lines · Marco Gerards
If there are no problems with this patch I will commit it Sunday, but only if I am sure it works on the PC.
I have tried it on 2 PCs and can confirm that it works, with PC partitions, after Hollis's changes are applied.
Thanks a lot for testing it! I will make the required changes and send in a new patch.
Thanks,
Marco
Quoted 3 lines · Marco Gerards
Here is a patch to modulize partition support. At the moment it will create pc.mod, amiga.mod and apple.mod. Loading one of these modules will give support for that specific partition map.
And here is version 2 of the patch. I have made the requested changes.
The grub_partition structure was split up. I've added a member `data' so per partition map type additional information can be added. This is used in biosdisk.c and in grub-setup.c, for example. Although I have tested this patch as much as I can, the grub-setup changes were not tested. I've just added a test to check if the right partition map type is used and the installer fails if this is not the case.
Can I check in this patch?
Thanks,
Marco
2004-11-24 Marco Gerards <[email protected]>
* commands/ls.c: Include <grub/partition.h> instead of <grub/machine/partition.h>.
* kern/disk.c: Likewise.
* kern/rescue.c: Likewise.
* loader/i386/pc/chainloader.c: Likewise.
* normal/cmdline.c: Likewise.
* kern/powerpc/ieee1275/init.c: Likewise. (grub_machine_init): Call grub_pc_partition_map_init', grub_amiga_partition_map_init' and `grub_apple_partition_map_init'.
* conf/i386-pc.rmk (kernel_img_SOURCES): Remove disk/i386/pc/partition.c'. Add kern/partition.c'. (kernel_img_HEADERS): Remove machine/partition.h'. Add partition.h' and pc_partition.h'. (grub_setup_SOURCES): Remove disk/i386/pc/partition.c'. Add kern/partition.c', partmap/amiga.c', partmap/apple.c' and partmap/pc.c'. (grub_emu_SOURCES): Likewise.
(pkgdata_MODULES): Add amiga.mod', apple.mod' and `pc.mod'. (amiga_mod_SOURCES, amiga_mod_CFLAGS, apple_mod_SOURCES) (apple_mod_CFLAGS, pc_mod_SOURCES, pc_mod_CFLAGS): New variables.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Remove disk/powerpc/ieee1275/partition.c'. Add kern/partition.c', partmap/amiga.c', partmap/apple.c' and `partmap/pc.c'. (grubof_SOURCES): Likewise.
* disk/i386/pc/partition.c: Removed.
* disk/powerpc/ieee1275/partition.c: Likewise.
* include/grub/partition.h: Removed.
* include/grub/pc_partition.h: Likewise.
* include/grub/powerpc/ieee1275/partition.h: Likewise.
* kern/partition.c: New file.
* partmap/amiga.c: Likewise.
* partmap/apple.c: Likewise.
* partmap/pc.c: Likewise.
* util/grub-emu.c: Include <grub/partition.h> instead of <grub/machine/partition.h>.
(main): Call grub_pc_partition_map_init', grub_amiga_partition_map_init' and `grub_apple_partition_map_init' and deinitialize afterwards.
* util/i386/pc/biosdisk.c: Include #include <grub/partition.h>' and include <grub/pc_partition.h>' instead of `<grub/machine/partition.h>'.
* util/i386/pc/grub-setup.c: Likewise.
* util/i386/pc/biosdisk.c: Likewise. (grub_util_biosdisk_get_grub_dev): Only access the PC specific partition information in case of a PC partition.
* util/i386/pc/grub-setup.c: Include #include <grub/partition.h>' and include <grub/pc_partition.h>' instead of `<grub/machine/partition.h>'.
(setup): Only access the PC specific partition information in case of a PC partition.
Index: commands/ls.c
===================================================================
RCS file: /cvsroot/grub/grub2/commands/ls.c,v
retrieving revision 1.3
ls.c +1 -1
@@ -28,7 +28,7 @@#include <grub/disk.h> #include <grub/device.h> #include <grub/term.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> #include <grub/file.h> static const struct grub_arg_option options[] =
Index: conf/i386-pc.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/i386-pc.rmk,v
retrieving revision 1.22
i386-pc.rmk +20 -5
@@ -25,7 +25,7 @@ diskboot_img_LDFLAGS = -nostdlib -Wl,-N, kernel_img_SOURCES = kern/i386/pc/startup.S kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \ - kern/i386/dl.c kern/i386/pc/init.c disk/i386/pc/partition.c \ + kern/i386/dl.c kern/i386/pc/init.c kern/partition.c \ kern/env.c disk/i386/pc/biosdisk.c \ term/i386/pc/console.c \ symlist.c
@@ -33,7 +33,7 @@ kernel_img_HEADERS = arg.h boot.h device file.h fs.h kernel.h loader.h misc.h mm.h net.h rescue.h symbol.h \ term.h types.h machine/biosdisk.h machine/boot.h \ machine/console.h machine/init.h machine/memory.h \ - machine/loader.h machine/partition.h machine/time.h machine/vga.h + machine/loader.h partition.h pc_partition.h machine/time.h machine/vga.h kernel_img_CFLAGS = $(COMMON_CFLAGS) kernel_img_ASFLAGS = $(COMMON_ASFLAGS) kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,8200
@@ -60,14 +60,16 @@ grub_mkimage_LDFLAGS = -llzo # For grub-setup. grub_setup_SOURCES = util/i386/pc/grub-setup.c util/i386/pc/biosdisk.c \ util/misc.c util/i386/pc/getroot.c kern/device.c kern/disk.c \ - kern/err.c kern/misc.c disk/i386/pc/partition.c fs/fat.c fs/ext2.c \ + kern/err.c kern/misc.c fs/fat.c fs/ext2.c \ + kern/partition.c partmap/amiga.c partmap/apple.c partmap/pc.c \ fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c kern/file.c kern/fs.c kern/env.c fs/fshelp.c # For grub grub_emu_SOURCES = kern/main.c kern/device.c fs/fshelp.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/misc.c kern/loader.c kern/rescue.c kern/term.c \ - disk/i386/pc/partition.c kern/env.c commands/ls.c \ + kern/partition.c kern/env.c commands/ls.c partmap/amiga.c \ + partmap/pc.c partmap/apple.c \ commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c \ util/i386/pc/biosdisk.c fs/fat.c fs/ext2.c fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c fs/iso9660.c \ normal/cmdline.c normal/command.c normal/main.c normal/menu.c normal/arg.c \
@@ -80,7 +82,8 @@ genmoddep_SOURCES = util/genmoddep.c # Modules. pkgdata_MODULES = _chain.mod _linux.mod linux.mod fat.mod ufs.mod ext2.mod minix.mod \ hfs.mod jfs.mod normal.mod hello.mod vga.mod font.mod _multiboot.mod ls.mod \ - boot.mod cmp.mod cat.mod terminal.mod fshelp.mod chain.mod multiboot.mod + boot.mod cmp.mod cat.mod terminal.mod fshelp.mod chain.mod multiboot.mod \ + amiga.mod apple.mod pc.mod # For _chain.mod. _chain_mod_SOURCES = loader/i386/pc/chainloader.c
@@ -175,3 +178,15 @@ _multiboot_mod_CFLAGS = $(COMMON_CFLAGS) # For multiboot.mod. multiboot_mod_SOURCES = loader/i386/pc/multiboot_normal.c multiboot_mod_CFLAGS = $(COMMON_CFLAGS) + +# For amiga.mod +amiga_mod_SOURCES = partmap/amiga.c +amiga_mod_CFLAGS = $(COMMON_CFLAGS) + +# For apple.mod +apple_mod_SOURCES = partmap/apple.c +apple_mod_CFLAGS = $(COMMON_CFLAGS) + +# For pc.mod +pc_mod_SOURCES = partmap/pc.c +pc_mod_CFLAGS = $(COMMON_CFLAGS)
Index: conf/powerpc-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/powerpc-ieee1275.rmk,v retrieving revision 1.14
powerpc-ieee1275.rmk +4 -3
@@ -24,11 +24,11 @@ noinst_UTILITIES = genmoddep grub_emu_SOURCES = kern/main.c kern/device.c \ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \ kern/misc.c kern/loader.c kern/rescue.c kern/term.c \ - disk/powerpc/ieee1275/partition.c fs/fshelp.c \ + partmap/amiga.c partmap/pc.c partmap/apple.c fs/fshelp.c \ util/i386/pc/biosdisk.c fs/fat.c fs/ext2.c fs/ufs.c fs/minix.c fs/hfs.c \ fs/jfs.c fs/iso9660.c \ normal/cmdline.c normal/command.c normal/main.c normal/menu.c \ - normal/arg.c \ + normal/arg.c kern/partition.c \ util/console.c util/grub-emu.c util/misc.c util/i386/pc/getroot.c \ kern/env.c commands/ls.c \ commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c
@@ -41,7 +41,8 @@ grubof_SOURCES = boot/powerpc/ieee1275/c kern/powerpc/ieee1275/init.c term/powerpc/ieee1275/ofconsole.c \ kern/powerpc/ieee1275/openfw.c fs/ext2.c fs/ufs.c fs/minix.c fs/hfs.c \ fs/jfs.c normal/cmdline.c normal/command.c normal/main.c normal/menu.c \ - disk/powerpc/ieee1275/ofdisk.c disk/powerpc/ieee1275/partition.c \ + disk/powerpc/ieee1275/ofdisk.c partmap/amiga.c partmap/pc.c \ + partmap/apple.c kern/partition.c \ kern/env.c normal/arg.c loader/powerpc/ieee1275/linux.c \ loader/powerpc/ieee1275/linux_normal.c commands/boot.c \ normal/powerpc/setjmp.S
Index: disk/i386/pc/partition.c
===================================================================
RCS file: disk/i386/pc/partition.c
i386/pc/partition.c deleted +0 -248
248 lines not on this page · raw message
Index: disk/powerpc/ieee1275/partition.c
===================================================================
RCS file: disk/powerpc/ieee1275/partition.c
powerpc/ieee1275/partition.c deleted +0 -120
120 lines not on this page · raw message
Index: include/grub/partition.h
===================================================================
RCS file: include/grub/partition.h
grub/partition.h new file +106 -0
106 lines not on this page · raw message
Index: include/grub/pc_partition.h
===================================================================
RCS file: include/grub/pc_partition.h
grub/pc_partition.h new file +209 -0
209 lines not on this page · raw message
Index: include/grub/i386/pc/partition.h
===================================================================
RCS file: include/grub/i386/pc/partition.h
grub/i386/pc/partition.h deleted +0 -242
242 lines not on this page · raw message
Index: include/grub/powerpc/ieee1275/partition.h
===================================================================
RCS file: include/grub/powerpc/ieee1275/partition.h
grub/powerpc/ieee1275/partition.h deleted +0 -140
140 lines not on this page · raw message
Index: kern/disk.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/disk.c,v
retrieving revision 1.8
disk.c +1 -1
@@ -21,7 +21,7 @@#include <grub/err.h> #include <grub/mm.h> #include <grub/types.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> #include <grub/misc.h> #include <grub/machine/time.h> #include <grub/file.h>
Index: kern/partition.c
===================================================================
RCS file: kern/partition.c
partition.c new file +95 -0
95 lines not on this page · raw message
Index: kern/rescue.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/rescue.c,v
retrieving revision 1.10
rescue.c +1 -1
@@ -28,7 +28,7 @@#include <grub/err.h> #include <grub/loader.h> #include <grub/dl.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> #include <grub/env.h> #define GRUB_RESCUE_BUF_SIZE 256
Index: kern/powerpc/ieee1275/init.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/powerpc/ieee1275/init.c,v retrieving revision 1.8
powerpc/ieee1275/init.c +4 -1
@@ -22,7 +22,7 @@#include <grub/dl.h> #include <grub/disk.h> #include <grub/mm.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> #include <grub/machine/ieee1275.h> #include <grub/normal.h> #include <grub/fs.h>
@@ -78,6 +78,9 @@ grub_machine_init (void)grub_boot_init ();grub_linux_init ();grub_linux_normal_init (); +grub_pc_partition_map_init (); +grub_amiga_partition_map_init (); +grub_apple_partition_map_init ();grub_ofdisk_init (); }
Index: loader/i386/pc/chainloader.c
===================================================================
RCS file: /cvsroot/grub/grub2/loader/i386/pc/chainloader.c,v retrieving revision 1.7
i386/pc/chainloader.c +1 -1
@@ -28,7 +28,7 @@#include <grub/misc.h> #include <grub/types.h> #include <grub/machine/init.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> #include <grub/machine/memory.h> #include <grub/rescue.h> #include <grub/dl.h>
Index: normal/cmdline.c
===================================================================
RCS file: /cvsroot/grub/grub2/normal/cmdline.c,v
retrieving revision 1.8
cmdline.c +1 -1
@@ -23,7 +23,7 @@#include <grub/err.h> #include <grub/types.h> #include <grub/mm.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> #include <grub/disk.h> #include <grub/file.h> #include <grub/env.h>
Index: partmap/amiga.c
===================================================================
RCS file: partmap/amiga.c
amiga.c new file +229 -0
229 lines not on this page · raw message
Index: partmap/apple.c
===================================================================
RCS file: partmap/apple.c
apple.c new file +231 -0
231 lines not on this page · raw message
Index: partmap/pc.c
===================================================================
RCS file: partmap/pc.c
pc.c new file +314 -0
314 lines not on this page · raw message
Index: util/grub-emu.c
===================================================================
RCS file: /cvsroot/grub/grub2/util/grub-emu.c,v
retrieving revision 1.8
grub-emu.c +8 -1
@@ -34,6 +34,7 @@#include <grub/normal.h> #include <grub/util/getroot.h> #include <grub/env.h> +#include <grub/partition.h> #ifdef __NetBSD__/* NetBSD uses /boot for its boot block. */
@@ -154,6 +155,9 @@ main (int argc, char *argv[])/* XXX: This is a bit unportable. */ grub_util_biosdisk_init (args.dev_map); +grub_pc_partition_map_init (); +grub_amiga_partition_map_init (); +grub_apple_partition_map_init ();/* Initialize the default modules. */ grub_iso9660_init ();
@@ -187,6 +191,9 @@ main (int argc, char *argv[])grub_cmp_fini ();grub_cat_fini ();grub_terminal_fini (); - +grub_amiga_partition_map_fini (); +grub_pc_partition_map_fini (); +grub_apple_partition_map_fini (); +return 0 ; }
Index: util/i386/pc/biosdisk.c
===================================================================
RCS file: /cvsroot/grub/grub2/util/i386/pc/biosdisk.c,v retrieving revision 1.8
i386/pc/biosdisk.c +27 -10
@@ -20,7 +20,8 @@#include <grub/machine/biosdisk.h> #include <grub/disk.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> +#include <grub/pc_partition.h> #include <grub/types.h> #include <grub/err.h> #include <grub/util/misc.h>
@@ -736,18 +737,34 @@ grub_util_biosdisk_get_grub_dev (const cint find_partition (const grub_partition_t partition) { -if (partition->bsd_part <0 ) -grub_util_info ("DOS partition %d starts from %lu" , - partition->dos_part, partition->start); -else -grub_util_info ("BSD partition %d,%c starts from %lu" , - partition->dos_part, partition->bsd_part +'a' , - partition->start); +struct grub_pc_partition *pcdata =0 ; + +if (!strcmp (partition->partmap->name,"pc" )) + pcdata = partition->data; + +if (pcdata) + { +if (pcdata->bsd_part <0 ) +grub_util_info ("DOS partition %d starts from %lu" , + pcdata->dos_part, partition->start); +else +grub_util_info ("BSD partition %d,%c starts from %lu" , + pcdata->dos_part, pcdata->bsd_part +'a' , + partition->start); + }if (hdg.start == partition->start) { - dos_part = partition->dos_part; - bsd_part = partition->bsd_part; +if (pcdata) + { + dos_part = pcdata->dos_part; + bsd_part = pcdata->bsd_part; + } +else + { + dos_part =0 ; + bsd_part =0 ; + }return 1 ; }
Index: util/i386/pc/grub-setup.c
===================================================================
RCS file: /cvsroot/grub/grub2/util/i386/pc/grub-setup.c,v retrieving revision 1.8
i386/pc/grub-setup.c +22 -7
@@ -25,7 +25,8 @@#include <grub/disk.h> #include <grub/file.h> #include <grub/fs.h> -#include <grub/machine/partition.h> +#include <grub/partition.h> +#include <grub/pc_partition.h> #include <grub/machine/util/biosdisk.h> #include <grub/machine/boot.h> #include <grub/machine/kernel.h>
@@ -107,8 +108,10 @@ setup (const char *prefix, const char *dint find_first_partition_start (const grub_partition_t p) { -if (!grub_partition_is_empty (p->dos_type) - && !grub_partition_is_bsd (p->dos_type) +struct grub_pc_partition *pcdata = p->data; + +if (!grub_pc_partition_is_empty (pcdata->dos_type) + && !grub_pc_partition_is_bsd (pcdata->dos_type) && first_start > p->start) first_start = p->start;
@@ -252,10 +255,16 @@ setup (const char *prefix, const char *d/* Embed information about the installed location. */ if (root_dev->disk->partition) { +struct grub_pc_partition *pcdata = + root_dev->disk->partition->data; + +if (strcmp (root_dev->disk->partition->partmap->name,"pc" )) +grub_util_error ("No PC style partitions found" ); + *install_dos_part - =grub_cpu_to_le32 (root_dev->disk->partition->dos_part); + =grub_cpu_to_le32 (pcdata->dos_part); *install_bsd_part - =grub_cpu_to_le32 (root_dev->disk->partition->bsd_part); + =grub_cpu_to_le32 (pcdata->bsd_part); }else *install_dos_part = *install_bsd_part =grub_cpu_to_le32 (-1 );
@@ -400,10 +409,16 @@ setup (const char *prefix, const char *d/* Embed information about the installed location. */ if (root_dev->disk->partition) { +struct grub_pc_partition *pcdata = + root_dev->disk->partition->data; + +if (strcmp (root_dev->disk->partition->partmap->name,"pc" )) +grub_util_error ("No PC style partitions found" ); + *install_dos_part - =grub_cpu_to_le32 (root_dev->disk->partition->dos_part); + =grub_cpu_to_le32 (pcdata->dos_part); *install_bsd_part - =grub_cpu_to_le32 (root_dev->disk->partition->bsd_part); + =grub_cpu_to_le32 (pcdata->bsd_part); }else *install_dos_part = *install_bsd_part =grub_cpu_to_le32 (-1 );
Quoted 8 lines · Marco Gerards
Quoted 3 lines · Marco Gerards
Here is a patch to modulize partition support. At the moment it will create pc.mod, amiga.mod and apple.mod. Loading one of these modules will give support for that specific partition map.
And here is version 2 of the patch. I have made the requested changes.
[...]
Quoted 1 line
Can I check in this patch?
Until now no-one replied. I will apply this patch next Thursday if no one reports a problem with it.
Thanks,
Marco
Quoted 2 lines · Marco Gerards
Until now no-one replied. I will apply this patch next Thursday if no one reports a problem with it.
Sorry. I just forgot to reply. Your patch is ok for me.
Okuji
Quoted 5 lines · Yoshinori K. Okuji
Quoted 2 lines · Marco Gerards
Until now no-one replied. I will apply this patch next Thursday if no one reports a problem with it.
Sorry. I just forgot to reply. Your patch is ok for me.
For some reason I can not commit this patch. I get the following message:
cvs commit: [15:39:54] waiting for uid65534's lock in /cvsroot/grub/grub2/disk/powerpc/ieee1275
Can someone please help me with this problem?
Thanks,
Marco
Quoted 7 lines · Marco Gerards
For some reason I can not commit this patch. I get the following message:
cvs commit: [15:39:54] waiting for uid65534's lock in /cvsroot/grub/grub2/disk/powerpc/ieee1275
Can someone please help me with this problem?
It is a so-called cvs lock. Ask savannah-hackers.
Okuji
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 6 lines · Michael J. Flickinger
Quoted 5 lines
cvs commit: [15:39:54] waiting for uid65534's lock in /cvsroot/grub/grub2/disk/powerpc/ieee1275
Can someone please help me with this problem?
This should be fixed now.
It is, thanks a lot. The patch is applied now.
Thanks,
Marco