merge trunk

This commit is contained in:
Colin Watson 2011-03-14 22:01:32 +00:00
commit 7bdeb3987a
83 changed files with 1453 additions and 383 deletions

View file

@ -44,7 +44,6 @@ grub-kbdcomp
grub-macho2img
grub-menulst2cfg
grub-mk*
grub-pbkdf2
grub-pe2elf
grub-probe
grub_probe_init.c

7
BUGS Normal file
View file

@ -0,0 +1,7 @@
GRUB team is aware of following problems:
- Currently search and assembling multidevice abstractions scans
all the devices which can be slow.
- Cache isn't used correctly for video which results in slowness.
While these are bugs their solution has a potential of breaking more and more
seriously. So it was decided for 1.99 that they aren't fixed.

480
ChangeLog
View file

@ -1,3 +1,483 @@
2011-03-11 Colin Watson <cjwatson@ubuntu.com>
* grub-core/boot/i386/pc/lnxboot.S (real_code_2): Ensure that the
initial chunk read from the kernel always includes GRUB's multiboot
header, which is now outside the first sector.
2011-03-09 Colin Watson <cjwatson@ubuntu.com>
* grub-core/loader/i386/linux.c (find_efi_mmap_size): Page-align
cached mmap_size, so that this works correctly when called multiple
times.
Reported by: Daniel Kahn Gillmor. Should fix Debian bug #616638.
2011-03-09 Colin Watson <cjwatson@ubuntu.com>
* docs/grub.texi (Simple configuration): Tidy up formatting.
2011-03-07 Szymon Janc <szymon@janc.net.pl>
* grub-core/fs/zfs/zfs.c (zap_leaf_lookup):
Set-but-not-used variable removed.
2011-02-12 Vladimir Serbinenko <phcoder@gmail.com>
Workaround yet another IEEE1275 bug.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_flag): New enum value
GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS.
* grub-core/kern/ieee1275/mmap.c (grub_machine_mmap_iterate): Ignore
adress_cells and size:cells if GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS
is set.
* grub-core/kern/ieee1275/cmain.c (grub_ieee1275_find_options): Set
GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS on powermacs.
2011-02-12 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/partmap/msdos.c (pc_partition_map_embed): Fix off by one
error.
2011-02-11 Colin Watson <cjwatson@ubuntu.com>
* util/grub.d/20_linux_xen.in: Bail out early if linux_list is
empty, since in that case we can only generate either nothing or a
syntactically invalid configuration file.
Reported by: Michal Suchanek. Fixes Debian bug #612898.
2011-02-09 Colin Watson <cjwatson@ubuntu.com>
* docs/grub.texi (Kernel): Add reference to grub-mkrescue.
(Making a GRUB bootable CD-ROM): Likewise.
(Invoking grub-mkrescue): New section.
Reported by: Yann Dirson. Fixes Debian bug #612585.
2011-02-09 Colin Watson <cjwatson@ubuntu.com>
* util/grub-install.in: Remove unnecessary brackets from tr
arguments.
* util/grub.d/10_hurd.in: Likewise.
* util/grub.d/10_kfreebsd.in: Likewise.
* util/grub.d/10_linux.in: Likewise.
* util/grub.d/20_linux_xen.in: Likewise.
Reported by: Jamie Heilman. Fixes Debian bug #612564.
2011-02-08 Colin Watson <cjwatson@ubuntu.com>
* include/grub/file.h (not_easly_seekable): Rename to ...
(not_easily_seekable): ... this. Update all users.
2011-01-28 Colin Watson <cjwatson@ubuntu.com>
* docs/grub.texi (Making a GRUB bootable CD-ROM): Update to describe
grub-mkrescue.
2011-01-24 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkimage.c (generate_image): Refuse to create the images
bigger than the actual flash (512K) in Loongson machines. 512K is also
the biggest chip supported by them.
2011-01-22 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/emu/getroot.c: Include config-util.h explicitly.
2011-01-22 Anthony DeRobertis <anthony@derobert.net>
* grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Check
super_offset field.
2011-01-22 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-install.in: Ignore install device on platforms
where it doesn't make sense. Always use UUIDs except on pc, efi and
sparc64.
Reported by: Daniel Kahn Gillmor.
2011-01-22 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/bus/bonito.c (write_bases): Fix direction of the shift.
2011-01-22 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/partmap/bsdlabel.c: Include grub/emu/misc.h and not grub/util/misc.h.
(iterate_real): Don't rely on partition being non-NULL.
2011-01-22 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/script/argv.c (round_up_exp): unsigned is 32-bit on all
supported platforms. Put a compile time assert for this rather than
generate a warning with 32-bit shift.
2011-01-22 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/scsi.c (grub_scsi_read): Fix binary and check and make
logical expression more readable.
2011-01-22 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/raid.c (insert_array): Ensure uniqueness of p->number
even if some elements have a name.
Reported by: Alexander GQ Gerasiov.
2011-01-22 Colin Watson <cjwatson@ubuntu.com>
* util/grub-mkconfig_lib.in (is_path_readable_by_grub): Consider a
path unreadable if `grub-probe -t abstraction' fails, for example if
memberlist fails on an LVM volume group.
Reported by: Darius Jahandarie.
2011-01-22 Colin Watson <cjwatson@ubuntu.com>
* docs/grub.texi (Simple configuration): Document
GRUB_PRELOAD_MODULES.
2011-01-17 Colin Watson <cjwatson@ubuntu.com>
* .bzrignore: Remove nonexistent grub-pbkdf2.
2011-01-16 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Bump version to 1.99~rc1.
2011-01-15 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkimage.c (generate_image): Check fwstart.img checksum
for safety.
2011-01-14 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/mips/yeeloong/init.c (grub_machine_init): Init boot
module.
2011-01-14 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/Makefile.core.def (fwstart): Add lost LDFLAGS.
2011-01-13 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/zfs/zfsinfo.c (grub_cmd_zfs_bootfs): Quote bootpath and
diskdevid.
2011-01-13 Vladimir Serbinenko <phcoder@gmail.com>
Fix compilation on cygwin.
* conf/Makefile.common (STRIPFLAGS_KERNEL): Add -F elf32-i386 and
-R .drectve on cygwin.
* conf/i386-pc-cygwin-img-ld.sc: Merge rdata and pdata into data.
* configure.ac: Use $(top_builddir) in TARGET_OBJ2ELF.
(COND_CYGWIN): New condition.
* grub-core/Makefile.am (%.mod): Set TARGET_OBJ2ELF.
* grub-core/genmod.sh.in: Use ${TARGET_OBJ2ELF} and
not @TARGET_OBJ2ELF@.
* util/grub-pe2elf.c (write_symbol_table): Use pe_symtab->type and not
type to determine whether aux is to be used.
2011-01-12 Vladimir Serbinenko <phcoder@gmail.com>
* util/ieee1275/ofpath.c (grub_util_devname_to_ofpath): Use the
realpath'ed device string.
Handle floppy (somewhat).
Issue error in unknown case rather than garbage.
Reported by: Axel Beckert.
2011-01-12 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub.d/00_header.in (load_video): Handle the case when no video
drivers available.
Thanks to: Axel Beckert.
2011-01-12 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkfont.c (write_font_pf2): Use appropriate type for data
variable. Fixes problem on big endian platforms.
2011-01-12 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/Makefile.core.def (ieee1275_fb): Disable on sparc.
It doesn't work well there.
2011-01-12 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/normal/context.c (grub_env_context_close): Silence spurious
warning.
* grub-core/normal/menu.c (grub_menu_execute_entry): Likewise.
* grub-core/partmap/msdos.c (pc_partition_map_embed): Use unsigned
counter.
2011-01-12 Vladimir Serbinenko <phcoder@gmail.com>
Use alias->path rather than buggy "canon".
* grub-core/disk/ieee1275/ofdisk.c (ofdisk_hash_add_real): New function.
(ofdisk_hash_add): New argument curcan. All users updated.
2011-01-11 Colin Watson <cjwatson@ubuntu.com>
* configure.ac: Fall back to `true' if `makeinfo' does not exist.
2011-01-11 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/powerpc/ieee1275/linux.c (grub_linux_load32): Apply
loadmask before doing any calculations. Use correct type for offset.
(grub_linux_load64): Likewise.
2011-01-11 Colin Watson <cjwatson@ubuntu.com>
* util/grub-mklayout.c (console_grub_equivalences_shift): Terminate
with NULL.
(console_grub_equivalences_unshift): Likewise.
Reported by: Daniel Dehennin.
2011-01-11 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/i386/pc/pxe.c (set_mac_env): Export variable.
(set_env_limn_ro): Likewise.
(GRUB_MOD_INIT): Likewise.
* grub-core/hook/datehook.c (GRUB_MOD_INIT): Likewise. Change to
ARRAY_SIZE while on it.
(GRUB_MOD_FINI): Change to ARRAY_SIZE.
* grub-core/normal/context.c (grub_env_export): Move from here ...
* grub-core/kern/env.c (grub_env_export): ... here.
* grub-core/normal/context.c (grub_cmd_export): Skip exporting root and
prefix.
* grub-core/kern/main.c (grub_main): Export root and prefix.
* include/grub/env.h (grub_env_export): Export.
Reported by: Seth Goldberg.
2011-01-11 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi):
Take into account space used by ELF sections and multiboot palette.
Reported by: Grégoire Sutre.
2011-01-11 Vladimir Serbinenko <phcoder@gmail.com>
* BUGS: New file.
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
Pass more appropriate video id to Linux.
* grub-core/loader/i386/linux.c (grub_linux_setup_video): Use
grub_video_get_driver_id and variable gfxpayloadforcelfb to
fill have_vga.
(grub_linux_boot): Rely on grub_linux_setup_video to fill have_vga and
shift params->lfb_size.
* include/grub/i386/linux.h: Make an enume out of have_vga values.
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-menulst2cfg.c: Add missing include of misc.h.
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/zfs/zfsinfo.c (grub_cmd_zfs_bootfs): Use comma as
separator and pass bootpath/devid even if only one of them is available.
Reported by: Seth Goldberg.
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
Don't use post-4G memory on EFI even if 64-bit since some non-compliant
implementations bug on them.
* grub-core/kern/efi/mm.c (grub_efi_allocate_pages): Skip post-4G
memory.
(filter_memory_map): Likewise.
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-kbdcomp.in: Add missing prefix and exec_prefix variables.
Reported by: nebuchadnezzar.
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-kbdcomp.in: Add missing transform and bindir variables.
Reported by: nebuchadnezzar.
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
Submenu default support.
* grub-core/normal/menu.c (grub_menu_execute_entry): New parameter
auto_boot. All users updated.
Declared static.
Handle chosen and default with submenus.
(grub_menu_execute_with_fallback): Declared static.
Don't notify failure if autobooted. Upper level does it.
(menuentry_eq): New function.
(get_entry_number): Use menuentry_eq.
(show_menu): New parameter "autobooted". All users updated.
(grub_show_menu): Likewise.
* include/grub/normal.h (grub_show_menu): Likewise.
* include/grub/menu.h (grub_menu_execute_entry): Removed.
(grub_menu_execute_with_fallback): Likewise.
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mklayout.c (usage): Update help text.
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/legacycfg.c (legacy_file): Trim the line.
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-menulst2cfg.c (main): Trim the line.
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/i386/pc/init.c (grub_get_conv_memsize): Removed.
(grub_machine_init): Don't check amount of low memory as reportedly
INT 12h can be broken and if low memory is too low we wouldn't have
gotten into grub_machine_init anyway.
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/i386/pc/mmap.c (grub_get_conv_memsize): New function.
(grub_machine_mmap_iterate): Take low memory into account
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/btrfs.c (grub_btrfs_mount): Transform out of range into
badfs.
Reported by: TiCPU.
2011-01-10 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/raid.c (insert_array): Display RAID name in duplicate
members errors.
2011-01-09 Grégoire Sutre <gregoire.sutre@gmail.com>
* util/grub.d/10_netbsd.in (netbsd_load_fs_module): New function.
(netbsd_entry): Use netbsd_load_fs_module() to load filesystem module.
2011-01-09 Grégoire Sutre <gregoire.sutre@gmail.com>
* util/grub-mkconfig_lib.in (prepare_grub_to_access_device): Handle
openbsd and netbsd types being in part_bsd module.
2011-01-08 Vladimir Serbinenko <phcoder@gmail.com>
* config.h.in (_LARGEFILE_SOURCE): Add missing define.
(_FILE_OFFSET_BITS): Likewise.
Reported by: Seth Goldberg.
2011-01-08 Grégoire Sutre <gregoire.sutre@gmail.com>
* configure.ac: Check for libdevmapper header.
2011-01-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/zfs/zfs.c (dmu_read): Use void * for some pointers to
avoid aliasing.
(fzap_lookup): Likewise.
(dnode_get): Likewise.
(make_mdn): Likewise.
(zfs_mount): Likewise.
(fzap_iterate): Use temporary pointer to avoid aliasing.
(grub_zfs_read): Likewise.
* grub-core/loader/i386/xnu.c (grub_xnu_boot): Likewise.
* grub-core/loader/xnu.c (grub_cmd_xnu_kernel): Use void * for some
pointers to avoid aliasing.
(grub_cmd_xnu_kernel64): Likewise.
(grub_xnu_load_driver): Likewise.
2011-01-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/terminal.c (grub_cmd_terminal_input): Silence
aliasing warning.
(grub_cmd_terminal_output): Likewise.
Reported and tested by: Grégoire Sutre.
2011-01-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/term/at_keyboard.c (grub_keyboard_getkey): Silence spurious
warning.
Reported and tested by: Grégoire Sutre.
2011-01-08 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Do CPU substitution even if it's specified explicitly.
Reported and tested by: Alain Greppin.
2011-01-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/Makefile.am (rs_decoder.S): Force compilation with -Os.
Reported and tested by: Alain Greppin.
2011-01-08 Vladimir Serbinenko <phcoder@gmail.com>
Satisfy some bison versions need for inttypes.h.
* grub-core/lib/posix_wrap/inttypes.h: New file.
* grub-core/lib/posix_wrap/sys/types.h (int8_t): New type.
(int16_t): Likewise.
(int32_t): Likewise.
(int64_t): Likewise.
Reported and tested by: Alain Greppin.
2011-01-08 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/i386/bsdXX.c (grub_netbsd_load_elf_meta):
Silence spurious warning.
Reported and tested by: Alain Greppin.
2011-01-07 Szymon Janc <szymon@janc.net.pl>
* docs/grub.texi (Support automatic decompression): Update with xz
decompression support.
2011-01-07 Szymon Janc <szymon@janc.net.pl>
Improve loaders' kernel command line handling.
* grub-core/lib/cmdline.c: New file.
* include/grub/lib/cmdline.h: Likewise.
* grub-core/loader/i386/linux.c (grub_cmd_linux): Use
grub_create_loader_cmdline to create kernel command line.
* grub-core/loader/i386/pc/linux.c (grub_cmd_linux): Likewise.
* grub-core/loader/powerpc/ieee1275/linux.c (grub_cmd_linux): Likewise.
* grub-core/loader/sparc64/ieee1275/linux.c (grub_cmd_linux): Likewise.
* grub-core/Makefile.core.def (linux16): Add lib/cmdline.c on i386_pc.
(linux): Add lib/cmdline.c on common.
2011-01-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/xfs.c (grub_xfs_iterate_dir): Take into account that
inopos might be unaligned.
2011-01-07 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Add missing
endian transformations.
* grub-core/disk/mdraid_linux.c (grub_mdraid_detect): Likewise.
Based on report by: Doug Nazar.
2011-01-07 Doug Nazar <nazard.michi@gmail.com>
* grub-core/disk/raid5_recover.c (grub_raid5_recover): Add missing
array->members[i].start_sector.
* grub-core/disk/raid6_recover.c (grub_raid6_recover): Likewise.
2011-01-07 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-setup.c (setup): Handle NetBSD and OpenBSD disklabels.
Reported and tested by: Grégoire Sutre.
2011-01-06 Colin Watson <cjwatson@ubuntu.com>
* tests/util/grub-shell.in: Set serial terminfo type to `dumb', to
avoid causing test failures by clearing the screen.
2011-01-06 Colin Watson <cjwatson@ubuntu.com>
* grub-core/kern/emu/getroot.c (find_root_device_from_mountinfo):
Fix prefix check to handle the case where dir ends with a slash
(most significantly, "/" itself).
Reported by: Michael Vogt.
2011-01-05 Vladimir Serbinenko <phcoder@gmail.com>
Run terminfo_cls on initing terminfo output to clear the screen and

View file

@ -67,7 +67,11 @@ CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib -Wl,-N -static-libgcc
CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
if COND_CYGWIN
STRIPFLAGS_KERNEL = -F elf32-i386 -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve
else
STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment
endif
CFLAGS_MODULE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_MODULE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib -Wl,-N,-r,-d

View file

@ -13,15 +13,9 @@ SECTIONS
__data_start__ = . ;
*(.data)
__data_end__ = . ;
}
.rdata :
{
__rdata_start__ = . ;
*(.rdata)
__rdata_end__ = . ;
}
.pdata :
{
*(.pdata)
edata = . ;
}

View file

@ -1,3 +1,7 @@
#undef _LARGEFILE_SOURCE
#undef _FILE_OFFSET_BITS
#define _LARGEFILE_SOURCE
#define _FILE_OFFSET_BITS 64
#if defined (GRUB_UTIL) || !defined (GRUB_MACHINE)
#include <config-util.h>
#define NESTED_FUNC_ATTR

View file

@ -32,7 +32,7 @@ dnl type, so there is no conflict. Variables with the prefix "TARGET_"
dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
dnl type.
AC_INIT([GRUB],[1.99~beta0],[bug-grub@gnu.org])
AC_INIT([GRUB],[1.99~rc1],[bug-grub@gnu.org])
AC_CONFIG_AUX_DIR([build-aux])
@ -103,15 +103,12 @@ else
platform="$with_platform"
fi
# Adjust CPU unless target was explicitly specified.
if test -z "$target_alias"; then
case "$target_cpu"-"$platform" in
x86_64-efi) ;;
x86_64-emu) ;;
x86_64-*) target_cpu=i386 ;;
powerpc64-ieee1275) target_cpu=powerpc ;;
esac
fi
case "$target_cpu"-"$platform" in
x86_64-efi) ;;
x86_64-emu) ;;
x86_64-*) target_cpu=i386 ;;
powerpc64-ieee1275) target_cpu=powerpc ;;
esac
# Check if the platform is supported, make final adjustments.
case "$target_cpu"-"$platform" in
@ -249,7 +246,7 @@ else
fi
# These are not a "must".
AC_PATH_PROG(MAKEINFO, makeinfo)
AC_PATH_PROGS(MAKEINFO, makeinfo true)
#
# Checks for host programs.
@ -457,7 +454,7 @@ fi
# For platforms where ELF is not the default link format.
AC_MSG_CHECKING([for command to convert module to ELF format])
case "${host_os}" in
cygwin) TARGET_OBJ2ELF='$(grub_utildir)/grub-pe2elf';
cygwin) TARGET_OBJ2ELF='$(top_builddir)/grub-pe2elf';
# FIXME: put proper test here
NEED_REGISTER_FRAME_INFO=1
;;
@ -866,6 +863,12 @@ if test x"$enable_device_mapper" = xno ; then
device_mapper_excuse="explicitly disabled"
fi
if test x"$device_mapper_excuse" = x ; then
# Check for device-mapper header.
AC_CHECK_HEADER([libdevmapper.h], [],
[device_mapper_excuse="need libdevmapper header"])
fi
if test x"$device_mapper_excuse" = x ; then
# Check for device-mapper library.
AC_CHECK_LIB([devmapper], [dm_task_create], [],
@ -961,6 +964,7 @@ AM_CONDITIONAL([COND_APPLE_CC], [test x$TARGET_APPLE_CC = x1])
AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
AM_CONDITIONAL([COND_HAVE_ASM_USCORE], [test x$HAVE_ASM_USCORE = x1])
AM_CONDITIONAL([COND_CYGWIN], [test x$host_os = xcygwin])
# Output files.
grub_CHECK_LINK_DIR

View file

@ -36,6 +36,7 @@ Invariant Sections.
* grub-install: (grub)Invoking grub-install. Install GRUB on your drive
* grub-mkconfig: (grub)Invoking grub-mkconfig. Generate GRUB configuration
* grub-mkpasswd-pbkdf2: (grub)Invoking grub-mkpasswd-pbkdf2.
* grub-mkrescue: (grub)Invoking grub-mkrescue. Make a GRUB rescue image
@end direntry
@setchapternewpage odd
@ -94,6 +95,7 @@ This edition documents version @value{VERSION}.
* Invoking grub-mkconfig:: Generate a GRUB configuration file
* Invoking grub-mkpasswd-pbkdf2::
Generate GRUB password hashes
* Invoking grub-mkrescue:: Make a GRUB rescue image
* Obtaining and Building GRUB:: How to obtain and build GRUB
* Reporting bugs:: Where you should send a bug report
* Future:: Some future plans on GRUB
@ -346,9 +348,11 @@ ext2/ext3/ext4}, @dfn{DOS FAT12/FAT16/FAT32}, @dfn{HFS}, @dfn{HFS+},
@dfn{BSD UFS/UFS2}, and @dfn{XFS}. @xref{Filesystem}, for more information.
@item Support automatic decompression
Can decompress files which were compressed by @command{gzip}. This
function is both automatic and transparent to the user (i.e. all
functions operate upon the uncompressed contents of the specified
Can decompress files which were compressed by @command{gzip} or
@command{xz}@footnote{Only CRC32 data integrity check is supported (xz default
is CRC64 so one should use --check=crc32 option). LZMA BCJ filters are
supported.}. This function is both automatic and transparent to the user
(i.e. all functions operate upon the uncompressed contents of the specified
files). This greatly reduces a file size and loading time, a
particularly great benefit for floppies.@footnote{There are a few
pathological cases where loading a very badly organized ELF kernel might
@ -649,15 +653,22 @@ using BIOS functions.}. This means that you can use the whole CD-ROM
from GRUB and you don't have to make a floppy or hard disk image file,
which can cause compatibility problems.
For booting from a CD-ROM, GRUB uses a special Stage 2 called
@file{stage2_eltorito}. The only GRUB files you need to have in your
bootable CD-ROM are this @file{stage2_eltorito} and optionally a config file
@file{grub.cfg}. You don't need to use @file{stage1} or @file{stage2},
because El Torito is quite different from the standard boot process.
For booting from a CD-ROM, GRUB uses a special image called
@file{cdboot.img}, which is concatenated with @file{core.img}. The
@file{core.img} used for this should be built with at least the
@samp{iso9660} and @samp{biosdisk} modules. Your bootable CD-ROM will
usually also need to include a configuration file @file{grub.cfg} and some
other GRUB modules.
Here is an example of procedures to make a bootable CD-ROM
image. First, make a top directory for the bootable image, say,
@samp{iso}:
To make a simple generic GRUB rescue CD, you can use the
@command{grub-mkrescue} program (@pxref{Invoking grub-mkrescue}):
@example
$ @kbd{grub-mkrescue -o grub.iso}
@end example
You will often need to include other files in your image. To do this, first
make a top directory for the bootable image, say, @samp{iso}:
@example
$ @kbd{mkdir iso}
@ -669,33 +680,24 @@ Make a directory for GRUB:
$ @kbd{mkdir -p iso/boot/grub}
@end example
Copy the file @file{stage2_eltorito}:
@example
$ @kbd{cp /usr/lib/grub/i386-pc/stage2_eltorito iso/boot/grub}
@end example
If desired, make the config file @file{grub.cfg} under @file{iso/boot/grub}
(@pxref{Configuration}), and copy any files and directories for the disc to the
directory @file{iso/}.
Finally, make a ISO9660 image file like this:
Finally, make the image:
@example
$ @kbd{mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \
-boot-load-size 4 -boot-info-table -o grub.iso iso}
$ @kbd{grub-mkrescue -o grub.iso iso}
@end example
This produces a file named @file{grub.iso}, which then can be burned
into a CD (or a DVD). @kbd{mkisofs} has already set up the disc to boot
from the @kbd{boot/grub/stage2_eltorito} file, so there is no need to
setup GRUB on the disc. (Note that the @kbd{-boot-load-size 4} bit is
required for compatibility with the BIOS on many older machines.)
into a CD (or a DVD), or written to a USB mass storage device.
You can use the device @samp{(cd)} to access a CD-ROM in your
config file. This is not required; GRUB automatically sets the root device
to @samp{(cd)} when booted from a CD-ROM. It is only necessary to refer to
@samp{(cd)} if you want to access other drives as well.
The root device will be set up appropriately on entering your
@file{grub.cfg} configuration file, so you can refer to file names on the CD
without needing to use an explicit device name. This makes it easier to
produce rescue images that will work on both optical drives and USB mass
storage devices.
@node Device map
@ -1034,8 +1036,8 @@ it as a new default entry for use by future runs of GRUB. This is only
useful if @samp{GRUB_DEFAULT=saved}; it is a separate option because
@samp{GRUB_DEFAULT=saved} is useful without this option, in conjunction with
@command{grub-set-default} or @command{grub-reboot}. Unset by default.
The remarks of @pxref{Changes from GRUB Legacy} on the availability
of @samp{save_env} apply.
@samp{save_env} may not be available in all situations
(@pxref{Changes from GRUB Legacy}).
@item GRUB_TIMEOUT
Boot the default entry this many seconds after the menu is displayed, unless
@ -1179,6 +1181,11 @@ directly to @ref{play}.
If this option is set, GRUB will issue a @ref{badram} command to filter
out specified regions of RAM.
@item GRUB_PRELOAD_MODULES
This option may be set to a list of GRUB module names separated by spaces.
Each module will be loaded as early as possible, at the start of
@file{grub.cfg}.
@end table
For more detailed customisation of @command{grub-mkconfig}'s output, you may
@ -3604,6 +3611,64 @@ Length of the salt. Defaults to 64.
@end table
@node Invoking grub-mkrescue
@chapter Invoking grub-mkrescue
The program @command{grub-mkrescue} generates a bootable GRUB rescue image
(@pxref{Making a GRUB bootable CD-ROM}).
@example
grub-mkrescue -o grub.iso
@end example
All arguments not explicitly listed as @command{grub-mkrescue} options are
passed on directly to @command{xorriso} in @command{mkisofs} emulation mode.
Options passed to @command{xorriso} will normally be interpreted as
@command{mkisofs} options; if the option @samp{--} is used, then anything
after that will be interpreted as native @command{xorriso} options.
Non-option arguments specify additional source directories. This is
commonly used to add extra files to the image:
@example
mkdir -p disk/boot/grub
@r{(add extra files to @file{disk/boot/grub})}
grub-mkrescue -o grub.iso disk
@end example
@command{grub-mkrescue} accepts the following options:
@table @option
@item --help
Print a summary of the command-line options and exit.
@item --version
Print the version number of GRUB and exit.
@item -o @var{file}
@itemx --output=@var{file}
Save output in @var{file}. This "option" is required.
@item --modules=@var{modules}
Pre-load the named GRUB modules in the image. Multiple entries in
@var{modules} should be separated by whitespace (so you will probably need
to quote this for your shell).
@item --rom-directory=@var{dir}
If generating images for the QEMU or Coreboot platforms, copy the resulting
@file{qemu.img} or @file{coreboot.elf} files respectively to the @var{dir}
directory as well as including them in the image.
@item --xorriso=@var{file}
Use @var{file} as the @command{xorriso} program, rather than the built-in
default.
@item --grub-mkimage=@var{file}
Use @var{file} as the @command{grub-mkimage} program, rather than the
built-in default.
@end table
@node Obtaining and Building GRUB
@appendix How to obtain and build GRUB

View file

@ -50,7 +50,7 @@ grub_script.yy.h: script/yylex.l
grub_script.yy.c: grub_script.yy.h
rs_decoder.S: $(srcdir)/lib/reed_solomon.c
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I$(top_builddir) -S -DSTANDALONE -o $@ $< -g0 -mregparm=3
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Os -I$(top_builddir) -S -DSTANDALONE -o $@ $< -g0 -mregparm=3
kern/i386/pc/startup.S: $(builddir)/rs_decoder.S
@ -303,7 +303,7 @@ platform_DATA += moddep.lst
CLEANFILES += config.log syminfo.lst moddep.lst
$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT)
sh $^ $@
TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@
platform_DATA += $(MOD_FILES)
CLEANFILES += $(MOD_FILES)

View file

@ -324,6 +324,7 @@ image = {
name = fwstart;
mips_yeeloong = boot/mips/yeeloong/fwstart.S;
objcopyflags = '-O binary';
ldflags = '-static-libgcc -lgcc -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
enable = mips_yeeloong;
};
@ -1149,6 +1150,7 @@ module = {
module = {
name = linux16;
i386_pc = loader/i386/pc/linux.c;
i386_pc = lib/cmdline.c;
enable = i386_pc;
};
@ -1183,6 +1185,7 @@ module = {
mips = loader/mips/linux.c;
powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c;
sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c;
common = lib/cmdline.c;
enable = noemu;
};
@ -1461,7 +1464,6 @@ module = {
name = ieee1275_fb;
ieee1275 = video/ieee1275.c;
enable = powerpc;
enable = sparc64;
};
module = {

View file

@ -178,8 +178,13 @@ real_code_2:
pushw %es
popw %ds
#if GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART + 4 < 0x200
movl $0x200, %ecx
addl %ecx, %esi
#else
movl $(GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART + 4), %ecx
addl $0x200, %esi
#endif
movl $DATA_ADDR, %edi
call LOCAL(move_memory)
@ -196,7 +201,11 @@ real_code_2:
1:
movl %ss:(DATA_ADDR + GRUB_KERNEL_MACHINE_COMPRESSED_SIZE), %ecx
#if GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART + 4 < 0x200
addl $(GRUB_KERNEL_MACHINE_RAW_SIZE - 0x200), %ecx
#else
addl $(GRUB_KERNEL_MACHINE_RAW_SIZE - (GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART + 4)), %ecx
#endif
2:
call LOCAL(move_memory)

View file

@ -38,7 +38,7 @@ write_bases (void)
for (i = 0; i < GRUB_MACHINE_PCI_NUM_WIN; i++)
reg |= (((base_win[i] >> GRUB_MACHINE_PCI_WIN_SHIFT)
& GRUB_MACHINE_PCI_WIN_MASK)
>> (i * GRUB_MACHINE_PCI_WIN_MASK_SIZE));
<< (i * GRUB_MACHINE_PCI_WIN_MASK_SIZE));
GRUB_MACHINE_PCI_IO_CTRL_REG = reg;
}

View file

@ -83,9 +83,13 @@ legacy_file (const char *filename)
{
char *oldname = NULL;
char *newsuffix;
char *ptr;
for (ptr = buf; *ptr && grub_isspace (*ptr); ptr++);
oldname = entryname;
parsed = grub_legacy_parse (buf, &entryname, &newsuffix);
parsed = grub_legacy_parse (ptr, &entryname, &newsuffix);
grub_free (buf);
buf = NULL;
if (newsuffix)
{
@ -209,7 +213,7 @@ grub_cmd_legacy_source (struct grub_command *cmd,
grub_menu_t menu;
menu = grub_env_get_menu ();
if (menu && menu->size)
grub_show_menu (menu, 1);
grub_show_menu (menu, 1, 0);
if (!extractor)
grub_env_context_close ();
}

View file

@ -210,11 +210,11 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, init);
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, fini);
return handle_command (argc, args,
(struct abstract_terminal **) &grub_term_inputs,
(struct abstract_terminal **) &grub_term_inputs_disabled,
grub_term_input_autoload,
N_ ("Active input terminals:"),
N_ ("Available input terminals:"));
(struct abstract_terminal **) (void *) &grub_term_inputs,
(struct abstract_terminal **) (void *) &grub_term_inputs_disabled,
grub_term_input_autoload,
N_ ("Active input terminals:"),
N_ ("Available input terminals:"));
}
static grub_err_t
@ -225,11 +225,12 @@ grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)),
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, name);
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, init);
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, fini);
return handle_command (argc, args, (struct abstract_terminal **) &grub_term_outputs,
(struct abstract_terminal **) &grub_term_outputs_disabled,
grub_term_output_autoload,
N_ ("Active output terminals:"),
N_ ("Available output terminals:"));
return handle_command (argc, args,
(struct abstract_terminal **) (void *) &grub_term_outputs,
(struct abstract_terminal **) (void *) &grub_term_outputs_disabled,
grub_term_output_autoload,
N_ ("Active output terminals:"),
N_ ("Available output terminals:"));
}
static grub_command_t cmd_terminal_input, cmd_terminal_output;

View file

@ -62,11 +62,10 @@ ofdisk_hash_find (const char *devpath)
}
static struct ofdisk_hash_ent *
ofdisk_hash_add (char *devpath)
ofdisk_hash_add_real (char *devpath)
{
struct ofdisk_hash_ent *p;
struct ofdisk_hash_ent **head = &ofdisk_hash[ofdisk_hash_fn(devpath)];
struct ofdisk_hash_ent *p, *pcan;
char *curcan;
p = grub_malloc(sizeof (*p));
if (!p)
@ -76,17 +75,27 @@ ofdisk_hash_add (char *devpath)
p->next = *head;
p->shortest = 0;
*head = p;
return p;
}
static struct ofdisk_hash_ent *
ofdisk_hash_add (char *devpath, char *curcan)
{
struct ofdisk_hash_ent *p, *pcan;
p = ofdisk_hash_add_real (devpath);
grub_dprintf ("disk", "devpath = %s, canonical = %s\n", devpath, curcan);
curcan = grub_ieee1275_canonicalise_devname (devpath);
if (!curcan)
{
grub_errno = GRUB_ERR_NONE;
p->shortest = devpath;
return p;
}
pcan = ofdisk_hash_find (curcan);
if (!pcan)
pcan = ofdisk_hash_add (curcan);
pcan = ofdisk_hash_add_real (curcan);
else
grub_free (curcan);
@ -118,17 +127,22 @@ scan (void)
return 0;
grub_dprintf ("disk", "disk name = %s\n", alias->name);
grub_dprintf ("disk", "disk name = %s, path = %s\n", alias->name,
alias->path);
op = ofdisk_hash_find (alias->path);
op = ofdisk_hash_find (alias->name);
if (!op)
{
char *name = grub_strdup (alias->name);
if (!name)
char *can = grub_strdup (alias->path);
if (!name || !can)
{
grub_errno = GRUB_ERR_NONE;
grub_free (name);
grub_free (can);
return 0;
}
op = ofdisk_hash_add (name);
op = ofdisk_hash_add (name, can);
}
return 0;
}
@ -247,7 +261,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
struct ofdisk_hash_ent *op;
op = ofdisk_hash_find (devpath);
if (!op)
op = ofdisk_hash_add (devpath);
op = ofdisk_hash_add (devpath, NULL);
else
grub_free (devpath);
if (!op)

View file

@ -143,24 +143,28 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array,
&sb))
return grub_errno;
if (sb.magic != SB_MAGIC)
if (grub_le_to_cpu32 (sb.magic) != SB_MAGIC
|| grub_le_to_cpu64 (sb.super_offset) != sector)
continue;
{
grub_uint64_t sb_size;
struct grub_raid_super_1x *real_sb;
grub_uint32_t level;
if (sb.major_version != 1)
if (grub_le_to_cpu32 (sb.major_version) != 1)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Unsupported RAID version: %d",
sb.major_version);
grub_le_to_cpu32 (sb.major_version));
level = grub_le_to_cpu32 (sb.level);
/* Multipath. */
if ((int) sb.level == -4)
sb.level = 1;
if ((int) level == -4)
level = 1;
if (sb.level != 0 && sb.level != 1 && sb.level != 4 &&
sb.level != 5 && sb.level != 6 && sb.level != 10)
if (level != 0 && level != 1 && level != 4 &&
level != 5 && level != 6 && level != 10)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Unsupported RAID level: %d", sb.level);
@ -209,7 +213,7 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array,
grub_memcpy (array->uuid, real_sb->set_uuid, 16);
*start_sector = real_sb->data_offset;
*start_sector = grub_le_to_cpu64 (real_sb->data_offset);
grub_free (real_sb);
return 0;

View file

@ -167,6 +167,7 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array,
grub_uint64_t size;
struct grub_raid_super_09 sb;
grub_uint32_t *uuid;
grub_uint32_t level;
/* The sector where the mdraid 0.90 superblock is stored, if available. */
size = grub_disk_get_size (disk);
@ -178,36 +179,40 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array,
return grub_errno;
/* Look whether there is a mdraid 0.90 superblock. */
if (sb.md_magic != SB_MAGIC)
if (grub_le_to_cpu32 (sb.md_magic) != SB_MAGIC)
return grub_error (GRUB_ERR_OUT_OF_RANGE, "not 0.9x raid");
if (sb.major_version != 0 || sb.minor_version != 90)
if (grub_le_to_cpu32 (sb.major_version) != 0
|| grub_le_to_cpu32 (sb.minor_version) != 90)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"unsupported RAID version: %d.%d",
sb.major_version, sb.minor_version);
grub_le_to_cpu32 (sb.major_version),
grub_le_to_cpu32 (sb.minor_version));
/* FIXME: Check the checksum. */
level = grub_le_to_cpu32 (sb.level);
/* Multipath. */
if ((int) sb.level == -4)
sb.level = 1;
if ((int) level == -4)
level = 1;
if (sb.level != 0 && sb.level != 1 && sb.level != 4 &&
sb.level != 5 && sb.level != 6 && sb.level != 10)
if (level != 0 && level != 1 && level != 4 &&
level != 5 && level != 6 && level != 10)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"unsupported RAID level: %d", sb.level);
if (sb.this_disk.number == 0xffff || sb.this_disk.number == 0xfffe)
"unsupported RAID level: %d", level);
if (grub_le_to_cpu32 (sb.this_disk.number) == 0xffff
|| grub_le_to_cpu32 (sb.this_disk.number) == 0xfffe)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"spares aren't implemented");
array->name = NULL;
array->number = sb.md_minor;
array->level = sb.level;
array->layout = sb.layout;
array->total_devs = sb.raid_disks;
array->disk_size = (sb.size) ? sb.size * 2 : sector;
array->chunk_size = sb.chunk_size >> 9;
array->index = sb.this_disk.number;
array->number = grub_le_to_cpu32 (sb.md_minor);
array->level = level;
array->layout = grub_le_to_cpu32 (sb.layout);
array->total_devs = grub_le_to_cpu32 (sb.raid_disks);
array->disk_size = (sb.size) ? grub_le_to_cpu32 (sb.size) * 2 : sector;
array->chunk_size = grub_le_to_cpu32 (sb.chunk_size) >> 9;
array->index = grub_le_to_cpu32 (sb.this_disk.number);
array->uuid_len = 16;
array->uuid = grub_malloc (16);
if (!array->uuid)

View file

@ -530,8 +530,8 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array,
/* We found multiple devices with the same number. Again,
this shouldn't happen. */
return grub_error (GRUB_ERR_BAD_DEVICE,
"found two disks with the number %d",
new_array->number);
"found two disks with the index %d for RAID %s",
new_array->index, array->name);
if (new_array->disk_size < array->disk_size)
array->disk_size = new_array->disk_size;
@ -570,7 +570,7 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array,
{
for (p = array_list; p != NULL; p = p->next)
{
if (! p->name && p->number == array->number)
if (p->number == array->number)
break;
}
}

View file

@ -45,7 +45,9 @@ grub_raid5_recover (struct grub_raid_array *array, int disknr,
if (i == disknr)
continue;
err = grub_disk_read (array->members[i].device, sector, 0, size, buf2);
err = grub_disk_read (array->members[i].device,
array->members[i].start_sector + sector,
0, size, buf2);
if (err)
{

View file

@ -119,7 +119,8 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p,
else
{
if ((array->members[pos].device) &&
(! grub_disk_read (array->members[pos].device, sector,
(! grub_disk_read (array->members[pos].device,
array->members[i].start_sector + sector,
0, size, buf)))
{
grub_raid_block_xor (pbuf, buf, size);
@ -150,7 +151,9 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p,
{
/* One bad device */
if ((array->members[p].device) &&
(! grub_disk_read (array->members[p].device, sector, 0, size, buf)))
(! grub_disk_read (array->members[p].device,
array->members[i].start_sector + sector,
0, size, buf)))
{
grub_raid_block_xor (buf, pbuf, size);
goto quit;
@ -163,7 +166,8 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p,
}
grub_errno = GRUB_ERR_NONE;
if (grub_disk_read (array->members[q].device, sector, 0, size, buf))
if (grub_disk_read (array->members[q].device,
array->members[i].start_sector + sector, 0, size, buf))
goto quit;
grub_raid_block_xor (buf, qbuf, size);
@ -181,12 +185,16 @@ grub_raid6_recover (struct grub_raid_array *array, int disknr, int p,
goto quit;
}
if (grub_disk_read (array->members[p].device, sector, 0, size, buf))
if (grub_disk_read (array->members[p].device,
array->members[i].start_sector + sector,
0, size, buf))
goto quit;
grub_raid_block_xor (pbuf, buf, size);
if (grub_disk_read (array->members[q].device, sector, 0, size, buf))
if (grub_disk_read (array->members[q].device,
array->members[i].start_sector + sector,
0, size, buf))
goto quit;
grub_raid_block_xor (qbuf, buf, size);

View file

@ -506,7 +506,7 @@ grub_scsi_read (grub_disk_t disk, grub_disk_addr_t sector,
if (scsi->blocksize != GRUB_DISK_SECTOR_SIZE)
{
unsigned spb = scsi->blocksize >> GRUB_DISK_SECTOR_BITS;
if (! (spb != 0 && (scsi->blocksize & GRUB_DISK_SECTOR_SIZE) == 0))
if (spb == 0 || (scsi->blocksize & (GRUB_DISK_SECTOR_SIZE - 1)) != 0)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"unsupported SCSI block size");

View file

@ -60,6 +60,9 @@ grub_btrfs_mount (grub_disk_t disk)
return data;
fail:
if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
grub_error (GRUB_ERR_BAD_FS, "not a Btrfs filesystem");
grub_free (data);
return NULL;
}

View file

@ -281,7 +281,7 @@ grub_pxefs_open (struct grub_file *file, const char *name)
}
file->data = data;
file->not_easly_seekable = 1;
file->not_easily_seekable = 1;
grub_memcpy (file_int, file, sizeof (struct grub_file));
curr_file = file_int;
@ -420,6 +420,7 @@ set_mac_env (grub_uint8_t *mac_addr, grub_size_t mac_len)
grub_env_set ("net_pxe_mac", buf);
/* XXX: Is it possible to change MAC in PXE? */
grub_register_variable_hook ("net_pxe_mac", 0, grub_env_write_readonly);
grub_env_export ("net_pxe_mac");
}
static void
@ -431,6 +432,7 @@ set_env_limn_ro (const char *varname, char *value, grub_size_t len)
grub_env_set (varname, value);
value[len] = c;
grub_register_variable_hook (varname, 0, grub_env_write_readonly);
grub_env_export (varname);
}
static void
@ -624,12 +626,19 @@ GRUB_MOD_INIT(pxe)
grub_env_write_pxe_default_server);
grub_register_variable_hook ("pxe_default_gateway", 0,
grub_env_write_pxe_default_gateway);
/* XXX: Is it possible to change IP in PXE? */
grub_register_variable_hook ("net_pxe_ip", 0,
grub_env_write_readonly);
grub_register_variable_hook ("pxe_blksize", 0,
grub_env_write_pxe_blocksize);
grub_env_export ("pxe_default_server");
grub_env_export ("pxe_default_gateway");
grub_env_export ("net_pxe_ip");
grub_env_export ("pxe_blksize");
grub_disk_dev_register (&grub_pxe_dev);
grub_fs_register (&grub_pxefs_fs);
}

View file

@ -451,18 +451,27 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
for (i = 0; i < diro->inode.data.dir.dirhead.count; i++)
{
grub_uint64_t ino;
void *inopos = (((char *) de)
grub_uint8_t *inopos = (((grub_uint8_t *) de)
+ sizeof (struct grub_xfs_dir_entry)
+ de->len - 1);
char name[de->len + 1];
/* inopos might be unaligned. */
if (smallino)
{
ino = grub_be_to_cpu32 (*(grub_uint32_t *) inopos);
ino = grub_cpu_to_be64 (ino);
}
ino = (((grub_uint32_t) inopos[0]) << 24)
| (((grub_uint32_t) inopos[1]) << 16)
| (((grub_uint32_t) inopos[2]) << 8)
| (((grub_uint32_t) inopos[3]) << 0);
else
ino = *(grub_uint64_t *) inopos;
ino = (((grub_uint64_t) inopos[0]) << 56)
| (((grub_uint64_t) inopos[1]) << 48)
| (((grub_uint64_t) inopos[2]) << 40)
| (((grub_uint64_t) inopos[3]) << 32)
| (((grub_uint64_t) inopos[4]) << 24)
| (((grub_uint64_t) inopos[5]) << 16)
| (((grub_uint64_t) inopos[6]) << 8)
| (((grub_uint64_t) inopos[7]) << 0);
ino = grub_cpu_to_be64 (ino);
grub_memcpy (name, de->name, de->len);
name[de->len] = '\0';

View file

@ -603,7 +603,8 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf,
int idx, level;
blkptr_t *bp_array = dn->dn.dn_blkptr;
int epbs = dn->dn.dn_indblkshift - SPA_BLKPTRSHIFT;
blkptr_t *bp, *tmpbuf = 0;
blkptr_t *bp;
void *tmpbuf = 0;
grub_zfs_endian_t endian;
grub_err_t err = GRUB_ERR_NONE;
@ -646,7 +647,7 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf,
break;
}
grub_dprintf ("zfs", "endian = %d\n", endian);
err = zio_read (bp, endian, (void **) &tmpbuf, 0, data);
err = zio_read (bp, endian, &tmpbuf, 0, data);
endian = (grub_zfs_to_cpu64 (bp->blk_prop, endian) >> 63) & 1;
if (err)
break;
@ -836,14 +837,12 @@ zap_leaf_lookup (zap_leaf_phys_t * l, grub_zfs_endian_t endian,
name))
{
struct zap_leaf_array *la;
grub_uint8_t *ip;
if (le->le_int_size != 8 || le->le_value_length != 1)
return grub_error (GRUB_ERR_BAD_FS, "invalid leaf chunk entry");
/* get the uint64_t property value */
la = &ZAP_LEAF_CHUNK (l, blksft, le->le_value_chunk).l_array;
ip = la->la_array;
*value = grub_be_to_cpu64 (la->la_array64);
@ -880,7 +879,7 @@ static grub_err_t
fzap_lookup (dnode_end_t * zap_dnode, zap_phys_t * zap,
char *name, grub_uint64_t * value, struct grub_zfs_data *data)
{
zap_leaf_phys_t *l;
void *l;
grub_uint64_t hash, idx, blkid;
int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec,
zap_dnode->endian) << DNODE_SHIFT);
@ -903,7 +902,7 @@ fzap_lookup (dnode_end_t * zap_dnode, zap_phys_t * zap,
/* Get the leaf block */
if ((1U << blksft) < sizeof (zap_leaf_phys_t))
return grub_error (GRUB_ERR_BAD_FS, "ZAP leaf is too small");
err = dmu_read (zap_dnode, blkid, (void **) &l, &leafendian, data);
err = dmu_read (zap_dnode, blkid, &l, &leafendian, data);
if (err)
return err;
@ -920,6 +919,7 @@ fzap_iterate (dnode_end_t * zap_dnode, zap_phys_t * zap,
struct grub_zfs_data *data)
{
zap_leaf_phys_t *l;
void *l_in;
grub_uint64_t idx, blkid;
grub_uint16_t chunk;
int blksft = zfs_log2 (grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec,
@ -947,7 +947,8 @@ fzap_iterate (dnode_end_t * zap_dnode, zap_phys_t * zap,
{
blkid = ((grub_uint64_t *) zap)[idx + (1 << (blksft - 3 - 1))];
err = dmu_read (zap_dnode, blkid, (void **) &l, &endian, data);
err = dmu_read (zap_dnode, blkid, &l_in, &endian, data);
l = l_in;
if (err)
{
grub_errno = GRUB_ERR_NONE;
@ -1108,7 +1109,7 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type,
grub_uint64_t blkid, blksz; /* the block id this object dnode is in */
int epbs; /* shift of number of dnodes in a block */
int idx; /* index within a block */
dnode_phys_t *dnbuf;
void *dnbuf;
grub_err_t err;
grub_zfs_endian_t endian;
@ -1131,7 +1132,7 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type,
grub_dprintf ("zfs", "endian = %d, blkid=%llx\n", mdn->endian,
(unsigned long long) blkid);
err = dmu_read (mdn, blkid, (void **) &dnbuf, &endian, data);
err = dmu_read (mdn, blkid, &dnbuf, &endian, data);
if (err)
return err;
grub_dprintf ("zfs", "alive\n");
@ -1153,7 +1154,7 @@ dnode_get (dnode_end_t * mdn, grub_uint64_t objnum, grub_uint8_t type,
data->dnode_endian = endian;
}
grub_memmove (&(buf->dn), &dnbuf[idx], DNODE_SIZE);
grub_memmove (&(buf->dn), (dnode_phys_t *) dnbuf + idx, DNODE_SIZE);
buf->endian = endian;
if (type && buf->dn.dn_type != type)
return grub_error(GRUB_ERR_BAD_FS, "incorrect dnode type");
@ -1465,7 +1466,7 @@ get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname,
static grub_err_t
make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data)
{
objset_phys_t *osp;
void *osp;
blkptr_t *bp;
grub_size_t ospsize;
grub_err_t err;
@ -1473,7 +1474,7 @@ make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data)
grub_dprintf ("zfs", "endian = %d\n", mdn->endian);
bp = &(((dsl_dataset_phys_t *) DN_BONUS (&mdn->dn))->ds_bp);
err = zio_read (bp, mdn->endian, (void **) &osp, &ospsize, data);
err = zio_read (bp, mdn->endian, &osp, &ospsize, data);
if (err)
return err;
if (ospsize < OBJSET_PHYS_SIZE_V14)
@ -1483,7 +1484,8 @@ make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data)
}
mdn->endian = (grub_zfs_to_cpu64 (bp->blk_prop, mdn->endian)>>63) & 1;
grub_memmove ((char *) &(mdn->dn), (char *) &osp->os_meta_dnode, DNODE_SIZE);
grub_memmove ((char *) &(mdn->dn),
(char *) &((objset_phys_t *) osp)->os_meta_dnode, DNODE_SIZE);
grub_free (osp);
return GRUB_ERR_NONE;
}
@ -1960,7 +1962,7 @@ zfs_mount (grub_device_t dev)
int label = 0;
uberblock_phys_t *ub_array, *ubbest = NULL;
vdev_boot_header_t *bh;
objset_phys_t *osp = 0;
void *osp = 0;
grub_size_t ospsize;
grub_err_t err;
int vdevnum;
@ -2038,7 +2040,7 @@ zfs_mount (grub_device_t dev)
? LITTLE_ENDIAN : BIG_ENDIAN);
err = zio_read (&ubbest->ubp_uberblock.ub_rootbp,
ub_endian,
(void **) &osp, &ospsize, data);
&osp, &ospsize, data);
if (err)
{
grub_dprintf ("zfs", "couldn't zio_read\n");
@ -2067,7 +2069,8 @@ zfs_mount (grub_device_t dev)
continue;
#endif
/* Got the MOS. Save it at the memory addr MOS. */
grub_memmove (&(data->mos.dn), &osp->os_meta_dnode, DNODE_SIZE);
grub_memmove (&(data->mos.dn), &((objset_phys_t *) osp)->os_meta_dnode,
DNODE_SIZE);
data->mos.endian = (grub_zfs_to_cpu64 (ubbest->ubp_uberblock.ub_rootbp.blk_prop, ub_endian) >> 63) & 1;
grub_memmove (&(data->current_uberblock),
&ubbest->ubp_uberblock, sizeof (uberblock_t));
@ -2201,7 +2204,7 @@ grub_zfs_open (struct grub_file *file, const char *fsfilename)
*/
if (data->dnode.dn.dn_bonustype == DMU_OT_SA)
{
sa_hdr_phys_t *sahdrp;
void *sahdrp;
int hdrsize;
if (data->dnode.dn.dn_bonuslen != 0)
@ -2212,7 +2215,7 @@ grub_zfs_open (struct grub_file *file, const char *fsfilename)
{
blkptr_t *bp = &data->dnode.dn.dn_spill;
err = zio_read (bp, data->dnode.endian, (void **) &sahdrp, NULL, data);
err = zio_read (bp, data->dnode.endian, &sahdrp, NULL, data);
if (err)
return err;
}
@ -2221,7 +2224,7 @@ grub_zfs_open (struct grub_file *file, const char *fsfilename)
return grub_error (GRUB_ERR_BAD_FS, "filesystem is corrupt");
}
hdrsize = SA_HDR_SIZE (sahdrp);
hdrsize = SA_HDR_SIZE (((sa_hdr_phys_t *) sahdrp));
file->size = *(grub_uint64_t *) ((char *) sahdrp + hdrsize + SA_SIZE_OFFSET);
}
else
@ -2280,6 +2283,7 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len)
read = 0;
while (length)
{
void *t;
/*
* Find requested blkid and the offset within that block.
*/
@ -2287,8 +2291,9 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len)
grub_free (data->file_buf);
data->file_buf = 0;
err = dmu_read (&(data->dnode), blkid, (void **) &(data->file_buf),
err = dmu_read (&(data->dnode), blkid, &t,
0, data);
data->file_buf = t;
if (err)
return -1;

View file

@ -364,21 +364,16 @@ grub_cmd_zfs_bootfs (grub_command_t cmd __attribute__ ((unused)), int argc,
grub_free (nv);
grub_free (nvlist);
if (bootpath && devid)
{
bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu bootpath=%s diskdevid=%s",
poolname, (unsigned long long) mdnobj,
bootpath, devid);
if (!bootfs)
return grub_errno;
}
else
{
bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu",
poolname, (unsigned long long) mdnobj);
if (!bootfs)
return grub_errno;
}
bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu%s%s%s%s%s%s",
poolname, (unsigned long long) mdnobj,
bootpath ? ",bootpath=\"" : "",
bootpath ? : "",
bootpath ? "\"" : "",
devid ? ",diskdevid=\"" : "",
devid ? : "",
devid ? "\"" : "");
if (!bootfs)
return grub_errno;
if (argc >= 2)
grub_env_set (args[1], bootfs);
else

View file

@ -52,8 +52,8 @@ fi
rm -f $t1 $t2
if test x@TARGET_APPLE_CC@ != x1; then
if ! test -z "@TARGET_OBJ2ELF@"; then
./@TARGET_OBJ2ELF@ $tmpfile || exit 1
if ! test -z "${TARGET_OBJ2ELF}"; then
./${TARGET_OBJ2ELF} $tmpfile || exit 1
fi
if test x@platform@ != xemu; then
@STRIP@ --strip-unneeded \

View file

@ -86,18 +86,21 @@ grub_read_hook_datetime (struct grub_env_var *var,
GRUB_MOD_INIT(datehook)
{
int i;
unsigned i;
for (i = 0; i < 7; i++)
grub_register_variable_hook (grub_datetime_names[i],
grub_read_hook_datetime, 0);
for (i = 0; i < ARRAY_SIZE (grub_datetime_names); i++)
{
grub_register_variable_hook (grub_datetime_names[i],
grub_read_hook_datetime, 0);
grub_env_export (grub_datetime_names[i]);
}
}
GRUB_MOD_FINI(datehook)
{
int i;
unsigned i;
for (i = 0; i < 7; i++)
for (i = 0; i < ARRAY_SIZE (grub_datetime_names); i++)
{
grub_register_variable_hook (grub_datetime_names[i], 0, 0);
grub_env_unset (grub_datetime_names[i]);

View file

@ -74,7 +74,7 @@ grub_bufio_open (grub_file_t io, int size)
file->data = bufio;
file->read_hook = 0;
file->fs = &grub_bufio_fs;
file->not_easly_seekable = io->not_easly_seekable;
file->not_easily_seekable = io->not_easily_seekable;
return file;
}

View file

@ -1136,7 +1136,7 @@ grub_gzio_open (grub_file_t io)
file->data = gzio;
file->read_hook = 0;
file->fs = &grub_gzio_fs;
file->not_easly_seekable = 1;
file->not_easily_seekable = 1;
if (! test_header (file))
{

View file

@ -200,7 +200,7 @@ grub_xzio_open (grub_file_t io)
file->read_hook = 0;
file->fs = &grub_xzio_fs;
file->size = GRUB_FILE_SIZE_UNKNOWN;
file->not_easly_seekable = 1;
file->not_easily_seekable = 1;
if (grub_file_tell (xzio->file) != 0)
grub_file_seek (xzio->file, 0);

View file

@ -52,13 +52,13 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
grub_efi_status_t status;
grub_efi_boot_services_t *b;
#if GRUB_TARGET_SIZEOF_VOID_P < 8
#if 1
/* Limit the memory access to less than 4GB for 32-bit platforms. */
if (address > 0xffffffff)
return 0;
#endif
#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL)
#if 1
if (address == 0)
{
type = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
@ -251,7 +251,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
{
if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY
#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL)
#if 1
&& desc->physical_start <= 0xffffffff
#endif
&& desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000
@ -267,7 +267,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
desc->physical_start = 0x100000;
}
#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL)
#if 1
if (BYTES_TO_PAGES (filtered_desc->physical_start)
+ filtered_desc->num_pages
> BYTES_TO_PAGES (0x100000000LL))

View file

@ -17,7 +17,9 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config-util.h>
#include <config.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <assert.h>
@ -135,8 +137,12 @@ find_root_device_from_mountinfo (const char *dir)
continue; /* only a subtree is mounted */
enc_path_len = strlen (enc_path);
/* Check that enc_path is a prefix of dir. The prefix must either be
the entire string, or end with a slash, or be immediately followed
by a slash. */
if (strncmp (dir, enc_path, enc_path_len) != 0 ||
(dir[enc_path_len] && dir[enc_path_len] != '/'))
(enc_path_len && dir[enc_path_len - 1] != '/' &&
dir[enc_path_len] && dir[enc_path_len] != '/'))
continue;
/* This is a parent of the requested directory. /proc/self/mountinfo

View file

@ -240,3 +240,23 @@ grub_register_variable_hook (const char *name,
return GRUB_ERR_NONE;
}
grub_err_t
grub_env_export (const char *name)
{
struct grub_env_var *var;
var = grub_env_find (name);
if (! var)
{
grub_err_t err;
err = grub_env_set (name, "");
if (err)
return err;
var = grub_env_find (name);
}
var->global = 1;
return GRUB_ERR_NONE;
}

View file

@ -140,36 +140,27 @@ compact_mem_regions (void)
}
}
/*
*
* grub_get_conv_memsize(i) : return the conventional memory size in KB.
* BIOS call "INT 12H" to get conventional memory size
* The return value in AX.
*/
static inline grub_uint16_t
grub_get_conv_memsize (void)
{
struct grub_bios_int_registers regs;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x12, &regs);
return regs.eax & 0xffff;
}
void
grub_machine_init (void)
{
int i;
#if 0
int grub_lower_mem;
#endif
/* Initialize the console as early as possible. */
grub_console_init ();
/* This sanity check is useless since top of GRUB_MEMORY_MACHINE_RESERVED_END
is used for stack and if it's unavailable we wouldn't have gotten so far.
*/
#if 0
grub_lower_mem = grub_get_conv_memsize () << 10;
/* Sanity check. */
if (grub_lower_mem < GRUB_MEMORY_MACHINE_RESERVED_END)
grub_fatal ("too small memory");
#endif
/* FIXME: This prevents loader/i386/linux.c from using low memory. When our
heap implements support for requesting a chunk in low memory, this should

View file

@ -36,6 +36,22 @@ struct grub_machine_mmap_entry
} __attribute__((packed));
/*
*
* grub_get_conv_memsize(i) : return the conventional memory size in KB.
* BIOS call "INT 12H" to get conventional memory size
* The return value in AX.
*/
static inline grub_uint16_t
grub_get_conv_memsize (void)
{
struct grub_bios_int_registers regs;
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
grub_bios_interrupt (0x12, &regs);
return regs.eax & 0xffff;
}
/*
* grub_get_ext_memsize() : return the extended memory size in KB.
* BIOS call "INT 15H, AH=88H" to get extended memory size
@ -155,6 +171,10 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook)
{
grub_uint32_t eisa_mmap = grub_get_eisa_mmap ();
if (hook (0x0, ((grub_uint32_t) grub_get_conv_memsize ()) << 10,
GRUB_MEMORY_AVAILABLE))
return 0;
if (eisa_mmap)
{
if (hook (0x100000, (eisa_mmap & 0xFFFF) << 10,
@ -162,7 +182,8 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook)
hook (0x1000000, eisa_mmap & ~0xFFFF, GRUB_MEMORY_AVAILABLE);
}
else
hook (0x100000, grub_get_ext_memsize () << 10, GRUB_MEMORY_AVAILABLE);
hook (0x100000, ((grub_uint32_t) grub_get_ext_memsize ()) << 10,
GRUB_MEMORY_AVAILABLE);
}
return 0;

View file

@ -84,6 +84,9 @@ grub_ieee1275_find_options (void)
if (rc >= 0 && !grub_strcmp (tmp, "Emulated PC"))
is_qemu = 1;
if (grub_strncmp (tmp, "PowerMac", sizeof ("PowerMac") - 1) == 0)
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS);
if (is_smartfirmware)
{
/* Broken in all versions */

View file

@ -50,6 +50,12 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
"couldn't examine /memory/available property");
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS))
{
address_cells = 1;
size_cells = 1;
}
/* Decode each entry and call `hook'. */
i = 0;
available_size /= sizeof (grub_uint32_t);

