* util/i386/efi/grub-mkimage.c (get_target_address): Return a
pointer, not an integer. This fixes a warning and prevents
precision loss on 64-bit systems.
(relocate_addresses): Remove unneeded cast.
* util/grub.d/40_custom.in: New file. Example on how to add custom
entries to /etc/grub.d.
* conf/common.rmk (%, update-grub_SCRIPTS, CLEANFILES): Install
40_custom (implicitly, by merging all the grub.d rules).
This fixes a performance issue when pc & gpt partmap iterators
didn't abort iteration even after our hook found what it was
looking for (often causing expensive probes of non-existant drives).
Some callers relied on previous buggy behaviour, since they would
rise an error when their own hooks caused early abortion of its
iteration.
* kern/device.c (grub_device_open): Improve error message.
* disk/lvm.c (grub_lvm_open): Likewise.
* disk/raid.c (grub_raid_open): Likewise.
* partmap/pc.c (pc_partition_map_iterate): Abort parent iteration
when hook requests it, independently of grub_errno.
(pc_partition_map_probe): Do not fail when find_func() caused
early abortion of pc_partition_map_iterate().
* partmap/gpt.c (gpt_partition_map_iterate): Abort parent iteration
when hook requests it, independently of grub_errno.
(gpt_partition_map_probe): Do not fail when find_func() caused
early abortion of gpt_partition_map_iterate().
* kern/partition.c (grub_partition_iterate): Abort parent iteration
when hook requests it, independently of grub_errno. Do not fail when
part_map_iterate_hook() caused early abortion of p->iterate().
* util/biosdisk.c (grub_util_biosdisk_get_grub_dev): Do not fail
when grub_partition_iterate() returned with non-zero.
* include/grub/ieee1275.h (grub_ieee1275_flag): New constant
GRUB_IEEE1275_FLAG_CANNOT_INTERPRET, GRUB_IEEE1275_FLAG_FORCE_CLAIM
and GRUB_IEEE1275_FLAG_NO_ANSI.
* kern/ieee1275/cmain.c (grub_ieee1275_find_options): Set flag
GRUB_IEEE1275_FLAG_CANNOT_INTERPRET, GRUB_IEEE1275_FLAG_FORCE_CLAIM
and GRUB_IEEE1275_FLAG_NO_ANSI for Open Hackware.
* kern/ieee1275/ieee1275.c (grub_ieee1275_interpret): Return
immediately if GRUB_IEEE1275_FLAG_CANNOT_INTERPRET is set.
* kern/ieee1275/init.c (grub_claim_heap): Claim memory directly if
GRUB_IEEE1275_FLAG_FORCE_CLAIM is set.
* term/ieee1275/ofconsole.c (grub_ofconsole_writeesc): Don't output
esc sequence on non ANSI terminal.
(grub_ofconsole_gotoxy): Emulate backspace key on non ANSI terminal.
* util/elf/grub-mkimage.c (add_segments): Move ELF header to the
beginning of file.
* util/i386/pc/grub-setup.c (setup): Write install_dos_part and
install_bsd_part immediately before core.img is embedded or
modified on disk. This fixes core.img verification if core.img
cannot be embedded.
* util/update-grub_lib.in (font_path): Search for fonts in
/boot/grub first, which is more likely to be readable (we aren't
deciding where fonts live, just looking for them).
* util/grub.d/10_linux.in: Avoid passing UUIDs to Linux when either
"/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" does not exist, or when a
Linux image includes no initrd.
* util/grub.d/00_header.in: Move last prepare_grub_to_access_device()
call from here ...
* util/grub.d/10_hurd.in: ... to here ...
* util/grub.d/10_linux.in: ... and here.
* util/update-grub_lib.in (prepare_grub_to_access_device): Remove
check for partition that provides /boot/grub. Its logic is flawed,
as it prevents prepare_grub_to_access_device() from being called
multiple times.
* util/update-grub_lib.in (prepare_grub_to_access_device): Issue
"insmod" command directly when abstraction modules are needed,
instead of reliing on GRUB_PRELOAD_MODULES (which had no effect
since it had already been processed).
* util/i386/pc/grub-install.in: If the drive is LVM or RAID, prepend
it in prefix.
* util/i386/pc/grub-setup.c (main): Don't handle prefix at all. Set
`must_embed' to 1 when root_dev is a RAID device. When dest_dev is
a RAID device, run setup() for all members independently on whether
LVM abstraction is being used.
(setup): Don't handle prefix at all; let grub-mkimage take care of it.
If grub-mkimage has set `*install_dos_part == -2', don't override this
value.
Perform *install_dos_part adjustments independently on whether
we're embedding or not.
Clarify error message when image is too big for embedding.
Remove duplicate *install_dos_part stanza.
* util/update-grub_lib.in (prepare_grub_to_access_device): Use
/boot/grub for the check in last commit, not /boot (they could be
different partitions).
* util/update-grub_lib.in (prepare_grub_to_access_device): If we were
asked to setup access for the same partition that provides /boot,
don't bother using UUIDs since our root already has the value we
want.
* util/i386/pc/grub-mkimage.c (generate_image): If we included a drive
in our prefix, set install_{dos,bsd}_part = -2 to indicate this can be
skipped later.
(main): If a memdisk was requested, add "(memdisk)" drive explicitly to
the beginning of the prefix.
* kern/i386/pc/init.c (make_install_device): Remove memdisk check.
It is assumed that if we have a memdisk, grub-mkimage has set
grub_prefix to include the "(memdisk)" drive in it.
* util/biosdisk.c (open_device): Revert last change to the
function, it broke installation. The sector needs to be
different dependent on which device is opened.
* util/grub-emu.c (grub_machine_init): Move code in this function from
here ...
(main): ... to here (before grub_util_biosdisk_init() call, to prevent
segfault in case grub_printf() is called).
* util/i386/pc/grub-install.in: Append `--device-map=${device_map}' to
grub_probe. Update all users not to explicitly add it again.
(grub_device): New variable; contains corresponding device for grubdir.
(fs_module, partmap_module, devabstraction_module): Pass
`--device ${grub_device}' to grub_probe to avoid traversing /dev
every time.
* util/biosdisk.c (get_drive): Verify that `map[i].drive' is non-NULL
before dereferencing it.
* fs/fat.c (struct grub_fat_bpb): Move fat32-specific fields into a
union with fat12/fat16-specific ones. Add some new fields, including
`num_serial' for both versions.
(struct grub_fat_data): Add `uuid' member.
(grub_fat_mount): Refer to fat32-specific fields in `bpb' by their new
names. Initialize `data->uuid' using `num_serial'.
(grub_fat_uuid): New function.
(grub_fat_fs): Reference grub_fat_uuid() in `uuid' struct member.
* fs/reiserfs.c (grub_reiserfs_superblock): Add `uuid' field.
(grub_reiserfs_uuid): New function.
(grub_reiserfs_fs): Reference grub_reiserfs_uuid() in `uuid' struct
member.
* fs/xfs.c (grub_xfs_sblock): Add `uuid' field.
(grub_xfs_uuid): New function.
(grub_xfs_fs): Reference grub_reiserfs_uuid() in `uuid' struct member.
* util/biosdisk.c (linux_find_partition): Simplify logic and
make the code more universal. Keep special processing for
devfs, but use a simple rule for all other devices. If the
device ends with a number, append 'p' and the partition number.
Otherwise, append only the partition number.
* util/update-grub.in (GRUB_DISABLE_LINUX_UUID): Export variable.
* util/grub.d/10_linux.in: If GRUB_DEVICE_UUID is set, and
GRUB_DISABLE_LINUX_UUID isn't true, use the filesystem UUIDs as
the `root' parameter to Linux.
* commands/search.c (options): Rename --fs_uuid to --fs-uuid.
* util/update-grub_lib.in (prepare_grub_to_access_device): Replace
--fs_uuid with --fs-uuid.
* util/update-grub.in: Allow filesystem UUID probes to fail (since not
all filesystems support them).
* util/grub.d/00_header.in: Remove obsolete comment referencing
convert_system_path_to_grub_path().
* util/update-grub.in: Likewise.
* util/update-grub_lib.in (is_path_readable_by_grub): New function.
(convert_system_path_to_grub_path): Add a warning message explaining
that this function is deprecated. Rely on is_path_readable_by_grub()
for the readability checks.
(font_path): Use is_path_readable_by_grub() for the readability
check rather than convert_system_path_to_grub_path().
* util/update-grub_lib.in (prepare_grub_to_access_device): New function.
* util/update-grub.in: Set `GRUB_FONT_PATH' to the system path, without
converting it first.
* util/grub.d/00_header.in: Use prepare_grub_to_access_device() to setup
grub.cfg for access to font file, and afterwards call it again to set
the root device.
* commands/search.c (options): Add --fs_uuid option.
(search_fs_uuid): New function.
(grub_cmd_search): Fix --set argument passing.
Use search_fs_uuid() when requested via --fs_uuid.
(grub_search_init): Update help message.
* fs/ext2.c (struct grub_ext2_sblock): Rename `unique_id' to `uuid'
and redeclare it as an array of 16-bit words.
(grub_ext2_uuid): New function.
(grub_ext2_fs): Reference grub_ext2_uuid() in `uuid' struct member.
* include/grub/fs.h (struct grub_fs): Add `uuid' struct member.
* util/update-grub.in (GRUB_DEVICE_UUID, GRUB_DEVICE_BOOT)
(GRUB_DEVICE_BOOT_UUID): New variables.
(GRUB_DRIVE. GRUB_DRIVE_BOOT. GRUB_DRIVE_BOOT_GRUB): Remove.
* util/grub.d/00_header.in: Set root using `search --fs_uuid' command
whenever possible.
* util/grub.d/10_hurd.in: Avoid explicit use of root drive. Instead,
just assume `root' variable has the right value.
* util/grub.d/10_linux.in: Likewise.
* util/grub-probe.c (probe): Probe for filesystem UUID when requested
via PRINT_FS_UUID.
(main): Recognise `-t fs_uuid' argument.
* util/biosdisk.c (map): Redefine structure to hold information
about GRUB drive name.
(get_drive): Reimplement without assuming (and verifiing) BIOS-like
drive names.
(call_hook): Remove.
(grub_util_biosdisk_iterate): Access drive names via `.drive' struct
member. Assume drive has partitions.
(grub_util_biosdisk_open): Access device names via `.device' struct
member.
(open_device): Likewise.
(find_drive): Likewise.
(read_device_map): Adjust map[] usage to match the new struct
definition. Don't check for duplicates (still possible, but not cheap
anymore).
(grub_util_biosdisk_fini): Free malloced buffers referenced by map[].
(make_device_name): Remove assumption of BIOS-like drive names.