Environment block support for grub2
PATCH 1/1 Environment block support for grub2
Hi,
This patch add environment block support, which can be used to locate root device using uuid or label.
The environment block occupied the space previously used to store prefix. The structure is like this:
Magic numbe: "EvbK" (4 bytes)
Length of environment block (2 bytes) null-ended name=value pairs, ended with an empty string.
The previous prefix is stored in variable rdir.
Different platform use grub_machine_get_envblk to return a pointer to the name=value area of environment block. In main.c, it uses grub_parse_envblk to walk through the list and assign values to variables.
I also replace grub_machine_set_prefix with grub_machine_set_root. As it seems strange to compute the prefix in grub_machine_set_prefix, and then split it in grub_set_root_dev to get the root device. Now, grub_machine_set_root set the root directly, and in grub_set_root_dev, it uses root and rdir to generate the prefix.
A new tool grub-editenv is added to manage the environment block, for example:
grub-editenv FILE create
Create a blank environment block file. It's used to store external environment file.
grub-editenv FILE info
Show the info about location and size of environment block in core.img or external environment file.
grub-editenv FILE list
List the content of environment block.
grub-editenv FILE edit name=value
Edit the environment block. If no value is specify, name=, it deletes the item.
grub-editenv FILE clear
Remove all variables in the environment block.
And there is a new module findroot.mod. It will scan all partitions and compare their uuid/label with the uuid and label variable, whose value can be set in the environment block.
Here is an example:
First, use grub-mkimage to create core.img:
grub-mkimage -o core.img pc ext2 findroot
grub-mkimage will initialize the environment block with one item:
rdir=/boot/grub
Second, use grub-editenv to set the uuid or label of the root device. For example:
grub-editenv core.img edit uuid=xxx-xxxx
grub-editenv core.img edit label=System
If both uuid and label is specified, uuid will take preference, unless the fs don't support uuid.
You can also change rdir to change the default root directory, or add debug=all to show debug message, etc.
Signature · 1 line
Bean
boot/i386/pc/lnxboot.S +1 -1
@@ -185,7 +185,7 @@ real_code_2: call move_memory /* Check for multiboot signature. */ - cmpl $MULTIBOOT_MAGIC, %ss:(DATA_ADDR + 0x50) + cmpl $MULTIBOOT_MAGIC, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_DATA_END) jz 1f movl (ramdisk_image - start), %esi
conf/common.rmk +12 -1
@@ -94,6 +94,12 @@ grub_fstest_init.c: grub_fstest_init.lst $(filter-out grub_fstest_init.c,$(grub_ rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@ DISTCLEANFILES += grub_fstest_init.c +# for grub-editenv +bin_UTILITIES += grub-editenv +grub_editenv_SOURCES = util/grub-editenv.c util/envblk.c util/misc.c \ + kern/err.c kern/misc.c +CLEANFILES += grub-editenv + # For update-grub update-grub: util/update-grub.in config.status ./config.status --file=$@:$<
@@ -365,7 +371,7 @@ hexdump_mod_CFLAGS = $(COMMON_CFLAGS) hexdump_mod_LDFLAGS = $(COMMON_LDFLAGS) # Misc. -pkglib_MODULES += gzio.mod elf.mod +pkglib_MODULES += gzio.mod elf.mod findroot.mod # For elf.mod. elf_mod_SOURCES = kern/elf.c
@@ -386,3 +392,8 @@ read_mod_LDFLAGS = $(COMMON_LDFLAGS) sleep_mod_SOURCES = commands/sleep.c sleep_mod_CFLAGS = $(COMMON_CFLAGS) sleep_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For findroot.mod. +findroot_mod_SOURCES = kern/findroot.c +findroot_mod_CFLAGS = $(COMMON_CFLAGS) +findroot_mod_LDFLAGS = $(COMMON_LDFLAGS)
include/grub/envblk.h new file +47 -0
47 lines not on this page · raw message
include/grub/i386/pc/kernel.h +7 -7
@@ -37,14 +37,14 @@/* The offset of GRUB_MEMDISK_IMAGE_SIZE. */ #define GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_SIZE 0x1c -/* The offset of GRUB_PREFIX. */ -#define GRUB_KERNEL_MACHINE_PREFIX 0x20 +/* The offset of GRUB_ENVBLK. */ +#define GRUB_KERNEL_MACHINE_ENVBLK 0x26/* End of the data section. */ -#define GRUB_KERNEL_MACHINE_DATA_END 0x50 +#define GRUB_KERNEL_MACHINE_DATA_END 0x70/* The size of the first region which won't be compressed. */ -#define GRUB_KERNEL_MACHINE_RAW_SIZE 0x4A0 +#define GRUB_KERNEL_MACHINE_RAW_SIZE 0x4C0#ifndef ASM_FILE
@@ -66,9 +66,9 @@ extern grub_int32_t grub_install_bsd_part;/* The size of memory disk image, if present. */ extern grub_int32_t grub_memdisk_image_size; -/* The prefix which points to the directory where GRUB modules and its -configuration file are located. */ -extern char grub_prefix[]; +/* The envblk contains variable which can be used to locate the directory where +GRUB modules and its configuration file. */ +extern char grub_envblk[];/* The boot BIOS drive number. */ extern grub_int32_t EXPORT_VAR (grub_boot_drive );
include/grub/kernel.h +4 -2
@@ -55,8 +55,10 @@ void grub_machine_init (void);/* The machine-specific finalization. */ void grub_machine_fini (void ); -/* The machine-specific prefix initialization. */ -void grub_machine_set_prefix (void ); +/* The machine-specific root initialization. */ +void grub_machine_set_root (void ); + +char *grub_machine_get_envblk (void );/* Register all the exported symbols. This is automatically generated. */ void grub_register_exported_symbols (void );
kern/findroot.c new file +96 -0
96 lines not on this page · raw message
kern/i386/pc/init.c +32 -37
83 lines not on this page · raw message
kern/i386/pc/startup.S +8 -2
@@ -52,6 +52,7 @@ #include <grub/term.h> #include <multiboot.h> #include <multiboot2.h> +#include <grub/envblk.h> #define ABS(x) ((x) - EXT_C(start) + GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200)
@@ -98,14 +99,19 @@ VARIABLE(grub_install_bsd_part) .long 0xFFFFFFFF VARIABLE(grub_memdisk_image_size) .long 0 -VARIABLE(grub_prefix) + .long GRUB_ENVBLK_SIGNATURE + .word envblk_end - grub_envblk +VARIABLE(grub_envblk) + .byte 0 /* to be filled by grub-mkimage */ /* * Leave some breathing room for the prefix. */ - . = EXT_C(start) + 0x50 + . = EXT_C(start) + 0x70 + +envblk_end: /* * Support for booting GRUB from a Multiboot boot loader (e.g. GRUB itself).
kern/main.c +47 -14
90 lines not on this page · raw message
util/envblk.c new file +123 -0
123 lines not on this page · raw message
util/grub-editenv.c new file +259 -0
259 lines not on this page · raw message
util/grub-emu.c +11 -9
@@ -36,15 +36,13 @@#include <grub/util/getroot.h> #include <grub/env.h> #include <grub/partition.h> +#include <grub/envblk.h> #include <grub_emu_init.h> /* Used for going back to the main function. */ jmp_buf main_env; -/* Store the prefix specified by an argument. */ -static char *prefix =0 ; -grub_addr_t grub_arch_modules_addr (void ) {
@@ -76,11 +74,15 @@ grub_machine_init (void) }void -grub_machine_set_prefix (void ) +grub_machine_set_root (void ) { -grub_env_set ("prefix" , prefix); -free (prefix); - prefix =0 ; +/* Do nothing, as root is already set. */ +} + +char * +grub_machine_get_envblk (void ) +{ +return 0 ; }void
@@ -205,8 +207,8 @@ main (int argc, char *argv[]) } dir =grub_get_prefix (dir); - prefix =xmalloc (strlen (root_dev) +2 +strlen (dir) +1 ); -sprintf (prefix,"(%s)%s" , root_dev, dir); +grub_env_set (GRUB_ENVBLK_RDIR , dir); +grub_env_set ("root" , root_dev);free (dir);/* Start GRUB! */
util/i386/pc/grub-mkimage.c +4 -2
@@ -27,6 +27,7 @@#include <grub/util/misc.h> #include <grub/util/resolve.h> #include <grub/misc.h> +#include <grub/envblk.h> #include <stdio.h> #include <unistd.h>
@@ -109,9 +110,10 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[], char *me kernel_img =xmalloc (kernel_size + total_module_size + memdisk_size);grub_util_load_image (kernel_path, kernel_img); -if (GRUB_KERNEL_MACHINE_PREFIX +strlen (prefix) +1 >GRUB_KERNEL_MACHINE_DATA_END ) +if (GRUB_KERNEL_MACHINE_ENVBLK +sizeof (GRUB_ENVBLK_RDIR ) +2 +strlen (prefix) >GRUB_KERNEL_MACHINE_DATA_END )grub_util_error ("prefix too long" ); -strcpy (kernel_img +GRUB_KERNEL_MACHINE_PREFIX , prefix); +strcpy (kernel_img +GRUB_KERNEL_MACHINE_ENVBLK ,GRUB_ENVBLK_RDIR "=" ); +strcpy (kernel_img +GRUB_KERNEL_MACHINE_ENVBLK +sizeof (GRUB_ENVBLK_RDIR ), prefix);/* Fill in the grub_module_info structure. */ modinfo = (struct grub_module_info *) (kernel_img + kernel_size);
util/i386/pc/grub-setup.c +5 -1
@@ -34,6 +34,7 @@#include <grub/term.h> #include <grub/util/raid.h> #include <grub/util/lvm.h> +#include <grub/envblk.h> static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot =GRUB_GPT_PARTITION_TYPE_BIOS_BOOT ;
@@ -235,7 +236,10 @@ setup (const char *prefix, const char *dir, install_bsd_part = (grub_int32_t *) (core_img +GRUB_DISK_SECTOR_SIZE +GRUB_KERNEL_MACHINE_INSTALL_BSD_PART ); install_prefix = (core_img +GRUB_DISK_SECTOR_SIZE - +GRUB_KERNEL_MACHINE_PREFIX ); + +GRUB_KERNEL_MACHINE_ENVBLK ); + +strcpy (install_prefix,GRUB_ENVBLK_RDIR "=" ); + install_prefix +=sizeof (GRUB_ENVBLK_RDIR );/* Open the root device and the destination device. */ root_dev =grub_device_open (root);
Quoted 4 lines · Bean
Hi,
This patch add environment block support, which can be used to locate root device using uuid or label.
Nice :-)
Quoted 1 line
The previous prefix is stored in variable rdir.
Do we need this?
Quoted 10 lines
Different platform use
grub_machine_get_envblkto return a pointer to the name=value area of environment block. Inmain.c, it usesgrub_parse_envblkto walk through the list and assign values to variables.I also replace
grub_machine_set_prefixwithgrub_machine_set_root. As it seems strange to compute the prefix ingrub_machine_set_prefix, and then split it ingrub_set_root_devto get the root device. Now,grub_machine_set_rootset the root directly, and ingrub_set_root_dev, it uses root and rdir to generate the prefix.
Note that root and prefix don't necessarily have to point at the same device.
prefix always points at the directory containing GRUB modules etc, and is needed at initial stage. root is used later on by grub.cfg to access our payload (I think our current use of root to initialise prefix is gratuitous and could better be avoided).
Since for initialising root we don't have any problem, as we can use all the fancy stuff grub.cfg allows, unless I missed something I think it's better if at this stage we just focus on prefix.
Quoted 5 lines
grub-mkimage will initialize the environment block with one item:
rdir=/boot/grubSecond, use grub-editenv to set the uuid or label of the root device. For example:
Would it be simpler if grub-mkimage embedded an initialised environment block directly?
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What good is a phone call… if you are unable to speak? (as seen on /.)
Quoted 13 lines · Robert Millan
Quoted 10 lines
Different platform use
grub_machine_get_envblkto return a pointer to the name=value area of environment block. Inmain.c, it usesgrub_parse_envblkto walk through the list and assign values to variables.I also replace
grub_machine_set_prefixwithgrub_machine_set_root. As it seems strange to compute the prefix ingrub_machine_set_prefix, and then split it ingrub_set_root_devto get the root device. Now,grub_machine_set_rootset the root directly, and ingrub_set_root_dev, it uses root and rdir to generate the prefix.Note that root and prefix don't necessarily have to point at the same device.
Quoted 9 lines
prefix always points at the directory containing GRUB modules etc, and is needed at initial stage. root is used later on by grub.cfg to access our payload (I think our current use of root to initialise prefix is gratuitous and could better be avoided).
Since for initialising root we don't have any problem, as we can use all the fancy stuff grub.cfg allows, unless I missed something I think it's better if at this stage we just focus on prefix.
The root is assigned in the initialization phraze. Currently, it's done this way:
machine_machine_init -> calculate root device, then set variable prefix using root and grub_prefix.
modules initialization
grub_set_root_dev -> Use variable prefix to get the root variable.
Load normal.mod
As you can see, it first create prefix, then split it to find root. At the end of grub_set_root_dev, prefix and root will point to the same device. This also make it different to change the root setting in findroot, which is run in modules initialization stage. We must split prefix to find the root directory, and use the new root to form a new prefix. The prefix would later be split again to find root, what a mess.
The new method:
machine_machine_init -> calculate root device, then set root variable directly.
Load variable in the environment block
modules initialization
findroot
more modules initialization
grub_set_root_dev -> Use variable root to get the root prefix.
Load normal.mod
The end result would be the same, but the new method is cleaner, and allows overwrite of the root and rdir variable using environment block and findroot.
Quoted 8 lines
Quoted 5 lines
grub-mkimage will initialize the environment block with one item:
rdir=/boot/grubSecond, use grub-editenv to set the uuid or label of the root device. For example:
Would it be simpler if grub-mkimage embedded an initialised environment block directly?
I think it's better to have a seperate tool to do this. Besides, grub-editenv can also be used to manage external environment block file, which is used to load/save persistent variable like default.
Signature · 1 line
Bean
Quoted 33 lines · Bean
The root is assigned in the initialization phraze. Currently, it's done this way:
machine_machine_init-> calculate root device, then set variable prefix using root andgrub_prefix.modules initialization
grub_set_root_dev-> Use variable prefix to get the root variable.Load normal.mod
As you can see, it first create prefix, then split it to find root. At the end of
grub_set_root_dev, prefix and root will point to the same device. This also make it different to change the root setting in findroot, which is run in modules initialization stage. We must split prefix to find the root directory, and use the new root to form a new prefix. The prefix would later be split again to find root, what a mess.The new method:
machine_machine_init-> calculate root device, then set root variable directly.Load variable in the environment block
modules initialization
findroot
more modules initialization
Quoted 7 lines
grub_set_root_dev-> Use variable root to get the root prefix.Load normal.mod
The end result would be the same, but the new method is cleaner, and allows overwrite of the root and rdir variable using environment block and findroot.
I think the method is sound; what I'm complaining about (and it's not something specific to your patch) is that we're referring to two different things by the same name ("root"), and even put them in the same variable.
In the initialization phase, "root" is the device that contains our GRUB directory.
Afterwards, "root" is the device we're currently accessing (be it for loading fonts, backgrounds, Linux images, whatever).
If "root" means "just a placeholder for whatever device we're acessing at the moment", then it would make sense, but in our code (i.e. in the names we're giving to commands and functions) it's assumed to mean "the device containing /boot/grub".
So what do we want to do with this? Should we have different variables for each thing (and in that case, is "root" for initial stage or for grub.cfg) or should we use "root" as a placeholder for any path reference, and adjust our function names etc to reflect that?
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What good is a phone call… if you are unable to speak? (as seen on /.)
Quoted 16 lines · Robert Millan
I think the method is sound; what I'm complaining about (and it's not something specific to your patch) is that we're referring to two different things by the same name ("root"), and even put them in the same variable.
In the initialization phase, "root" is the device that contains our GRUB directory.
Afterwards, "root" is the device we're currently accessing (be it for loading fonts, backgrounds, Linux images, whatever).
If "root" means "just a placeholder for whatever device we're acessing at the moment", then it would make sense, but in our code (i.e. in the names we're giving to commands and functions) it's assumed to mean "the device containing
/boot/grub".
Quoted 4 lines
So what do we want to do with this? Should we have different variables for each thing (and in that case, is "root" for initial stage or for grub.cfg) or should we use "root" as a placeholder for any path reference, and adjust our function names etc to reflect that?
root is used in loaders as well, we shouldn't change its name. We could use another variable to store the root device at initial stage, it could actually be useful as it always points to the boot media. Perhaps we can name it "boot". What's your idea ?
Signature · 1 line
Bean
Hi,
This is the new patch, it contain the following changes:
1. command edit -> set in grub-editenv, as it seems more natural.
grub-editenv FILE set name=value ...
2. findroot can locate the root device using filename. To use it, just set idfile to any file inside the directory, For example:
idfile=normal.mod
Scan preference: uuid > label > idfile
3. Change the order device are reported in biosdisk, so that floppy appear last.
4. Add new command loadenv, which can be used to load/save environment variable.
load_env [-f FILE]
Load environment variable from external environment block file. The default file is $prefix/grubenv, but you can overwrite it with -f parameter.
list_env [-f FILE]
List the variables in external environment block file.
save_env [-f FILE] variable_name ..
Save the value of variable_name to external environment block file
So, to archive the effect of savedefault command in grub legacy, you can use:
load_env
..
menuentry aa {
..save_env default
}
You can also use save_env to save the variable directly to core.img, but it's not recommended. The environment block inside core.img is quite small, it's mainly used to store critical variable like rdir, uuid, label and idfile.
Signature · 1 line
Bean
boot/i386/pc/lnxboot.S +1 -1
@@ -185,7 +185,7 @@ real_code_2: call move_memory /* Check for multiboot signature. */ - cmpl $MULTIBOOT_MAGIC, %ss:(DATA_ADDR + 0x50) + cmpl $MULTIBOOT_MAGIC, %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_DATA_END) jz 1f movl (ramdisk_image - start), %esi
commands/loadenv.c new file +250 -0
250 lines not on this page · raw message
conf/common.rmk +26 -11
@@ -94,6 +94,11 @@ grub_fstest_init.c: grub_fstest_init.lst $(filter-out grub_fstest_init.c,$(grub_ rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@ DISTCLEANFILES += grub_fstest_init.c +# for grub-editenv +bin_UTILITIES += grub-editenv +grub_editenv_SOURCES = util/grub-editenv.c util/envblk.c util/misc.c +CLEANFILES += grub-editenv + # For update-grub update-grub: util/update-grub.in config.status ./config.status --file=$@:$<
@@ -282,7 +287,7 @@ pkglib_MODULES += hello.mod boot.mod terminal.mod ls.mod \ cmp.mod cat.mod help.mod font.mod search.mod \ loopback.mod configfile.mod echo.mod \ terminfo.mod test.mod blocklist.mod hexdump.mod \ - read.mod sleep.mod + read.mod sleep.mod loadenv.mod # For hello.mod. hello_mod_SOURCES = hello/hello.c
@@ -364,8 +369,23 @@ hexdump_mod_SOURCES = commands/hexdump.c hexdump_mod_CFLAGS = $(COMMON_CFLAGS) hexdump_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For read.mod. +read_mod_SOURCES = commands/read.c +read_mod_CFLAGS = $(COMMON_CFLAGS) +read_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For sleep.mod. +sleep_mod_SOURCES = commands/sleep.c +sleep_mod_CFLAGS = $(COMMON_CFLAGS) +sleep_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For loadenv.mod. +loadenv_mod_SOURCES = commands/loadenv.c util/envblk.c +loadenv_mod_CFLAGS = $(COMMON_CFLAGS) +loadenv_mod_LDFLAGS = $(COMMON_LDFLAGS) + # Misc. -pkglib_MODULES += gzio.mod elf.mod +pkglib_MODULES += gzio.mod elf.mod findroot.mod # For elf.mod. elf_mod_SOURCES = kern/elf.c
@@ -377,12 +397,7 @@ gzio_mod_SOURCES = io/gzio.c gzio_mod_CFLAGS = $(COMMON_CFLAGS) gzio_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For read.mod. -read_mod_SOURCES = commands/read.c -read_mod_CFLAGS = $(COMMON_CFLAGS) -read_mod_LDFLAGS = $(COMMON_LDFLAGS) - -# For sleep.mod. -sleep_mod_SOURCES = commands/sleep.c -sleep_mod_CFLAGS = $(COMMON_CFLAGS) -sleep_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For findroot.mod. +findroot_mod_SOURCES = kern/findroot.c +findroot_mod_CFLAGS = $(COMMON_CFLAGS) +findroot_mod_LDFLAGS = $(COMMON_LDFLAGS)
disk/i386/pc/biosdisk.c +6 -6
@@ -66,12 +66,6 @@ grub_biosdisk_iterate (int (*hook) (const char *name))int drive;int num_floppies; -/* For floppy disks, we can get the number safely. */ - num_floppies =grub_biosdisk_get_num_floppies (); -for (drive =0 ; drive < num_floppies; drive++) -if (grub_biosdisk_call_hook (hook, drive)) -return 1 ; -/* For hard disks, attempt to read the MBR. */ for (drive =0x80 ; drive <0x90 ; drive++) {
@@ -92,6 +86,12 @@ grub_biosdisk_iterate (int (*hook) (const char *name))return 1 ; } +/* For floppy disks, we can get the number safely. */ + num_floppies =grub_biosdisk_get_num_floppies (); +for (drive =0 ; drive < num_floppies; drive++) +if (grub_biosdisk_call_hook (hook, drive)) +return 1 ; +return 0 ; }
include/grub/envblk.h new file +51 -0
51 lines not on this page · raw message
include/grub/i386/pc/kernel.h +7 -7
@@ -37,14 +37,14 @@/* The offset of GRUB_MEMDISK_IMAGE_SIZE. */ #define GRUB_KERNEL_MACHINE_MEMDISK_IMAGE_SIZE 0x1c -/* The offset of GRUB_PREFIX. */ -#define GRUB_KERNEL_MACHINE_PREFIX 0x20 +/* The offset of GRUB_ENVBLK. */ +#define GRUB_KERNEL_MACHINE_ENVBLK 0x26/* End of the data section. */ -#define GRUB_KERNEL_MACHINE_DATA_END 0x50 +#define GRUB_KERNEL_MACHINE_DATA_END 0x70/* The size of the first region which won't be compressed. */ -#define GRUB_KERNEL_MACHINE_RAW_SIZE 0x4A0 +#define GRUB_KERNEL_MACHINE_RAW_SIZE 0x4C0#ifndef ASM_FILE
@@ -66,9 +66,9 @@ extern grub_int32_t grub_install_bsd_part;/* The size of memory disk image, if present. */ extern grub_int32_t grub_memdisk_image_size; -/* The prefix which points to the directory where GRUB modules and its -configuration file are located. */ -extern char grub_prefix[]; +/* The envblk contains variable which can be used to locate the directory where +GRUB modules and its configuration file. */ +extern char grub_envblk[];/* The boot BIOS drive number. */ extern grub_int32_t EXPORT_VAR (grub_boot_drive );
include/grub/kernel.h +4 -2
@@ -55,8 +55,10 @@ void grub_machine_init (void);/* The machine-specific finalization. */ void grub_machine_fini (void ); -/* The machine-specific prefix initialization. */ -void grub_machine_set_prefix (void ); +/* The machine-specific root initialization. */ +void grub_machine_set_root (void ); + +char *grub_machine_get_envblk (void );/* Register all the exported symbols. This is automatically generated. */ void grub_register_exported_symbols (void );
kern/findroot.c new file +110 -0
110 lines not on this page · raw message
kern/i386/pc/init.c +32 -37
83 lines not on this page · raw message
kern/i386/pc/startup.S +8 -2
@@ -52,6 +52,7 @@ #include <grub/term.h> #include <multiboot.h> #include <multiboot2.h> +#include <grub/envblk.h> #define ABS(x) ((x) - EXT_C(start) + GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200)
@@ -98,14 +99,19 @@ VARIABLE(grub_install_bsd_part) .long 0xFFFFFFFF VARIABLE(grub_memdisk_image_size) .long 0 -VARIABLE(grub_prefix) + .long GRUB_ENVBLK_SIGNATURE + .word envblk_end - grub_envblk +VARIABLE(grub_envblk) + .byte 0 /* to be filled by grub-mkimage */ /* * Leave some breathing room for the prefix. */ - . = EXT_C(start) + 0x50 + . = EXT_C(start) + 0x70 + +envblk_end: /* * Support for booting GRUB from a Multiboot boot loader (e.g. GRUB itself).
kern/main.c +47 -14
90 lines not on this page · raw message
util/envblk.c new file +171 -0
171 lines not on this page · raw message
util/grub-editenv.c new file +228 -0
228 lines not on this page · raw message
util/grub-emu.c +11 -9
@@ -36,15 +36,13 @@#include <grub/util/getroot.h> #include <grub/env.h> #include <grub/partition.h> +#include <grub/envblk.h> #include <grub_emu_init.h> /* Used for going back to the main function. */ jmp_buf main_env; -/* Store the prefix specified by an argument. */ -static char *prefix =0 ; -grub_addr_t grub_arch_modules_addr (void ) {
@@ -76,11 +74,15 @@ grub_machine_init (void) }void -grub_machine_set_prefix (void ) +grub_machine_set_root (void ) { -grub_env_set ("prefix" , prefix); -free (prefix); - prefix =0 ; +/* Do nothing, as root is already set. */ +} + +char * +grub_machine_get_envblk (void ) +{ +return 0 ; }void
@@ -205,8 +207,8 @@ main (int argc, char *argv[]) } dir =grub_get_prefix (dir); - prefix =xmalloc (strlen (root_dev) +2 +strlen (dir) +1 ); -sprintf (prefix,"(%s)%s" , root_dev, dir); +grub_env_set (GRUB_ENVBLK_RDIR , dir); +grub_env_set ("root" , root_dev);free (dir);/* Start GRUB! */
util/i386/pc/grub-mkimage.c +4 -2
@@ -27,6 +27,7 @@#include <grub/util/misc.h> #include <grub/util/resolve.h> #include <grub/misc.h> +#include <grub/envblk.h> #include <stdio.h> #include <unistd.h>
@@ -109,9 +110,10 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[], char *me kernel_img =xmalloc (kernel_size + total_module_size + memdisk_size);grub_util_load_image (kernel_path, kernel_img); -if (GRUB_KERNEL_MACHINE_PREFIX +strlen (prefix) +1 >GRUB_KERNEL_MACHINE_DATA_END ) +if (GRUB_KERNEL_MACHINE_ENVBLK +sizeof (GRUB_ENVBLK_RDIR ) +2 +strlen (prefix) >GRUB_KERNEL_MACHINE_DATA_END )grub_util_error ("prefix too long" ); -strcpy (kernel_img +GRUB_KERNEL_MACHINE_PREFIX , prefix); +strcpy (kernel_img +GRUB_KERNEL_MACHINE_ENVBLK ,GRUB_ENVBLK_RDIR "=" ); +strcpy (kernel_img +GRUB_KERNEL_MACHINE_ENVBLK +sizeof (GRUB_ENVBLK_RDIR ), prefix);/* Fill in the grub_module_info structure. */ modinfo = (struct grub_module_info *) (kernel_img + kernel_size);
util/i386/pc/grub-setup.c +5 -1
@@ -34,6 +34,7 @@#include <grub/term.h> #include <grub/util/raid.h> #include <grub/util/lvm.h> +#include <grub/envblk.h> static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot =GRUB_GPT_PARTITION_TYPE_BIOS_BOOT ;
@@ -235,7 +236,10 @@ setup (const char *prefix, const char *dir, install_bsd_part = (grub_int32_t *) (core_img +GRUB_DISK_SECTOR_SIZE +GRUB_KERNEL_MACHINE_INSTALL_BSD_PART ); install_prefix = (core_img +GRUB_DISK_SECTOR_SIZE - +GRUB_KERNEL_MACHINE_PREFIX ); + +GRUB_KERNEL_MACHINE_ENVBLK ); + +strcpy (install_prefix,GRUB_ENVBLK_RDIR "=" ); + install_prefix +=sizeof (GRUB_ENVBLK_RDIR );/* Open the root device and the destination device. */ root_dev =grub_device_open (root);
I've been thinking a bit more about this, and I think it should be possible to solve the problem at hand without extending the existing framework. I'm concerned about finding a solution that is as simple (and small) as possible.
Do you mind waiting a few days? I'll send a proposal tomorrow or so.
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What good is a phone call… if you are unable to speak? (as seen on /.)
Quoted 7 lines · Robert Millan
I've been thinking a bit more about this, and I think it should be possible to solve the problem at hand without extending the existing framework. I'm concerned about finding a solution that is as simple (and small) as possible.
Do you mind waiting a few days? I'll send a proposal tomorrow or so.
Ok, no hurry.
Signature · 1 line
Bean
UUID-based boot (Re: [PATCH] Environment block support for grub2)
Quoted 10 lines · Bean
Quoted 7 lines · Robert Millan
I've been thinking a bit more about this, and I think it should be possible to solve the problem at hand without extending the existing framework. I'm concerned about finding a solution that is as simple (and small) as possible.
Do you mind waiting a few days? I'll send a proposal tomorrow or so.
Ok, no hurry.
Sorry for the delay; it was quite a bit of work as I got hit by a number of bugs here and there :-)
Considering that the problem was quite similar to the "boot from LVM" issue we already knew about, I thought it'd be a good idea to start with that.
Although not directly related, the patch at in "boot from LVM / RAID" mail I just sent would allow to easily boot via UUID as well.
If we add a UUID-based disk driver (see "disk/fs_uuid.c" mail), then it's just a matter of increasing the grub_prefix size so that an UUID can fit in it, and adjusting the install scripts to do it.
Here's a sample (untested) patch to illustrate it.
Then for the Vista use case, I suppose the remaining questions are if NTFS supports UUIDs (or otherwise we have to ressort to labels?), and if we can extract filesystem metadata from Windows (if possible without requiring that a Cygwin installation is present).
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What good is a phone call… if you are unable to speak? (as seen on /.)
include/grub/i386/pc/kernel.h renamed from tmp.old/include/grub/i386/pc/kernel.h +1 -1
@@ -41,7 +41,7 @@#define GRUB_KERNEL_MACHINE_PREFIX 0x20/* End of the data section. */ -#define GRUB_KERNEL_MACHINE_DATA_END 0x50 +#define GRUB_KERNEL_MACHINE_DATA_END 0x60/* The size of the first region which won't be compressed. */ #define GRUB_KERNEL_MACHINE_RAW_SIZE (GRUB_KERNEL_MACHINE_DATA_END + 0x450)
util/i386/pc/grub-install.in renamed from tmp.old/util/i386/pc/grub-install.in +2 -2
@@ -232,13 +232,13 @@ partmap_module=`$grub_probe --target=par devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}` if [ "x${devabstraction_module}" = "x" ] ; then - prefix_drive= + prefix_drive=\(UUID=`$grub_probe --target=fs_uuid --device ${grub_device}`\) else prefix_drive=`$grub_probe --target=drive --device ${grub_device}` fi # _chain is often useful -modules="$modules $fs_module $partmap_module biosdisk $devabstraction_module _chain" +modules="$modules $fs_module $partmap_module biosdisk $devabstraction_module _chain fs_uuid" $grub_mkimage --output=${grubdir}/core.img \ --prefix=${prefix_drive}`make_system_path_relative_to_its_root ${grubdir}`/ \
util/i386/pc/grub-setup.c renamed from tmp.old/util/i386/pc/grub-setup.c +3 -1
@@ -300,7 +300,9 @@ setup (const char *prefix, const char *d block->segment =0 ;/* Embed information about the installed location. */ -if (must_embed) +if (install_prefix[0 ] =='(' ) +/* If we included a drive explicitly in prefix, force GRUB to use that instead +of root_drive. */ *install_dos_part = *install_bsd_part =grub_cpu_to_le32 (-2 );else if (root_dev->disk->partition) {
Re: UUID-based boot (Re: [PATCH] Environment block support for grub2)
Quoted 6 lines · Robert Millan
Sorry for the delay; it was quite a bit of work as I got hit by a number of bugs here and there :-)
Considering that the problem was quite similar to the "boot from LVM" issue we already knew about, I thought it'd be a good idea to start with that.
Quoted 8 lines
Although not directly related, the patch at in "boot from LVM / RAID" mail I just sent would allow to easily boot via UUID as well.
If we add a UUID-based disk driver (see "
disk/fs_uuid.c" mail), then it's just a matter of increasing thegrub_prefixsize so that an UUID can fit in it, and adjusting the install scripts to do it.Here's a sample (untested) patch to illustrate it.
I take a quick look at your patch, the method should work, but i remember okuji oppose embedding device name in prefix, don't know how he look at it now.
Quoted 5 lines
Then for the Vista use case, I suppose the remaining questions are if NTFS supports UUIDs (or otherwise we have to ressort to labels?), and if we can extract filesystem metadata from Windows (if possible without requiring that a Cygwin installation is present).
ntfs has a 64-bit serial number, it's not quite the same as uuid, but it can be used to identify the partition.
Signature · 1 line
Bean
Re: UUID-based boot (Re: [PATCH] Environment block support for grub2)
Quoted 14 lines · Bean
Quoted 13 lines · Robert Millan
Sorry for the delay; it was quite a bit of work as I got hit by a number of bugs here and there :-)
Considering that the problem was quite similar to the "boot from LVM" issue we already knew about, I thought it'd be a good idea to start with that.
Although not directly related, the patch at in "boot from LVM / RAID" mail I just sent would allow to easily boot via UUID as well.
If we add a UUID-based disk driver (see "
disk/fs_uuid.c" mail), then it's just a matter of increasing thegrub_prefixsize so that an UUID can fit in it, and adjusting the install scripts to do it.
Quoted 5 lines
Quoted 1 line
Here's a sample (untested) patch to illustrate it.
I take a quick look at your patch, the method should work, but i remember okuji oppose embedding device name in prefix, don't know how he look at it now.
Do you remember why? (or where it was discussed)
Anyway, CCing him. Okuji, please say something! :-)
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What good is a phone call… if you are unable to speak? (as seen on /.)
Re: UUID-based boot (Re: [PATCH] Environment block support for grub2)
Quoted 17 lines · Robert Millan
Quoted 16 lines · Bean
Quoted 14 lines · Robert Millan
Sorry for the delay; it was quite a bit of work as I got hit by a number of bugs here and there :-)
Considering that the problem was quite similar to the "boot from LVM" issue we already knew about, I thought it'd be a good idea to start with that.
Although not directly related, the patch at in "boot from LVM / RAID" mail I just sent would allow to easily boot via UUID as well.
If we add a UUID-based disk driver (see "
disk/fs_uuid.c" mail), then it's just a matter of increasing thegrub_prefixsize so that an UUID can fit in it, and adjusting the install scripts to do it.Here's a sample (untested) patch to illustrate it.
Quoted 7 lines
Quoted 3 lines
I take a quick look at your patch, the method should work, but i remember okuji oppose embedding device name in prefix, don't know how he look at it now.
Do you remember why? (or where it was discussed)
Anyway, CCing him. Okuji, please say something! :-)
Hi,
I find the post:
http://lists.gnu.org/archive/html/grub-devel/2008-02/msg00542.html
Signature · 1 line
Bean
Re: UUID-based boot (Re: [PATCH] Environment block support for grub2)
Quoted 6 lines · Bean
Hi,
I find the post:
http://lists.gnu.org/archive/html/grub-devel/2008-02/msg00542.html
I completely agree. The patch I sent makes it rely on UUIDs unconditionaly because it was just a proof of concept, but my intention is to only use UUIDs when at grub-install time we determined that there's no reliable way to find the root drive.
I would handle the following cases in the installer:
- If the boot drive is the same as the root drive, the BIOS will tell us about it at boot time, so we don't use UUIDs.
- If the root drive is LVM or RAID, we can reliably identify it by its LVM or RAID name, so there's no need to ressort to UUIDs.
- If the boot drive is different than the root drive, often a device.map guess will work, but not always. So we use UUIDs whenever they're available.
What do you think?
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What good is a phone call… if you are unable to speak? (as seen on /.)
Re: UUID-based boot (Re: [PATCH] Environment block support for grub2)
In reply to Robert MillanQuoted 15 lines · Robert Millan
Quoted 14 lines · Bean
Quoted 13 lines · Robert Millan
Sorry for the delay; it was quite a bit of work as I got hit by a number of bugs here and there :-)
Considering that the problem was quite similar to the "boot from LVM" issue we already knew about, I thought it'd be a good idea to start with that.
Although not directly related, the patch at in "boot from LVM / RAID" mail I just sent would allow to easily boot via UUID as well.
If we add a UUID-based disk driver (see "
disk/fs_uuid.c" mail), then it's just a matter of increasing thegrub_prefixsize so that an UUID can fit in it, and adjusting the install scripts to do it.
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Here's a sample (untested) patch to illustrate it.
I take a quick look at your patch, the method should work, but i remember okuji oppose embedding device name in prefix, don't know how he look at it now.
Do you remember why? (or where it was discussed)
Anyway, CCing him. Okuji, please say something! :-)
I thinks its related to recovery for server platforms. Anyway... Should we start creating use cases to wiki in what failure situations grub can face and then we can see how it can perform those situations.
PATCH 1/1 ntfs UUIDs (Re: UUID-based boot (Re: [PATCH] Environment block support for grub2))
In reply to BeanQuoted 7 lines · Bean
Quoted 4 lines
Then for the Vista use case, I suppose the remaining questions are if NTFS supports UUIDs (or otherwise we have to ressort to labels?), and if we can extract filesystem metadata from Windows (if possible without requiring that a Cygwin installation is present).
ntfs has a 64-bit serial number, it's not quite the same as uuid, but it can be used to identify the partition.
This patch adds the 64-bit serial number as UUID. But I'm not sure what is the "standard" method to stringify this number. Apparently, Windows only prints half of it in the dir command.
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What good is a phone call… if you are unable to speak? (as seen on /.)
fs/ntfs.c renamed from grub2/fs/ntfs.c +33 -0
@@ -830,6 +830,8 @@ grub_ntfs_mount (grub_disk_t disk) (disk, data->mft_start, 0, data->mft_size << BLK_SHR, data->mmft.buf)) goto fail; + *((grub_uint64_t *) &data->uuid) = bpb.num_serial; +if (fixup (data, data->mmft.buf, data->mft_size,"FILE" )) goto fail;
@@ -1078,6 +1080,36 @@ fail:return grub_errno; } +static grub_err_t +grub_ntfs_uuid (grub_device_t device,char **uuid) +{ +struct grub_ntfs_data *data; +grub_disk_t disk = device->disk; + +#ifndef GRUB_UTIL +grub_dl_ref (my_mod); +#endif + + data =grub_ntfs_mount (disk); +if (data) + { + *uuid =grub_malloc (sizeof ("xxxx-xxxx-xxxx-xxxx" )); +grub_sprintf (*uuid,"%04x-%04x-%04x-%04x" , +grub_le_to_cpu16 (data->uuid[0 ]),grub_le_to_cpu16 (data->uuid[1 ]), +grub_le_to_cpu16 (data->uuid[2 ]),grub_le_to_cpu16 (data->uuid[3 ])); + } +else + *uuid =NULL ; + +#ifndef GRUB_UTIL +grub_dl_unref (my_mod); +#endif + +grub_free (data); + +return grub_errno; +} +static struct grub_fs grub_ntfs_fs = { .name ="ntfs" , .dir = grub_ntfs_dir,
@@ -1085,6 +1117,7 @@ static struct grub_fs grub_ntfs_fs = { .read = grub_ntfs_read, .close = grub_ntfs_close, .label = grub_ntfs_label, + .uuid = grub_ntfs_uuid, .next = 0 };
include/grub/ntfs.h renamed from grub2/include/grub/ntfs.h +2 -1
@@ -115,7 +115,7 @@ struct grub_ntfs_bpbgrub_int8_t reserved_4[3 ];grub_int8_t clusters_per_index;grub_int8_t reserved_5[3 ]; -grub_uint64_t serial_number; +grub_uint64_t num_serial;grub_uint32_t checksum; } __attribute__ ((packed));
@@ -151,6 +151,7 @@ struct grub_ntfs_datagrub_uint32_t spc;grub_uint32_t blocksize;grub_uint32_t mft_start; +grub_uint16_t uuid[4 ]; };struct grub_ntfs_comp
Re: [PATCH] ntfs UUIDs (Re: UUID-based boot (Re: [PATCH] Environment block support for grub2))
Dne 7 Červen 2008, 01:31, Robert Millan napsal(a):
Quoted 3 lines
This patch adds the 64-bit serial number as UUID. But I'm not sure what is the "standard" method to stringify this number. Apparently, Windows only prints half of it in the dir command.
That seems to me as some backward (pronounce: awkward) compatibility of M$ Volume ID. Volume ID in M$ windows is (as you say) 'xxxx-xxxx' two 16 bit hexadecimal numbers. And all programs I tested report the number this way. So if we want user to enter these numbers manually we should ignore the remaining four bits. Alternatively we can provide utility that prints out whole serial number.
Signature · 2 lines
Tomas Ebenlendr
http://drak.ucw.cz/~ebikRe: [PATCH] ntfs UUIDs (Re: UUID-based boot (Re: [PATCH] Environment block support for grub2))
Quoted 11 lines · Tomáš Ebenlendr
Dne 7 Červen 2008, 01:31, Robert Millan napsal(a):
Quoted 3 lines
This patch adds the 64-bit serial number as UUID. But I'm not sure what is the "standard" method to stringify this number. Apparently, Windows only prints half of it in the dir command.
That seems to me as some backward (pronounce: awkward) compatibility of M$ Volume ID. Volume ID in M$ windows is (as you say) 'xxxx-xxxx' two 16 bit hexadecimal numbers. And all programs I tested report the number this way. So if we want user to enter these numbers manually we should ignore the remaining four bits. Alternatively we can provide utility that prints out whole serial number.
I suggest that you check udev sources:
http://www.us.kernel.org/pub/linux/utils/kernel/hotplug/
It calculates UUID for many filesystems (see extras/lib/volime_id/lib). It would be nice to stay compatible with udev.
Signature · 2 lines
Regards, Pavel Roskin
Re: [PATCH] ntfs UUIDs (Re: UUID-based boot (Re: [PATCH] Environment block support for grub2))
Quoted 13 lines · Pavel Roskin
Quoted 11 lines · Tomáš Ebenlendr
Dne 7 Červen 2008, 01:31, Robert Millan napsal(a):
Quoted 3 lines
This patch adds the 64-bit serial number as UUID. But I'm not sure what is the "standard" method to stringify this number. Apparently, Windows only prints half of it in the dir command.
That seems to me as some backward (pronounce: awkward) compatibility of M$ Volume ID. Volume ID in M$ windows is (as you say) 'xxxx-xxxx' two 16 bit hexadecimal numbers. And all programs I tested report the number this way. So if we want user to enter these numbers manually we should ignore the remaining four bits. Alternatively we can provide utility that prints out whole serial number.
Quoted 5 lines
I suggest that you check udev sources:
http://www.us.kernel.org/pub/linux/utils/kernel/hotplug/It calculates UUID for many filesystems (see extras/lib/volime_id/lib). It would be nice to stay compatible with udev.
Ok. I adjusted it to output the same format as vol_id and committed. Turns out this was the simplest to implement (get a 64-bit LE and print right away).
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What good is a phone call… if you are unable to speak? (as seen on /.)
Quoted 22 lines · Bean
Quoted 16 lines · Robert Millan
I think the method is sound; what I'm complaining about (and it's not something specific to your patch) is that we're referring to two different things by the same name ("root"), and even put them in the same variable.
In the initialization phase, "root" is the device that contains our GRUB directory.
Afterwards, "root" is the device we're currently accessing (be it for loading fonts, backgrounds, Linux images, whatever).
If "root" means "just a placeholder for whatever device we're acessing at the moment", then it would make sense, but in our code (i.e. in the names we're giving to commands and functions) it's assumed to mean "the device containing
/boot/grub".Quoted 4 lines
So what do we want to do with this? Should we have different variables for each thing (and in that case, is "root" for initial stage or for grub.cfg) or should we use "root" as a placeholder for any path reference, and adjust our function names etc to reflect that?
Quoted 4 lines
root is used in loaders as well, we shouldn't change its name. We could use another variable to store the root device at initial stage, it could actually be useful as it always points to the boot media. Perhaps we can name it "boot". What's your idea ?
I'm fine with "boot". I'm CCing Okuji; would like to make sure he doesn't have any objections (I think it was he who gave it this layout).
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What good is a phone call… if you are unable to speak? (as seen on /.)
Quoted 23 lines · On Saturday 31 May 2008 17:21:25 Robert Millan wrote:
Quoted 22 lines · Bean
Quoted 20 lines · Robert Millan
I think the method is sound; what I'm complaining about (and it's not something specific to your patch) is that we're referring to two different things by the same name ("root"), and even put them in the same variable.
In the initialization phase, "root" is the device that contains our GRUB directory.
Afterwards, "root" is the device we're currently accessing (be it for loading fonts, backgrounds, Linux images, whatever).
If "root" means "just a placeholder for whatever device we're acessing at the moment", then it would make sense, but in our code (i.e. in the names we're giving to commands and functions) it's assumed to mean "the device containing
/boot/grub".So what do we want to do with this? Should we have different variables for each thing (and in that case, is "root" for initial stage or for grub.cfg) or should we use "root" as a placeholder for any path reference, and adjust our function names etc to reflect that?
Quoted 7 lines
Quoted 4 lines
root is used in loaders as well, we shouldn't change its name. We could use another variable to store the root device at initial stage, it could actually be useful as it always points to the boot media. Perhaps we can name it "boot". What's your idea ?
I'm fine with "boot". I'm CCing Okuji; would like to make sure he doesn't have any objections (I think it was he who gave it this layout).
"boot" is used for a command, so it is very confusing to use the same name for a variable. If you want to have this kind of variable, please find another name. I myself have no idea.
Okuji
Quoted 29 lines · Yoshinori K. Okuji
Quoted 28 lines · On Saturday 31 May 2008 17:21:25 Robert Millan wrote:
Quoted 26 lines · Bean
Quoted 16 lines · Robert Millan
I think the method is sound; what I'm complaining about (and it's not something specific to your patch) is that we're referring to two different things by the same name ("root"), and even put them in the same variable.
In the initialization phase, "root" is the device that contains our GRUB directory.
Afterwards, "root" is the device we're currently accessing (be it for loading fonts, backgrounds, Linux images, whatever).
If "root" means "just a placeholder for whatever device we're acessing at the moment", then it would make sense, but in our code (i.e. in the names we're giving to commands and functions) it's assumed to mean "the device containing
/boot/grub".Quoted 4 lines
So what do we want to do with this? Should we have different variables for each thing (and in that case, is "root" for initial stage or for grub.cfg) or should we use "root" as a placeholder for any path reference, and adjust our function names etc to reflect that?
root is used in loaders as well, we shouldn't change its name. We could use another variable to store the root device at initial stage, it could actually be useful as it always points to the boot media. Perhaps we can name it "boot". What's your idea ?
Quoted 6 lines
Quoted 2 lines
I'm fine with "boot". I'm CCing Okuji; would like to make sure he doesn't have any objections (I think it was he who gave it this layout).
"boot" is used for a command, so it is very confusing to use the same name for a variable. If you want to have this kind of variable, please find another name. I myself have no idea.
Hi,
No problem, I can find another name.
BTW, there are now two schemes for locating device at boot, the environment block and robert's uuid device, which one do you favor, or is there other scheme you prefer ?
Signature · 1 line
Bean
Quoted 4 lines · Bean
Hi,
No problem, I can find another name.
Sorry, my mistake. I complained about $root being inappropiate for early stage use, but after that I noticed that $root is used in every stage to refer to "whatever drive we're currently accessing"; even before $prefix is initialised!
I'm fine with $root if nobody objects.
Quoted 3 lines
BTW, there are now two schemes for locating device at boot, the environment block and robert's uuid device, which one do you favor, or is there other scheme you prefer ?
I think there's no problem with having two schemes as long as they don't take extra core.img space (except for the rare use cases they're intended to) and don't conflict with each other.
As for the "findroot" approach, I have two comments/ideas:
- Since findroot.mod is basicaly an heuristic, and it's possible we may want different kinds of methods that work similarly, how about calling it "findroot_by_file" or something like that? Then we could have a separate module for "findroot_by_uuid", etc.
- I think your idea has the potential of obsoleting some parts of our init routines, maybe (if we're lucky) making kernel.img smaller. For example, we currently make grub_prefix a static length string (could it be dynamic? -> less space); then try to extract $root from it, since we embedded it in the same place (if we had a scheme to specify it separately -> less code to parse it).
Signature · 5 lines
Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What good is a phone call… if you are unable to speak? (as seen on /.)
Quoted 13 lines · Robert Millan
Quoted 4 lines · Bean
Hi,
No problem, I can find another name.
Sorry, my mistake. I complained about $root being inappropiate for early stage use, but after that I noticed that $root is used in every stage to refer to "whatever drive we're currently accessing"; even before $prefix is initialised!
I'm fine with $root if nobody objects.
Quoted 7 lines
Quoted 3 lines
BTW, there are now two schemes for locating device at boot, the environment block and robert's uuid device, which one do you favor, or is there other scheme you prefer ?
I think there's no problem with having two schemes as long as they don't take extra core.img space (except for the rare use cases they're intended to) and don't conflict with each other.
Yes, they can coexist easily. The environment block can overwrite root variable, so to use uuid fs, just set the root variable, and to use findroot, set uuid/lable/idfile.
Quoted 7 lines
As for the "findroot" approach, I have two comments/ideas:
- Since findroot.mod is basicaly an heuristic, and it's possible we may want different kinds of methods that work similarly, how about calling it "
findroot_by_file" or something like that? Then we could have a separate module for "findroot_by_uuid", etc.
Seems fine to me.
Quoted 7 lines
- I think your idea has the potential of obsoleting some parts of our init routines, maybe (if we're lucky) making kernel.img smaller. For example, we currently make
grub_prefixa static length string (could it be dynamic? -> less space); then try to extract $root from it, since we embedded it in the same place (if we had a scheme to specify it separately -> less code to parse it).
I think it can be dynamic, we can store it right after the modules. Although the area is compressed, so we can't use grub-editenv to change it easily.
Signature · 1 line
Bean