View file

@ -189,6 +189,8 @@ grub_main (void)
for convenience. */
grub_machine_set_prefix ();
grub_set_root_dev ();
grub_env_export ("root");
grub_env_export ("prefix");
grub_register_core_commands ();

View file

@ -41,6 +41,7 @@ extern void grub_at_keyboard_init (void);
extern void grub_serial_init (void);
extern void grub_terminfo_init (void);
extern void grub_keylayouts_init (void);
extern void grub_boot_init (void);
/* FIXME: use interrupt to count high. */
grub_uint64_t
@ -210,6 +211,8 @@ grub_machine_init (void)
grub_terminfo_init ();
grub_serial_init ();
grub_boot_init ();
}
void

105
grub-core/lib/cmdline.c Normal file
View file

@ -0,0 +1,105 @@
/* cmdline.c - linux command line handling */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/lib/cmdline.h>
#include <grub/misc.h>
static unsigned int check_arg (char *c, int *has_space)
{
int space = 0;
unsigned int size = 0;
while (*c)
{
if (*c == '\\' || *c == '\'' || *c == '"')
size++;
else if (*c == ' ')
space = 1;
size++;
c++;
}
if (space)
size += 2;
if (has_space)
*has_space = space;
return size;
}
unsigned int grub_loader_cmdline_size (int argc, char *argv[])
{
int i;
unsigned int size = 0;
for (i = 0; i < argc; i++)
{
size += check_arg (argv[i], 0);
size++; /* Separator space or NULL. */
}
return size;
}
int grub_create_loader_cmdline (int argc, char *argv[], char *buf,
grub_size_t size)
{
int i, space;
unsigned int arg_size;
char *c;
for (i = 0; i < argc; i++)
{
c = argv[i];
arg_size = check_arg(argv[i], &space);
arg_size++; /* Separator space or NULL. */
if (size < arg_size)
break;
size -= arg_size;
if (space)
*buf++ = '"';
while (*c)
{
if (*c == '\\' || *c == '\'' || *c == '"')
*buf++ = '\\';
*buf++ = *c;
c++;
}
if (space)
*buf++ = '"';
*buf++ = ' ';
}
/* Replace last space with null. */
if (i)
buf--;
*buf = 0;
return i;
}

