* genmk.rb (Image): Copy `extra_flags' from here ...
(PModule): ... to here. Use it in `#{obj}: #{src}' rule.
* commands/i386/cpuid.c (grub_cmd_cpuid): Add __attribute__ ((unused))
to `argc' and `args' arguments.
Clean up the code to support 64-bit addressing in disks and
files. This change is not enough for filesystems yet.
* util/i386/pc/grub-setup.c (struct boot_blocklist): Change the
type of "start" to grub_uint64_t.
(setup): Change the types of KERNEL_SECTOR and FIRST_SECTOR to
grub_disk_addr_t * and grub_disk_addr_t. Fix the format string in
save_first_sector and save_blocklists. Use grub_le_to_cpu64 to
convert addresses.
* util/i386/pc/biosdisk.c (open_device): Change the type of SECTOR
to grub_disk_addr_t.
* partmap/gpt.c (gpt_partition_map_iterate): Fix the format
string.
* partmap/pc.c (pc_partition_map_iterate): Likewise.
* partmap/amiga.c (amiga_partition_map_iterate): Cast RDSK.MAGIC
to char *.
* normal/script.c (grub_script_parse): Remove unused MEMFREE.
* normal/parser.y (YYLTYPE_IS_TRIVIAL): New macro.
* normal/lexer.c (grub_script_yyerror): Specify unused to LEX.
* loader/i386/pc/multiboot.c (grub_multiboot_load_elf64): Cast -1
to grub_off_t, to detect an error from grub_file_seek.
(grub_multiboot_load_elf32): Likewise.
* kern/misc.c (grub_strtoul): Use grub_strtoull. Return the
maximum unsigned long value when an overflow is detected.
(grub_strtoull): New function.
(grub_divmod64): Likewise.
(grub_lltoa): use grub_divmod64.
* kern/fs.c (struct grub_fs_block): Change the type of "offset" to
grub_disk_addr_t.
(grub_fs_blocklist_open): Increase P if P is not NULL to advance
the pointer to next character. Use grub_strtoull instead of
grub_strtoul.
(grub_fs_blocklist_read): Change the types of SECTOR, OFFSET and
SIZE to grub_disk_addr_t, grub_off_t and grub_size_t,
respectively.
* kern/file.c (grub_file_read): Prevent an oveflow of LEN, as the
return value is signed.
(grub_file_seek): Change the type of OLD to grub_off_t. Do not
test if OFFSET is less than zero, as OFFSET is unsigned now.
* kern/disk.c (struct grub_disk_cache): Change the type of
"sector" to grub_disk_addr_t.
(grub_disk_cache_get_index): Change the type of SECTOR to
grub_disk_addr_t. Calculate the hash with SECTOR casted to
unsigned after shifting.
(grub_disk_cache_invalidate): Change the type of SECTOR to
grub_disk_addr_t.
(grub_disk_cache_unlock): Likewise.
(grub_disk_cache_store): Likewise.
(grub_disk_check_range): Change the types of SECTOR, OFFSET, SIZE,
START and LEN to grub_disk_addr_t *, grub_off_t *, grub_size_t,
grub_disk_addr_t and grub_uint64_t, respectively.
(grub_disk_read): Use an unsigned variable REAL_OFFSET for the
body, as the value of OFFSET is tweaked by
grub_disk_check_range. Change the types of START_SECTOR, LEN and
POS to grub_disk_addr_t, grub_size_t and grub_size_t,
respectively.
(grub_disk_write): Use an unsigned variable REAL_OFFSET for the
body, as the value of OFFSET is tweaked by
grub_disk_check_range. Change the types of LEN and N to
grub_size_t.
* io/gzio.c (struct grub_gzio): Change the types of "data_offset"
and "saved_offset" to grub_off_t.
(test_header): Cast BUF to char *.
(get_byte): Cast GZIO->DATA_OFFSET to grub_off_t. Cast GZIO->INBUF
to char *.
(grub_gzio_read): Change the types of OFFSET and SIZE to
grub_off_t and grub_size_t, respectively.
* include/grub/i386/pc/boot.h (GRUB_BOOT_MACHINE_FORCE_LBA):
Removed.
(GRUB_BOOT_MACHINE_BOOT_DRIVE): Changed to 0x4c.
(GRUB_BOOT_MACHINE_KERNEL_ADDRESS): Changed to 0x40.
(GRUB_BOOT_MACHINE_KERNEL_SEGMENT): Changed to 0x42.
(GRUB_BOOT_MACHINE_DRIVE_CHECK): Changed to 0x4e.
(GRUB_BOOT_MACHINE_LIST_SIZE): Increased to 12.
* include/grub/types.h (grub_off_t): Unconditionally set to
grub_uint64_t.
(grub_disk_addr_t): Changed to grub_uint64_t.
* include/grub/partition.h (struct grub_partition): Change the
types of "start", "len" and "offset" to grub_disk_addr_t,
grub_uint64_t and grub_disk_addr_t, respectively.
(grub_partition_get_start): Return grub_disk_addr_t.
(grub_partition_get_len): Return grub_uint64_t.
* include/grub/misc.h (grub_strtoull): New prototype.
(grub_divmod64): Likewise.
* include/grub/fshelp.h (grub_fshelp_read_file): Change the types
of SECTOR, LEN and FILESIZE to grub_disk_addr_t, grub_size_t and
grub_off_t, respectively.
All callers and references changed.
* include/grub/fs.h (struct grub_fs): Change the type of LEN to
grub_size_t in "read".
All callers and references changed.
* include/grub/file.h (struct grub_file): Change the types of
"offset" and "size" to grub_off_t and grub_off_t,
respectively. Change the type of SECTOR to grub_disk_addr_t in
"read_hook".
(grub_file_read): Change the type of LEN to grub_size_t.
(grub_file_seek): Return grub_off_t. Change the type of OFFSET to
grub_off_t.
(grub_file_size): Return grub_off_t.
(grub_file_tell): Likewise.
All callers and references changed.
* include/grub/disk.h (struct grub_disk_dev): Change the types of
SECTOR and SIZE to grub_disk_addr_t and grub_size_t in "read" and
"write".
(struct grub_disk): Change the type of "total_sectors" to
grub_uint64_t. Change the type of SECTOR to grub_disk_addr_t in
"read_hook".
(grub_disk_read): Change the types of SECTOR, OFFSET and SIZE to
grub_disk_addr_t, grub_off_t and grub_size_t, respectively.
(grub_disk_write): Likewise.
All callers and references changed.
* fs/iso9660.c (grub_iso9660_susp_iterate): Cast parameters to
char * for grub_strncmp to silence gcc.
(grub_iso9660_mount): Likewise.
(grub_iso9660_mount): Likewise.
(grub_iso9660_read_symlink): Likewise. Also, remove the nonsense
return statement.
(grub_iso9660_iterate_dir): Likewise.
(grub_iso9660_label): Cast DATA->VOLDESC.VOLNAME to char *.
* fs/hfs.c (grub_hfs_read_file): Change the types of SECTOR and
LEN to grub_disk_addr_t and grub_size_t, respectively.
* fs/hfsplus.c (grub_hfsplus_read_file): Likewise.
* fs/jfs.c (grub_jfs_read_file): Likewise.
* fs/minix.c (grub_jfs_read_file): Likewise.
* fs/sfs.c (grub_jfs_read_file): Likewise.
* fs/ufs.c (grub_jfs_read_file): Likewise.
* fs/xfs.c (grub_jfs_read_file): Likewise.
* fs/fat.c (grub_fat_read_data): Change the types of SECTOR, LEN
and SIZE to grub_disk_addr_t, grub_size_t and grub_size_t,
respectively.
* fs/ext2.c (grub_ext2_read_block): When an error happens, set
BLKNR to -1 instead of returning GRUB_ERRNO.
(grub_ext2_read_file): Change the types of SECTOR and
LEN to grub_disk_addr_t and grub_size_t, respectively.
* fs/affs.c (grub_affs_read_file): Change the types of SECTOR and
LEN to grub_disk_addr_t and grub_size_t, respectively.
* font/manager.c (grub_font_get_glyph): Cast BITMAP to char * for
grub_file_read.
* disk/ieee1275/ofdisk.c (grub_ofdisk_read): Fix the format
string. Do not cast SECTOR explicitly.
* disk/i386/pc/biosdisk.c (grub_biosdisk_open): Change the type of
TOTAL_SECTORS to grub_uint64_t. Do not mask DRP->TOTAL_SECTORS.
(grub_biosdisk_rw): Change the types of SECTOR and SIZE to
grub_disk_addr_t and grub_size_t, respectively. If the sector is
over 2TB and LBA mode is not supported, raise an error.
(get_safe_sectors): New function.
(grub_biosdisk_read): Use get_safe_sectors.
(grub_biosdisk_write): Likewise.
* disk/efi/efidisk.c (grub_efidisk_read): Fix the format string.
(grub_efidisk_write): Likewise.
* disk/loopback.c (delete_loopback): Cosmetic changes.
(grub_cmd_loopback): Likewise. Also, test NEWDEV->FILENAME
correctly.
(grub_loopback_open): Likewise.
(grub_loopback_read): Likewise. Also, change the type of POS to
grub_off_t, and fix the usage of grub_memset.
* commands/i386/pc/play.c: Include grub/machine/time.h.
* commands/ls.c (grub_ls_list_files): Use "llu" instead of "d" to
print FILE->SIZE.
* commands/configfile.c: Include grub/env.h.
* commands/cmp.c (grub_cmd_cmp): Do not use ERR, but use
GRUB_ERRNO directly instead. Change the type of POS to
grub_off_t. Follow the coding standard.
* commands/blocklist.c: Include grub/partition.h.
(grub_cmd_blocklist): Return an error if the underlying device is
not a disk. Take the starting sector of a partition into account,
if a partition is used.
* boot/i386/pc/diskboot.S (bootloop): Adapted to the new offset of
a length field.
(lba_mode): Support 64-bit addresses.
(chs_mode): Likewise.
(copy_buffer): Adapted to the new offsets of a length field and a
segment field.
(blocklist_default_start): Allocate 64-bit space.
* boot/i386/pc/boot.S (force_lba): Removed.
(boot_drive): Moved to under KERNEL_SECTOR.
(kernel_sector): Moved to under KENREL_SEGMENT. Allocate 64-bit
space.
(real_start): Set %si earlier. Remove code for FORCE_LBA, since it
is useless.
(lba_mode): Refactored to support a 64-bit address. More size
optimization.
(setup_sectors): Likewise.
* commands/blocklist.c: New file.
* DISTLIST: Added commands/blocklist.c.
* term/efi/console.c (grub_console_highlight_color): Use a lighter
color for the background, and a daker color for the foreground.
(grub_console_checkkey): Return READ_KEY.
(grub_console_cls): Set the background to
GRUB_EFI_BACKGROUND_BLACK temporarily to clean out the screen.
* kern/efi/efi.c (grub_efi_exit_boot_services): New function.
* include/grub/i386/linux.h (struct linux_kernel_params): Fixed
the size of "padding5", "hd0_drive_info" and "hd1_drive_info".
* include/grub/efi/efi.h (grub_efi_exit_boot_services): New
prototype.
* include/grub/efi/api.h (GRUB_EFI_TEXT_ATTR): Do not shift
BG. The spec is wrong again.
* include/grub/normal.h [GRUB_UTIL] (grub_blocklist_init): New
prototype.
[GRUB_UTIL] (grub_blocklist_fini): Likewise.
* conf/i386-pc.rmk (grub_emu_SOURCES): Added
commands/blocklist.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise.
* conf/common.rmk (pkgdata_MODULES): Added blocklist.mod.
(blocklist_mod_SOURCES): New variable.
(blocklist_mod_CFLAGS): Likewise.
(blocklist_mod_LDFLAGS): Likewise.
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
* commands/configfile.c (grub_cmd_source): New function.
(GRUB_MOD_INIT): Register the commands `source' and `.'.
(GRUB_MOD_FINI): De-register the commands `source' and `.'.
* commands/configfile.c (grub_cmd_configfile): Execute the
configfile within its own context.
* include/grub/env.h (grub_env_context_open): New prototype.
(grub_env_context_close): Likewise.
* kern/env.c (grub_env): Removed.
(grub_env_sorted): Likewise.
(grub_env_context): New variable.
(grub_env_var_context): Likewise.
(grub_env_find): Search both the active context and the global
context.
(grub_env_context_open): New function.
(grub_env_context_close): Likewise.
(grub_env_insert): Likewise.
(grub_env_remove): Likewise.
(grub_env_export): Likewise.
(grub_env_set): Changed to use helper functions to avoid code
duplication.
(grub_env_iterate): Rewritten so both the current context and the
global context are being used.
* normal/command.c (export_command): New function.
(grub_command_init): Register the `export' function.
* term/ieee1275/ofconsole.c (grub_ofconsole_cls): Use both the ANSI
escape sequence and a literal ^L to clear the screen.
* commands/ieee1275/suspend.c (grub_cmd_suspend): Clear the screen
when returning from Open Firmware.
From Timothy Baldwin:
* commands/ls.c (grub_ls_list_files): Close FILE with
grub_file_close.
* kern/misc.c (grub_vsprintf): Terminate the string S with NUL.
* partmap/pc.c (pc_partition_map_iterate): Include the value of an
invalid magic in thre error.
* commands/search.c: New file.
* util/grub-emu.c (main): Call grub_search_init and
grub_search_fini.
* kern/rescue.c (grub_rescue_print_disks): Removed.
(grub_rescue_print_devices): New function.
(grub_rescue_cmd_ls): Use grub_device_iterate with
grub_rescue_print_devices instead of grub_disk_dev_iterate with
grub_rescue_print_disks.
* kern/partition.c (grub_partition_iterate): Return the result of
PARTMAP->ITERATE instead of GRUB_ERRNO.
* kern/device.c: Include grub/partition.h.
(grub_device_iterate): New function.
* include/grub/partition.h (grub_partition_iterate): Return int
instead of grub_err_t.
* include/grub/normal.h [GRUB_UTIL] (grub_search_init): New
prototype.
[GRUB_UTIL] (grub_search_fini): Likewise.
* include/grub/device.h (grub_device_iterate): New prototype.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Added
commands/search.c.
(pkgdata_MODULES): Added search.mod.
(search_mod_SOURCES): New variable.
(search_mod_CFLAGS): Likewise.
* conf/i386-pc.rmk (grub_emu_SOURCES): Added commands/search.c.
(pkgdata_MODULES): Added search.mod.
(search_mod_SOURCES): New variable.
(search_mod_CFLAGS): Likewise.
* commands/ls.c (grub_ls_list_disks): Renamed to ...
(grub_ls_list_devices): ... this, and use grub_device_iterate.
All callers changed.
* DISTLIST: Added commands/search.c.
* DISTLIST: Replace commands/i386/pc/vbe_list_modes.c and
commands/i386/pc/vbe_test.c with commands/i386/pc/vbeinfo.c and
commands/i386/pc/vbetest.c.
* video/i386/pc/vbe.c (grub_vbe_probe): If INFOBLOCK is not NULL,
call grub_vbe_get_controller_info again, because the returned
information is volatile.
(grub_vbe_set_video_mode): Mostly rewritten.
(grub_vbe_get_video_mode): Use grub_vbe_probe and use
grub_vbe_status_t correctly.
(grub_vbe_get_video_mode_info): Likewise.
(grub_vbe_set_pixel_rgb): Use a switch statement rather than
several if statements.
* commands/i386/pc/vbe_list_modes.c: Renamed to ...
* commands/i386/pc/vbeinfo.c: ... this.
* commands/i386/pc/vbe_test.c: Renamed to ...
* commands/i386/pc/vbetest.c: ... this.
* commands/i386/pc/vbeinfo.c (grub_cmd_vbe_list_modes): Renamed to
...
(grub_cmd_vbeinfo): ... this. Save video modes before
iterating. Skip a video mode, if it is not available, not enough
information is given or it is monochrome. Show the memory
model. Leave the interpretation of MODEVAR to grub_strtoul
completely.
(GRUB_MOD_INIT): Rename vbe_list_modes to vbeinfo.
(GRUB_MOD_FINI): Likewise.
* commands/i386/pc/vbetest.c (grub_cmd_vbe_test): Renamed to ...
(grub_cmd_vbetest): ... this. Don't print unnecessarily. Use
grub_err_t instead of grub_uint32_t. Don't use SPTR. Remove a
duplicated grub_env_get. Leave the interpretation of MODEVAR to
grub_strtoul completely.
(real2pm): Removed.
(GRUB_MOD_INIT): Rename vbe_test to vbetest.
(GRUB_MOD_FINI): Likewise.
* normal/misc.c: Include grub/mm.h.
* conf/i386-pc.rmk (pkgdata_MODULES): Replaced vbe_test.mod and
vbe_list_modes with vbetest.mod and vbeinfo.mod.
(vbe_list_modes_mod_SOURCES): Removed.
(vbe_list_modes_mod_CFLAGS): Likewise.
(vbe_test_mod_SOURCES): Likewise.
(vbe_test_mod_CFLAGS): Likewise.
(vbeinfo_mod_SOURCES): New variable.
(vbeinfo_mod_CFLAGS): Likewise.
(vbetest_mod_SOURCES): Likewise.
(vbetest_mod_CFLAGS): Likewise.
* normal/misc.c: New file.
* DISTLIST: Added normal/misc.c.
* partmap/amiga.c (amiga_partition_map_iterate): Add an argument
DISK to HOOK. Call HOOK with DISK.
* partmap/apple.c (apple_partition_map_iterate): Likewise.
* partmap/pc.c (pc_partition_map_iterate): Likewise.
* partmap/sun.c (sun_partition_map_iterate): Likewise.
* normal/menu_entry.c (struct screen): Added a new member
"completion_shown".
(completion_buffer): New global variable.
(make_screen): Set SCREEN->COMPLETION_SHOWN to zero.
(store_completion): New function.
(complete): Likewise.
(clear_completions): Likewise.
(grub_menu_entry_run): If SCREEN->COMPLETION_SHOWN is non-zero,
call clear_completions and reset SCREEN->COMPLETION_SHOWN. If C is
a tab, call complete.
* normal/completion.c (disk_dev): Removed.
(print_simple_completion): Likewise.
(print_partition_completion): Likewise.
(print_func): New global variable.
(add_completion): Do not take the arguments WHAT or PRINT any
longer. Added a new argument TYPE. Instead of printing directly,
call PRINT_FUNC if not NULL.
All callers changed.
(complete_device): Use a local variable DEV instead of
DISK_DEV. Do not move CURRENT_WORD to the end of a device name.
(grub_normal_do_completion): Take a new argument HOOK. Do not
initialize DISK_DEV. Initialize PRINT_FUNC to HOOK. If RET is an
empty string, return NULL instead.
All callers changed.
* normal/cmdline.c (print_completion): New function.
* kern/partition.c (grub_partition_iterate): Add an argument DISK
to HOOK.
All callers changed.
* kern/disk.c (grub_print_partinfo): Removed.
* include/grub/partition.h (struct grub_partition_map): Add a new
argument DISK into HOOK of ITERATE.
(grub_partition_iterate): Add a new argument DISK to HOOK.
* include/grub/normal.h (enum grub_completion_type): New enum.
(grub_completion_type_t): New type.
(GRUB_COMPLETION_TYPE_COMMAND): New constant.
(GRUB_COMPLETION_TYPE_DEVICE): Likewise.
(GRUB_COMPLETION_TYPE_PARTITION): Likewise.
(GRUB_COMPLETION_TYPE_FILE): Likewise.
(grub_normal_do_completion): Added a new argument HOOK.
(grub_normal_print_device_info): New prototype.
* include/grub/disk.h (grub_print_partinfo): Removed.
* conf/i386-pc.rmk (grub_emu_SOURCES): Added normal/misc.c.
(normal_mod_SOURCES): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Likewise.
(normal_mod_SOURCES): Likewise.
* commands/ls.c (grub_ls_list_disks): Use
grub_normal_print_device_info instead of grub_print_partinfo. Free
PNAME.
(grub_ls_list_files): Use grub_normal_print_device_info instead of
duplicating the code.
* include/grub/powerpc/ieee1275/ieee1275.h: Move ...
* include/grub/ieee1275/ieee1275.h: ... to here. All users updated.
Move `abort', `grub_reboot', and `grub_halt' prototypes ...
* include/grub/powerpc/ieee1275/kernel.h: ... to here.
* commands/ieee1275/halt.c: Include <grub/machine/kernel.h> instead
of <grub/machine/ieee1275.h>.
* commands/ieee1275/reboot.c: Likewise.
* boot/powerpc/ieee1275/ieee1275.c: Move ...
* kern/ieee1275.c: ... to here. All users updated. Change all
parameter structs to use new type `grub_ieee1275_cell_t'.
* term/powerpc/ieee1275/ofconsole.c: Move ...
* term/ieee1275/ofconsole.c: ... to here. All users updated.
* disk/powerpc/ieee1275/ofdisk.c: Move ...
* disk/ieee1275/ofdisk.c: ... to here. All users updated.
* boot/powerpc/ieee1275/cmain.c: Change `grub_ieee1275_entry_fn' type
to return int.
* include/grub/i386/pc/console.h: Move to include/grub/console.h.
Remove unused prototypes. All users updated.
* include/grub/powerpc/ieee1275/console.h: Removed.
* include/grub/powerpc/ieee1275/ieee1275.h: Define
`grub_ieee1275_cell_t'.
* kern/powerpc/ieee1275/openfw.c: Include <grub/machine/kernel.h>.
Cast comparisons with -1 to the correct type.
* loader/powerpc/ieee1275/linux.c (kernel_entry_t): Change parameter
type to match `grub_ieee1275_entry_fn'.
* loader/i386/pc/multiboot.c (grub_multiboot_is_elf32): New
function.
(grub_multiboot_load_elf32): Likewise.
(grub_multiboot_is_elf64): Likewise.
(grub_multiboot_load_elf64): Likewise.
(grub_multiboot_load_elf): Likewise.
(grub_rescue_cmd_multiboot): Call grub_multiboot_load_elf to load
an ELF32 or ELF64 file.
This is based on a patch from Ruslan Nikolaev <nruslan@mail.com>.
From Serbinenko Vladimir <serbinenko.vova@list.ru>:
* kern/disk.c (grub_print_partinfo): Check if FS->LABEL is not
NULL before calling FS->LABEL.
* fs/fat.c (grub_fat_dir): Initialize DIRNAME to NULL.
* commands/ls.c (grub_ls_list_files): Show labels, if possible.
(grub_ls_list_disks): Check if FS and FS->LABEL are not NULL
before calling FS->LABEL.
Change the semantics of variable hooks. They now return strings
instead of error values.
* util/i386/pc/grub-setup.c: Include grub/env.h.
(setup): Use grub_device_set_root instead of grub_env_set.
* kern/rescue.c (grub_rescue_cmd_root): Use grub_env_set and
grub_env_get instead of grub_device_set_root and
grub_device_get_root, respectively.
* kern/main.c (grub_env_write_root): New function.
(grub_set_root_dev): Register grub_env_write_hook for "root". Use
grub_env_set instead of grub_device_set_root.
* kern/env.c (HASHSZ): Reduced to 13, because GRUB does not need
many variables.
(grub_env_set): Set ENV->VALUE to the result of ENV->WRITE_HOOK
rather than calling ENV->WRITE_HOOK afterwards.
(grub_env_get): Return the result of ENV->READ_HOOK rather than
passing a pointer of a pointer.
(grub_register_variable_hook): Change the types of "read_hook" and
"write_hook" to grub_env_read_hook_t and grub_env_write_hook_t,
respectively.
Allocate the default empty string on the heap, because this string
may be freed later.
* kern/device.c: Include grub/env.h.
(grub_device_set_root): Removed.
(grub_device_get_root): Likewise.
(grub_device_open): Use grub_env_get instead of
grub_device_get_root.
* include/grub/env.h (grub_env_read_hook_t): New type.
(grub_env_write_hook_t): Likewise.
(grub_env_var): Change the types of "read_hook" and "write_hook"
to grub_env_read_hook_t and grub_env_write_hook_t, respectively.
(grub_register_variable_hook): Likewise.
* include/grub/device.h (grub_device_set_root): Removed.
(grub_device_set_root): Likewise.
* fs/fat.c (grub_fat_dir): Make a copy of PATH in DIRNAME, and
make sure that DIRNAME terminates with '/', so that
grub_fat_find_dir will fail if PATH is not a directory.
* commands/ls.c (grub_ls_list_files): Remove the qualifier const
from DIRNAME.
Use the qualifier auto for print_files and print_files_long.
If FS->DIR sets GRUB_ERRNO to GRUB_ERR_BAD_FILE_TYPE, try DIRNAME
as a regular file.
Put a newline only if there is no error.
(grub_cmd_ls): Remove grub_ls_print_files, because this is not
used.
* commands/ls.c (grub_ls_list_disks): Print the filesystem
information on each device, if it does not have partitions. Print
"Device" instead of "Disk", because this function is not specific
to disk devices.
* normal/main.c (grub_rescue_cmd_normal): Make the variable CONFIG
static to ensure that it is put on the memory rather than a
register.
* commands/cat.c (GRUB_MOD_INIT): Use better documentation.
(grub_cat_init): Likewise.
* loader/i386/pc/chainloader_normal.c (GRUB_MOD_INIT): Likewise.
(options): Likewise.
* commands/configfile.c (GRUB_MOD_INIT): Likewise.
(grub_configfile_init): Likewise.
* font/manager.c (GRUB_MOD_INIT): Likewise.
* commands/help.c (GRUB_MOD_INIT): Likewise.
(grub_help_init): Likewise.
* normal/command.c (grub_command_init): Likewise.
* loader/i386/pc/linux_normal.c (GRUB_MOD_INIT): Likewise.
* disk/loopback.c (grub_loop_init): Likewise.
(GRUB_MOD_INIT): Likewise.
* commands/ls.c (grub_ls_init): Likewise.
(GRUB_MOD_INIT): Likewise.
(options): Likewise.
* commands/boot.c (grub_boot_init): Likewise.
(GRUB_MOD_INIT): Likewise.
* loader/i386/pc/multiboot_normal.c (GRUB_MOD_INIT): Likewise.
* commands/i386/pc/reboot.c (grub_reboot_init): Likewise.
(GRUB_MOD_INIT): Likewise.
* commands/cmp.c (grub_cmp_init): Likewise.
(GRUB_MOD_INIT): Likewise.
* normal/arg.c: Use <> instead of "" to include header files.
(SHORT_ARG_HELP): New macro.
(SHORT_ARG_USAGE): Likewise.
(help_options): Specify SHORT_ARG_HELP and SHORT_ARG_USAGE instead
of 'h' and 'u' for help and usage, respectively. Use more GNU-like
descriptions.
(find_short): Check if C is 'h' or 'u' explicitly.
(grub_arg_show_help): Use space characters instead of tabs. Treat
SHORT_ARG_HELP and SHORT_ARG_USAGE exceptionally so that -h and -u
are shown with --help and --usage only if they are not used for
the command itself.
(parse_option): Use SHORT_ARG_HELP and SHORT_ARG_USAGE instead of
'h' and 'u'.
* include/grub/arg.h (struct grub_arg_option): Add the qualifier
const into "longarg". Change the type of "shortarg" to int.
* commands/cmp.c (BUFFER_SIZE): New macro.
(grub_cmd_cmp): Close the right file at the right time. Compare
only data just read. Don't report files of different size as
identical. Dynamically allocate buffers. Move variable
declarations at the beginning of function.
Automatic loading of commands is supported.
* normal/main.c (read_command_list): New function.
(grub_normal_execute): Call read_command_list.
* normal/command.c (grub_register_command): Return zero or CMD.
Allocate CMD->NAME from the heap.
Initialize CMD->MODULE_NAME to zero.
Find the same name as well. If the same command is found and it is
a dummy command, overwrite members. If it is not a dummy command,
return zero.
(grub_unregister_command): Free Q->NAME and Q->MODULE_NAME.
(grub_command_find): If a dummy command is found, load a module
and retry to find a command only once.
* normal/cmdline.c (grub_tab_complete): Call grub_command_find to
make sure that each command is loaded.
* include/grub/normal.h (GRUB_COMMAND_FLAG_NOT_LOADED): New
macro.
(struct grub_command): Remove const from the member `name'.
Add a new member `module_name'.
(grub_register_command): Return grub_command_t.
* commands/help.c (grub_cmd_help): Call grub_command_find to make
sure that each command is loaded.
* genmk.rb (PModule::rule): Specify a module name without the
suffix ".mod" to gencmdlist.sh.
* normal/arg.c (grub_arg_show_help): Do not show the bug report
address.
* commands/help.c (grub_cmd_help): Do not print newlines after
the last command in print_command_help.
* commands/default.h: New file.
* commands/timeout.h: Likewise.
* normal/context.c: Likewise.
* util/misc.c: Do not include sys/times.h.
Include sys/time.h and grub/machine/time.h.
(grub_get_rtc): Rewritten with gettimeofday.
* util/grub-emu.c (main): Call grub_default_init and
grub_timeout_init before grub_normal_init, and call
grub_timeout_fini and grub_default_fini after grub_main.
* util/console.c (grub_ncurses_checkkey): Return the read
character or -1.
* normal/menu.c (run_menu): Set MENU->TIMEOUT to -1 once it
timeouts.
* normal/main.c (read_config_file): Push MENU. If this fails,
print an error and wait for a user input.
Print an error only if GRUB_ERRNO is not GRUB_ERR_NONE.
If a menu is empty or an error occurs, pop MENU.
(grub_normal_execute): Pop and free MENU after grub_menu_run
returns.
* kern/loader.c (grub_loader_boot): Call grub_machine_fini.
* include/grub/powerpc/ieee1275/time.h [GRUB_UTIL]: Do not
include time.h.
[GRUB_UTIL] (GRUB_TICKS_PER_SECOND): Use the same definition as
without GRUB_UTIL.
* include/grub/i386/pc/time.h [GRUB_UTIL]: Do not include
time.h.
[GRUB_UTIL] (GRUB_TICKS_PER_SECOND): Use the same definition as
without GRUB_UTIL.
* include/grub/normal.h (struct grub_menu_list): New struct.
(grub_menu_list_t): New type.
(struct grub_context): New struct.
(grub_context_t): New type.
(grub_register_command): Got rid of EXPORT_FUNC.
(grub_unregister_command): Likewise.
(grub_context_get): New prototype.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
[GRUB_UTIL] (grub_default_init): Likewise.
[GRUB_UTIL] (grub_default_fini): Likewise.
[GRUB_UTIL] (grub_timeout_init): Likewise.
[GRUB_UTIL] (grub_timeout_fini): Likewise.
* conf/i386-pc.rmk (grub_emu_SOURCES): Added commands/default.c,
commands/timeout.c and normal/context.c.
(pkgdata_MODULES): Added default.mod and timeout.mod.
(normal_mod_SOURCES): Added normal/context.c.
(default_mod_SOURCES): New variable.
(default_mod_CFLAGS): Likewise.
(timeout_mod_SOURCES): Likewise.
(timeout_mod_CFLAGS): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Copied from
conf/i386-pc.rmk.
(pkgdata_MODULES): Added default.mod and timeout.mod.
(normal_mod_SOURCES): Added normal/context.c.
(default_mod_SOURCES): New variable.
(default_mod_CFLAGS): Likewise.
(timeout_mod_SOURCES): Likewise.
(timeout_mod_CFLAGS): Likewise.
* Makefile.in (all-local): Added $(MKFILES).
Modulize the partition map support and add support for the amiga
partition map.
* 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: File removed.
* disk/powerpc/ieee1275/partition.c: Likewise.
* include/grub/powerpc/ieee1275/partition.h: Likewise.
* include/grub/i386/pc/partition.h: Likewise.
* kern/partition.c: New file.
* partmap/amiga.c: Likewise.
* partmap/apple.c: Likewise.
* partmap/pc.c: Likewise.
* include/grub/partition.h: Likewise..
* include/grub/pc_partition.h: 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.
* commands/ls.c (grub_ls_list_files): Use the string following the
initial ')', if present, as the filesystem path.
* kern/rescue.c (grub_rescue_cmd_ls): Likewise.
* conf/powerpc-ieee1275.rmk (grubof_SOURCES): List crt0.S first.
* commands/boot.c (grub_boot_init) [GRUB_UTIL]: Make conditional.
(grub_boot_fini) [GRUB_UTIL]: Likewise.
(GRUB_MOD_INIT) [!GRUB_UTIL]: Likewise.
(GRUB_MOD_FINI) [!GRUB_UTIL]: Likewise.
* fs/hfs.c (grub_hfs_find_node): Add a prototype for `node_found'.
(grub_hfs_iterate_dir): Make the function static. Add prototypes
for `node_found' and `it_dir'.
(grub_hfs_dir): Add prototype for `dir_hook'.
* fs/minix.c (grub_minix_get_file_block): Add prototype for
`grub_get_indir'. Rename `indir' in two blocks to `indir16'
and `indir32' to silence a gcc warning.
* include/grub/fs.h (grub_hfs_init): New prototype.
(grub_hfs_fini): Likewise.
All symbols prefixed with PUPA_ and pupa_ are renamed to GRUB_
and grub_, respectively. Because the conversion is trivial and
mechanical, I omit the details here. Please refer to the CVS
if you need more information.
* commands/boot.c: New file.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/ls.c: Likewise.
* commands/terminal.c: Likewise.
* normal/command.c: Include <pupa/env.h> and <pupa/dl.h>.
(pupa_register_command): Changed interface to match the new
argument parser.
(pupa_command_execute): Changed (almost rewritten) so it uses
pupa_split_command. Added support for setting variables using the
syntax `foo=bar'.
(rescue_command): Changed to work with the new argument parser.
(terminal_command): Moved from here to commands/terminal.c.
(set_command): New function.
(unset_command): New function.
(insmod_command): New function.
(rmmod_command): New function.
(lsmod_command): New function.
(pupa_command_init): Don't initialize the command terminal
anymore. Initialize the commands set, unset, insmod, rmmod and
lsmod.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/env.c.
(kernel_img_HEADERS): Add arg.h and env.h.
(pupa_mkimage_LDFLAGS): Add kern/env.c.
(pupa_emu_SOURCES): Add kern/env.c, commands/ls.c,
commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c,
normal/arg.c.
(pkgdata_MODULES): Add ls.mod, boot.mod, cmp.mod, cat.mod and
terminal.mod.
(normal_mod_SOURCES): Add normal/arg.c and normal/arg.c.
(boot_mod_SOURCES): New variable.
(terminal_mod_SOURCES): Likewise.
(ls_mod_SOURCES): Likewise.
(cmp_mod_SOURCES): Likewise.
(cat_mod_SOURCES): Likewise.
* normal/arg.c: New file.
* kern/env.c: Likewise.
* include/pupa/arg.h: Likewise.
* include/pupa/env.h: Likewise.
* font/manager.c (font_command): Changed to match argument parsing
interface changes.
(PUPA_MOD_INIT): Likewise.
* hello/hello.c (pupa_cmd_hello): Likewise.
(PUPA_MOD_INIT): Likewise.
* include/pupa/disk.h: Include <pupa/device.h>.
(pupa_print_partinfo): New prototype.
* include/pupa/dl.h (pupa_dl_set_prefix): Prototype removed.
(pupa_dl_get_prefix): Likewise.
* include/pupa/misc.h: Include <pupa/err.h>.
(pupa_isgraph): New prototype.
(pupa_isdigit): Likewise.
(pupa_split_cmdline): Likewise.
* include/pupa/normal.h: Include <pupa/arg.h>.
(pupa_command): Changed the prototype of the member `func' to
match the argument parsing interface. Added member `options'.
(pupa_register_command): Updated to match function.
(pupa_arg_parse): New prototype.
(pupa_hello_init) [PUPA_UTIL]: New prototype.
(pupa_hello_fini) [PUPA_UTIL]: Likewise.
(pupa_ls_init) [PUPA_UTIL]: Likewise.
(pupa_ls_fini) [PUPA_UTIL]: Likewise.
(pupa_cat_init) [PUPA_UTIL]: Likewise.
(pupa_cat_fini) [PUPA_UTIL]: Likewise.
(pupa_boot_init) [PUPA_UTIL]: Likewise.
(pupa_boot_fini) [PUPA_UTIL]: Likewise.
(pupa_cmp_init) [PUPA_UTIL]: Likewise.
(pupa_cmp_fini) [PUPA_UTIL]: Likewise.
(pupa_terminal_init) [PUPA_UTIL]: Likewise.
(pupa_terminal_fini) [PUPA_UTIL]: Likewise.
* kern/disk.c: Include <pupa/file.h>.
(pupa_print_partinfo): New function.
* kern/dl.c: Include <pupa/env.h>.
(pupa_dl_dir): Variable removed.
(pupa_dl_load): Use the environment variable `prefix' instead of
the variable pupa_dl_dir.
(pupa_dl_set_prefix): Function removed.
(pupa_dl_get_prefix): Likewise.
* kern/i386/pc/init.c: Include <pupa/env.h>.
(pupa_machine_init): Use the environment variable `prefix' instead of
using pupa_dl_set_prefix to set the prefix.
* kern/main.c: Include <pupa/env.h>.
(pupa_set_root_dev): Use the environment variable `prefix' instead of
using pupa_dl_get_prefix to get the prefix.
* kern/misc.c: Include <pupa/env.h>.
(pupa_isdigit): New function.
(pupa_isgraph): Likewise.
(pupa_ftoa): Likewise.
(pupa_vsprintf): Added support for printing values of the type
`double'. Make it possible to format variable output when using
formatting like `%1.2%f'.
(pupa_split_cmdline): New function.
* kern/rescue.c: Include <pupa/env.h>.
(next_word): Removed function.
(pupa_rescue_cmd_prefix): Likewise.
(pupa_rescue_cmd_set): New function.
(pupa_rescue_cmd_unset): New function.
(pupa_enter_rescue_mode): Use the `pupa_split_cmdline' function to
split the command line instead of splitting it here. Added
support for setting variables using the syntax `foo=bar'. Don't
initialize the prefix command anymore. Initialized the set and
unset commands.
* normal/cmdline.c: Include <pupa/env.h>.
(pupa_tab_complete): Added prototypes for print_simple_completion,
print_partition_completion, add_completion, iterate_commands,
iterate_dev, iterate_part and iterate_dir. Moved code to print
partition information from here to kern/disk.c.
(pupa_cmdline_run): Don't check if the funtion exists anymore.
* normal/main.c: Include <pupa/env.h>.
(pupa_rescue_cmd_normal): Use the environment variable `prefix'
instead of using pupa_dl_get_prefix to get the prefix.
* term/i386/pc/vga.c: Include <pupa/arg.h>.
(check_vga_mem): Cast pointers to `void *' to silence a gcc
warning.
(pupa_vga_putchar) [! DEBUG_VGA]: Removed for this case.
(pupa_vga_setcolor): Declare unused variables with `__attribute__
((unused))' to silence a gcc warning.
(pupa_vga_setcolor): Likewise.
(debug_command): Changed to match argument parsing
interface changes.
* util/pupa-emu.c: Include <pupa/env.h>.
(options): Added 0's for unused fields to silence a gcc warning.
(argp): Likewise.
(main): Use the environment variable `prefix' instead of using
pupa_dl_set_prefix to set the prefix. Initialize the commands ls,
boot, cmp, cat and terminal. Finish the commands boot, cmp, cat
and terminal.
* util/i386/pc/getroot.c: Include <pupa/i386/pc/util/biosdisk.h>.
* util/misc.c: Include <malloc.h>.
(pupa_malloc): Rewritten so errors are correctly reported.
(pupa_realloc): Likewise.
(pupa_memalign): Likewise.
(pupa_mm_init_region): Declare unused variables with
`__attribute__ ((unused))' to silence a gcc warning.
* normal/i386/setjmp.S: Remove tab at the end of the file to
silence a gcc warning.
* loader/i386/pc/linux.c (pupa_rescue_cmd_initrd): Declare unused
variables with `__attribute__ ((unused))' to silence a gcc
warning.
* loader/i386/pc/multiboot.c (pupa_multiboot_unload): Make the
local variable i unsigned to silence a gcc warning.
* kern/term.c: Include <pupa/misc.h>.
(pupa_more_lines): New variable.
(pupa_more): Likewise.
(pupa_putcode): When the pager is active pause at the end of every
screen.
(pupa_set_more): New function.
* include/pupa/term.h (pupa_set_more): New prototype.