View file

@ -0,0 +1 @@
#include <sys/types.h>

View file

@ -32,6 +32,11 @@ typedef grub_uint16_t uint16_t;
typedef grub_uint32_t uint32_t;
typedef grub_uint64_t uint64_t;
typedef grub_int8_t int8_t;
typedef grub_int16_t int16_t;
typedef grub_int32_t int32_t;
typedef grub_int64_t int64_t;
#ifdef GRUB_CPU_WORDS_BIGENDIAN
#define WORDS_BIGENDIAN
#else

View file

@ -394,7 +394,7 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator,
grub_err_t err;
Elf_Ehdr e;
Elf_Shdr *s, *symsh, *strsh;
char *shdr;
char *shdr = NULL;
unsigned symsize, strsize;
void *sym_chunk;
grub_uint8_t *curload;

View file

@ -33,6 +33,7 @@
#include <grub/command.h>
#include <grub/i386/relocator.h>
#include <grub/i18n.h>
#include <grub/lib/cmdline.h>
#ifdef GRUB_MACHINE_PCBIOS
#include <grub/i386/pc/vesa_modes_table.h>
@ -135,7 +136,8 @@ find_efi_mmap_size (void)
later, and EFI itself may allocate more. */
mmap_size += (1 << 12);
return page_align (mmap_size);
mmap_size = page_align (mmap_size);
return mmap_size;
}
#endif
@ -312,6 +314,13 @@ grub_linux_setup_video (struct linux_kernel_params *params)
struct grub_video_mode_info mode_info;
void *framebuffer;
grub_err_t err;
grub_video_driver_id_t driver_id;
char *gfxlfbvar = grub_env_get ("gfxpayloadforcelfb");
driver_id = grub_video_get_driver_id ();
if (driver_id == GRUB_VIDEO_DRIVER_NONE)
return 1;
err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
@ -338,12 +347,40 @@ grub_linux_setup_video (struct linux_kernel_params *params)
params->reserved_mask_size = mode_info.reserved_mask_size;
params->reserved_field_pos = mode_info.reserved_field_pos;
if (gfxlfbvar && (gfxlfbvar[0] == '1' || gfxlfbvar[0] == 'y'))
params->have_vga = GRUB_VIDEO_LINUX_TYPE_SIMPLE;
else
{
switch (driver_id)
{
case GRUB_VIDEO_DRIVER_VBE:
params->lfb_size >>= 16;
params->have_vga = GRUB_VIDEO_LINUX_TYPE_VESA;
break;
case GRUB_VIDEO_DRIVER_EFI_UGA:
case GRUB_VIDEO_DRIVER_EFI_GOP:
params->have_vga = GRUB_VIDEO_LINUX_TYPE_EFIFB;
break;
/* FIXME: check if better id is available. */
case GRUB_VIDEO_DRIVER_SM712:
case GRUB_VIDEO_DRIVER_VGA:
case GRUB_VIDEO_DRIVER_CIRRUS:
case GRUB_VIDEO_DRIVER_BOCHS:
/* Make gcc happy. */
case GRUB_VIDEO_DRIVER_SDL:
case GRUB_VIDEO_DRIVER_NONE:
params->have_vga = GRUB_VIDEO_LINUX_TYPE_SIMPLE;
break;
}
}
#ifdef GRUB_MACHINE_PCBIOS
/* VESA packed modes may come with zeroed mask sizes, which need
to be set here according to DAC Palette width. If we don't,
this results in Linux displaying a black screen. */
if (mode_info.bpp <= 8)
if (driver_id == GRUB_VIDEO_DRIVER_VBE && mode_info.bpp <= 8)
{
struct grub_vbe_info_block controller_info;
int status;
@ -456,15 +493,7 @@ grub_linux_boot (void)
grub_errno = GRUB_ERR_NONE;
}
if (! grub_linux_setup_video (params))
{
/* Use generic framebuffer unless VESA is known to be supported. */
if (params->have_vga != GRUB_VIDEO_LINUX_TYPE_VESA)
params->have_vga = GRUB_VIDEO_LINUX_TYPE_SIMPLE;
else
params->lfb_size >>= 16;
}
else
if (grub_linux_setup_video (params))
{
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU)
params->have_vga = GRUB_VIDEO_LINUX_TYPE_TEXT;
@ -575,7 +604,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
grub_size_t real_size, prot_size;
grub_ssize_t len;
int i;
char *dest;
grub_dl_ref (my_mod);
@ -771,10 +799,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
break;
}
/* We can't detect VESA, but user is implicitly telling us that it
is built-in because `vga=' parameter was used. */
params->have_vga = GRUB_VIDEO_LINUX_TYPE_VESA;
linux_mode = &grub_vesa_mode_table[vid_mode
- GRUB_VESA_MODE_TABLE_START];
@ -836,22 +860,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
params->loadflags |= GRUB_LINUX_FLAG_QUIET;
}
/* Specify the boot file. */
dest = grub_stpcpy ((char *) real_mode_mem + GRUB_LINUX_CL_OFFSET,
"BOOT_IMAGE=");
dest = grub_stpcpy (dest, argv[0]);
/* Copy kernel parameters. */
for (i = 1;
i < argc
&& dest + grub_strlen (argv[i]) + 1 < ((char *) real_mode_mem
+ GRUB_LINUX_CL_END_OFFSET);
i++)
{
*dest++ = ' ';
dest = grub_stpcpy (dest, argv[i]);
}
/* Create kernel command line. */
grub_memcpy ((char *)real_mode_mem + GRUB_LINUX_CL_OFFSET, LINUX_IMAGE,
sizeof (LINUX_IMAGE));
grub_create_loader_cmdline (argc, argv,
(char *)real_mode_mem + GRUB_LINUX_CL_OFFSET
+ sizeof (LINUX_IMAGE) - 1,
GRUB_LINUX_CL_END_OFFSET - GRUB_LINUX_CL_OFFSET
- (sizeof (LINUX_IMAGE) - 1));
len = prot_size;
if (grub_file_read (file, prot_mode_mem, len) != len)

View file

@ -539,6 +539,9 @@ grub_multiboot_make_mbi (grub_uint32_t *target)
mbi->u.elf_sec.shndx = elf_sec_shstrndx;
mbi->flags |= MULTIBOOT_INFO_ELF_SHDR;
ptrorig += elf_sec_entsize * elf_sec_num;
ptrdest += elf_sec_entsize * elf_sec_num;
}
err = retrieve_video_parameters (mbi, ptrorig, ptrdest);
@ -547,6 +550,16 @@ grub_multiboot_make_mbi (grub_uint32_t *target)
grub_print_error ();
grub_errno = GRUB_ERR_NONE;
}
if ((mbi->flags & MULTIBOOT_INFO_FRAMEBUFFER_INFO)
&& mbi->framebuffer_type == MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED)
{
ptrorig += mbi->framebuffer_palette_num_colors
* sizeof (struct multiboot_color);
ptrdest += mbi->framebuffer_palette_num_colors
* sizeof (struct multiboot_color);
}
#if GRUB_MACHINE_HAS_VBE
ptrorig += sizeof (struct grub_vbe_info_block);
ptrdest += sizeof (struct grub_vbe_info_block);

View file

@ -34,6 +34,7 @@
#include <grub/cpu/relocator.h>
#include <grub/video.h>
#include <grub/i386/floppy.h>
#include <grub/lib/cmdline.h>
#define GRUB_LINUX_CL_OFFSET 0x9000
#define GRUB_LINUX_CL_END_OFFSET 0x90FF
@ -86,7 +87,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
grub_size_t real_size;
grub_ssize_t len;
int i;
char *dest;
char *grub_linux_prot_chunk;
int grub_linux_is_bzimage;
grub_addr_t grub_linux_prot_target;
@ -286,21 +286,14 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
((GRUB_LINUX_MAX_SETUP_SECTS - setup_sects - 1)
<< GRUB_DISK_SECTOR_BITS));
/* Specify the boot file. */
dest = grub_stpcpy (grub_linux_real_chunk + GRUB_LINUX_CL_OFFSET,
"BOOT_IMAGE=");
dest = grub_stpcpy (dest, argv[0]);
/* Copy kernel parameters. */
for (i = 1;
i < argc
&& dest + grub_strlen (argv[i]) + 1 < (grub_linux_real_chunk
+ GRUB_LINUX_CL_END_OFFSET);
i++)
{
*dest++ = ' ';
dest = grub_stpcpy (dest, argv[i]);
}
/* Create kernel command line. */
grub_memcpy ((char *)grub_linux_real_chunk + GRUB_LINUX_CL_OFFSET,
LINUX_IMAGE, sizeof (LINUX_IMAGE));
grub_create_loader_cmdline (argc, argv,
(char *)grub_linux_real_chunk
+ GRUB_LINUX_CL_OFFSET + sizeof (LINUX_IMAGE) - 1,
GRUB_LINUX_CL_END_OFFSET - GRUB_LINUX_CL_OFFSET
- (sizeof (LINUX_IMAGE) - 1));
if (grub_linux_is_bzimage)
grub_linux_prot_target = GRUB_LINUX_BZIMAGE_ADDR;

View file

@ -951,10 +951,11 @@ grub_err_t
grub_xnu_boot (void)
{
struct grub_xnu_boot_params *bootparams;
void *bp_in;
grub_addr_t bootparams_target;
grub_err_t err;
grub_efi_uintn_t memory_map_size = 0;
grub_efi_memory_descriptor_t *memory_map;
void *memory_map;
grub_addr_t memory_map_target;
grub_efi_uintn_t map_key = 0;
grub_efi_uintn_t descriptor_size = 0;
@ -1006,9 +1007,10 @@ grub_xnu_boot (void)
/* Relocate the boot parameters to heap. */
err = grub_xnu_heap_malloc (sizeof (*bootparams),
(void **) &bootparams, &bootparams_target);
&bp_in, &bootparams_target);
if (err)
return err;
bootparams = bp_in;
/* Set video. */
err = grub_xnu_set_video (bootparams);
@ -1035,7 +1037,7 @@ grub_xnu_boot (void)
memory map growth. */
memory_map_size += 20 * descriptor_size;
err = grub_xnu_heap_malloc (memory_map_size,
(void **) &memory_map, &memory_map_target);
&memory_map, &memory_map_target);
if (err)
return err;
@ -1109,7 +1111,7 @@ grub_xnu_boot (void)
grub_xnu_arg1 = bootparams_target;
grub_autoefi_set_virtual_address_map (memory_map_size, descriptor_size,
descriptor_version,memory_map);
descriptor_version, memory_map);
state.eip = grub_xnu_entry_point;
state.eax = grub_xnu_arg1;

View file

@ -27,6 +27,7 @@
#include <grub/command.h>
#include <grub/i18n.h>
#include <grub/memory.h>
#include <grub/lib/cmdline.h>
#define ELF32_LOADMASK (0xc0000000UL)
#define ELF64_LOADMASK (0xc000000000000000ULL)
@ -151,7 +152,8 @@ grub_linux_load32 (grub_elf_t elf)
Elf32_Addr base_addr;
grub_addr_t seg_addr;
grub_uint32_t align;
int offset;
grub_uint32_t offset;
Elf32_Addr entry;
linux_size = grub_elf32_size (elf, &base_addr, &align);
if (linux_size == 0)
@ -159,9 +161,12 @@ grub_linux_load32 (grub_elf_t elf)
/* Pad it; the kernel scribbles over memory beyond its load address. */
linux_size += 0x100000;
offset = elf->ehdr.ehdr32.e_entry - base_addr;
/* Linux's entry point incorrectly contains a virtual address. */
entry = elf->ehdr.ehdr32.e_entry & ~ELF32_LOADMASK;
/* Linux's incorrectly contains a virtual address. */
base_addr &= ~ELF32_LOADMASK;
offset = entry - base_addr;
/* On some systems, firmware occupies the memory we're trying to use.
* Happily, Linux can be loaded anywhere (it relocates itself). Iterate
@ -195,7 +200,8 @@ grub_linux_load64 (grub_elf_t elf)
Elf64_Addr base_addr;
grub_addr_t seg_addr;
grub_uint64_t align;
int offset;
grub_uint64_t offset;
Elf64_Addr entry;
linux_size = grub_elf64_size (elf, &base_addr, &align);
if (linux_size == 0)
@ -203,9 +209,10 @@ grub_linux_load64 (grub_elf_t elf)
/* Pad it; the kernel scribbles over memory beyond its load address. */
linux_size += 0x100000;
offset = elf->ehdr.ehdr64.e_entry - base_addr;
/* Linux's incorrectly contains a virtual address. */
base_addr &= ~ELF64_LOADMASK;
entry = elf->ehdr.ehdr64.e_entry & ~ELF64_LOADMASK;
offset = entry - base_addr;
/* Linux's incorrectly contains a virtual address. */
/* On some systems, firmware occupies the memory we're trying to use.
* Happily, Linux can be loaded anywhere (it relocates itself). Iterate
@ -238,9 +245,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
int argc, char *argv[])
{
grub_elf_t elf = 0;
int i;
int size;
char *dest;
grub_dl_ref (my_mod);
@ -275,23 +280,15 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
goto out;
}
size = sizeof ("BOOT_IMAGE=") + grub_strlen (argv[0]);
for (i = 0; i < argc; i++)
size += grub_strlen (argv[i]) + 1;
linux_args = grub_malloc (size);
size = grub_loader_cmdline_size(argc, argv);
linux_args = grub_malloc (size + sizeof (LINUX_IMAGE));
if (! linux_args)
goto out;
/* Specify the boot file. */
dest = grub_stpcpy (linux_args, "BOOT_IMAGE=");
dest = grub_stpcpy (dest, argv[0]);
for (i = 1; i < argc; i++)
{
*dest++ = ' ';
dest = grub_stpcpy (dest, argv[i]);
}
/* Create kernel command line. */
grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE));
grub_create_loader_cmdline (argc, argv, linux_args + sizeof (LINUX_IMAGE) - 1,
size);
out:

View file

@ -27,6 +27,7 @@
#include <grub/command.h>
#include <grub/i18n.h>
#include <grub/memory.h>
#include <grub/lib/cmdline.h>
static grub_dl_t my_mod;
@ -295,9 +296,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
{
grub_file_t file = 0;
grub_elf_t elf = 0;
int i;
int size;
char *dest;
grub_dl_ref (my_mod);
@ -333,23 +332,16 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
goto out;
}
size = sizeof ("BOOT_IMAGE=") + grub_strlen (argv[0]);
for (i = 0; i < argc; i++)
size += grub_strlen (argv[i]) + 1;
size = grub_loader_cmdline_size(argc, argv);
linux_args = grub_malloc (size);
linux_args = grub_malloc (size + sizeof (LINUX_IMAGE));
if (! linux_args)
goto out;
/* Specify the boot file. */
dest = grub_stpcpy (linux_args, "BOOT_IMAGE=");
dest = grub_stpcpy (dest, argv[0]);
for (i = 1; i < argc; i++)
{
*dest++ = ' ';
dest = grub_stpcpy (dest, argv[i]);
}
/* Create kernel command line. */
grub_memcpy (linux_args, LINUX_IMAGE, sizeof (LINUX_IMAGE));
grub_create_loader_cmdline (argc, argv, linux_args + sizeof (LINUX_IMAGE) - 1,
size);
out:
if (elf)

View file

@ -342,7 +342,8 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)),
grub_macho_t macho;
grub_uint32_t startcode, endcode;
int i;
char *ptr, *loadaddr;
char *ptr;
void *loadaddr;
grub_addr_t loadaddr_target;
if (argc < 1)
@ -375,7 +376,7 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)),
if (!grub_xnu_relocator)
return grub_errno;
grub_xnu_heap_target_start = startcode;
err = grub_xnu_heap_malloc (endcode - startcode, (void **) &loadaddr,
err = grub_xnu_heap_malloc (endcode - startcode, &loadaddr,
&loadaddr_target);
if (err)
@ -386,7 +387,8 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)),
}
/* Load kernel. */
err = grub_macho_load32 (macho, loadaddr - startcode, GRUB_MACHO_NOBSS);
err = grub_macho_load32 (macho, (char *) loadaddr - startcode,
GRUB_MACHO_NOBSS);
if (err)
{
grub_macho_close (macho);
@ -450,7 +452,8 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)),
grub_macho_t macho;
grub_uint64_t startcode, endcode;
int i;
char *ptr, *loadaddr;
char *ptr;
void *loadaddr;
grub_addr_t loadaddr_target;
if (argc < 1)
@ -486,7 +489,7 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)),
if (!grub_xnu_relocator)
return grub_errno;
grub_xnu_heap_target_start = startcode;
err = grub_xnu_heap_malloc (endcode - startcode, (void **) &loadaddr,
err = grub_xnu_heap_malloc (endcode - startcode, &loadaddr,
&loadaddr_target);
if (err)
@ -497,7 +500,8 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)),
}
/* Load kernel. */
err = grub_macho_load64 (macho, loadaddr - startcode, GRUB_MACHO_NOBSS);
err = grub_macho_load64 (macho, (char *) loadaddr - startcode,
GRUB_MACHO_NOBSS);
if (err)
{
grub_macho_close (macho);
@ -636,7 +640,8 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile)
grub_file_t infoplist;
struct grub_xnu_extheader *exthead;
int neededspace = sizeof (*exthead);
grub_uint8_t *buf, *buf0;
grub_uint8_t *buf;
void *buf0;
grub_addr_t buf_target;
grub_size_t infoplistsize = 0, machosize = 0;
char *name, *nameend;
@ -692,7 +697,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile)
err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE);
if (err)
return err;
err = grub_xnu_heap_malloc (neededspace, (void **) &buf0, &buf_target);
err = grub_xnu_heap_malloc (neededspace, &buf0, &buf_target);
if (err)
return err;
buf = buf0;
@ -704,7 +709,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile)
/* Load the binary. */
if (macho)
{
exthead->binaryaddr = buf_target + (buf - buf0);
exthead->binaryaddr = buf_target + (buf - (grub_uint8_t *) buf0);
exthead->binarysize = machosize;
if (grub_xnu_is_64bit)
err = grub_macho_readfile64 (macho, buf);
@ -723,7 +728,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile)
/* Load the plist. */
if (infoplist)
{
exthead->infoplistaddr = buf_target + (buf - buf0);
exthead->infoplistaddr = buf_target + (buf - (grub_uint8_t *) buf0);
exthead->infoplistsize = infoplistsize + 1;
if (grub_file_read (infoplist, buf, infoplistsize)
!= (grub_ssize_t) (infoplistsize))
@ -739,7 +744,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile)
}
grub_errno = GRUB_ERR_NONE;
exthead->nameaddr = (buf - buf0) + buf_target;
exthead->nameaddr = (buf - (grub_uint8_t *) buf0) + buf_target;
exthead->namesize = namelen + 1;
grub_memcpy (buf, name, namelen);
buf[namelen] = 0;

View file

@ -148,7 +148,7 @@ grub_env_context_close (void)
grub_err_t
grub_env_extractor_close (int source)
{
grub_menu_t menu, menu2;
grub_menu_t menu = NULL;
grub_menu_entry_t *last;
grub_err_t err;
@ -161,6 +161,7 @@ grub_env_extractor_close (int source)
if (source)
{
grub_menu_t menu2;
menu2 = grub_env_get_menu ();
last = &menu2->entry_list;
@ -175,26 +176,6 @@ grub_env_extractor_close (int source)
return err;
}
grub_err_t
grub_env_export (const char *name)
{
struct grub_env_var *var;
var = grub_env_find (name);
if (! var)
{
grub_err_t err;
err = grub_env_set (name, "");
if (err)
return err;
var = grub_env_find (name);
}
var->global = 1;
return GRUB_ERR_NONE;
}
static grub_command_t export_cmd;
static grub_err_t
@ -216,9 +197,6 @@ grub_cmd_export (struct grub_command *cmd __attribute__ ((unused)),
void
grub_context_init (void)
{
grub_env_export ("root");
grub_env_export ("prefix");
export_cmd = grub_register_command ("export", grub_cmd_export,
N_("ENVVAR [ENVVAR] ..."),
N_("Export variables."));

View file

@ -287,7 +287,7 @@ grub_normal_execute (const char *config, int nested, int batch)
{
if (menu && menu->size)
{
grub_show_menu (menu, nested);
grub_show_menu (menu, nested, 0);
if (nested)
grub_normal_free_menu (menu);
}

View file

@ -154,12 +154,15 @@ get_and_remove_first_entry_number (const char *name)
}
/* Run a menu entry. */
void
grub_menu_execute_entry(grub_menu_entry_t entry)
static void
grub_menu_execute_entry(grub_menu_entry_t entry, int auto_boot)
{
grub_err_t err = GRUB_ERR_NONE;
int errs_before;
grub_menu_t menu;
grub_menu_t menu = NULL;
char *optr, *buf, *oldchosen = NULL, *olddefault = NULL;
const char *ptr, *chosen, *def;
grub_size_t sz = 0;
if (entry->restricted)
err = grub_auth_check_authentication (entry->users);
@ -173,6 +176,9 @@ grub_menu_execute_entry(grub_menu_entry_t entry)
errs_before = grub_err_printed_errors;
chosen = grub_env_get ("chosen");
def = grub_env_get ("default");
if (entry->submenu)
{
grub_env_context_open ();
@ -180,9 +186,64 @@ grub_menu_execute_entry(grub_menu_entry_t entry)
if (! menu)
return;
grub_env_set_menu (menu);
if (auto_boot)
grub_env_set ("timeout", "0");
}
grub_env_set ("chosen", entry->title);
for (ptr = entry->title; *ptr; ptr++)
sz += (*ptr == '>') ? 2 : 1;
if (chosen)
{
oldchosen = grub_strdup (chosen);
if (!oldchosen)
grub_print_error ();
}
if (def)
{
olddefault = grub_strdup (def);
if (!olddefault)
grub_print_error ();
}
sz++;
if (chosen)
sz += grub_strlen (chosen);
sz++;
buf = grub_malloc (sz);
if (!buf)
grub_print_error ();
else
{
optr = buf;
if (chosen)
{
optr = grub_stpcpy (optr, chosen);
*optr++ = '>';
}
for (ptr = entry->title; *ptr; ptr++)
{
if (*ptr == '>')
*optr++ = '>';
*optr++ = *ptr;
}
*optr = 0;
grub_env_set ("chosen", buf);
grub_env_export ("chosen");
grub_free (buf);
}
for (ptr = def; *ptr; ptr++)
{
if (ptr[0] == '>' && ptr[1] == '>')
{
ptr++;
continue;
}
if (ptr[0] == '>')
break;
}
if (ptr[0] && ptr[1])
grub_env_set ("default", ptr + 1);
else
grub_env_unset ("default");
grub_script_execute_sourcecode (entry->sourcecode, entry->argc, entry->args);
if (errs_before != grub_err_printed_errors)
@ -196,20 +257,30 @@ grub_menu_execute_entry(grub_menu_entry_t entry)
{
if (menu && menu->size)
{
grub_show_menu (menu, 1);
grub_show_menu (menu, 1, auto_boot);
grub_normal_free_menu (menu);
}
grub_env_context_close ();
}
if (oldchosen)
grub_env_set ("chosen", oldchosen);
else
grub_env_unset ("chosen");
if (olddefault)
grub_env_set ("default", olddefault);
else
grub_env_unset ("default");
grub_env_unset ("timeout");
}
/* Execute ENTRY from the menu MENU, falling back to entries specified
in the environment variable "fallback" if it fails. CALLBACK is a
pointer to a struct of function pointers which are used to allow the
caller provide feedback to the user. */
void
static void
grub_menu_execute_with_fallback (grub_menu_t menu,
grub_menu_entry_t entry,
int autobooted,
grub_menu_execute_callback_t callback,
void *callback_data)
{
@ -217,7 +288,7 @@ grub_menu_execute_with_fallback (grub_menu_t menu,
callback->notify_booting (entry, callback_data);
grub_menu_execute_entry (entry);
grub_menu_execute_entry (entry, 1);
/* Deal with fallback entries. */
while ((fallback_entry = get_and_remove_first_entry_number ("fallback"))
@ -228,14 +299,15 @@ grub_menu_execute_with_fallback (grub_menu_t menu,
entry = grub_menu_get_entry (menu, fallback_entry);
callback->notify_fallback (entry, callback_data);
grub_menu_execute_entry (entry);
grub_menu_execute_entry (entry, 1);
/* If the function call to execute the entry returns at all, then this is
taken to indicate a boot failure. For menu entries that do something
other than actually boot an operating system, this could assume
incorrectly that something failed. */
}
callback->notify_failure (callback_data);
if (!autobooted)
callback->notify_failure (callback_data);
}
static struct grub_menu_viewer *viewers;
@ -309,11 +381,35 @@ grub_menu_register_viewer (struct grub_menu_viewer *viewer)
viewers = viewer;
}
static int
menuentry_eq (const char *title, const char *spec)
{
const char *ptr1, *ptr2;
ptr1 = title;
ptr2 = spec;
while (1)
{
if (*ptr2 == '>' && ptr2[1] != '>' && *ptr1 == 0)
return 1;
if (*ptr2 == '>' && ptr2[1] != '>')
return 0;
if (*ptr2 == '>')
ptr2++;
if (*ptr1 != *ptr2)
return 0;
if (*ptr1 == 0)
return 1;
ptr1++;
ptr2++;
}
}
/* Get the entry number from the variable NAME. */
static int
get_entry_number (grub_menu_t menu, const char *name)
{
char *val;
const char *val;
int entry;
val = grub_env_get (name);
@ -334,7 +430,7 @@ get_entry_number (grub_menu_t menu, const char *name)
for (i = 0; e; i++)
{
if (grub_strcmp (e->title, val) == 0)
if (menuentry_eq (e->title, val))
{
entry = i;
break;
@ -590,7 +686,7 @@ static struct grub_menu_execute_callback execution_callback =
};
static grub_err_t
show_menu (grub_menu_t menu, int nested)
show_menu (grub_menu_t menu, int nested, int autobooted)
{
while (1)
{
@ -609,22 +705,26 @@ show_menu (grub_menu_t menu, int nested)
grub_cls ();
if (auto_boot)
grub_menu_execute_with_fallback (menu, e, &execution_callback, 0);
grub_menu_execute_with_fallback (menu, e, autobooted,
&execution_callback, 0);
else
grub_menu_execute_entry (e);
grub_menu_execute_entry (e, 0);
if (autobooted)
break;
}
return GRUB_ERR_NONE;
}
grub_err_t
grub_show_menu (grub_menu_t menu, int nested)
grub_show_menu (grub_menu_t menu, int nested, int autoboot)
{
grub_err_t err1, err2;
while (1)
{
err1 = show_menu (menu, nested);
err1 = show_menu (menu, nested, autoboot);
autoboot = 0;
grub_print_error ();
if (grub_normal_exit_level)

View file

@ -1227,7 +1227,7 @@ run (struct screen *screen)
{
if (menu && menu->size)
{
grub_show_menu (menu, 1);
grub_show_menu (menu, 1, 0);
grub_normal_free_menu (menu);
}
grub_env_context_close ();

View file

@ -26,7 +26,7 @@
#include <grub/msdos_partition.h>
#ifdef GRUB_UTIL
#include <grub/util/misc.h>
#include <grub/emu/misc.h>
#endif
static struct grub_partition_map grub_bsdlabel_partition_map;
@ -101,7 +101,8 @@ iterate_real (grub_disk_t disk, grub_disk_addr_t sector, int freebsd,
#ifdef GRUB_UTIL
char *partname;
/* disk->partition != NULL as 0 < delta */
partname = grub_partition_get_name (disk->partition);
partname = disk->partition ? grub_partition_get_name (disk->partition)
: "";
grub_util_warn ("Discarding improperly nested partition (%s,%s,%s%d)",
disk->name, partname, p.partmap->name, p.number + 1);
grub_free (partname);

View file

@ -271,14 +271,14 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
break;
}
if (end >= *nsectors + 1)
if (end >= *nsectors + 2)
{
int i, j;
unsigned i, j;
char *embed_signature_check;
unsigned int orig_nsectors;
orig_nsectors = *nsectors;
*nsectors = end - 1;
*nsectors = end - 2;
*sectors = grub_malloc (*nsectors * sizeof (**sectors));
if (!*sectors)
return grub_errno;

View file

@ -25,6 +25,8 @@
static unsigned
round_up_exp (unsigned v)
{
COMPILE_TIME_ASSERT (sizeof (v) == 4);
v--;
v |= v >> 1;
v |= v >> 2;
@ -32,9 +34,6 @@ round_up_exp (unsigned v)
v |= v >> 8;
v |= v >> 16;
if (sizeof (v) > 4)
v |= v >> 32;
v++;
v += (v == 0);

View file

@ -494,7 +494,7 @@ static int
grub_keyboard_getkey (void)
{
int key;
int is_break;
int is_break = 0;
key = fetch_key (&is_break);
if (key == -1)

View file

@ -53,7 +53,7 @@ grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *name,
grub_err_t grub_env_context_open (void);
grub_err_t grub_env_context_close (void);
grub_err_t grub_env_export (const char *name);
grub_err_t EXPORT_FUNC(grub_env_export) (const char *name);
void grub_env_unset_menu (void);
grub_menu_t grub_env_get_menu (void);

View file

@ -39,8 +39,8 @@ struct grub_file
/* The file size. */
grub_off_t size;
/* If file is not easly seekable. Should be set by underlying layer. */
int not_easly_seekable;
/* If file is not easily seekable. Should be set by underlying layer. */
int not_easily_seekable;
/* Filesystem-specific data. */
void *data;
@ -123,7 +123,7 @@ grub_file_tell (const grub_file_t file)
static inline int
grub_file_seekable (const grub_file_t file)
{
return !file->not_easly_seekable;
return !file->not_easily_seekable;
}
#endif /* ! GRUB_FILE_HEADER */

View file

@ -79,9 +79,13 @@ struct grub_e820_mmap
grub_uint32_t type;
} __attribute__((packed));
#define GRUB_VIDEO_LINUX_TYPE_TEXT 0x01
#define GRUB_VIDEO_LINUX_TYPE_VESA 0x23 /* VESA VGA in graphic mode. */
#define GRUB_VIDEO_LINUX_TYPE_SIMPLE 0x70 /* Linear framebuffer without any additional functions. */
enum
{
GRUB_VIDEO_LINUX_TYPE_TEXT = 0x01,
GRUB_VIDEO_LINUX_TYPE_VESA = 0x23, /* VESA VGA in graphic mode. */
GRUB_VIDEO_LINUX_TYPE_EFIFB = 0x70, /* EFI Framebuffer. */
GRUB_VIDEO_LINUX_TYPE_SIMPLE = 0x70 /* Linear framebuffer without any additional functions. */
};
/* For the Linux/i386 boot protocol version 2.03. */
struct linux_kernel_header

View file

@ -106,6 +106,12 @@ enum grub_ieee1275_flag
/* OLPC / XO firmware has the cursor ON/OFF routines. */
GRUB_IEEE1275_FLAG_HAS_CURSORONOFF,
/* Some PowerMacs claim to use 2 address cells but in fact use only 1.
Other PowerMacs claim to use only 1 and really do so. Always assume
1 address cell is used on PowerMacs.
*/
GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS,
};
extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag);

View file

@ -0,0 +1,31 @@
/* cmdline.h - linux command line handling */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_CMDLINE_HEADER
#define GRUB_CMDLINE_HEADER 1
#include <grub/types.h>
#define LINUX_IMAGE "BOOT_IMAGE="
unsigned int grub_loader_cmdline_size (int argc, char *argv[]);
int grub_create_loader_cmdline (int argc, char *argv[], char *buf,
grub_size_t size);
#endif /* ! GRUB_CMDLINE_HEADER */

View file

@ -94,11 +94,6 @@ typedef struct grub_menu_execute_callback
grub_menu_entry_t grub_menu_get_entry (grub_menu_t menu, int no);
int grub_menu_get_timeout (void);
void grub_menu_set_timeout (int timeout);
void grub_menu_execute_entry (grub_menu_entry_t entry);
void grub_menu_execute_with_fallback (grub_menu_t menu,
grub_menu_entry_t entry,
grub_menu_execute_callback_t callback,
void *callback_data);
void grub_menu_entry_run (grub_menu_entry_t entry);
int grub_menu_get_default_entry_index (grub_menu_t menu);

View file

@ -89,7 +89,7 @@ void grub_print_message_indented (const char *msg, int margin_left,
void
grub_menu_text_register_instances (int entry, grub_menu_t menu, int nested);
grub_err_t
grub_show_menu (grub_menu_t menu, int nested);
grub_show_menu (grub_menu_t menu, int nested, int autobooted);
/* Defined in `handler.c'. */
void read_handler_list (void);

View file

@ -119,6 +119,7 @@ cat <<EOF >${cfgfile}
grubshell=yes
insmod serial
serial
terminfo serial dumb
terminal_input serial
terminal_output serial
EOF

View file

@ -64,7 +64,7 @@ if test -f "${sysconfdir}/default/grub" ; then
. "${sysconfdir}/default/grub"
fi
bootloader_id="$(echo "$GRUB_DISTRIBUTOR" | tr '[A-Z]' '[a-z]' | cut -d' ' -f1)"
bootloader_id="$(echo "$GRUB_DISTRIBUTOR" | tr 'A-Z' 'a-z' | cut -d' ' -f1)"
if test -z "$bootloader_id"; then
bootloader_id=grub
fi
@ -270,6 +270,11 @@ if test "x$install_device" = x && ([ "${target_cpu}-${platform}" = "i386-pc" ] \
exit 1
fi
if ! ([ "${target_cpu}-${platform}" = "i386-pc" ] \
|| [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ]); then
install_device=
fi
# If the debugging feature is enabled, print commands.
setup_verbose=
if test x"$debug" = xyes; then
@ -516,27 +521,24 @@ if [ "x${devabstraction_module}" = "x" ] ; then
# Strip partition number
grub_partition="`echo "${grub_drive}" | sed -e 's/^[^,]*[,)]//; s/)$//'`"
grub_drive="`echo "${grub_drive}" | sed -e s/,[a-z0-9,]*//g`"
if [ "$disk_module" = ata ] ; then
if [ "$disk_module" = ata ] || [ "x${grub_drive}" != "x${install_drive}" ] || ([ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${target_cpu}-${platform}" != x"sparc64-ieee1275" ]) ; then
# generic method (used on coreboot and ata mod)
uuid="`"$grub_probe" --device-map="${device_map}" --target=fs_uuid --device "${grub_device}"`"
if [ "x${uuid}" = "x" ] ; then
echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
if [ "x$platform" != xefi ] && [ "x$platform" != xpc ] && [ x"${target_cpu}-${platform}" != x"sparc64-ieee1275" ]; then
echo "UUID needed with $platform, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
elif [ "$disk_module" = ata ]; then
echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
else
echo "UUID needed with cross-disk installs, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
fi
exit 1
fi
echo "search.fs_uuid ${uuid} root " >> "${grubdir}/load.cfg"
echo 'set prefix=($root)'"${relative_grubdir}" >> "${grubdir}/load.cfg"
config_opt="-c ${grubdir}/load.cfg "
modules="$modules search_fs_uuid"
elif [ "x${grub_drive}" != "x${install_drive}" ] ; then
uuid="`"$grub_probe" --device-map="${device_map}" --target=fs_uuid --device "${grub_device}"`"
if [ "x${uuid}" = "x" ] ; then
echo "You attempted a cross-disk install, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
exit 1
fi
echo "search.fs_uuid ${uuid} root " >> ${grubdir}/load.cfg
echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg
config_opt="-c ${grubdir}/load.cfg "
modules="$modules search_fs_uuid"
elif [ "x$platform" = xefi ] || [ "x$platform" = xpc ]; then
# we need to hardcode the partition number in the core image's prefix.
if [ x"$grub_partition" = x ]; then

View file

@ -1,5 +1,11 @@
#!/bin/sh
transform="@program_transform_name@"
prefix="@prefix@"
exec_prefix="@exec_prefix@"
bindir="@bindir@"
grub_mklayout=${bindir}/`echo grub-mklayout | sed ${transform}`
ckbcomp "$@" | $grub_mklayout -o "$1".gkb

View file

@ -23,6 +23,7 @@
#include <string.h>
#include <errno.h>
#include <grub/util/misc.h>
#include <grub/misc.h>
int
main (int argc, char **argv)
@ -78,9 +79,12 @@ main (int argc, char **argv)
{
char *oldname = NULL;
char *newsuffix;
char *ptr;
for (ptr = buf; *ptr && grub_isspace (*ptr); ptr++);
oldname = entryname;
parsed = grub_legacy_parse (buf, &entryname, &newsuffix);
parsed = grub_legacy_parse (ptr, &entryname, &newsuffix);
if (newsuffix)
{
suffixlen += strlen (newsuffix);

View file

@ -61,6 +61,12 @@ is_path_readable_by_grub ()
return 1
fi
# ... or if we can't figure out the abstraction module, for example if
# memberlist fails on an LVM volume group.
if ${grub_probe} -t abstraction $path > /dev/null 2>&1 ; then : ; else
return 1
fi
return 0
}
@ -107,7 +113,12 @@ prepare_grub_to_access_device ()
partmap="`${grub_probe} --device ${device} --target=partmap`"
for module in ${partmap} ; do
echo "insmod part_${module}"
case "${module}" in
netbsd | openbsd)
echo "insmod part_bsd";;
*)
echo "insmod part_${module}";;
esac
done
fs="`${grub_probe} --device ${device} --target=fs`"

View file

@ -859,7 +859,7 @@ void
write_font_pf2 (struct grub_font_info *font_info, char *output_file)
{
FILE *file;
grub_uint32_t leng, data;
grub_uint32_t leng;
char style_name[20], *font_name;
int offset;
struct grub_glyph_info *cur;
@ -959,12 +959,14 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file)
for (cur = font_info->glyphs_sorted;
cur < font_info->glyphs_sorted + font_info->num_glyphs; cur++)
{
data = grub_cpu_to_be32 (cur->char_code);
grub_util_write_image ((char *) &data, 4, file);
data = 0;
grub_util_write_image ((char *) &data, 1, file);
data = grub_cpu_to_be32 (offset);
grub_util_write_image ((char *) &data, 4, file);
grub_uint32_t data32;
grub_uint8_t data8;
data32 = grub_cpu_to_be32 (cur->char_code);
grub_util_write_image ((char *) &data32, 4, file);
data8 = 0;
grub_util_write_image ((char *) &data8, 1, file);
data32 = grub_cpu_to_be32 (offset);
grub_util_write_image ((char *) &data32, 4, file);
offset += 10 + cur->bitmap_size;
}
@ -976,6 +978,7 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file)
for (cur = font_info->glyphs_sorted;
cur < font_info->glyphs_sorted + font_info->num_glyphs; cur++)
{
grub_uint16_t data;
data = grub_cpu_to_be16 (cur->width);
grub_util_write_image ((char *) &data, 2, file);
data = grub_cpu_to_be16 (cur->height);

View file

@ -29,6 +29,7 @@
#include <grub/util/resolve.h>
#include <grub/misc.h>
#include <grub/offsets.h>
#include <grub/crypto.h>
#include <time.h>
#include <stdio.h>
@ -1167,12 +1168,37 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
size_t rom_size;
char *boot_path, *boot_img;
size_t boot_size;
grub_uint8_t context[GRUB_MD_SHA512->contextsize];
/* fwstart.img is the only part which can't be testes by using *-elf
target. Check it against the checksum. This checksum is obtained with
sha512sum utility after compiling on Gnewsense.
*/
const grub_uint8_t fwstart_good_hash[] =
{ 0x75, 0xbf, 0xa3, 0x0e, 0x7c, 0xd1, 0x03, 0x82,
0xe1, 0x34, 0x55, 0xd7, 0x09, 0x1e, 0x6c, 0xcc,
0xef, 0x08, 0x61, 0xc1, 0x3c, 0xd8, 0xc7, 0x9f,
0xe8, 0x2d, 0x3d, 0xb2, 0xda, 0x41, 0xd3, 0x83,
0xd7, 0xb8, 0xe3, 0xd7, 0x13, 0xec, 0x9b, 0xf6,
0xf6, 0xae, 0x6b, 0x32, 0x29, 0xc1, 0x69, 0x82,
0xfa, 0x65, 0x2d, 0x97, 0x3e, 0x83, 0x6e, 0x6c,
0xce, 0x34, 0x10, 0x59, 0x74, 0x0e, 0x96, 0x26 };
boot_path = grub_util_get_path (dir, "fwstart.img");
boot_size = grub_util_get_image_size (boot_path);
boot_img = grub_util_read_image (boot_path);
rom_size = ALIGN_UP (core_size + boot_size, 512 * 1024);
grub_memset (context, 0, sizeof (context));
GRUB_MD_SHA512->init (context);
GRUB_MD_SHA512->write (context, boot_img, boot_size);
GRUB_MD_SHA512->final (context);
if (grub_memcmp (GRUB_MD_SHA512->read (context), fwstart_good_hash,
GRUB_MD_SHA512->mdlen) != 0)
grub_util_warn ("fwstart.img doesn't match the known good version. "
"Proceed at your own risk");
if (core_size + boot_size > 512 * 1024)
grub_util_error ("firmware image is too big");
rom_size = 512 * 1024;
rom_img = xmalloc (rom_size);
memset (rom_img, 0, rom_size);

View file

@ -60,6 +60,8 @@ static struct console_grub_equivalence console_grub_equivalences_shift[] = {
{"KP_8", '8'},
{"KP_9", '9'},
{"KP_Period", '.'},
{NULL, '\0'}
};
static struct console_grub_equivalence console_grub_equivalences_unshift[] = {
@ -74,6 +76,8 @@ static struct console_grub_equivalence console_grub_equivalences_unshift[] = {
{"KP_8", GRUB_TERM_KEY_UP},
{"KP_9", GRUB_TERM_KEY_PPAGE},
{"KP_Period", GRUB_TERM_KEY_DC},
{NULL, '\0'}
};
static struct console_grub_equivalence console_grub_equivalences_common[] = {
@ -259,8 +263,9 @@ usage (int status)
fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
else
printf ("\
Usage: %s [OPTIONS] LAYOUT\n\
-o, --output set output base name file. Default is LAYOUT.gkb\n\
Usage: %s [OPTIONS]\n\
-i, --input set input filename. Default is STDIN\n\
-o, --output set output filename. Default is STDOUT\n\
-h, --help display this message and exit.\n\
-V, --version print version information and exit.\n\
-v, --verbose print verbose messages.\n\

View file

@ -337,7 +337,7 @@ write_symbol_table (FILE* fp, char *image,
else
bind = STB_LOCAL;
if ((type != STT_FUNC) && (pe_symtab->num_aux))
if ((pe_symtab->type != GRUB_PE32_DT_FUNCTION) && (pe_symtab->num_aux))
{
if (! pe_symtab->value)
type = STT_SECTION;

View file

@ -49,6 +49,7 @@
#include <grub/emu/getroot.h>
#include "progname.h"
#include <grub/reed_solomon.h>
#include <grub/msdos_partition.h>
#define _GNU_SOURCE 1
#include <argp.h>
@ -339,6 +340,12 @@ setup (const char *dir,
{
if (p->parent != container)
return 0;
/* NetBSD and OpenBSD subpartitions have metadata inside a partition,
so they are safe to ignore.
*/
if (grub_strcmp (p->partmap->name, "netbsd") == 0
|| grub_strcmp (p->partmap->name, "openbsd") == 0)
return 0;
if (dest_partmap == NULL)
{
dest_partmap = p->partmap;
@ -352,6 +359,15 @@ setup (const char *dir,
grub_partition_iterate (dest_dev->disk, identify_partmap);
if (container && grub_strcmp (container->partmap->name, "msdos") == 0
&& dest_partmap
&& (container->msdostype == GRUB_PC_PARTITION_TYPE_NETBSD
|| container->msdostype == GRUB_PC_PARTITION_TYPE_OPENBSD))
{
grub_util_warn (_("Attempting to install GRUB to a disk with multiple partition labels or both partition label and filesystem. This is not supported yet."));
goto unable_to_embed;
}
fs = grub_fs_probe (dest_dev);
if (!fs)
grub_errno = GRUB_ERR_NONE;

View file

@ -84,11 +84,16 @@ if [ -n "${GRUB_VIDEO_BACKEND}" ]; then
EOF
else
# Insert all available backends; GRUB will use the most appropriate.
have_video=0;
for backend in $(cat "${GRUB_PREFIX}/video.lst"); do
have_video=1;
cat <<EOF
insmod ${backend}
EOF
done
if [ x$have_video = x0 ]; then
echo "true"
fi
fi
cat <<EOF
}

View file

@ -28,7 +28,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU
else
OS="${GRUB_DISTRIBUTOR} GNU/Hurd"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}"
fi
at_least_one=false

View file

@ -31,7 +31,7 @@ CLASS="--class os"
case "${GRUB_DISTRIBUTOR}" in
Debian)
OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) --class gnu-kfreebsd --class gnu ${CLASS}"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) --class gnu-kfreebsd --class gnu ${CLASS}"
;;
*)
OS="FreeBSD"

View file

@ -32,7 +32,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux
else
OS="${GRUB_DISTRIBUTOR} GNU/Linux"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}"
fi
# loop-AES arranges things so that /dev/loop/X can be our root device, but

View file

@ -27,11 +27,65 @@ export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@localedir@
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=NetBSD
OS="NetBSD"
else
OS="${GRUB_DISTRIBUTOR} NetBSD"
fi
netbsd_load_fs_module ()
{
loader="$1" # "knetbsd" or "multiboot"
kernel="$2" # absolute path to the kernel file
case $(zcat -f "${kernel}" | file -bL - | cut -d , -f 2 | tr -d ' ') in
Intel80386)
karch="i386"
;;
x86-64)
karch="amd64"
;;
*)
return
;;
esac
case $(${grub_probe} --target=fs -d ${GRUB_DEVICE}) in
ext2)
kmod="ext2fs"
;;
fat)
kmod="msdosfs"
;;
ntfs)
kmod="ntfs"
;;
ufs*)
kmod="ffs"
;;
*)
return
;;
esac
kversion=$(zcat -f "${kernel}" | strings | sed -n -e '/^@(#)NetBSD/ { s/^@(#)NetBSD \([0-9\.]*\) .*$/\1/g ; p ; q ; }')
kmodule="/stand/${karch}/${kversion}/modules/${kmod}/${kmod}.kmod"
if test -z "$karch" -o -z "$kversion" -o ! -f "${kmodule}"; then
return
fi
kmodule_rel=$(make_system_path_relative_to_its_root "$kmodule") || return
prepare_grub_to_access_device $(${grub_probe} -t device "${kmodule}") | sed -e 's,^, ,'
case "${loader}" in
knetbsd)
printf "\tknetbsd_module_elf %s\n" "${kmodule_rel}"
;;
multiboot)
printf "\tmodule %s\n" "${kmodule_rel}"
;;
esac
}
netbsd_entry ()
{
loader="$1" # "knetbsd" or "multiboot"
@ -59,6 +113,9 @@ netbsd_entry ()
"${kernel}" "${kernel}" "${kroot_device}" "${GRUB_CMDLINE_NETBSD} ${args}"
;;
esac
netbsd_load_fs_module "${loader}" "${kernel}"
printf "}\n"
}
@ -72,8 +129,7 @@ for k in $(ls -t /netbsd*) ; do
if ! grub_file_is_not_garbage "$k" ; then
continue
fi
if ! ((file -bL "$k" | grep -q "${pattern}") ||
(zcat "$k" | file -bL - | grep -q "${pattern}")) 2>/dev/null ; then
if ! (zcat -f "$k" | file -bL - | grep -q "${pattern}") 2>/dev/null ; then
continue
fi

View file

@ -32,7 +32,7 @@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux
else
OS="${GRUB_DISTRIBUTOR} GNU/Linux"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr 'A-Z' 'a-z' | cut -d' ' -f1) ${CLASS}"
fi
# loop-AES arranges things so that /dev/loop/X can be our root device, but
@ -98,6 +98,9 @@ linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
version=$(echo $basename | sed -e "s,^[^0-9]*-,,g")
if grub_file_is_not_garbage "$i" && grep -qx "CONFIG_XEN_DOM0=y" /boot/config-${version} 2> /dev/null ; then echo -n "$i " ; fi
done`
if [ "x${linux_list}" = "x" ] ; then
exit 0
fi
xen_list=`for i in /boot/xen*; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
done`

View file

@ -377,8 +377,8 @@ grub_util_devname_to_ofpath (const char *devname)
if (! name_buf)
grub_util_error ("cannot get the real path of `%s'", devname);
device = get_basename (devname);
devnode = strip_trailing_digits (devname);
device = get_basename (name_buf);
devnode = strip_trailing_digits (name_buf);
devicenode = strip_trailing_digits (device);
ofpath = xmalloc (OF_PATH_MAX);
@ -391,6 +391,13 @@ grub_util_devname_to_ofpath (const char *devname)
else if (device[0] == 'v' && device[1] == 'd' && device[2] == 'i'
&& device[3] == 's' && device[4] == 'k')
of_path_of_vdisk(ofpath, name_buf, device, devnode, devicenode);
else if (device[0] == 'f' && device[1] == 'd'
&& device[2] == '0' && device[3] == '\0')
/* All the models I've seen have a devalias "floppy".
New models have no floppy at all. */
strcpy (ofpath, "floppy");
else
grub_util_error ("unknown device type %s\n", device);
free (devnode);
free (devicenode);