Compare commits

..

16 Commits

Author SHA1 Message Date
Vladimir Serbinenko
3635094bf4 .org simplification 2013-12-24 02:48:31 +01:00
Vladimir Serbinenko
aeebec13ab Fix .org 2013-12-24 02:31:44 +01:00
Vladimir Serbinenko
3863ea6088 Replace .= with .org 2013-12-24 01:22:27 +01:00
Vladimir Serbinenko
0290aa8596 Check for .code16 support 2013-12-24 01:17:34 +01:00
Vladimir Serbinenko
09f5da1df6 Remove addr32 2013-12-24 01:11:32 +01:00
Vladimir Serbinenko
002ba123eb Remove useless addr32 2013-12-24 00:47:58 +01:00
Vladimir Serbinenko
a7831929d3 remove data32 2013-12-24 00:44:07 +01:00
Vladimir Serbinenko
2cbee7340c Merge branch 'master' into phcoder/scratch
Conflicts:
	grub-core/kern/arm/cache_armv6.S
	grub-core/kern/uboot/init.c
	include/grub/arm/system.h
2013-12-24 00:33:47 +01:00
Vladimir Serbinenko
850da8e056 dmraid 2013-12-24 00:32:40 +01:00
Colin Watson
f9fa053b69 mkconfig fix by Colin 2013-12-24 00:32:20 +01:00
Vladimir Serbinenko
2f1fd54c38 Skip apple ghosts 2013-12-24 00:05:22 +01:00
Vladimir Serbinenko
df056a2788 Gain more info about vendor path 2013-12-23 22:45:56 +01:00
Vladimir Serbinenko
1d83f4d467 Merge branch 'master' into phcoder/scratch 2013-12-23 04:16:55 +01:00
Vladimir Serbinenko
b2b8ed7032 ARM cache 2013-12-23 04:14:24 +01:00
Vladimir Serbinenko
4b03082fa9 EFI debug 2013-12-22 23:15:43 +01:00
Vladimir Serbinenko
d5edef1a77 Half boot time on pi when using standalone by using greffs 2013-12-22 21:17:54 +01:00
391 changed files with 4604 additions and 11707 deletions

7
.gitignore vendored
View File

@@ -58,8 +58,6 @@ grub-emu.exe
grub-emu-lite.exe
grub_emu_init.c
grub_emu_init.h
/grub-file
/grub-file.exe
grub-fstest
grub-fstest.exe
grub_fstest_init.c
@@ -68,8 +66,6 @@ grub_func_test
grub-install
grub-install.exe
grub-kbdcomp
/grub-macbless
/grub-macbless.exe
grub-macho2img
/grub-menulst2cfg
/grub-menulst2cfg.exe
@@ -124,8 +120,6 @@ grub-shell
grub-shell-tester
grub-sparc64-setup
grub-sparc64-setup.exe
/grub-syslinux2cfg
/grub-syslinux2cfg.exe
gzcompress_test
hddboot_test
help_test
@@ -200,7 +194,6 @@ grub-core/modinfo.sh
grub-core/*.module
grub-core/*.module.exe
grub-core/*.pp
grub-core/kernel.img.bin
util/bash-completion.d/grub
grub-core/gnulib/alloca.h
grub-core/gnulib/arg-nonnull.h

View File

@@ -1,959 +1,3 @@
2015-01-23 Vladimir Serbinenko <phcoder@gmail.com>
* tests/file_filter/file: Really add missing file.
2015-01-23 Andrei Borzenkov <arvidjaar@gmail.com>
* grub-core/disk/xen/xendisk.c: Accept hdX as disk names on Xen to
allow legacy menu.lst processing.
2015-01-22 Felix Janda <felix.janda@posteo.de>
Remove direct _llseek code and require long filesystem libc.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
Remove potential division by 0 in gfxmenu.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/normal/menu_text.c (grub_menu_init_page): Avoid
returning 0 geometry to avoid divisions by 0.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/osdep/unix/cputime.c (grub_util_get_cpu_time_ms): Cache
sc_clk_tck and check it for sanity.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/efi/mm.c (grub_efi_get_memory_map): Never return a
descriptor_size==0 to avoid potential divisions by zero.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/osdep/haiku/getroot.c (grub_util_find_partition_start_os):
Avoid division by zero.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/generic/rtc_get_time_ms.c (grub_rtc_get_time_ms): Avoid
division by zero.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/i386/xnu.c (guessfsb): Avoid division by 0.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/i386/tsc.c (calibrate_tsc): Ensure that
no division by 0 occurs.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/misc.h (grub_div_roundup): Remove as it's unused.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/term/gfxterm.c: Avoid division by zero.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
Avoid division by zero in serial.
* grub-core/term/serial.c (grub_cmd_serial): Ensure speed is not 0.
* grub-core/term/ns8250.c (serial_get_divisor): Exit if speed is 0.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/video/readers/jpeg.c: Avoid sivision by zero.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/diskfilter.c: Validate volumes to avoid division
by zero.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/term.h: Avoid returining 0-sized terminal
as it may lead to division by zero.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/zfs.c: Avoid divisions by zero.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/btrfs.c: Avoid divisions by zero.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/lib/pbkdf2.c (grub_crypto_pbkdf2): Check that hash len is not 0.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/osdep/linux/blocklist.c (grub_install_get_blocklist): Check
blocksize validity.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/i386/pc/biosdisk.c: Check disk size sanity.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/ieee1275/nand.c (grub_nand_open): Check block size
validity.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/dmraid_nvidia.c (grub_dmraid_nv_detect): Do not
divide by zero.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/hfs.c (grub_hfs_mount): Additional filesystem
sanity checks.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/minix.c: Additional filesystem
sanity checks.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/ext2.c (grub_ext2_mount): Additional
checks for superblock validity.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/ufs.c (grub_ufs_mount): Check
that sblock.ino_per_group is not 0.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
Reject NILFS2 superblocks with over 1GiB blocks.
* grub-core/fs/nilfs2.c (grub_nilfs2_valid_sb): Check that
block size is <= 1GiB.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/ata.c (grub_ata_setaddress): Check that geometry
is sane when using CHS addressing.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/AFSplitter.c (AF_merge): Check that mdlen is not 0.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/i386/pc/play.c (grub_cmd_play): Avoid
division by zero.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/bus/usb/usbtrans.c (grub_usb_bulk_maxpacket): Avoid
potentially returning 0.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/minix.c (grub_minix_read_file): Avoid reading past
the end of file.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/fshelp.c (grub_fshelp_read_file): Don't attempt to read
past the end of file.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/script/lexer.c (grub_script_lexer_yywrap): Update len
synchronously with line.
2015-01-20 Vladimir Serbinenko <phcoder@gmail.com>
Replace explicit sizeof divisions by ARRAY_SIZE.
2015-01-19 Kris Moore <kris@pcbsd.org>
* grub-core/disk/geli.c: Support GELI v6 and v7.
2014-12-09 Andrei Borzenkov <arvidjaar@gmail.com>
* grub-core/term/serial.c (grub_cmd_serial): Fix --rtscts
option processing.
2014-12-07 David Kozub <zub.272@gmail.com>
* grub-core/kern/arm/misc.S: fix unaligned 64bit local variable
in __aeabi_uidivmod
Fixes Savannah bug #43632.
2014-12-07 Peter Nelson <peterdn>
* grub-core/fs/ext2.c (grub_ext2_read_block): Support large sparse
chunks.
2014-12-07 Andrei Borzenkov <arvidjaar@gmail.com>
* util/grub-mkconfig_lib.in (version_test_gt): Remove redundant
non-portable '-n' echo option.
* util/grub.d/10_kfreebsd.in: Change how list is built to avoid
non-portable 'echo -n.
* util/grub.d/10_linux.in: Likewise (closes 43668).
* util/grub.d/20_linux_xen.in: Likewise.
* util/grub.d/30_os-prober.in: Print spaces directly to avoid
non-portable 'echo -n'.
2014-12-07 Curtis Larsen <larsen@dixie.edu>
* grub-core/net/tcp.c (grub_net_recv_tcp_packet): Fix double
free when multiple empty segments were received (closes 42765).
2014-12-05 Andrei Borzenkov <arvidjaar@gmail.com>
* tests/util/grub-shell.in: Support --files also for netboot.
* tests/file_filter_test.in: New file with file filters tests.
* Makefile.util.def: Add file_filter_test.
* conf/Makefile.extra-dist: ... and here.
* tests/file_filter/file.gz: Test file for file_filter_test.
* tests/file_filter/file.gz.sig: Likewise.
* tests/file_filter/file.lzop: Likewise.
* tests/file_filter/file.lzop.sig: Likewise.
* tests/file_filter/file.xz: Likewise.
* tests/file_filter/file.xz.sig: Likewise.
* tests/file_filter/keys: Likewise.
* tests/file_filter/keys.pub: Likewise.
* tests/file_filter/test.cfg: Likewise.
* grub-core/commands/verify.c: Fix memory corruption doing
signature check for network files (closes 43601).
2014-12-01 Andrei Borzenkov <arvidjaar@gmail.com>
* grub-core/loader/i386/xen_fileXX.c (grub_xen_get_infoXX): Fix
memory leak (CID 73645, 73782).
* grub-core/fs/zfs/zfsinfo.c (print_vdev_info): Fix memory leak
(CID 73635).
2014-11-30 Andrei Borzenkov <arvidjaar@gmail.com>
* grub-core/lib/syslinux_parse.c (free_menu): Do not free
inline array (CID 73610).
2014-11-28 Andrei Borzenkov <arvidjaar@gmail.com>
* grub-core/io/lzopio.c (test_header): Fix double free (CID 73665)
* grub-core/disk/geli.c (configure_ciphers): Fix memory leaks
(Coverity CID 73813, 73710)
* grub-core/disk/luks.c (configure_ciphers): Fix memory leaks
and use after free (Coverity CID 73813, 73710, 73730)
* grub-core/disk/luks.c (luks_recover_key): Fix memory leak (Coverity
CID 73854)
* util/grub-install-common.c (grub_install_get_target): Check return
value of grub_util_fd_read (Coverity CID 73819).
* util/grub-mkstandalone.c (add_tar_file): Fix out of bound access
to hd.magic (Coverity CID 73587, 73888, bug 43690).
2014-11-20 Andrei Borzenkov <arvidjaar@gmail.com>
* tests/util/grub-fs-tester.in: Consistently print output
of grub ls if test fails.
2014-11-07 Leif Lindholm <leif.lindholm@linaro.org>
* grub-core/kern/efi/init.c: check value of *path before
dereferencing.
2014-11-03 Michael Chang <mchang@suse.com>
* grub-core/net/icmp6.c (grub_net_recv_icmp6_packet): Fix size
of neighbor solicitation packet in grub_netbuff_pull.
2014-10-14 Andrei Borzenkov <arvidjaar@gmail.com>
* grub-core/loader/arm/linux.c: Use full initializer for initrd_ctx to
avoid fatal warnings with older gcc (probably before 4.7).
* grub-core/loader/arm64/linux.c: Likewise.
* grub-core/loader/i386/linux.c: Likewise.
* grub-core/loader/i386/pc/linux.c: Likewise.
* grub-core/loader/ia64/efi/linux.c: Likewise.
* grub-core/loader/mips/linux.c: Likewise.
* grub-core/loader/powerpc/ieee1275/linux.c: Likewise.
* grub-core/loader/sparc64/ieee1275/linux.c: Likewise.
2014-09-25 Colin Watson <cjwatson@ubuntu.com>
Fix in-tree --platform=none
* configure.ac: Only remove include/grub/cpu and
include/grub/machine in the --platform=none case, not all of
include/grub.
2014-09-23 Colin Watson <cjwatson@ubuntu.com>
Add a new "none" platform that only builds utilities
* configure.ac: Add "none" platform. Default to it for unsupported
CPUs rather than stopping with a fatal error. Don't downgrade
x86_64-none to i386. Define COND_real_platform Automake conditional
if the platform is anything other than "none". Don't do any include
directory linking for "none".
* Makefile.am: Skip building grub-core and all bootcheck targets if
!COND_real_platform.
* include/grub/time.h: Don't include <grub/cpu/time.h> if GRUB_UTIL
is defined.
2014-09-22 Andrei Borzenkov <arvidjaar@gmail.com>
Use grub_cpu_to_XXX_compile_time for constants.
2014-09-21 Valentin Dornauer <valentin@unimplemented.org>
The AML parser implements only a small subset of possible AML
opcodes. On the Fujitsu Lifebook E744 this and another bug in
the parser (incorrect handling of TermArg data types) would lead
to the laptop not turning off (_S5 not found).
* grub-core/commands/acpihalt.c: Support OpAlias in the AML parser;
in skip_ext_op(), handle some Type2Opcodes more correctly (TermArgs
aren't always simply strings!); Add function to skip TermArgs
* include/grub/acpi.h: Add new opcodes
2014-09-21 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/normal/main.c: Don't drop to rescue console in
case of password-protected prompt and no menu entries.
2014-09-21 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/keylayouts.c: Ignore unknown keys.
2014-09-21 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/gmodule.pl.in: Accept newer binutils which output
empty column rather than 0x0.
2014-09-21 Michael Chang <mchang@suse.com>
* grub-core/osdep/unix/config.c: Remove extraneous comma.
2014-09-21 Peter Jones <pjones@redhat.com>
* grub-core/loader/arm/linux.c: Initialized initrd_ctx so
we don't free a random pointer from the stack.
* grub-core/loader/arm64/linux.c: Likewise.
* grub-core/loader/i386/linux.c: Likewise.
* grub-core/loader/i386/pc/linux.c: Likewise.
* grub-core/loader/ia64/efi/linux.c: Likewise.
* grub-core/loader/mips/linux.c: Likewise.
* grub-core/loader/powerpc/ieee1275/linux.c: Likewise.
* grub-core/loader/sparc64/ieee1275/linux.c: Likewise.
2014-09-15 Khem Raj <raj.khem@gmail.com>
* grub-core/kern/emu/hostfs.c: use _DEFAULT_SOURCE in addition to
_BSD_SOURCE to avoid warnings under glibc 2.20+.
2014-09-08 Michael Chang <mchang@suse.com>
* grub-core/fs/btrfs.c (grub_btrfs_extent_read): Fix extent size
check; comparing &data->extent against addresses in the region it
points to is unpredictable.
2014-09-07 Colin Watson <cjwatson@ubuntu.com>
Support grub-emu on x32 (ILP32 but with x86-64 instruction set)
* configure.ac: Remove -m64 from checks for -mcmodel=large and
-mno-red-zone. These are always either unnecessary (x86_64-emu) or
already in TARGET_CFLAGS at this point, and they produce incorrect
results when building for x32.
* grub-core/kern/x86_64/dl.c (grub_arch_dl_relocate_symbols): Cast
pointers to Elf64_Xword via grub_addr_t, in order to work on x32.
* include/grub/x86_64/types.h (GRUB_TARGET_SIZEOF_VOID_P,
GRUB_TARGET_SIZEOF_LONG): Define to 4 on x32.
2014-09-07 Colin Watson <cjwatson@ubuntu.com>
* configure.ac: Remove several unnecessary semicolons.
2014-08-25 Colin Watson <cjwatson@ubuntu.com>
* grub-core/kern/mips/arc/init.c (grub_machine_get_bootlocation):
Initialise pend to pacify GCC.
2014-08-14 Andrey Borzenkov <arvidjaar@gmail.com>
* util/grub-mkconfig.in: Fix typo (gettext_print instead of
gettext_printf).
2014-08-13 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/term/at_keyboard.c: Retry probing keyboard if
scancode setup failed.
2014-08-10 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/disk_common.c: Clump disk size to 1EiB.
2014-08-10 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Add
safety to avoid triggerring VirtualBox bug.
2014-08-10 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/cbfs.c: Don't probe disks of unknow size.
Fixes hang on virtualbox.
2014-07-08 Colin Watson <cjwatson@ubuntu.com>
* util/grub.d/10_hurd.in: Make kernel list progression not fail on
kernels whose paths contain regex metacharacters.
* util/grub.d/10_kfreebsd.in: Likewise.
* util/grub.d/10_linux.in: Likewise.
* util/grub.d/20_linux_xen.in: Likewise.
Reported by: Heimo Stranner.
2014-06-26 Colin Watson <cjwatson@ubuntu.com>
* docs/grub-dev.texi (Finding your way around): The build system no
longer uses AutoGen directly.
2014-06-21 Роман Пехов <roman_pekhov>
* grub-core/commands/loadenv.c (check_blocklists): Fix overlap check.
2014-06-21 Glenn Washburn <development@efficientek.com>
* util/grub-install.c: Fix handling of --disk-module.
2014-06-21 Stephane Rochoy <sheda>
* grub-core/loader/i386/bsd.c (grub_netbsd_boot): Pass pointer to
EFI system table.
2014-06-21 Stephane Rochoy <sheda>
* grub-core/commands/efi/lsefisystab.c (grub_cmd_lsefisystab): Show
EFI system table physical address.
2014-06-21 Trevor Woerner <trevor.woerner@linaro.org>
* util/grub-gen-asciih.c (add_glyph): Fix uninitialised variable.
2014-06-21 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/verify.c (grub_pubkey_open): Trust procfs.
2014-06-21 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/verify.c (grub_pubkey_open): Fix memdisk
check.
2014-04-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/misc.c (__bzero): Don't compile in GRUB_UTIL.
Reported by: Yves Blusseau <blusseau@zetam.org>.
2014-04-20 Piotr Krysiuk <piotras@gmail.com>
* grub-core/lib/i386/relocator.c: Allow loading old kernels by placing
GDT in conventional memory.
2014-04-10 Colin Watson <cjwatson@ubuntu.com>
* util/grub.d/30_os-prober.in: Tolerate devices with no filesystem
UUID. Other parts of grub-mkconfig tolerate these, they were
previously allowed here up to commit
55e706c918922def17f5012c23cfe88c4c645208, and they can arise in
practice when the system has active LVM snapshots.
Fixes Ubuntu bug #1287436.
2014-04-10 Colin Watson <cjwatson@ubuntu.com>
* grub-core/disk/lvm.c (grub_lvm_detect): Search for
"logical_volumes" block a little more accurately.
2014-04-06 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/lib/syslinux_parse.c: Fix timeout quoting.
2014-04-04 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/libgcc.h: Remove ctzsi2 and ctzdi2. They're no longer
pulled from libgcc.
2014-04-04 Vladimir Serbinenko <phcoder@gmail.com>
Replace few instances of memcmp/memcpy in the code that should be
grub_memcmp/grub_memcpy.
2014-04-03 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Support NVMe
device names.
2014-03-31 Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
btrfs: fix get_root key comparison failures due to endianness
* grub-core/fs/btrfs.c (get_root): Convert
GRUB_BTRFS_ROOT_VOL_OBJECTID to little-endian.
2014-03-31 Colin Watson <cjwatson@ubuntu.com>
Fix partmap, cryptodisk, and abstraction handling in grub-mkconfig.
Commit 588744d0dc655177d5883bdcb8f72ff5160109ed caused grub-mkconfig
no longer to be forgiving of trailing spaces on grub-probe output
lines, which among other things means that util/grub.d/10_linux.in
no longer detects LVM. To fix this, make grub-probe's output
delimiting more consistent. As a bonus, this improves the coverage
of the -0 option.
Fixes Debian bug #735935.
* grub-core/disk/cryptodisk.c
(grub_util_cryptodisk_get_abstraction): Add a user-data argument.
* grub-core/disk/diskfilter.c (grub_diskfilter_get_partmap):
Likewise.
* include/grub/cryptodisk.h (grub_util_cryptodisk_get_abstraction):
Update prototype.
* include/grub/diskfilter.h (grub_diskfilter_get_partmap): Likewise.
* util/grub-install.c (push_partmap_module, push_cryptodisk_module,
probe_mods): Adjust for extra user-data arguments.
* util/grub-probe.c (do_print, probe_partmap, probe_cryptodisk_uuid,
probe_abstraction): Use configured delimiter. Update callers.
2014-03-31 Colin Watson <cjwatson@ubuntu.com>
* util/grub-probe,c (options): Make -0 work again (broken by
conversion to argp).
(main): Simplify logic.
2014-03-26 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/lib/relocator.c: Fix the case when end of leftover is used.
2014-03-26 Fu Wei <fu.wei@linaro.org>
* grub-core/loader/arm64/linux.c: Remove redundant "0x".
2014-02-28 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/i386/openbsd_bootarg.h: Add addr and frequency fields.
* grub-core/loader/i386/bsd.c (grub_cmd_openbsd): Fill addr field.
Suggested by: Markus Müller.
2014-02-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/i386/pc/mmap.c: Fallback to EISA memory map
if E820 failed to return any regions.
2014-02-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/mmap/i386/uppermem.c (lower_hook) [COREBOOT]: Ignore low
tables for low memory calculations.
2014-02-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi): Limit
location to 640K.
2014-02-28 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/i386/coreboot/mmap.c: Filter out 0xa0000-0x100000
region.
2014-02-20 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/ahci.c: Ignore NPORTS field and rely on PI
exclusively.
2014-02-04 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
Add bootpath parser for open firmware.
It enables net boot even when there is no bootp/dhcp server.
* grub-core/net/drivers/ieee1275/ofnet.c: Add grub_ieee1275_parse_bootpath
and call it at grub_ieee1275_net_config_real.
* grub-core/kern/ieee1275/init.c: Add bootpath to
grub_ieee1275_net_config.
* include/grub/ieee1275/ieee1275.h: Likewise.
2014-02-04 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
Add grub_env_set_net_property function.
* grub-core/net/bootp.c: Remove set_env_limn_ro.
* grub-core/net/net.c: Add grub_env_set_net_property.
* include/grub/net.h: Likewise.
2014-02-03 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkrescue.c: Build fix for argp.h with older gcc.
2014-02-03 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkfont.c: Build fix for argp.h with older gcc.
2014-01-29 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/ahci.c: Increase timeout. Some SSDs take up to
7 seconds to recover if last poweroff was bad.
2014-01-29 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/ahci.c: Properly handle transactions with no
transferred data.
2014-01-29 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/ahci.c: Add safety cleanups.
2014-01-29 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/ahci.c: Allocate and clean space for all possible 32
slots to avoid pointing to uninited area.
2014-01-29 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/ahci.c: Do not enable I/O decoding and keep
enabling busmaster for the end.
2014-01-29 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mkfont.c: Downgrade warnings about unhandled features
to debug.
2014-01-29 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/term/at_keyboard.c: Tolerate missing keyboard.
2014-01-29 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
* .gitignore: add missing files and .exe variants.
2014-01-26 Mike Gilbert <floppym@gentoo.org>
grub-install: support for partitioned partx loop devices.
* grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Detect
/dev/loopX as being the parent of /dev/loopXpY.
2014-01-26 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/term/serial.c (grub_serial_register): Fix invalid free.
Ensure that pointers are inited to NULL and that pointers are not
accessed after free.
2014-01-25 Andrey Borzenkov <arvidjaar@gmail.com>
* include/grub/crypto.h: Replace __attribute__ ((format (printf)) with
__attribute__ ((format (__printf__)) to fix compilation under MinGW-w64.
* include/grub/emu/misc.h: ... and here.
* include/grub/err.h: ... and here.
* util/import_gcry.py: ... and here (in files g10lib.h).
2014-01-25 Andrey Borzenkov <arvidjaar@gmail.com>
* util/grub-mkimage.c: Make prefix argument mandatory.
2014-01-24 Vladimir Serbinenko <phcoder@gmail.com>
Fix several translatable strings.
Suggested by: D. Prévot.
2014-01-24 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-install.c: List available targets.
2014-01-23 Colin Watson <cjwatson@ubuntu.com>
* util/grub-install.c (write_to_disk): Add an info message.
2014-01-21 Andrey Borzenkov <arvidjaar@gmail.com>
* Makefile.am: Allow adding extra files to generated Windows ZIP
archive by setting GRUB_WINDOWS_EXTRA_DIST.
2014-01-21 Andrey Borzenkov <arvidjaar@gmail.com>
* configure.ac: Look for DejaVuSans also in /usr/share/fonts/truetype.
Show detected font path in summary.
2014-01-21 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
* grub-core/net/arp.c (grub_net_arp_send_request): Increase network try
interval gradually.
* grub-core/net/icmp6.c (grub_net_icmp6_send_request): Likewise.
* grub-core/net/net.c (grub_net_fs_read_real): Likewise.
* grub-core/net/tftp.c (tftp_open): Likewise.
* include/grub/net.h (GRUB_NET_INTERVAL_ADDITION): New define.
2014-01-21 Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
* grub-core/net/net.c (receive_packets): Change stop condition to avoid
infinite loops.
In net/net.c there is a while (1) that only exits if there is a stop
condition and more then 10 packages or if there is no package received.
If GRUB is idle and enter in this loop, the only condition to leave is
if it doesn't have incoming packages. In a network with heavy traffic
this never happens.
2014-01-19 Colin Watson <cjwatson@ubuntu.com>
* grub-core/osdep/freebsd/hostdisk.c (grub_util_fd_open): Ignore
EPERM when modifying kern.geom.debugflags. It is only a problem for
such things as installing GRUB to the MBR, in which case there'll be
an error later anyway, not for opening files during tests.
2014-01-18 Andrey Borzenkov <arvidjaar@gmail.com>
* grub-core/Makefile.am: Build grub_emu_init.[ch] from MODULE_FILES
instead of MOD_FILES.
* grub-core/genemuinit.sh: Simplify stripping of suffix so it works
both with and without .exe.
* grub-core/genemuinitheader.sh: Same.
2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-install.c: Fix a typo.
2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/normal/main.c (read_config_file): Buffer config file.
Reduces boot time.
2014-01-18 Andrey Borzenkov <arvidjaar@gmail.com>
* acinclude.m4 (grub_CHECK_LINK_DIR): Check that we can also remove
symbolic link to directory. It fails in Msys shell on Windows 2003.
2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
* Makefile.am (default_payload.elf): Add modules
multiboot cbmemc linux16 gzio echo help.
2014-01-18 Mike Gilbert <floppym@gentoo.org>
* Makefile.util.def: Link grub-ofpathname with zfs libs.
2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/macbless.c: Rename FILE and DIR to avoid
conflicts.
Reported by: Andrey Borzenkov.
2014-01-18 Andrey Borzenkov <arvidjaar@gmail.com>
* include/grub/misc.h: Move macros for compiler features to ...
* include/grub/compiler.h: ... new file.
* include/grub/list.h: Include <grub/compiler.h> instead of <grub/misc.h>.
* grub-core/commands/fileXX.c: Include <grub/misc.h>.
* grub-core/efiemu/prepare.c: Include <grub/misc.h>.
* grub-core/loader/i386/xen_file.c: Include <grub/misc.h>.
* grub-core/loader/i386/xen_fileXX.c: Include <grub/misc.h>.
* grub-core/video/capture.c: Include <grub/misc.h>.
* include/grub/command.h: Include <grub/misc.h>.
* include/grub/dl.h: Include <grub/misc.h>.
* include/grub/procfs.h: Include <grub/misc.h>.
2014-01-18 Andrey Borzenkov <arvidjaar@gmail.com>
* configure.ac: Add support for BUILD_EXEEXT and use it ...
* Makefile.am: ... here.
* Makefile.util.def: ... and here.
* grub-core/Makefile.am: ... and here.
2014-01-18 Andrey Borzenkov <arvidjaar@gmail.com>
* include/grub/osdep/hostfile_windows.h: Use _W64 instead of
FILE_OFFSET_BITS to differentiate between native MinGW and Mingw W64.
2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/term/terminfo.c: Recognize keys F1-F12.
2014-01-18 Andrey Borzenkov <arvidjaar@gmail.com>
* configure.ac: Add support for BUILD_LDFLAGS.
* Makefile.am: Use BUILD_LDFLAGS for build time programs here ...
* grub-core/Makefile.am: ... and here.
* INSTALL: Mention BUILD_LDFLAGS.
2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-mount.c: Extend GCC warning workaround to grub-mount.
2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/efi/efi.c: Ensure that the result starts with /
and has no //.
2014-01-18 Vladimir Serbinenko <phcoder@gmail.com>
* NEWS: Add few missing entries.
2014-01-17 Colin Watson <cjwatson@ubuntu.com>
* util/grub.d/00_header.in (make_timeout): Use && rather than test
-a.
* util/grub.d/10_windows.in: Likewise.
* util/grub.d/10_netbsd.in (netbsd_load_fs_module): Use || rather
than test -o.
* util/grub.d/30_os-prober.in: Use && rather than test -a, and ||
rather than test -o.
2014-01-17 Colin Watson <cjwatson@ubuntu.com>
* grub-core/osdep/freebsd/hostdisk.c (grub_util_fd_open): Remove
redundant preprocessor conditional.
2014-01-08 Colin Watson <cjwatson@ubuntu.com>
* Makefile.util.def (grub-macbless): Change mansection to 8.
2014-01-07 Leif Lindholm <leif.lindholm@linaro.org>
* grub-core/loader/arm64/linux.c: correctly set device path end length.
2014-01-07 Andrey Borzenkov <arvidjaar@gmail.com>
* util/grub-install.c: Use bootaa64.efi instead of bootaarch64.efi on
arm64 to comply with EFI specification. Also use grubaa64.efi for
consistency.
* util/grub-mkrescue.c: Change to use bootaa64.efi too.
2014-01-07 Andrey Borzenkov <arvidjaar@gmail.com>
* include/grub/osdep/hostfile_windows.h: Do not redefine fseeko/ftello
on MinGW-64 when compiling for 32 bits.
2013-12-30 Andrey Borzenkov <arvidjaar@gmail.com>
* grub-core/Makefile.core.def: strip .eh_frame section for arm64-efi.
2013-12-30 Vladimir Serbinenko <phcoder@gmail.com>
* NEWS: Add few missing entries. Correct existing ones.
2013-12-28 Vladimir Serbinenko <phcoder@gmail.com>
Don't abort() on unavailable coreboot tables if not running on coreboot.
2013-12-28 Andrey Borzenkov <arvidjaar@gmail.com>
* grub-core/kern/emu/misc.c: Remove unused error.h; fixes compilation
on mingw.
2013-12-28 Colin Watson <cjwatson@ubuntu.com>
* NEWS: The cmosclean command in fact dates back to 1.99. Remove
mention of it from 2.02.
2013-12-27 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/kern/arm/cache_armv6.S: Remove .arch directive.
As these functions are used on pre-ARMv6 CPUs as well we don't want
to make assembler assume that architecture is higher than default one.
2013-12-27 Colin Watson <cjwatson@ubuntu.com>
* NEWS: First draft of 2.02 entry.
2013-12-27 Colin Watson <cjwatson@ubuntu.com>
* INSTALL (Cross-compiling the GRUB): Fix some spelling mistakes.
* docs/grub.texi (Getting the source code): Likewise.
2013-12-25 Andrey Borzenkov <arvidjaar@gmail.com>
* grub-core/osdep/windows/platform.c (get_platform): Fix EFI
detection.
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
* configure.ac: Set version to 2.02~beta2.
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/disk/efi/efidisk.c (name_devices): Skip Apple ghosts.
2013-12-24 Andrey Borzenkov <arvidjaar@gmail.com>
* util/grub-probe.c: Improve help message and simplify list handling.
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
Fix buffer overflow in grub_efi_print_device_path.
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
Show SATA device path.
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
Revert grub-file usage in grub-mkconfig.
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
Make newly-created files other than grub.cfg world-readable.
2013-12-24 Andrey Borzenkov <arvidjaar@gmail.com>
* util/grub.d/00_header.in: Improve compatibility with old config.
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
Make rijndael.c respect aliasing rules.
Trivial backport of dfb4673da8ee52d95e0a62c9f49ca8599943f22e.
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
Make grub_util_device_is_mapped_stat available in grub-emu core.
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
Add -Qn to TARGET_CFLAGS if it's supported.
Fixes compilation on cygwin.
Reported by: Andrey Borzenkov.
Suggested by: Andrey Borzenkov.
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
Save TARGET_CC version in modinfo.sh.
Suggested by: Andrey Borzenkov.
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
Make grub_util_devmapper_part_to_disk and grub_util_find_partition_start
follow the same algorithm to avoid method mismatch. Don't assume
DMRAID- UUID to mean full disk but instead check that mapping is linear.
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
Declare GRUB_EFI_VENDOR_APPLE_GUID.
2013-12-24 Vladimir Serbinenko <phcoder@gmail.com>
Dump type and vendor specific data when printing device path.
2013-12-23 Colin Watson <cjwatson@debian.org>
Update some documentation to refer to Git rather than Bazaar.
@@ -1295,6 +339,10 @@
Allow compilation without thumb-interwork as long as no thumb is
involved or only thumb2 is used.
2013-12-18 Vladimir Serbinenko <phcoder@gmail.com>
Use -Wl,--no-relax rather than -mno-relax for uniformity.
2013-12-18 Vladimir Serbinenko <phcoder@gmail.com>
* INSTALL: Update comment as to why sparc64 clang isn't usable.
@@ -1748,7 +796,7 @@
2013-12-14 Vladimir Serbinenko <phcoder@gmail.com>
* .gitignore: add .exe variants. add missing files. remove few outdated
* .gitignore: Add .exe variants. Add missing files. Remove few outdated
entries.
2013-12-14 Vladimir Serbinenko <phcoder@gmail.com>

29
INSTALL
View File

@@ -13,9 +13,6 @@ configuring the GRUB.
* GCC 4.1.3 or later
Note: older versions may work but support is limited
Experimental support for clang 3.3 or later (results in much bigger binaries)
for i386, x86_64, arm (except thumb), arm64, mips(el), powerpc, sparc64
Note: clang 3.2 or later works for i386 and x86_64 targets but results in
much bigger binaries.
earlier versions not tested
@@ -29,8 +26,7 @@ configuring the GRUB.
fail.
Note: clang 3.2 or later works for powerpc
earlier versions not tested
Note: clang 3.5 or later works for sparc64
earlier versions return "error: unable to interface with target machine"
Note: clang doesn't support -mno-app-regs and so can't be used for sparc64
Note: clang has no support for ia64 and hence you can't compile GRUB
for ia64 with clang
* GNU Make
@@ -39,7 +35,6 @@ configuring the GRUB.
* GNU binutils 2.9.1.0.23 or later
* Flex 2.5.35 or later
* Other standard GNU/Unix tools
* a libc with large file support (e.g. glibc 2.1 or later)
On GNU/Linux, you also need:
@@ -104,9 +99,6 @@ The simplest way to compile this package is:
3. Type `./autogen.sh'.
* autogen.sh uses python. By default invocation is "python" but can be
overriden by setting variable $PYTHON.
4. Type `./configure' to configure the package for your system.
If you're using `csh' on an old version of System V, you might
need to type `sh ./configure' instead to prevent `csh' from trying
@@ -148,7 +140,7 @@ If build and host are different make check isn't available.
If build and host are different man pages are not generated.
As an example imagine you have a build system running on FreeBSD on sparc
which prepares packages for developers running amd64 GNU/Linux laptop and
which prepares packages for developpers running amd64 GNU/Linux laptop and
they need to make images for ARM board running U-boot. In this case:
build=sparc64-freebsd
@@ -157,7 +149,7 @@ target=arm-uboot
For this example the configure line might look like (more details below)
(some options are optional and included here for completeness but some rarely
used options are omitted):
used options are omited):
./configure BUILD_CC=gcc BUILD_FREETYPE=freetype-config --host=amd64-linux-gnu
CC=amd64-linux-gnu-gcc CFLAGS="-g -O2" FREETYPE=amd64-linux-gnu-freetype-config
@@ -176,15 +168,14 @@ corresponding platform are not needed for the platform in question.
generate sin and cos tables.
2. BUILD_CFLAGS= for C options for build.
3. BUILD_CPPFLAGS= for C preprocessor options for build.
4. BUILD_LDFLAGS= for linker options for build.
5. BUILD_FREETYPE= for freetype-config for build (optional).
4. BUILD_FREETYPE= for freetype-config for build (optional).
- For host
1. --host= to autoconf name of host.
2. CC= for gcc able to compile for host
3. HOST_CFLAGS= for C options for host.
4. HOST_CPPFLAGS= for C preprocessor options for host.
5. HOST_LDFLAGS= for linker options for host.
3. CFLAGS= for C options for host.
4. CPPFLAGS= for C preprocessor options for host.
5. LDFLAGS= for linker options for host.
6. FREETYPE= for freetype-config for host (optional).
7. Libdevmapper if any must be in standard linker folders (-ldevmapper) (optional).
8. Libfuse if any must be in standard linker folders (-lfuse) (optional).
@@ -205,9 +196,9 @@ corresponding platform are not needed for the platform in question.
11. TARGET_RANLIB= for ranlib for target.
- Additionally for emu, for host and target.
1. SDL is looked for in standard linker directories (-lSDL) (optional)
2. libpciaccess is looked for in standard linker directories (-lpciaccess) (optional)
3. libusb is looked for in standard linker directories (-lusb) (optional)
1. SDL is looked for in stadard linker directories (-lSDL) (optional)
2. libpciaccess is looked for in stadard linker directories (-lpciaccess) (optional)
3. libusb is looked for in stadard linker directories (-lusb) (optional)
- Platform-agnostic tools and data.
1. make is the tool you execute after ./configure.

View File

@@ -1,11 +1,7 @@
AUTOMAKE_OPTIONS = subdir-objects -Wno-portability
DEPDIR = .deps-util
SUBDIRS = grub-core/gnulib .
if COND_real_platform
SUBDIRS += grub-core
endif
SUBDIRS += po docs util/bash-completion.d
SUBDIRS = grub-core/gnulib . grub-core po docs util/bash-completion.d
include $(top_srcdir)/conf/Makefile.common
include $(top_srcdir)/conf/Makefile.extra-dist
@@ -70,22 +66,22 @@ endif
starfield_theme_files = $(srcdir)/themes/starfield/blob_w.png $(srcdir)/themes/starfield/boot_menu_c.png $(srcdir)/themes/starfield/boot_menu_e.png $(srcdir)/themes/starfield/boot_menu_ne.png $(srcdir)/themes/starfield/boot_menu_n.png $(srcdir)/themes/starfield/boot_menu_nw.png $(srcdir)/themes/starfield/boot_menu_se.png $(srcdir)/themes/starfield/boot_menu_s.png $(srcdir)/themes/starfield/boot_menu_sw.png $(srcdir)/themes/starfield/boot_menu_w.png $(srcdir)/themes/starfield/slider_c.png $(srcdir)/themes/starfield/slider_n.png $(srcdir)/themes/starfield/slider_s.png $(srcdir)/themes/starfield/starfield.png $(srcdir)/themes/starfield/terminal_box_c.png $(srcdir)/themes/starfield/terminal_box_e.png $(srcdir)/themes/starfield/terminal_box_ne.png $(srcdir)/themes/starfield/terminal_box_n.png $(srcdir)/themes/starfield/terminal_box_nw.png $(srcdir)/themes/starfield/terminal_box_se.png $(srcdir)/themes/starfield/terminal_box_s.png $(srcdir)/themes/starfield/terminal_box_sw.png $(srcdir)/themes/starfield/terminal_box_w.png $(srcdir)/themes/starfield/theme.txt $(srcdir)/themes/starfield/README $(srcdir)/themes/starfield/COPYING.CC-BY-SA-3.0
build-grub-mkfont$(BUILD_EXEEXT): util/grub-mkfont.c grub-core/unidata.c grub-core/kern/emu/misc.c util/misc.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-mkfont\" $^ $(build_freetype_cflags) $(build_freetype_libs)
CLEANFILES += build-grub-mkfont$(BUILD_EXEEXT)
build-grub-mkfont: util/grub-mkfont.c grub-core/unidata.c grub-core/kern/emu/misc.c util/misc.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-mkfont\" $^ $(build_freetype_cflags) $(build_freetype_libs)
CLEANFILES += build-grub-mkfont
garbage-gen$(BUILD_EXEEXT): util/garbage-gen.c
$(BUILD_CC) -o $@ $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $^
CLEANFILES += garbage-gen$(BUILD_EXEEXT)
garbage-gen: util/garbage-gen.c
$(BUILD_CC) -o $@ $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $^
CLEANFILES += garbage-gen
EXTRA_DIST += util/garbage-gen.c
build-grub-gen-asciih$(BUILD_EXEEXT): util/grub-gen-asciih.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
CLEANFILES += build-grub-gen-asciih$(BUILD_EXEEXT)
build-grub-gen-asciih: util/grub-gen-asciih.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
CLEANFILES += build-grub-gen-asciih
build-grub-gen-widthspec$(BUILD_EXEEXT): util/grub-gen-widthspec.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
CLEANFILES += build-grub-gen-widthspec$(BUILD_EXEEXT)
build-grub-gen-widthspec: util/grub-gen-widthspec.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
CLEANFILES += build-grub-gen-widthspec
if COND_STARFIELD
starfield_DATA = dejavu_10.pf2 dejavu_12.pf2 dejavu_bold_14.pf2 dejavu_14.pf2 dejavu_16.pf2 $(starfield_theme_files)
@@ -136,8 +132,6 @@ nodist_platform_HEADERS = config.h
pkgdata_DATA += grub-mkconfig_lib
if COND_real_platform
if COND_i386_coreboot
QEMU32=qemu-system-i386
endif
@@ -389,10 +383,12 @@ if COND_powerpc_ieee1275
BOOTCHECKS = bootcheck-linux-ppc
endif
EXTRA_DIST += grub-core/tests/boot/kbsd.init-i386.S grub-core/tests/boot/kbsd.init-x86_64.S grub-core/tests/boot/kbsd.spec.txt grub-core/tests/boot/kernel-8086.S grub-core/tests/boot/kernel-i386.S grub-core/tests/boot/kfreebsd-aout.cfg grub-core/tests/boot/kfreebsd.cfg grub-core/tests/boot/kfreebsd.init-i386.S grub-core/tests/boot/kfreebsd.init-x86_64.S grub-core/tests/boot/knetbsd.cfg grub-core/tests/boot/kopenbsd.cfg grub-core/tests/boot/kopenbsdlabel.txt grub-core/tests/boot/linux16.cfg grub-core/tests/boot/linux.cfg grub-core/tests/boot/linux.init-i386.S grub-core/tests/boot/linux.init-mips.S grub-core/tests/boot/linux.init-ppc.S grub-core/tests/boot/linux.init-x86_64.S grub-core/tests/boot/linux-ppc.cfg grub-core/tests/boot/multiboot2.cfg grub-core/tests/boot/multiboot.cfg grub-core/tests/boot/ntldr.cfg grub-core/tests/boot/pc-chainloader.cfg grub-core/tests/boot/qemu-shutdown-x86.S
.PHONY: bootcheck-linux-i386 bootcheck-linux-x86_64 \
bootcheck-kfreebsd-i386 bootcheck-kfreebsd-x86_64 \
bootcheck-knetbsd-i386 bootcheck-knetbsd-x86_64 \
bootcheck-linux-mips FORCE
bootcheck-linux-mips
# Randomly generated
SUCCESSFUL_BOOT_STRING=3e49994fd5d82b7c9298d672d774080d
@@ -403,13 +399,9 @@ bootcheck: $(BOOTCHECKS)
if COND_i386_coreboot
default_payload.elf: grub-mkstandalone grub-mkimage
pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos xfs ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg
pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos xfs ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg
endif
endif
EXTRA_DIST += grub-core/tests/boot/kbsd.init-i386.S grub-core/tests/boot/kbsd.init-x86_64.S grub-core/tests/boot/kbsd.spec.txt grub-core/tests/boot/kernel-8086.S grub-core/tests/boot/kernel-i386.S grub-core/tests/boot/kfreebsd-aout.cfg grub-core/tests/boot/kfreebsd.cfg grub-core/tests/boot/kfreebsd.init-i386.S grub-core/tests/boot/kfreebsd.init-x86_64.S grub-core/tests/boot/knetbsd.cfg grub-core/tests/boot/kopenbsd.cfg grub-core/tests/boot/kopenbsdlabel.txt grub-core/tests/boot/linux16.cfg grub-core/tests/boot/linux.cfg grub-core/tests/boot/linux.init-i386.S grub-core/tests/boot/linux.init-mips.S grub-core/tests/boot/linux.init-ppc.S grub-core/tests/boot/linux.init-x86_64.S grub-core/tests/boot/linux-ppc.cfg grub-core/tests/boot/multiboot2.cfg grub-core/tests/boot/multiboot.cfg grub-core/tests/boot/ntldr.cfg grub-core/tests/boot/pc-chainloader.cfg grub-core/tests/boot/qemu-shutdown-x86.S
windowsdir=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows
windowsdir: $(PROGRAMS) $(starfield_DATA) $(platform_DATA)
test -d $(windowsdir) && rm -rf $(windowsdir) || true
@@ -428,33 +420,10 @@ windowsdir: $(PROGRAMS) $(starfield_DATA) $(platform_DATA)
for x in $(starfield_DATA); do \
cp -fp $$x $(windowsdir)/themes/starfield/$$(basename $$x); \
done
for x in $(GRUB_WINDOWS_EXTRA_DIST); do \
cp -fp $$x $(windowsdir); \
done
windowszip=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows.zip
windowszip: windowsdir
test -f $(windowszip) && rm $(windowszip) || true
zip -r $(windowszip) $(windowsdir)
rm -rf $(windowsdir)
EXTRA_DIST += linguas.sh
changelog_start_date = 2015-01-23
gitlog_to_changelog = $(top_srcdir)/build-aux/gitlog-to-changelog
ChangeLog: FORCE
if test -d $(top_srcdir)/.git; then \
$(gitlog_to_changelog) --srcdir=$(top_srcdir) --since=$(changelog_start_date) > '$@.tmp'; \
rm -f '$@'; mv '$@.tmp' '$@'; \
else \
touch $@; \
fi
EXTRA_DIST += ChangeLog ChangeLog-2015
syslinux_test: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_grub.cfg
tests/syslinux/ubuntu10.04_grub.cfg: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_grub.cfg.in
(for x in tests/syslinux/ubuntu10.04_grub.cfg.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
CLEANFILES += tests/syslinux/ubuntu10.04_grub.cfg

View File

@@ -48,7 +48,6 @@ library = {
common = grub-core/partmap/gpt.c;
common = grub-core/partmap/msdos.c;
common = grub-core/fs/proc.c;
common = grub-core/fs/archelp.c;
};
library = {
@@ -92,6 +91,7 @@ library = {
common = grub-core/fs/bfs.c;
common = grub-core/fs/btrfs.c;
common = grub-core/fs/cbfs.c;
common = grub-core/fs/archelp.c;
common = grub-core/fs/cpio.c;
common = grub-core/fs/cpio_be.c;
common = grub-core/fs/odc.c;
@@ -119,6 +119,7 @@ library = {
common = grub-core/fs/sfs.c;
common = grub-core/fs/squash4.c;
common = grub-core/fs/tar.c;
common = grub-core/fs/greffs.c;
common = grub-core/fs/udf.c;
common = grub-core/fs/ufs2.c;
common = grub-core/fs/ufs.c;
@@ -384,7 +385,7 @@ program = {
ldadd = libgrubgcry.a;
ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBGEOM)';
};
program = {
@@ -405,7 +406,7 @@ program = {
program = {
name = grub-macbless;
installdir = sbin;
mansection = 8;
mansection = 1;
common = util/grub-macbless.c;
common = grub-core/osdep/init.c;
common = grub-core/kern/emu/argp_common.c;
@@ -439,49 +440,42 @@ script = {
name = '10_hurd';
common = util/grub.d/10_hurd.in;
installdir = grubconf;
condition = COND_HOST_HURD;
};
script = {
name = '10_kfreebsd';
common = util/grub.d/10_kfreebsd.in;
installdir = grubconf;
condition = COND_HOST_KFREEBSD;
};
script = {
name = '10_illumos';
common = util/grub.d/10_illumos.in;
installdir = grubconf;
condition = COND_HOST_ILLUMOS;
};
script = {
name = '10_netbsd';
common = util/grub.d/10_netbsd.in;
installdir = grubconf;
condition = COND_HOST_NETBSD;
};
script = {
name = '10_linux';
common = util/grub.d/10_linux.in;
installdir = grubconf;
condition = COND_HOST_LINUX;
};
script = {
name = '10_xnu';
common = util/grub.d/10_xnu.in;
installdir = grubconf;
condition = COND_HOST_XNU;
};
script = {
name = '20_linux_xen';
common = util/grub.d/20_linux_xen.in;
installdir = grubconf;
condition = COND_HOST_LINUX;
};
script = {
@@ -613,6 +607,7 @@ program = {
common = grub-core/disk/host.c;
common = util/resolve.c;
enable = noemu;
common = grub-core/kern/emu/argp_common.c;
common = grub-core/osdep/init.c;
@@ -707,7 +702,7 @@ script = {
name = grub-fs-tester;
common = tests/util/grub-fs-tester.in;
installdir = noinst;
dependencies = 'garbage-gen$(BUILD_EXEEXT)';
dependencies = garbage-gen;
};
script = {
@@ -1149,24 +1144,6 @@ script = {
common = tests/grub_cmd_tr.in;
};
script = {
testcase;
name = file_filter_test;
common = tests/file_filter_test.in;
};
script = {
testcase;
name = grub_cmd_test;
common = tests/grub_cmd_test.in;
};
script = {
testcase;
name = syslinux_test;
common = tests/syslinux_test.in;
};
program = {
testcase;
name = example_unit_test;

160
NEWS
View File

@@ -1,160 +1,3 @@
New in 2.02:
* New/improved filesystem and disk support:
* Big-endian UFS1.
* Experimental 64-bit ext2 support.
* Various fixes for non-512-byte sector devices.
* New `proc' filesystem framework, used by LUKS disks.
* Fix DM-RAID partition handling.
* New `nativedisk' command to switch from firmware to native disk drivers.
* Compressed HFS+.
* DragonFly BSD labels.
* CBFS (coreboot).
* Handle partitioned LVM properly.
* Use LVM UUIDs whenever possible.
* GPT PReP.
* New `progress' module that shows progress information while reading
files.
* ZFS features support.
* ZFS LZ4 support.
* XFS V5 format support.
* New/improved terminal and video support:
* Monochrome text (matching `hercules' in GRUB Legacy).
* Morse code output using system speaker.
* `spkmodem' output (simple data protocol using system speaker).
* Handle Japanese special keys.
* coreboot framebuffer.
* Serial on ARC.
* Native vt100 handling for grub-emu, replacing the use of the curses
library.
* New gfxmenu options for terminal window positioning, theme background
image handling, and scrollbar padding, plus `item_pixmap_style' and
`highlight_overlay'.
* Support several more image types (paletted and greyscale).
* Boot protocol improvements:
* Support Apple FAT binaries on non-Apple platforms.
* Improve FreeDOS direct loading support compatibility.
* Enable `linux16' on all x86 platforms, not just BIOS.
* New TrueCrypt ISO loader.
* multiboot2 boot-services EFI specification.
* multiboot2 EFI memory map specification.
* multiboot2 full-file specfication.
* New/improved network support:
* New variables `net_default_*' containing properties of the default
interface.
* Autoload `http' and `tftp' modules if necessary.
* Improve TFTP robustness.
* Parse `nd' disk names in GRUB Legacy configuration files.
* Issue separate DNS queries for IPv4 and IPv6.
* Coreboot improvements:
* CBFS support both in on-disk images (loopback) and flash.
* Ability to launch another payload from flash or disk
* Coreboot framebuffer
* CBMEMC support (both logging and inspecting logs)
* Command for inspecting coreboot timestamps (`coreboot_boottime').
* Command for inspecting coreboot tables (`lscoreboot').
* New target default_payload.elf.
* Increased maximal core size.
* New/improved platform support:
* New `efifwsetup' and `lsefi' commands on EFI platforms.
* New `cmosdump' and `cmosset' commands on platforms with CMOS support.
* New command `pcidump' for PCI platforms.
* Improve opcode parsing in ACPI halt implementation.
* Use the TSC as a possible time source on i386-ieee1275.
* Merge PowerPC grub-mkrescue implementation with the common one.
* Support grub-mkrescue on i386-ieee1275, sparc64, bootinfo machines such
as pSeries, and mips-arc.
* Make grub-mkrescue better support Apple Intel Macs on CD.
* Enable GRUB Legacy configuration file parsing on EFI.
* Support halt for Loongson 2E.
* ARM U-Boot and EFI ports.
* Reorganise platform-dependent code in utilities to avoid #ifdef mess.
* AROS and Haiku support for userspace utilities.
* Xen PV port.
* Fix EFI stack alignment.
* ARM64 EFI port.
* On Linux, read partition start offsets from sysfs if possible.
* New grub-macbless utility, and better integration with Mac firmware in
grub-install.
* Support Yeeloong 3A.
* Add `cpuid --pae' option to detect Physical Address Extension on x86.
* Support for USB debug dongles.
* Support for *-emu on all platforms (previously only i386/x86_64 worked).
* Support *-emu on Windows.
* New platform `none' which builds only user level utilities. This is now
default if target CPU is not supported.
* Support for booting little-endian Linux kernel on powerpc.
* Security:
* Add optional facility to enforce that all files read by the core image
from disk have a valid detached digital signature.
* Performance:
* Avoid costly division operations in many places.
* New boot time analysis framework (`./configure --enable-boot-time').
* Initialise USB ports in parallel.
* New `testspeed' command to test file read speed.
* Speed-up gfxterm by storing intermediate results in more compact format.
* Lazy LVM/mdraid scan.
* Disk hints.
* Scripting:
* New `eval' and `tr' commands.
* grub-script-check fails on scripts containing no commands.
* Installation and other utility improvements:
* Add option to compress files on installation or image creation.
* Using grub-reboot no longer requires setting `GRUB_DEFAULT=saved'.
* Support probing EFI System Partition (requires os-prober >= 1.58).
* Fix inconsistent use of `GRUB_CRYPTODISK_ENABLE' and
`GRUB_ENABLE_CRYPTODISK'; the latter is now used consistently.
* grub-mount handles symbolic links to directories.
* Support disabling submenus with `GRUB_DISABLE_SUBMENU' configuration key
for grub-mkconfig.
* grub-install, grub-mknetdir, grub-mkrescue, and grub-mkstandalone
rewritten in C. They should now work in supported non-Unix-like
environments.
* Native mingw support.
* Ability to install on EFI under windows.
* Reorganise timeout handling using new `timeout_style' environment
variable and `GRUB_TIMEOUT_STYLE' configuration key for grub-mkconfig.
Menu hotkeys pressed during a hidden timeout now boot the corresponding
menu entry immediately.
* New `file' command and grub-file utility to check file types.
* New syslinux configuration file parser.
* Build system:
* Remove all uses of nested functions; GRUB no longer requires an
executable stack.
* Fix documentation build with Texinfo >= 5.1.
* More robust and documented cross-compiling support.
* Partial clang support for some platforms (experimental).
* Partial mingw64 x86_64-efi compile support (highly experimental).
* Partial mingw32 i386-* (other than already present i386-pc)
compile support (highly experimental).
* Support for grub-mkpasswd on Windows.
* Eliminate the use of AutoGen. This allowed some performance
improvements to the build system.
* Remove variable length arrays.
* OpenBSD compile and tools support (NetBSD and FreeBSD were already supported).
* Fix build with FreeType >= 2.5.1.
* Make gentpl.py compatible with Python 3. It now requires at least
Python 2.6.
* modinfo.sh contains build information now.
* Added many new tests to improve robustness.
* Target is built without libgcc now. Necessary builtins are reimplemented
directly. This removes requirement for target-specific runtime on build
system.
* emu libusb support removed (was broken and unmaintained).
* powerpc64le compile support.
* Revision control moved to git.
New in 2.00:
* Appearance:
@@ -181,6 +24,7 @@ New in 2.00:
* IEEE1275 serial.
* EFI serial.
* Network stack for BIOS, IEEE1275, EMU and EFI, including TFTP, HTTP and DNS.
* VBE on coreboot support.
* New filesystem, filters and disks formats:
* DVH partition map.
@@ -204,7 +48,7 @@ New in 2.00:
* multidevice, mirrored and raidz(2,3) ZFS support.
* RAID LVM (internal RAIDing) support.
* ZFS crypto support.
* ZLE, LZ4 and GZIP on ZFS support.
* ZLE and GZIP on ZFS support.
* Support ZFS up to 33.
* HFS string is now treated like mac-roman and not UTF-8
* HFS mtime support.

4
README
View File

@@ -12,9 +12,11 @@ The URL is <http://www.gnu.org/software/grub/grub.html>.
More extensive documentation is available in the Info manual,
accessible using 'info grub' after building and installing GRUB 2.
Please look at the GRUB Wiki <http://grub.enbug.org> for testing
procedures.
There are a number of important user-visible differences from the
first version of GRUB, now known as GRUB Legacy. For a summary, please
see:
info grub Introduction 'Changes from GRUB Legacy'
info grub Introduction 'Changes from GRUB Legacy'

View File

@@ -93,7 +93,7 @@ else
fi
grub_cv_prog_objcopy_absolute=yes
for link_addr in 0x2000 0x8000 0x7C00; do
if AC_TRY_COMMAND([${CC-cc} ${TARGET_CFLAGS} ${TARGET_LDFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},$link_addr conftest.o -o conftest.exec]); then :
if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},$link_addr conftest.o -o conftest.exec]); then :
else
AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr])
fi
@@ -344,15 +344,15 @@ else
[fi]
])
dnl Check if ln -s can handle directories properly (mingw).
dnl Check if ln can handle directories properly (mingw).
AC_DEFUN([grub_CHECK_LINK_DIR],[
AC_MSG_CHECKING([whether ln -s can handle directories properly])
AC_MSG_CHECKING([whether ln can handle directories properly])
[mkdir testdir 2>/dev/null
case $srcdir in
[\\/$]* | ?:[\\/]* ) reldir=$srcdir/include/grub/util ;;
*) reldir=../$srcdir/include/grub/util ;;
esac
if ln -s $reldir testdir/util 2>/dev/null && rm -f testdir/util 2>/dev/null ; then]
if ln -s $reldir testdir/util 2>/dev/null ; then]
AC_MSG_RESULT([yes])
[link_dir=yes
else

View File

@@ -1,20 +0,0 @@
/* on arm clang doesn't support .arch directive */
.text
.syntax unified
#if !defined (__thumb2__)
.arch armv7a
.arm
#else
.arch armv7
.thumb
#endif
mcr p15, 0, r11, c7, c14, 2
/* clang restricts access to dsb/isb despite .arch */
dsb
isb

View File

@@ -1,10 +0,0 @@
/* on x86 old clang doesn't support .code16
newer clang supports it but creates 6-byte jumps instead of 3-byte ones
which makes us go over boot sector size. */
.code16
jmp far
.org 4
.space 300
far:
.byte 0

View File

@@ -1,4 +0,0 @@
/* on x86 old clang doesn't support .code16 */
.code16
movb %al, %bl

View File

@@ -1,11 +0,0 @@
/* on mips clang doesn't support privilegied instructions, doubleword store/load
and crashes with hand-written assembly
*/
.set mips3
sync
ld $t2, 0($t1)
a:
addiu $t1, $s0, (b - a)
b: nop

View File

@@ -1,8 +0,0 @@
/* clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly
used by gcrypt */
/* Cache invalidation loop is a fair test. */
li 5, 0
1: icbi 5, 3
addi 5, 5, 32
cmpw 5, 4
blt 1b

View File

@@ -1,9 +0,0 @@
.text
1:
/* A small list of examples of what clang doesn't support. */
clr %o0
lduw [%o4 + 4], %o4
and %o6, ~0xff, %o6
stw %o5, [%o3]
bne,pt %icc, 1b
nop

View File

@@ -2,9 +2,6 @@
set -e
# Set ${PYTHON} to plain 'python' if not set already
: ${PYTHON:=python}
export LC_COLLATE=C
unset LC_ALL
@@ -12,10 +9,10 @@ find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './b
find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in
echo "Importing unicode..."
${PYTHON} util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c
python util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c
echo "Importing libgcrypt..."
${PYTHON} util/import_gcry.py grub-core/lib/libgcrypt/ grub-core
python util/import_gcry.py grub-core/lib/libgcrypt/ grub-core
sed -n -f util/import_gcrypth.sed < grub-core/lib/libgcrypt/src/gcrypt.h.in > include/grub/gcrypt/gcrypt.h
if [ -f include/grub/gcrypt/g10lib.h ]; then
rm include/grub/gcrypt/g10lib.h
@@ -57,8 +54,8 @@ for extra in contrib/*/Makefile.core.def; do
fi
done
${PYTHON} gentpl.py $UTIL_DEFS > Makefile.util.am
${PYTHON} gentpl.py $CORE_DEFS > grub-core/Makefile.core.am
python gentpl.py $UTIL_DEFS > Makefile.util.am
python gentpl.py $CORE_DEFS > grub-core/Makefile.core.am
for extra in contrib/*/Makefile.common; do
if test -e "$extra"; then

View File

@@ -1,432 +0,0 @@
eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}'
& eval 'exec perl -wS "$0" $argv:q'
if 0;
# Convert git log output to ChangeLog format.
my $VERSION = '2012-07-29 06:11'; # UTC
# The definition above must lie within the first 8 lines in order
# for the Emacs time-stamp write hook (at end) to update it.
# If you change this file with Emacs, please let the write hook
# do its job. Otherwise, update this string manually.
# Copyright (C) 2008-2014 Free Software Foundation, Inc.
# This program 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.
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
# Written by Jim Meyering
use strict;
use warnings;
use Getopt::Long;
use POSIX qw(strftime);
(my $ME = $0) =~ s|.*/||;
# use File::Coda; # http://meyering.net/code/Coda/
END {
defined fileno STDOUT or return;
close STDOUT and return;
warn "$ME: failed to close standard output: $!\n";
$? ||= 1;
}
sub usage ($)
{
my ($exit_code) = @_;
my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR);
if ($exit_code != 0)
{
print $STREAM "Try '$ME --help' for more information.\n";
}
else
{
print $STREAM <<EOF;
Usage: $ME [OPTIONS] [ARGS]
Convert git log output to ChangeLog format. If present, any ARGS
are passed to "git log". To avoid ARGS being parsed as options to
$ME, they may be preceded by '--'.
OPTIONS:
--amend=FILE FILE maps from an SHA1 to perl code (i.e., s/old/new/) that
makes a change to SHA1's commit log text or metadata.
--append-dot append a dot to the first line of each commit message if
there is no other punctuation or blank at the end.
--no-cluster never cluster commit messages under the same date/author
header; the default is to cluster adjacent commit messages
if their headers are the same and neither commit message
contains multiple paragraphs.
--srcdir=DIR the root of the source tree, from which the .git/
directory can be derived.
--since=DATE convert only the logs since DATE;
the default is to convert all log entries.
--format=FMT set format string for commit subject and body;
see 'man git-log' for the list of format metacharacters;
the default is '%s%n%b%n'
--strip-tab remove one additional leading TAB from commit message lines.
--strip-cherry-pick remove data inserted by "git cherry-pick";
this includes the "cherry picked from commit ..." line,
and the possible final "Conflicts:" paragraph.
--help display this help and exit
--version output version information and exit
EXAMPLE:
$ME --since=2008-01-01 > ChangeLog
$ME -- -n 5 foo > last-5-commits-to-branch-foo
SPECIAL SYNTAX:
The following types of strings are interpreted specially when they appear
at the beginning of a log message line. They are not copied to the output.
Copyright-paperwork-exempt: Yes
Append the "(tiny change)" notation to the usual "date name email"
ChangeLog header to mark a change that does not require a copyright
assignment.
Co-authored-by: Joe User <user\@example.com>
List the specified name and email address on a second
ChangeLog header, denoting a co-author.
Signed-off-by: Joe User <user\@example.com>
These lines are simply elided.
In a FILE specified via --amend, comment lines (starting with "#") are ignored.
FILE must consist of <SHA,CODE+> pairs where SHA is a 40-byte SHA1 (alone on
a line) referring to a commit in the current project, and CODE refers to one
or more consecutive lines of Perl code. Pairs must be separated by one or
more blank line.
Here is sample input for use with --amend=FILE, from coreutils:
3a169f4c5d9159283548178668d2fae6fced3030
# fix typo in title:
s/all tile types/all file types/
1379ed974f1fa39b12e2ffab18b3f7a607082202
# Due to a bug in vc-dwim, I mis-attributed a patch by Paul to myself.
# Change the author to be Paul. Note the escaped "@":
s,Jim .*>,Paul Eggert <eggert\\\@cs.ucla.edu>,
EOF
}
exit $exit_code;
}
# If the string $S is a well-behaved file name, simply return it.
# If it contains white space, quotes, etc., quote it, and return the new string.
sub shell_quote($)
{
my ($s) = @_;
if ($s =~ m![^\w+/.,-]!)
{
# Convert each single quote to '\''
$s =~ s/\'/\'\\\'\'/g;
# Then single quote the string.
$s = "'$s'";
}
return $s;
}
sub quoted_cmd(@)
{
return join (' ', map {shell_quote $_} @_);
}
# Parse file F.
# Comment lines (starting with "#") are ignored.
# F must consist of <SHA,CODE+> pairs where SHA is a 40-byte SHA1
# (alone on a line) referring to a commit in the current project, and
# CODE refers to one or more consecutive lines of Perl code.
# Pairs must be separated by one or more blank line.
sub parse_amend_file($)
{
my ($f) = @_;
open F, '<', $f
or die "$ME: $f: failed to open for reading: $!\n";
my $fail;
my $h = {};
my $in_code = 0;
my $sha;
while (defined (my $line = <F>))
{
$line =~ /^\#/
and next;
chomp $line;
$line eq ''
and $in_code = 0, next;
if (!$in_code)
{
$line =~ /^([0-9a-fA-F]{40})$/
or (warn "$ME: $f:$.: invalid line; expected an SHA1\n"),
$fail = 1, next;
$sha = lc $1;
$in_code = 1;
exists $h->{$sha}
and (warn "$ME: $f:$.: duplicate SHA1\n"),
$fail = 1, next;
}
else
{
$h->{$sha} ||= '';
$h->{$sha} .= "$line\n";
}
}
close F;
$fail
and exit 1;
return $h;
}
# git_dir_option $SRCDIR
#
# From $SRCDIR, the --git-dir option to pass to git (none if $SRCDIR
# is undef). Return as a list (0 or 1 element).
sub git_dir_option($)
{
my ($srcdir) = @_;
my @res = ();
if (defined $srcdir)
{
my $qdir = shell_quote $srcdir;
my $cmd = "cd $qdir && git rev-parse --show-toplevel";
my $qcmd = shell_quote $cmd;
my $git_dir = qx($cmd);
defined $git_dir
or die "$ME: cannot run $qcmd: $!\n";
$? == 0
or die "$ME: $qcmd had unexpected exit code or signal ($?)\n";
chomp $git_dir;
push @res, "--git-dir=$git_dir/.git";
}
@res;
}
{
my $since_date;
my $format_string = '%s%n%b%n';
my $amend_file;
my $append_dot = 0;
my $cluster = 1;
my $strip_tab = 0;
my $strip_cherry_pick = 0;
my $srcdir;
GetOptions
(
help => sub { usage 0 },
version => sub { print "$ME version $VERSION\n"; exit },
'since=s' => \$since_date,
'format=s' => \$format_string,
'amend=s' => \$amend_file,
'append-dot' => \$append_dot,
'cluster!' => \$cluster,
'strip-tab' => \$strip_tab,
'strip-cherry-pick' => \$strip_cherry_pick,
'srcdir=s' => \$srcdir,
) or usage 1;
defined $since_date
and unshift @ARGV, "--since=$since_date";
# This is a hash that maps an SHA1 to perl code (i.e., s/old/new/)
# that makes a correction in the log or attribution of that commit.
my $amend_code = defined $amend_file ? parse_amend_file $amend_file : {};
my @cmd = ('git',
git_dir_option $srcdir,
qw(log --log-size),
'--pretty=format:%H:%ct %an <%ae>%n%n'.$format_string, @ARGV);
open PIPE, '-|', @cmd
or die ("$ME: failed to run '". quoted_cmd (@cmd) ."': $!\n"
. "(Is your Git too old? Version 1.5.1 or later is required.)\n");
my $prev_multi_paragraph;
my $prev_date_line = '';
my @prev_coauthors = ();
while (1)
{
defined (my $in = <PIPE>)
or last;
$in =~ /^log size (\d+)$/
or die "$ME:$.: Invalid line (expected log size):\n$in";
my $log_nbytes = $1;
my $log;
my $n_read = read PIPE, $log, $log_nbytes;
$n_read == $log_nbytes
or die "$ME:$.: unexpected EOF\n";
# Extract leading hash.
my ($sha, $rest) = split ':', $log, 2;
defined $sha
or die "$ME:$.: malformed log entry\n";
$sha =~ /^[0-9a-fA-F]{40}$/
or die "$ME:$.: invalid SHA1: $sha\n";
# If this commit's log requires any transformation, do it now.
my $code = $amend_code->{$sha};
if (defined $code)
{
eval 'use Safe';
my $s = new Safe;
# Put the unpreprocessed entry into "$_".
$_ = $rest;
# Let $code operate on it, safely.
my $r = $s->reval("$code")
or die "$ME:$.:$sha: failed to eval \"$code\":\n$@\n";
# Note that we've used this entry.
delete $amend_code->{$sha};
# Update $rest upon success.
$rest = $_;
}
# Remove lines inserted by "git cherry-pick".
if ($strip_cherry_pick)
{
$rest =~ s/^\s*Conflicts:\n.*//sm;
$rest =~ s/^\s*\(cherry picked from commit [\da-f]+\)\n//m;
}
my @line = split "\n", $rest;
my $author_line = shift @line;
defined $author_line
or die "$ME:$.: unexpected EOF\n";
$author_line =~ /^(\d+) (.*>)$/
or die "$ME:$.: Invalid line "
. "(expected date/author/email):\n$author_line\n";
# Format 'Copyright-paperwork-exempt: Yes' as a standard ChangeLog
# `(tiny change)' annotation.
my $tiny = (grep (/^Copyright-paperwork-exempt:\s+[Yy]es$/, @line)
? ' (tiny change)' : '');
my $date_line = sprintf "%s %s$tiny\n",
strftime ("%F", localtime ($1)), $2;
my @coauthors = grep /^Co-authored-by:.*$/, @line;
# Omit meta-data lines we've already interpreted.
@line = grep !/^(?:Signed-off-by:[ ].*>$
|Co-authored-by:[ ]
|Copyright-paperwork-exempt:[ ]
)/x, @line;
# Remove leading and trailing blank lines.
if (@line)
{
while ($line[0] =~ /^\s*$/) { shift @line; }
while ($line[$#line] =~ /^\s*$/) { pop @line; }
}
# Record whether there are two or more paragraphs.
my $multi_paragraph = grep /^\s*$/, @line;
# Format 'Co-authored-by: A U Thor <email@example.com>' lines in
# standard multi-author ChangeLog format.
for (@coauthors)
{
s/^Co-authored-by:\s*/\t /;
s/\s*</ </;
/<.*?@.*\..*>/
or warn "$ME: warning: missing email address for "
. substr ($_, 5) . "\n";
}
# If clustering of commit messages has been disabled, if this header
# would be different from the previous date/name/email/coauthors header,
# or if this or the previous entry consists of two or more paragraphs,
# then print the header.
if ( ! $cluster
|| $date_line ne $prev_date_line
|| "@coauthors" ne "@prev_coauthors"
|| $multi_paragraph
|| $prev_multi_paragraph)
{
$prev_date_line eq ''
or print "\n";
print $date_line;
@coauthors
and print join ("\n", @coauthors), "\n";
}
$prev_date_line = $date_line;
@prev_coauthors = @coauthors;
$prev_multi_paragraph = $multi_paragraph;
# If there were any lines
if (@line == 0)
{
warn "$ME: warning: empty commit message:\n $date_line\n";
}
else
{
if ($append_dot)
{
# If the first line of the message has enough room, then
if (length $line[0] < 72)
{
# append a dot if there is no other punctuation or blank
# at the end.
$line[0] =~ /[[:punct:]\s]$/
or $line[0] .= '.';
}
}
# Remove one additional leading TAB from each line.
$strip_tab
and map { s/^\t// } @line;
# Prefix each non-empty line with a TAB.
@line = map { length $_ ? "\t$_" : '' } @line;
print "\n", join ("\n", @line), "\n";
}
defined ($in = <PIPE>)
or last;
$in ne "\n"
and die "$ME:$.: unexpected line:\n$in";
}
close PIPE
or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n";
# FIXME-someday: include $PROCESS_STATUS in the diagnostic
# Complain about any unused entry in the --amend=F specified file.
my $fail = 0;
foreach my $sha (keys %$amend_code)
{
warn "$ME:$amend_file: unused entry: $sha\n";
$fail = 1;
}
exit $fail;
}
# Local Variables:
# mode: perl
# indent-tabs-mode: nil
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "my $VERSION = '"
# time-stamp-format: "%:y-%02m-%02d %02H:%02M"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "'; # UTC"
# End:

View File

@@ -7,7 +7,12 @@ unexport LC_ALL
# Platform specific options
if COND_sparc64_ieee1275
LDFLAGS_PLATFORM = -Wl,-melf64_sparc
CFLAGS_PLATFORM += -mno-app-regs
LDFLAGS_PLATFORM = -Wl,-melf64_sparc -Wl,--no-relax
endif
if COND_sparc64_emu
CFLAGS_PLATFORM += -mno-app-regs
LDFLAGS_PLATFORM = -Wl,--no-relax
endif
if COND_arm
if !COND_emu
@@ -17,9 +22,6 @@ endif
if COND_arm64
CFLAGS_PLATFORM += -mcmodel=large
endif
if COND_powerpc_ieee1275
CFLAGS_PLATFORM += -mcpu=powerpc
endif
#FIXME: discover and check XEN headers
CPPFLAGS_XEN = -I/usr/include
@@ -37,19 +39,21 @@ CPPFLAGS_DEFAULT += -I$(top_srcdir)/grub-core/lib/libgcrypt-grub/src/
CCASFLAGS_DEFAULT = $(CPPFLAGS_DEFAULT) -DASM_FILE=1
BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT)
CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC)
LDADD_KERNEL = $(TARGET_LIBGCC)
CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC)
CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1
CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags
STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version
CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
CFLAGS_MODULE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_MODULE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
CFLAGS_IMAGE = $(CFLAGS_PLATFORM) -fno-builtin
LDFLAGS_IMAGE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S
CFLAGS_IMAGE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -fno-builtin
LDFLAGS_IMAGE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S
CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)

View File

@@ -5,7 +5,6 @@ EXTRA_DIST += gentpl.py
EXTRA_DIST += Makefile.util.def
EXTRA_DIST += Makefile.utilgcry.def
EXTRA_DIST += asm-tests
EXTRA_DIST += unicode
EXTRA_DIST += util/import_gcry.py
@@ -111,26 +110,3 @@ EXTRA_DIST += tests/dfly-mbr-mbexample.mbr.img.gz
EXTRA_DIST += tests/dfly-mbr-mbexample.dfly.img.gz
EXTRA_DIST += coreboot.cfg
EXTRA_DIST += tests/file_filter/file
EXTRA_DIST += tests/file_filter/file.gz
EXTRA_DIST += tests/file_filter/file.gz.sig
EXTRA_DIST += tests/file_filter/file.lzop
EXTRA_DIST += tests/file_filter/file.lzop.sig
EXTRA_DIST += tests/file_filter/file.xz
EXTRA_DIST += tests/file_filter/file.xz.sig
EXTRA_DIST += tests/file_filter/keys
EXTRA_DIST += tests/file_filter/keys.pub
EXTRA_DIST += tests/file_filter/test.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/prompt.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/txt.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/menu.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/po4a.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04_grub.cfg.in

View File

@@ -7,20 +7,11 @@
#endif
#define GCRYPT_NO_DEPRECATED 1
#define HAVE_MEMMOVE 1
/* Define to 1 to enable disk cache statistics. */
#define DISK_CACHE_STATS @DISK_CACHE_STATS@
#define BOOT_TIME_STATS @BOOT_TIME_STATS@
/* We don't need those. */
#define MINILZO_CFG_SKIP_LZO_PTR 1
#define MINILZO_CFG_SKIP_LZO_UTIL 1
#define MINILZO_CFG_SKIP_LZO_STRING 1
#define MINILZO_CFG_SKIP_LZO_INIT 1
#define MINILZO_CFG_SKIP_LZO1X_1_COMPRESS 1
#define MINILZO_CFG_SKIP_LZO1X_DECOMPRESS 1
#if defined (GRUB_BUILD)
#undef ENABLE_NLS
#define BUILD_SIZEOF_LONG @BUILD_SIZEOF_LONG@

View File

@@ -26,20 +26,20 @@ dnl This is necessary because the target type in autoconf does not
dnl describe such a system very well.
dnl
dnl The current strategy is to use variables with no prefix (such as
dnl CC, CFLAGS, etc.) for the host type, variables with prefix "BUILD_"
dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables
dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are
dnl used for the target type. See INSTALL for full list of variables.
dnl CC, CFLAGS, etc.) for the host type as well as the build type,
dnl because GRUB does not need to use those variables for the build
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],[2.02~beta2],[bug-grub@gnu.org])
AC_INIT([GRUB],[2.02~beta1],[bug-grub@gnu.org])
AC_CONFIG_AUX_DIR([build-aux])
# We don't want -g -O2 by default in CFLAGS
: ${CFLAGS=""}
# Checks for build, host and target systems.
AC_CANONICAL_BUILD
# Checks for host and target systems.
AC_CANONICAL_HOST
save_program_prefix="${program_prefix}"
AC_CANONICAL_TARGET
@@ -78,27 +78,30 @@ fi
# Default HOST_CPPFLAGS
HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
case "$target_cpu" in
i[[3456]]86) target_cpu=i386 ;;
amd64) target_cpu=x86_64 ;;
sparc) target_cpu=sparc64 ;;
mipsel|mips64el)
target_cpu=mipsel
machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1"
target_cpu=mipsel;
machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1";
;;
mips|mips64)
target_cpu=mips
machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1"
target_cpu=mips;
machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1";
;;
arm*)
target_cpu=arm
target_cpu=arm;
;;
aarch64*)
target_cpu=arm64
target_cpu=arm64;
;;
esac
@@ -116,17 +119,13 @@ if test "x$with_platform" = x; then
x86_64-*) platform=pc ;;
powerpc-*) platform=ieee1275 ;;
powerpc64-*) platform=ieee1275 ;;
powerpc64le-*) platform=ieee1275 ;;
sparc64-*) platform=ieee1275 ;;
mipsel-*) platform=loongson ;;
mips-*) platform=arc ;;
ia64-*) platform=efi ;;
arm-*) platform=uboot ;;
arm64-*) platform=efi ;;
*)
AC_MSG_WARN([unsupported CPU: "$target_cpu" - only building utilities])
platform=none
;;
*) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
esac
else
platform="$with_platform"
@@ -136,10 +135,8 @@ case "$target_cpu"-"$platform" in
x86_64-efi) ;;
x86_64-emu) ;;
x86_64-xen) ;;
x86_64-none) ;;
x86_64-*) target_cpu=i386 ;;
powerpc64-ieee1275) target_cpu=powerpc ;;
powerpc64le-ieee1275) target_cpu=powerpc ;;
esac
# Check if the platform is supported, make final adjustments.
@@ -170,7 +167,6 @@ case "$target_cpu"-"$platform" in
arm-efi) ;;
arm64-efi) ;;
*-emu) ;;
*-none) ;;
*) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
esac
@@ -182,7 +178,7 @@ if test x$platform != xemu ; then
fi
if test x"$target_cpu-$platform" = xsparc64-emu ; then
target_m64=1
target_m64=1 ;
fi
case "$target_os" in
@@ -353,9 +349,6 @@ if test x"$target_cpu-$platform" = xsparc64-emu ; then
HOST_CFLAGS="$HOST_CFLAGS -m64"
fi
CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
HOST_CPPFLAGS="$HOST_CPPFLAGS -D_FILE_OFFSET_BITS=64"
AC_C_BIGENDIAN
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(long)
@@ -368,14 +361,6 @@ case "$host_os" in
;;
esac
case "$host_os" in
cygwin | windows* | mingw32* | aros*)
;;
*)
AC_CHECK_SIZEOF(off_t)
test x"$ac_cv_sizeof_off_t" = x8 || AC_MSG_ERROR([Large file support is required]);;
esac
if test x$USE_NLS = xno; then
HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext"
fi
@@ -438,16 +423,6 @@ case "$build_os" in
haiku*) BUILD_LIBM= ;;
*) BUILD_LIBM=-lm ;;
esac
dnl FIXME proper test seems to require too deep dive into Autoconf internals.
dnl For now just list known platforms that we support.
case "$build_os" in
cygwin*|mingw32*|mingw64*) BUILD_EXEEXT=.exe ;;
*) BUILD_EXEEXT= ;;
esac
AC_SUBST(BUILD_EXEEXT)
# For gnulib.
gl_INIT
@@ -502,7 +477,6 @@ AC_SUBST(HOST_CC)
AC_SUBST(BUILD_CC)
AC_SUBST(BUILD_CFLAGS)
AC_SUBST(BUILD_CPPFLAGS)
AC_SUBST(BUILD_LDFLAGS)
AC_SUBST(TARGET_CC)
AC_SUBST(TARGET_NM)
AC_SUBST(TARGET_RANLIB)
@@ -529,8 +503,6 @@ if test "x$target_cpu" != xi386 && test "x$target_cpu" != xx86_64; then
TARGET_CFLAGS="$TARGET_CFLAGS -Wcast-align"
fi
TARGET_CC_VERSION="$(LC_ALL=C $TARGET_CC --version | head -n1)"
AC_CACHE_CHECK([which extra warnings work], [grub_cv_target_cc_w_extra_flags], [
LDFLAGS="$TARGET_LDFLAGS -nostdlib -static"
@@ -551,7 +523,7 @@ int main (void);
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags"
AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang],
AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang]
[
CFLAGS="$TARGET_CFLAGS"
AC_COMPILE_IFELSE(
@@ -562,148 +534,56 @@ AC_COMPILE_IFELSE(
]])],
[grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then
AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [
grub_cv_target_cc_big_endian=no
for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \
"-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \
"-EB" "-mbig-endian"; do
if test x"$grub_cv_target_cc_big_endian" != xno ; then
break
fi
CFLAGS="$TARGET_CFLAGS $cand -Werror"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__)
#error still little endian
#endif
asm (".globl start; start:");
asm (".globl _start; _start:");
asm (".globl __start; __start:");
void __main (void);
void __main (void) {}
int main (void);
]], [[]])],
[grub_cv_target_cc_big_endian="$cand"], [])
done
])
if test x"$grub_cv_target_cc_big_endian" = xno ; then
AC_MSG_ERROR([could not force big-endian])
fi
skip_linkflags="$(echo "$grub_cv_target_cc_big_endian"|sed 's@-Wl,-EB@@')"
TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
elif test x$target_cpu = xmipsel; then
AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [
grub_cv_target_cc_little_endian=no
for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \
"-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \
"-EL"; do
if test x"$grub_cv_target_cc_little_endian" != xno ; then
break
fi
CFLAGS="$TARGET_CFLAGS $cand -Werror"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__)
#error still big endian
#endif
asm (".globl start; start:");
asm (".globl _start; _start:");
asm (".globl __start; __start:");
void __main (void);
void __main (void) {}
int main (void);
]], [[]])],
[grub_cv_target_cc_little_endian="$cand"], [])
done
])
if test x"$grub_cv_target_cc_little_endian" = xno ; then
AC_MSG_ERROR([could not force little-endian])
fi
skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')"
TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
# on x86 clang doesn't support .code16
# on arm clang doesn't support .arch directive
# on mips clang doesn't support privilegied instructions, doubleword store/load
# and crashes with hand-written assembly
if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xarm \
|| test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ); then
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
fi
# GRUB code is N32-compliant but it's experimental and we would prefer to
# avoid having too much variety when it doesn't result in any real improvement.
# Moreover N64 isn't supported.
if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
grub_cv_target_cc_mips_o32_abi=no
for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
break
fi
CFLAGS="$TARGET_CFLAGS $arg -Werror"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
#error not o32 ABI
if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 \
|| test "x$target_cpu" = xx86_64 ); then
AC_CACHE_CHECK([if clang can handle .code16], [grub_cv_cc_target_clang_code16]
[
CFLAGS="$TARGET_CCASFLAGS"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
asm volatile (".code16\n"
"xorw %ax, %ax\n"
#ifdef __x86_64__
".code64\n"
#else
".code32\n"
#endif
asm (".globl start; start:");
asm (".globl _start; _start:");
asm (".globl __start; __start:");
void __main (void);
void __main (void) {}
int main (void);
]], [[]])],
[grub_cv_target_cc_mips_o32_abi="$arg"], [])
done
])
if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
AC_MSG_ERROR([could not force MIPS o32 ABI])
fi
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
);
]])],
[grub_cv_cc_target_clang_code16=yes], [grub_cv_cc_target_clang_code16=no])])
if test x$grub_cv_cc_target_clang_code16 = xno ; then
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
fi
fi
AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
test_program=
case "x$target_cpu-$platform" in
xmips-* | xmipsel-*)
test_program=mips
;;
xi386-pc)
test_program=i386-pc
;;
xi386-* | xx86_64-*)
test_program=i386
;;
xpowerpc-* | xsparc64-* | xarm-*)
test_program=$target_cpu
;;
esac
if test x"$test_program" = x ; then
grub_cv_cc_target_asm_compile=
else
found=no
for arg in "" "-no-integrated-as"; do
cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
grub_cv_cc_target_asm_compile="$arg"
found=yes
break
fi
done
if test x"$found" = xno ; then
AC_MSG_ERROR([could not compile assembly])
fi
if test "x$grub_cv_cc_target_clang" = xyes && test "x$target_cpu" = xpowerpc; then
AC_CACHE_CHECK([if clang can handle ame instruction], [grub_cv_cc_target_clang_ame]
[
CFLAGS="$TARGET_CFLAGS"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
unsigned int a = 0, b = 0;
asm volatile ("{ame|addme} %0,%1" : "=r" (a) : "r" (b));
if (a)
return 1;
]])],
[grub_cv_cc_target_clang_ame=yes], [grub_cv_cc_target_clang_ame=no])])
# clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly
# used by gcrypt
if test x$grub_cv_cc_target_clang_ame = xno ; then
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
TARGET_CFLAGS="$TARGET_CFLAGS -no-integrated-as"
fi
fi
])
TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile"
if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
@@ -786,102 +666,6 @@ if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$p
TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
fi
# GRUB doesn't use float or doubles at all. Yet some toolchains may decide
# that floats are a good fit to run instead of what's written in the code.
# Given that floating point unit is disabled (if present to begin with)
# when GRUB is running which may result in various hard crashes.
if test x"$platform" != xemu ; then
AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
grub_cv_target_cc_soft_float=no
if test "x$target_cpu" = xarm64; then
CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_target_cc_soft_float="-mgeneral-regs-only"], [])
fi
if test "x$target_cpu" = xia64; then
CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], [])
fi
for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \
"-Xclang -msoft-float -Xclang -no-implicit-float" \
"-Xclang -msoft-float" "-msoft-float"; do
if test x"$grub_cv_target_cc_soft_float" != xno ; then
break
fi
CFLAGS="$TARGET_CFLAGS $cand -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_target_cc_soft_float="$cand"], [])
done
])
if test x"$grub_cv_target_cc_soft_float" = xno ; then
AC_MSG_ERROR([could not force soft-float])
fi
case x"$grub_cv_target_cc_soft_float" in
x*"-Xclang"*)
# A trick so that clang doesn't see it on link stаge
TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float"
;;
*)
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
;;
esac
TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
fi
if test x"$target_cpu" = xsparc64 ; then
AC_CACHE_CHECK([for options to reserve application registers], grub_cv_target_cc_mno_app_regs, [
grub_cv_target_cc_mno_app_regs=no
for cand in "-mllvm -sparc-reserve-app-registers" \
"-mno-app-regs"; do
if test x"$grub_cv_target_cc_mno_app_regs" != xno ; then
break
fi
CFLAGS="$TARGET_CFLAGS $cand -Werror"
CPPFLAGS="$TARGET_CPPFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_target_cc_mno_app_regs="$cand"], [])
done
])
if test x"$grub_cv_target_cc_mno_app_regs" = xno ; then
AC_MSG_ERROR([could not reserve application registers])
fi
if test x"$grub_cv_target_cc_mno_app_regs" = x"-mllvm -sparc-reserve-app-registers" ; then
# A trick so that clang doesn't see it on link stаge
TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_app_regs"
else
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_app_regs"
fi
AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [
grub_cv_target_cc_mno_relax=no
for cand in "-mno-relax" "-Wl,--no-relax"; do
if test x"$grub_cv_target_cc_mno_relax" != xno ; then
break
fi
LDFLAGS="$TARGET_LDFLAGS $cand -nostdlib -static"
CFLAGS="$TARGET_CFLAGS -Werror"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
asm (".globl start; start:");
void __main (void);
void __main (void) {}
int main (void);
]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], [])
done
])
LDFLAGS="$TARGET_LDFLAGS"
CFLAGS="$TARGET_CFLAGS"
if test x"$grub_cv_target_cc_mno_relax" = xno ; then
AC_MSG_ERROR([could not find no-relax options])
fi
TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax"
fi
# By default, GCC 4.4 generates .eh_frame sections containing unwind
# information in some cases where it previously did not. GRUB doesn't need
# these and they just use up vital space. Restore the old compiler
@@ -966,7 +750,7 @@ if test x"$efiemu_excuse" = x ; then
]], [[]])], [flag=1], [flag=0])
if test x"$flag" = x1; then
grub_cv_target_cc_efiemu64_link_format="$format"
break
break;
fi
done])
if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
@@ -999,12 +783,12 @@ if test x"$platform" = xemu ; then
;;
*windows* | *cygwin* | *mingw*)
if test x${target_cpu} = xi386 ; then
grub_cv_target_cc_link_format=-mi386pe
TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
grub_cv_target_cc_link_format=-mi386pe;
TARGET_OBJ2ELF='./build-grub-pe2elf';
fi
if test x${target_cpu} = xx86_64 ; then
grub_cv_target_cc_link_format=-mi386pep
TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
grub_cv_target_cc_link_format=-mi386pep;
TARGET_OBJ2ELF='./build-grub-pep2elf';
fi
TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
;;
@@ -1030,7 +814,7 @@ elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
]], [[]])], [flag=1], [flag=0])
if test x"$flag" = x1; then
grub_cv_target_cc_link_format="$format"
break
break;
fi
done])
if test x"$grub_cv_target_cc_link_format" = xunknown; then
@@ -1038,10 +822,10 @@ elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
fi
TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then
TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'
TARGET_OBJ2ELF='./build-grub-pe2elf';
fi
if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'
TARGET_OBJ2ELF='./build-grub-pep2elf';
fi
fi
@@ -1083,17 +867,17 @@ AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
LDFLAGS="$TARGET_LDFLAGS"
if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 ; then
if test "$target_cpu" = x86_64 || test "$target_cpu-$platform" = sparc64-emu ; then
# Use large model to support 4G memory
AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
CFLAGS="$TARGET_CFLAGS -mcmodel=large"
CFLAGS="$TARGET_CFLAGS -m64 -mcmodel=large"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_mcmodel=yes],
[grub_cv_cc_mcmodel=no])
])
if test "x$grub_cv_cc_mcmodel" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
elif test "$target_cpu" = sparc64; then
elif test "$target_cpu-$platform" = sparc64-emu; then
TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany"
fi
fi
@@ -1101,7 +885,7 @@ fi
if test "$target_cpu"-"$platform" = x86_64-efi; then
# EFI writes to stack below %rsp, we must not use the red zone
AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
CFLAGS="$TARGET_CFLAGS -mno-red-zone"
CFLAGS="$TARGET_CFLAGS -m64 -mno-red-zone"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_no_red_zone=yes],
[grub_cv_cc_no_red_zone=no])
@@ -1131,21 +915,23 @@ if test "x$target_cpu" = xarm; then
])
if test "x$grub_cv_cc_mthumb_interwork" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork"
# Clang defaults to thumb interworking
elif test "x$grub_cv_cc_target_clang" = xno ; then
AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork])
else
CFLAGS="$TARGET_CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
#if defined (__thumb__) && !defined (__thumb2__)
#error thumb without interworking
#endif
]])],
[no_interwork_ok=yes],
[no_interwork_ok=no])
if test x$no_interwork_ok = xno ; then
AC_MSG_ERROR([attempt to compile to thumb with no thumb interwork])
fi
fi
fi
AC_CACHE_CHECK([whether option -Qn works], grub_cv_target_cc_qn, [
CFLAGS="$TARGET_CFLAGS -Qn -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_target_cc_qn=yes],
[grub_cv_target_cc_qn=no])])
if test "x$grub_cv_target_cc_qn" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -Qn"
fi
#
# Compiler features.
#
@@ -1208,7 +994,7 @@ if test "$target_cpu" = arm; then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0])
if test x"$flag" = x1; then
grub_cv_target_cc_strict_align="$arg"
break
break;
fi
done])
@@ -1231,17 +1017,22 @@ fi
# Set them to their new values for the tests below.
CC="$TARGET_CC"
if test x"$platform" = xemu ; then
CFLAGS="$TARGET_CFLAGS -Wno-error"
elif test "x$TARGET_APPLE_LINKER" = x1 ; then
if test "x$TARGET_APPLE_LINKER" = x1 ; then
CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error"
else
CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
fi
CPPFLAGS="$TARGET_CPPFLAGS"
if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then
TARGET_LIBGCC=
else
TARGET_LIBGCC=-lgcc
fi
LIBS="$TARGET_LIBGCC"
grub_ASM_USCORE
if test "x$TARGET_APPLE_LINKER" = x0 && test x"$platform" != xemu; then
if test "x$TARGET_APPLE_LINKER" = x0 ; then
if test x$grub_cv_asm_uscore = xyes; then
DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main"
else
@@ -1251,9 +1042,7 @@ CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM"
fi
# Check for libgcc symbols
if test x"$platform" = xemu; then
AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms)
fi
AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x)
if test "x$TARGET_APPLE_LINKER" = x1 ; then
CFLAGS="$TARGET_CFLAGS -nostdlib -static"
@@ -1355,6 +1144,10 @@ else
fi
AC_SUBST([BOOT_TIME_STATS])
AC_ARG_ENABLE([grub-emu-usb],
[AS_HELP_STRING([--enable-grub-emu-usb],
[build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
AC_ARG_ENABLE([grub-emu-sdl],
[AS_HELP_STRING([--enable-grub-emu-sdl],
[build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
@@ -1365,6 +1158,34 @@ AC_ARG_ENABLE([grub-emu-pci],
if test "$platform" = emu; then
if test x"$enable_grub_emu_usb" != xyes ; then
grub_emu_usb_excuse="not enabled"
fi
if test x"$enable_grub_emu_pci" = xyes ; then
grub_emu_usb_excuse="conflicts with PCI support"
fi
[if [ x"$grub_emu_usb_excuse" = x ]; then
# Check for libusb libraries.]
AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
[grub_emu_usb_excuse=["need libusb library"]])
AC_SUBST([LIBUSB])
[fi]
[if [ x"$grub_emu_usb_excuse" = x ]; then
# Check for headers.]
AC_CHECK_HEADERS([usb.h], [],
[grub_emu_usb_excuse=["need libusb headers"]])
[fi]
if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled ($grub_emu_usb_excuse)])
fi
if test x"$grub_emu_usb_excuse" = x ; then
enable_grub_emu_usb=yes
else
enable_grub_emu_usb=no
fi
if test x"$enable_grub_emu_sdl" = xno ; then
grub_emu_sdl_excuse="explicitly disabled"
fi
@@ -1394,6 +1215,10 @@ if test x"$enable_grub_emu_pci" != xyes ; then
grub_emu_pci_excuse="not enabled"
fi
if test x"$enable_grub_emu_usb" = xyes ; then
grub_emu_pci_excuse="conflicts with USB support"
fi
[if [ x"$grub_emu_pci_excuse" = x ]; then
# Check for libpci libraries.]
AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
@@ -1402,7 +1227,7 @@ fi
[fi]
[if [ x"$grub_emu_pci_excuse" = x ]; then
# Check for headers.]
AC_CHECK_HEADERS([pciaccess.h], [],
AC_CHECK_HEADERS([pci/pci.h], [],
[grub_emu_pci_excuse=["need libpciaccess headers"]])
[fi]
@@ -1414,12 +1239,14 @@ enable_grub_emu_pci=no
fi
AC_SUBST([enable_grub_emu_sdl])
AC_SUBST([enable_grub_emu_usb])
AC_SUBST([enable_grub_emu_pci])
else
# Ignore --enable-emu-* if platform is not emu
enable_grub_emu_sdl=no
enable_grub_emu_usb=no
enable_grub_emu_pci=no
fi
@@ -1471,12 +1298,10 @@ SAVED_CC="$CC"
SAVED_CPP="$CPP"
SAVED_CFLAGS="$CFLAGS"
SAVED_CPPFLAGS="$CPPFLAGS"
SAVED_LDFLAGS="$LDFLAGS"
CC="$BUILD_CC"
CPP="$BUILD_CPP"
CFLAGS="$BUILD_CFLAGS"
CPPFLAGS="$BUILD_CPPFLAGS"
LDFLAGS="$BUILD_LDFAGS"
unset ac_cv_c_bigendian
unset ac_cv_header_ft2build_h
@@ -1539,7 +1364,6 @@ CC="$SAVED_CC"
CPP="$SAVED_CPP"
CFLAGS="$SAVED_CFLAGS"
CPPFLAGS="$SAVED_CPPFLAGS"
LDFLAGS="$SAVED_LDFLAGS"
DJVU_FONT_SOURCE=
@@ -1559,7 +1383,7 @@ fi
if test x"$starfield_excuse" = x; then
for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do
for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do
if test -f "$dir/DejaVuSans.$ext"; then
DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
break 2
@@ -1586,7 +1410,7 @@ for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
# PCF and BDF from version 6.3 isn't hanled properly by libfreetype.
if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then
continue
continue;
fi
FONT_SOURCE="$dir/unifont.$ext"
break 2
@@ -1628,7 +1452,7 @@ fi
if test x"$grub_mount_excuse" = x ; then
# Check for fuse headers.
SAVED_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -DFUSE_USE_VERSION=26"
CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26"
AC_CHECK_HEADERS([fuse/fuse.h], [],
[grub_mount_excuse=["need FUSE headers"]])
CPPFLAGS="$SAVED_CPPFLAGS"
@@ -1671,7 +1495,7 @@ if test x"$device_mapper_excuse" = x ; then
fi
if test x"$device_mapper_excuse" = x ; then
LIBDEVMAPPER="-ldevmapper"
LIBDEVMAPPER="-ldevmapper";
AC_DEFINE([HAVE_DEVICE_MAPPER], [1],
[Define to 1 if you have the devmapper library.])
fi
@@ -1776,15 +1600,15 @@ if test x"$enable_werror" != xno ; then
HOST_CFLAGS="$HOST_CFLAGS -Werror"
fi
if test "x$grub_cv_cc_target_clang" = xno; then
TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc"
else
TARGET_LDFLAGS_STATIC_LIBGCC=
fi
TARGET_CPP="$TARGET_CC -E"
TARGET_CCAS=$TARGET_CC
# Includes which include make-time substitutions. They must come last
# as to avoid executing top_builddir in shell.
HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
GRUB_TARGET_CPU="${target_cpu}"
GRUB_PLATFORM="${platform}"
@@ -1792,11 +1616,12 @@ AC_SUBST(GRUB_TARGET_CPU)
AC_SUBST(GRUB_PLATFORM)
AC_SUBST(TARGET_OBJCONV)
AC_SUBST(TARGET_LIBGCC)
AC_SUBST(TARGET_LDFLAGS_STATIC_LIBGCC)
AC_SUBST(TARGET_CPP)
AC_SUBST(TARGET_CCAS)
AC_SUBST(TARGET_OBJ2ELF)
AC_SUBST(TARGET_MODULE_FORMAT)
AC_SUBST(TARGET_CC_VERSION)
AC_SUBST(TARGET_CFLAGS)
AC_SUBST(TARGET_LDFLAGS)
@@ -1819,8 +1644,8 @@ AC_SUBST(BUILD_LIBM)
# Automake conditionals
#
AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone])
AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
AM_CONDITIONAL([COND_clang], [test x$grub_cv_cc_target_clang = xyes])
AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
@@ -1846,15 +1671,10 @@ AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi])
AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ])
AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi])
AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd])
AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
AM_CONDITIONAL([COND_HOST_NETBSD], [test x$host_kernel = xnetbsd])
AM_CONDITIONAL([COND_HOST_WINDOWS], [test x$host_kernel = xwindows])
AM_CONDITIONAL([COND_HOST_KFREEBSD], [test x$host_kernel = xkfreebsd])
AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
@@ -1891,30 +1711,24 @@ AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir])
# Output files.
if test "$platform" != none; then
cpudir="${target_cpu}"
if test x${cpudir} = xmipsel; then
cpudir=mips;
fi
grub_CHECK_LINK_DIR
if test x"$link_dir" = xyes ; then
AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
if test "$platform" != emu ; then
AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
fi
else
mkdir -p include/grub 2>/dev/null
rm -rf include/grub/cpu
cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
if test "$platform" != emu ; then
rm -rf include/grub/machine
cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
fi
cpudir="${target_cpu}"
if test x${cpudir} = xmipsel; then
cpudir=mips;
fi
grub_CHECK_LINK_DIR
if test x"$link_dir" = xyes ; then
AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir])
if test "$platform" != emu ; then
AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform])
fi
else
# Just enough to stop the compiler failing with -I$(srcdir)/include.
mkdir -p include 2>/dev/null
rm -rf include/grub/cpu include/grub/machine
mkdir -p include/grub 2>/dev/null
rm -rf include/grub/cpu
cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null
if test "$platform" != emu ; then
rm -rf include/grub/machine
cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null
fi
fi
AC_CONFIG_FILES([Makefile])
@@ -1932,6 +1746,11 @@ echo "*******************************************************"
echo GRUB2 will be compiled with following components:
echo Platform: "$target_cpu"-"$platform"
if [ x"$platform" = xemu ]; then
if [ x"$grub_emu_usb_excuse" = x ]; then
echo USB support for grub-emu: Yes
else
echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
fi
if [ x"$grub_emu_sdl_excuse" = x ]; then
echo SDL support for grub-emu: Yes
else
@@ -1982,7 +1801,6 @@ echo grub-mount: No "($grub_mount_excuse)"
fi
if [ x"$starfield_excuse" = x ]; then
echo starfield theme: Yes
echo With DejaVuSans font from $DJVU_FONT_SOURCE
else
echo starfield theme: No "($starfield_excuse)"
fi

View File

@@ -108,16 +108,16 @@ The branches available are:
@table @samp
@item master
Main development branch.
Main developpement branch.
@item grub-legacy
GRUB 0.97 codebase. Kept for reference and legal reasons
@item multiboot
Multiboot specfication
@item multiboot2
Multiboot2 specfication
@item developer branches
Prefixed with developer name. Every developer of a team manages his own branches.
Developer branches do not need changelog entries.
@item developper branches
Prefixed with developper name. Every developper of a team manages his own branches.
Developper branches do not need changelog entries.
@end table
Once you have used @kbd{git clone} to fetch an initial copy of a branch, you
@@ -228,12 +228,12 @@ The opening @samp{/*} and closing @samp{*/} should be placed together on a line
Here is a brief map of the GRUB code base.
GRUB uses Autoconf and Automake, with most of the Automake input generated
by a Python script. The top-level build rules are in @file{configure.ac},
by AutoGen. The top-level build rules are in @file{configure.ac},
@file{grub-core/Makefile.core.def}, and @file{Makefile.util.def}. Each
block in a @file{*.def} file represents a build target, and specifies the
source files used to build it on various platforms. The @file{*.def} files
are processed into Automake input by @file{gentpl.py} (which you only need
to look at if you are extending the build system). If you are adding a new
are processed into AutoGen input by @file{gentpl.py} (which you only need to
look at if you are extending the build system). If you are adding a new
module which follows an existing pattern, such as a new command or a new
filesystem implementation, it is usually easiest to grep
@file{grub-core/Makefile.core.def} and @file{Makefile.util.def} for an

View File

@@ -5162,10 +5162,8 @@ by @var{shortname} which can be used to remove it (@pxref{net_del_route}).
Perform configuration of @var{card} using DHCP protocol. If no card name
is specified, try to configure all existing cards. If configuration was
successful, interface with name @var{card}@samp{:dhcp} and configured
address is added to @var{card}.
@comment If server provided gateway information in
@comment DHCP ACK packet, it is added as route entry with the name @var{card}@samp{:dhcp:gw}.
Additionally the following DHCP options are recognized and processed:
address is added to @var{card}. If server provided gateway information in
DHCP ACK packet, it is added as route entry with the name @var{card}@samp{:dhcp:gw}. Additionally the following DHCP options are recognized and processed:
@table @samp
@item 1 (Subnet Mask)
@@ -5428,12 +5426,10 @@ In order to enable authentication support, the @samp{superusers} environment
variable must be set to a list of usernames, separated by any of spaces,
commas, semicolons, pipes, or ampersands. Superusers are permitted to use
the GRUB command line, edit menu entries, and execute any menu entry. If
@samp{superusers} is set, then use of the command line and editing of menu
entries are automatically restricted to superusers. Setting @samp{superusers}
to empty string effectively disables both access to CLI and editing of menu
entries.
@samp{superusers} is set, then use of the command line is automatically
restricted to superusers.
Other users may be allowed to execute specific menu entries by giving a list of
Other users may be given access to specific menu entries by giving a list of
usernames (as above) using the @option{--users} option to the
@samp{menuentry} command (@pxref{menuentry}). If the @option{--unrestricted}
option is used for a menu entry, then that entry is unrestricted.
@@ -5852,7 +5848,7 @@ Following variables must be defined:
@multitable @columnfractions .30 .65
@item GRUB_PAYLOADS_DIR @tab directory containing the required kernels
@item GRUB_CBFSTOOL @tab cbfstool from Coreboot package (for coreboot platform only)
@item GRUB_CBFSTOOL @tab cbfstoll from Coreboot package (for coreboot platform only)
@item GRUB_COREBOOT_ROM @tab empty Coreboot ROM
@item GRUB_QEMU_OPTS @tab additional options to be supplied to QEMU
@end multitable

View File

@@ -76,13 +76,7 @@ for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i)
# Flattened Device Trees (FDT)
GROUPS["fdt"] = [ "arm64_efi", "arm_uboot", "arm_efi" ]
# Needs software helpers for division
# Must match GRUB_DIVISION_IN_SOFTWARE in misc.h
GROUPS["softdiv"] = GROUPS["arm"] + ["ia64_efi"]
GROUPS["no_softdiv"] = GRUB_PLATFORMS[:]
for i in GROUPS["softdiv"]: GROUPS["no_softdiv"].remove(i)
# Miscellaneous groups scheduled to disappear in future
# Miscelaneous groups schedulded to disappear in future
GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"]
GROUPS["nopc"] = GRUB_PLATFORMS[:]; GROUPS["nopc"].remove("i386_pc")
@@ -606,7 +600,7 @@ def foreach_enabled_platform(defn, closure):
# enable = emu;
# enable = i386;
# enable = mips_loongson;
# emu_condition = COND_GRUB_EMU_SDL;
# emu_condition = COND_GRUB_EMU_USB;
# };
#
def under_platform_specific_conditionals(defn, platform, closure):
@@ -759,7 +753,7 @@ def image(defn, platform):
if test x$(TARGET_APPLE_LINKER) = x1; then \
$(MACHO2IMG) $< $@; \
else \
$(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \
$(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \
fi
""")
@@ -834,20 +828,6 @@ def data(defn, platform):
var_add("dist_" + installdir(defn) + "_DATA", platform_sources(defn, platform))
gvar_add("dist_noinst_DATA", extra_dist(defn))
def transform_data(defn, platform):
name = defn['name']
var_add(installdir(defn) + "_DATA", name)
rule(name, "$(top_builddir)/config.status " + platform_sources(defn, platform) + platform_dependencies(defn, platform), """
(for x in """ + platform_sources(defn, platform) + """; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
chmod a+x """ + name + """
""")
gvar_add("CLEANFILES", name)
gvar_add("EXTRA_DIST", extra_dist(defn))
gvar_add("dist_noinst_DATA", platform_sources(defn, platform))
def script(defn, platform):
name = defn['name']
@@ -895,7 +875,6 @@ rules("library", library)
rules("program", program)
rules("script", script)
rules("data", data)
rules("transform_data", transform_data)
write_output(section='decl')
write_output()

View File

@@ -26,22 +26,20 @@ CFLAGS_LIBRARY += $(CFLAGS_PLATFORM) -fno-builtin
CPPFLAGS_LIBRARY += $(CPPFLAGS_PLATFORM)
CCASFLAGS_LIBRARY += $(CCASFLAGS_PLATFORM)
build-grub-pep2elf$(BUILD_EXEEXT): $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=64 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pep2elf\" $^
CLEANFILES += build-grub-pep2elf$(BUILD_EXEEXT)
build-grub-pep2elf: $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=64 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pep2elf\" $^
build-grub-pe2elf$(BUILD_EXEEXT): $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=32 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pe2elf\" $^
CLEANFILES += build-grub-pe2elf$(BUILD_EXEEXT)
build-grub-pe2elf: $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=32 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pe2elf\" $^
# gentrigtables
gentrigtables$(BUILD_EXEEXT): gentrigtables.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $< $(BUILD_LIBM)
CLEANFILES += gentrigtables$(BUILD_EXEEXT)
gentrigtables: gentrigtables.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $< $(BUILD_LIBM)
CLEANFILES += gentrigtables
# trigtables.c
trigtables.c: gentrigtables$(BUILD_EXEEXT) gentrigtables.c $(top_srcdir)/configure.ac
./gentrigtables$(BUILD_EXEEXT) > $@
trigtables.c: gentrigtables gentrigtables.c $(top_srcdir)/configure.ac
./gentrigtables > $@
CLEANFILES += trigtables.c
# XXX Use Automake's LEX & YACC support
@@ -76,11 +74,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i18n.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/list.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/misc.h
if COND_emu
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt-emu.h
else
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt.h
endif
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/parser.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/partition.h
@@ -88,6 +81,9 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h
if !COND_clang
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
endif
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h
if COND_i386_pc
@@ -250,6 +246,9 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
if COND_GRUB_EMU_SDL
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h
endif
if COND_GRUB_EMU_USB
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libusb.h
endif
if COND_GRUB_EMU_PCI
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libpciaccess.h
endif
@@ -293,12 +292,12 @@ grub_emu-grub_emu_init.$(OBJEXT):grub_emu_init.h
kern/emu/grub_emu_dyn-main.$(OBJEXT):grub_emu_init.h
grub_emu_dyn-grub_emu_init.$(OBJEXT):grub_emu_init.h
grub_emu_init.h: genemuinitheader.sh $(MODULE_FILES)
rm -f $@; echo $(MODULE_FILES) | sh $(srcdir)/genemuinitheader.sh $(TARGET_NM) > $@
grub_emu_init.h: genemuinitheader.sh $(MOD_FILES)
rm -f $@; echo $(MOD_FILES) | sh $(srcdir)/genemuinitheader.sh $(TARGET_NM) > $@
CLEANFILES += grub_emu_init.h
grub_emu_init.c: grub_emu_init.h genemuinit.sh $(MODULE_FILES)
rm -f $@; echo $(MODULE_FILES) | sh $(srcdir)/genemuinit.sh $(TARGET_NM) > $@
grub_emu_init.c: grub_emu_init.h genemuinit.sh $(MOD_FILES)
rm -f $@; echo $(MOD_FILES) | sh $(srcdir)/genemuinit.sh $(TARGET_NM) > $@
CLEANFILES += grub_emu_init.c
endif

View File

@@ -1,43 +1,43 @@
AutoGen definitions Makefile.tpl;
transform_data = {
script = {
installdir = noinst;
name = gensyminfo.sh;
common = gensyminfo.sh.in;
};
transform_data = {
script = {
installdir = noinst;
name = genmod.sh;
common = genmod.sh.in;
};
transform_data = {
script = {
installdir = noinst;
name = modinfo.sh;
common = modinfo.sh.in;
};
transform_data = {
script = {
installdir = platform;
name = gmodule.pl;
common = gmodule.pl.in;
};
transform_data = {
script = {
installdir = platform;
name = gdb_grub;
common = gdb_grub.in;
};
transform_data = {
script = {
installdir = platform;
name = grub.chrp;
common = boot/powerpc/grub.chrp.in;
enable = powerpc_ieee1275;
};
transform_data = {
script = {
installdir = platform;
name = bootinfo.txt;
common = boot/powerpc/bootinfo.txt.in;
@@ -66,7 +66,7 @@ kernel = {
arm_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
arm64_efi_ldflags = '-Wl,-r,-d';
arm64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame';
arm64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000';
@@ -83,6 +83,8 @@ kernel = {
x86_64_xen_ldflags = '$(TARGET_IMG_LDFLAGS)';
x86_64_xen_ldflags = '$(TARGET_IMG_BASE_LDOPT),0';
ldadd = '$(LDADD_KERNEL)';
mips_loongson_ldflags = '-Wl,-Ttext,0x80200000';
powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
@@ -130,7 +132,6 @@ kernel = {
common = kern/rescue_reader.c;
common = kern/term.c;
noemu = kern/compiler-rt.c;
noemu = kern/mm.c;
noemu = kern/time.c;
noemu = kern/generic/millisleep.c;
@@ -158,8 +159,6 @@ kernel = {
terminfoinkernel = commands/extcmd.c;
terminfoinkernel = lib/arg.c;
softdiv = lib/division.c;
i386 = kern/i386/dl.c;
i386_xen = kern/i386/dl.c;
@@ -253,7 +252,6 @@ kernel = {
powerpc_ieee1275 = kern/powerpc/cache.S;
powerpc_ieee1275 = kern/powerpc/dl.c;
powerpc_ieee1275 = kern/powerpc/compiler-rt.S;
sparc64_ieee1275 = kern/sparc64/cache.S;
sparc64_ieee1275 = kern/sparc64/dl.c;
@@ -265,7 +263,7 @@ kernel = {
arm = kern/arm/cache_armv7.S;
extra_dist = kern/arm/cache.S;
arm = kern/arm/cache.c;
arm = kern/arm/compiler-rt.S;
arm = kern/arm/misc.S;
arm64 = kern/arm64/cache.c;
arm64 = kern/arm64/cache_flush.S;
@@ -443,13 +441,13 @@ image = {
common = lib/xzembed/xz_dec_bcj.c;
common = lib/xzembed/xz_dec_lzma2.c;
common = lib/xzembed/xz_dec_stream.c;
common = kern/compiler-rt.c;
cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1';
objcopyflags = '-O binary';
mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
cflags = '-Wno-unreachable-code';
mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
ldadd = '$(TARGET_LIBGCC)';
cflags = '-Wno-unreachable-code $(TARGET_LDFLAGS_STATIC_LIBGCC)';
enable = mips;
};
@@ -461,7 +459,9 @@ image = {
cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1';
objcopyflags = '-O binary';
mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
ldadd = '$(TARGET_LIBGCC)';
cflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC)';
enable = mips;
};
@@ -479,7 +479,7 @@ image = {
name = fwstart;
mips_loongson = boot/mips/loongson/fwstart.S;
objcopyflags = '-O binary';
ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
enable = mips_loongson;
};
@@ -487,7 +487,7 @@ image = {
name = fwstart_fuloong2f;
mips_loongson = boot/mips/loongson/fuloong2f.S;
objcopyflags = '-O binary';
ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
enable = mips_loongson;
};
@@ -509,6 +509,13 @@ module = {
enable = x86;
};
module = {
name = libusb;
emu = bus/usb/emu/usb.c;
enable = emu;
condition = COND_GRUB_EMU_USB;
};
module = {
name = lsspd;
mips_loongson = commands/mips/loongson/lsspd.c;
@@ -523,6 +530,13 @@ module = {
enable = usb;
};
module = {
name = emuusb;
common = bus/usb/usb.c;
enable = emu;
condition = COND_GRUB_EMU_USB;
};
module = {
name = usbserial_common;
common = bus/usb/serial/common.c;
@@ -1385,6 +1399,11 @@ module = {
common = fs/tar.c;
};
module = {
name = greffs;
common = fs/greffs.c;
};
module = {
name = udf;
common = fs/udf.c;
@@ -1448,6 +1467,7 @@ module = {
module = {
name = gfxmenu;
common = gfxmenu/gfxmenu.c;
common = gfxmenu/model.c;
common = gfxmenu/view.c;
common = gfxmenu/font.c;
common = gfxmenu/icon_manager.c;
@@ -1646,13 +1666,6 @@ module = {
enable = x86;
};
module = {
name = xen_boot;
common = lib/cmdline.c;
arm64 = loader/arm64/xen_boot.c;
enable = arm64;
};
module = {
name = linux;
x86 = loader/i386/linux.c;
@@ -1671,12 +1684,6 @@ module = {
enable = noemu;
};
module = {
name = fdt;
arm64 = loader/arm64/fdt.c;
enable = arm64;
};
module = {
name = xnu;
x86 = loader/xnu_resume.c;
@@ -1967,42 +1974,11 @@ module = {
enable = xen;
};
module = {
name = div;
common = lib/division.c;
enable = no_softdiv;
};
module = {
name = div_test;
common = tests/div_test.c;
};
module = {
name = mul_test;
common = tests/mul_test.c;
};
module = {
name = shift_test;
common = tests/shift_test.c;
};
module = {
name = cmp_test;
common = tests/cmp_test.c;
};
module = {
name = ctz_test;
common = tests/ctz_test.c;
};
module = {
name = bswap_test;
common = tests/bswap_test.c;
};
module = {
name = videotest_checksum;
common = tests/videotest_checksum.c;

View File

@@ -21,7 +21,7 @@
#include <grub/decompressor.h>
void *
grub_memset (void *s, int c, grub_size_t len)
memset (void *s, int c, grub_size_t len)
{
grub_uint8_t *ptr;
for (ptr = s; len; ptr++, len--)
@@ -68,6 +68,15 @@ grub_memcmp (const void *s1, const void *s2, grub_size_t n)
return 0;
}
int memcmp (const void *s1, const void *s2, grub_size_t n)
__attribute__ ((alias ("grub_memcmp")));
void *memmove (void *dest, const void *src, grub_size_t n)
__attribute__ ((alias ("grub_memmove")));
void *memcpy (void *dest, const void *src, grub_size_t n)
__attribute__ ((alias ("grub_memmove")));
void *grub_decompressor_scratch;
void

View File

@@ -179,14 +179,14 @@ start:
* End of BIOS parameter block.
*/
LOCAL(kernel_address):
kernel_address:
.word GRUB_BOOT_MACHINE_KERNEL_ADDR
#ifndef HYBRID_BOOT
.org GRUB_BOOT_MACHINE_KERNEL_SECTOR
LOCAL(kernel_sector):
kernel_sector:
.long 1
LOCAL(kernel_sector_high):
kernel_sector_high:
.long 0
#endif
@@ -275,7 +275,7 @@ real_start:
andw $1, %cx
jz LOCAL(chs_mode)
LOCAL(lba_mode):
lba_mode:
xorw %ax, %ax
movw %ax, 4(%si)
@@ -290,9 +290,9 @@ LOCAL(lba_mode):
movw $0x0010, (%si)
/* the absolute address */
movl LOCAL(kernel_sector), %ebx
movl kernel_sector, %ebx
movl %ebx, 8(%si)
movl LOCAL(kernel_sector_high), %ebx
movl kernel_sector_high, %ebx
movl %ebx, 12(%si)
/* the segment of buffer address */
@@ -361,13 +361,13 @@ LOCAL(final_init):
setup_sectors:
/* load logical sector start (top half) */
movl LOCAL(kernel_sector_high), %eax
movl kernel_sector_high, %eax
orl %eax, %eax
jnz LOCAL(geometry_error)
/* load logical sector start (bottom half) */
movl LOCAL(kernel_sector), %eax
movl kernel_sector, %eax
/* zero %edx */
xorl %edx, %edx
@@ -452,7 +452,7 @@ LOCAL(copy_buffer):
popa
/* boot kernel */
jmp *(LOCAL(kernel_address))
jmp *(kernel_address)
/* END OF MAIN LOOP */
@@ -512,9 +512,9 @@ LOCAL(message):
#ifdef HYBRID_BOOT
.org 0x1b0
LOCAL(kernel_sector):
kernel_sector:
.long 1
LOCAL(kernel_sector_high):
kernel_sector_high:
.long 0
#endif
.org GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC

View File

@@ -41,7 +41,7 @@ data_start:
xorl %ebp, %ebp
jmp LOCAL(linux_next)
.org 0x1F1
.org 0x1F1
setup_sects:
.byte CODE_SECTORS
@@ -292,4 +292,4 @@ LOCAL(fail):
err_int15_msg:
.ascii "move memory fails\0"
.org (CODE_SECTORS * 512 + 512)
.org (CODE_SECTORS + 1) * 512

View File

@@ -38,5 +38,5 @@ start:
/* This region is a junk. Do you say that this is wasteful?
But I like that the memory layout of the body is consistent
among different kernels rather than scamping just for 1.5KB. */
.org 0x8200 - 0x7C00 - 0x200 - 1
.org 0x8200 - 0x7C00 - 0x200 - 1
.byte 0

View File

@@ -48,9 +48,8 @@ VARIABLE(grub_core_entry_addr)
/* Transition to protected mode. We use pushl to force generation
of a flat return address. */
pushl $1f
jmp real_to_prot
jmpl real_to_prot
.code32
1:
/* Ensure A20 is enabled. We're in qemu, so control port A works
and there is no need to wait since there is no real logic, it's
all emulated. */
@@ -58,6 +57,7 @@ VARIABLE(grub_core_entry_addr)
andb $(~0x03), %al
orb $0x02, %al
outb $0x92
1:
movl EXT_C(grub_core_entry_addr), %edx
jmp *%edx

View File

@@ -344,7 +344,7 @@ printhex:
nop
srl $t1, $a0, 28
addiu $t1, $t1, -10
bltz $t1, 2f
blt $t1, $zero, 2f
sll $a0, $a0, 4
addiu $t1, $t1, 'A'-10-'0'
2: addiu $t1, $t1, '0'+10
@@ -398,7 +398,7 @@ read_spd:
move $t2, $a0
move $t3, $ra
lui $a0, %hi(read_spd_fail)
addiu $a0, $a0, %lo(read_spd_fail)
addiu $a0, $a0, %hi(read_spd_fail)
/* Send START. */
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F)
@@ -547,7 +547,7 @@ gpio_dump:
#endif
gpio_dump_end:
.p2align 3
.p2align
write_dumpreg:
ld $t2, 0($t6)

View File

@@ -22,7 +22,6 @@
#include <grub/machine/memory.h>
#include <grub/machine/kernel.h>
#include <grub/offsets.h>
#include <grub/mips/asm.h>
#define BASE_ADDR 8
@@ -119,50 +118,50 @@ parsestr:
move $v0, $zero
move $t3, $t1
3:
lb GRUB_ASM_T4, 0($t2)
lb GRUB_ASM_T5, 0($t3)
lb $t4, 0($t2)
lb $t5, 0($t3)
addiu $t2, $t2, 1
addiu $t3, $t3, 1
beq GRUB_ASM_T5, $zero, 1f
beq $t5, $zero, 1f
nop
beq GRUB_ASM_T5, GRUB_ASM_T4, 3b
beq $t5, $t4, 3b
nop
bne GRUB_ASM_T4, $zero, 1f
bne $t4, $zero, 1f
nop
addiu $t3, $t3, 0xffff
digcont:
lb GRUB_ASM_T5, 0($t3)
lb $t5, 0($t3)
/* Substract '0' from digit. */
addiu GRUB_ASM_T5, GRUB_ASM_T5, 0xffd0
bltz GRUB_ASM_T5, 1f
addiu $t5, $t5, 0xffd0
bltz $t5, 1f
nop
addiu GRUB_ASM_T4, GRUB_ASM_T5, 0xfff7
bgtz GRUB_ASM_T4, 1f
addiu $t4, $t5, 0xfff7
bgtz $t4, 1f
nop
/* Multiply $v0 by 10 with bitshifts. */
sll $v0, $v0, 1
sll GRUB_ASM_T4, $v0, 2
addu $v0, $v0, GRUB_ASM_T4
addu $v0, $v0, GRUB_ASM_T5
sll $t4, $v0, 2
addu $v0, $v0, $t4
addu $v0, $v0, $t5
addiu $t3, $t3, 1
b digcont
nop
1:
jr $ra
nop
busclockstr: .asciz "busclock="
cpuclockstr: .asciz "cpuclock="
memsizestr: .asciz "memsize="
highmemsizestr: .asciz "highmemsize="
machtype_yeeloong_str1: .asciz "machtype=8.9"
machtype_yeeloong_str2: .asciz "machtype=lemote-yeeloong-"
machtype_fuloong2f_str: .asciz "machtype=lemote-fuloong-2f"
machtype_fuloong2e_str: .asciz "machtype=lemote-fuloong-2e"
pmon_yeeloong_str: .asciz "PMON_VER=LM8"
pmon_fuloong2f_str: .asciz "PMON_VER=LM6"
pmon_yeeloong_verstr: .asciz "Version=LM8"
pmon_fuloong2f_verstr: .asciz "Version=LM6"
busclockstr: .asciiz "busclock="
cpuclockstr: .asciiz "cpuclock="
memsizestr: .asciiz "memsize="
highmemsizestr: .asciiz "highmemsize="
machtype_yeeloong_str1: .asciiz "machtype=8.9"
machtype_yeeloong_str2: .asciiz "machtype=lemote-yeeloong-"
machtype_fuloong2f_str: .asciiz "machtype=lemote-fuloong-2f"
machtype_fuloong2e_str: .asciiz "machtype=lemote-fuloong-2e"
pmon_yeeloong_str: .asciiz "PMON_VER=LM8"
pmon_fuloong2f_str: .asciiz "PMON_VER=LM6"
pmon_yeeloong_verstr: .asciiz "Version=LM8"
pmon_fuloong2f_verstr: .asciiz "Version=LM6"
.p2align 2
argdone:
@@ -183,10 +182,10 @@ argdone:
b argdone
addiu $a1, $a1, 4
do_check:
lb GRUB_ASM_T4, 0($t7)
beq GRUB_ASM_T4, $zero, 1f
lb $t4, 0($t7)
beq $t4, $zero, 1f
lb $t3, 0($t6)
bne $t3, GRUB_ASM_T4, 2f
bne $t3, $t4, 2f
addiu $t6, $t6, 1
b do_check
addiu $t7, $t7, 1
@@ -223,8 +222,8 @@ cmdlinedone:
1:
beq $t1, $t3, 2f
lb GRUB_ASM_T4, 0($t2)
sb GRUB_ASM_T4, 0($t1)
lb $t4, 0($t2)
sb $t4, 0($t1)
addiu $t1, $t1, 1
b 1b
addiu $t2, $t2, 1

View File

@@ -55,8 +55,7 @@ grub_pci_device_map_range (grub_pci_device_t dev, grub_addr_t base,
int err;
err = pci_device_map_range (dev, base, size, PCI_DEV_MAP_FLAG_WRITABLE, &addr);
if (err)
grub_util_error ("mapping 0x%llx failed (error %d)",
(unsigned long long) base, err);
grub_util_error ("mapping 0x%x failed (error %d)\n", base, err);
return addr;
}
@@ -67,12 +66,12 @@ grub_pci_device_unmap_range (grub_pci_device_t dev, void *mem,
pci_device_unmap_range (dev, mem, size);
}
GRUB_MOD_INIT (emupci)
GRUB_MOD_INIT (pci)
{
pci_system_init ();
}
GRUB_MOD_FINI (emupci)
GRUB_MOD_FINI (pci)
{
pci_system_cleanup ();
}

View File

@@ -670,23 +670,23 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
for (i = 0; i < (GRUB_EHCI_N_TD - 1); i++)
{
e->td_virt[i].link_td = e->td_phys + (i + 1) * sizeof (struct grub_ehci_td);
e->td_virt[i].next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
e->td_virt[i].alt_next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
e->td_virt[i].next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
e->td_virt[i].alt_next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
}
e->td_virt[GRUB_EHCI_N_TD - 1].next_td =
grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
e->td_virt[GRUB_EHCI_N_TD - 1].alt_next_td =
grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
e->tdfree_virt = e->td_virt;
/* Set Terminate in first QH, which is used in framelist */
e->qh_virt[0].qh_hptr = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE | GRUB_EHCI_HPTR_TYPE_QH);
e->qh_virt[0].td_overlay.next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
e->qh_virt[0].qh_hptr = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE | GRUB_EHCI_HPTR_TYPE_QH);
e->qh_virt[0].td_overlay.next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
e->qh_virt[0].td_overlay.alt_next_td =
grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
/* Also set Halted bit in token */
e->qh_virt[0].td_overlay.token = grub_cpu_to_le32_compile_time (GRUB_EHCI_STATUS_HALTED);
e->qh_virt[0].td_overlay.token = grub_cpu_to_le32 (GRUB_EHCI_STATUS_HALTED);
/* Set the H bit in first QH used for AL */
e->qh_virt[1].ep_char = grub_cpu_to_le32_compile_time (GRUB_EHCI_H);
e->qh_virt[1].ep_char = grub_cpu_to_le32 (GRUB_EHCI_H);
/* Set Terminate into TD in rest of QHs and set horizontal link
* pointer to itself - these QHs will be used for asynchronous
* schedule and they should have valid value in horiz. link */
@@ -697,12 +697,12 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
e->qh_chunk) &
GRUB_EHCI_POINTER_MASK) | GRUB_EHCI_HPTR_TYPE_QH);
e->qh_virt[i].td_overlay.next_td =
grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
e->qh_virt[i].td_overlay.alt_next_td =
grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
/* Also set Halted bit in token */
e->qh_virt[i].td_overlay.token =
grub_cpu_to_le32_compile_time (GRUB_EHCI_STATUS_HALTED);
grub_cpu_to_le32 (GRUB_EHCI_STATUS_HALTED);
}
/* Note: QH 0 and QH 1 are reserved and must not be used anywhere.
@@ -991,7 +991,7 @@ grub_ehci_find_qh (struct grub_ehci *e, grub_usb_transfer_t transfer)
target = ((transfer->endpoint << GRUB_EHCI_EP_NUM_OFF) |
transfer->devaddr) & GRUB_EHCI_TARGET_MASK;
target = grub_cpu_to_le32 (target);
mask = grub_cpu_to_le32_compile_time (GRUB_EHCI_TARGET_MASK);
mask = grub_cpu_to_le32 (GRUB_EHCI_TARGET_MASK);
/* low speed interrupt transfers are linked to the periodic */
/* schedule, everything else to the asynchronous schedule */
@@ -1200,7 +1200,7 @@ grub_ehci_transaction (struct grub_ehci *e,
grub_memset ((void *) td, 0, sizeof (struct grub_ehci_td));
/* Don't point to any TD yet, just terminate. */
td->next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
td->next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
/* Set alternate pointer. When short packet occurs, alternate TD
* will not be really fetched because it is not active. But don't
* forget, EHCI will try to fetch alternate TD every scan of AL
@@ -1325,9 +1325,9 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
/* Fill whole alternate TD by zeros (= inactive) and set
* Terminate bits and Halt bit */
grub_memset ((void *) cdata->td_alt_virt, 0, sizeof (struct grub_ehci_td));
cdata->td_alt_virt->next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
cdata->td_alt_virt->alt_next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
cdata->td_alt_virt->token = grub_cpu_to_le32_compile_time (GRUB_EHCI_STATUS_HALTED);
cdata->td_alt_virt->next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
cdata->td_alt_virt->alt_next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
cdata->td_alt_virt->token = grub_cpu_to_le32 (GRUB_EHCI_STATUS_HALTED);
/* Allocate appropriate number of TDs and set */
for (i = 0; i < transfer->transcnt; i++)
@@ -1364,7 +1364,7 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
cdata->td_last_virt = td;
cdata->td_last_phys = grub_dma_virt2phys (td, e->td_chunk);
/* Last TD should not have set alternate TD */
cdata->td_last_virt->alt_next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
cdata->td_last_virt->alt_next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
grub_dprintf ("ehci", "setup_transfer: cdata=%p, qh=%p\n",
cdata,cdata->qh_virt);
@@ -1377,14 +1377,14 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
/* Start transfer: */
/* Unlink possible alternate pointer in QH */
cdata->qh_virt->td_overlay.alt_next_td =
grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE);
grub_cpu_to_le32 (GRUB_EHCI_TERMINATE);
/* Link new TDs with QH via next_td */
cdata->qh_virt->td_overlay.next_td =
grub_cpu_to_le32 (grub_dma_virt2phys
(cdata->td_first_virt, e->td_chunk));
/* Reset Active and Halted bits in QH to activate Advance Queue,
* i.e. reset token */
cdata->qh_virt->td_overlay.token = grub_cpu_to_le32_compile_time (0);
cdata->qh_virt->td_overlay.token = grub_cpu_to_le32 (0);
/* Finito */
transfer->controller_data = cdata;
@@ -1408,9 +1408,9 @@ grub_ehci_pre_finish_transfer (grub_usb_transfer_t transfer)
* safely manipulate with QH TD part. */
cdata->qh_virt->td_overlay.token = (cdata->qh_virt->td_overlay.token
|
grub_cpu_to_le32_compile_time
grub_cpu_to_le32
(GRUB_EHCI_STATUS_HALTED)) &
grub_cpu_to_le32_compile_time (~GRUB_EHCI_STATUS_ACTIVE);
grub_cpu_to_le32 (~GRUB_EHCI_STATUS_ACTIVE);
/* Print debug data here if necessary */

203
grub-core/bus/usb/emu/usb.c Normal file
View File

@@ -0,0 +1,203 @@
/* usb.c -- libusb USB support for GRUB. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 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 <config.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <usb.h>
#include <grub/usb.h>
#include <grub/dl.h>
GRUB_MOD_LICENSE ("GPLv3+");
static struct grub_usb_controller_dev usb_controller =
{
.name = "libusb"
};
static struct grub_usb_device *grub_usb_devs[128];
struct usb_bus *busses;
static grub_err_t
grub_libusb_devices (void)
{
struct usb_bus *bus;
int last = 0;
busses = usb_get_busses();
for (bus = busses; bus; bus = bus->next)
{
struct usb_device *usbdev;
struct grub_usb_device *dev;
for (usbdev = bus->devices; usbdev; usbdev = usbdev->next)
{
struct usb_device_descriptor *desc = &usbdev->descriptor;
grub_err_t err;
if (! desc->bcdUSB)
continue;
dev = grub_malloc (sizeof (*dev));
if (! dev)
return grub_errno;
dev->data = usbdev;
/* Fill in all descriptors. */
err = grub_usb_device_initialize (dev);
if (err)
{
grub_errno = GRUB_ERR_NONE;
continue;
}
/* Register the device. */
grub_usb_devs[last++] = dev;
}
}
return GRUB_USB_ERR_NONE;
}
void
grub_usb_poll_devices (void)
{
/* TODO: recheck grub_usb_devs */
}
int
grub_usb_iterate (grub_usb_iterate_hook_t hook, void *hook_data)
{
int i;
for (i = 0; i < 128; i++)
{
if (grub_usb_devs[i])
{
if (hook (grub_usb_devs[i], hook_data))
return 1;
}
}
return 0;
}
grub_usb_err_t
grub_usb_root_hub (grub_usb_controller_t controller __attribute__((unused)))
{
return GRUB_USB_ERR_NONE;
}
grub_usb_err_t
grub_usb_control_msg (grub_usb_device_t dev, grub_uint8_t reqtype,
grub_uint8_t request, grub_uint16_t value,
grub_uint16_t idx, grub_size_t size, char *data)
{
usb_dev_handle *devh;
struct usb_device *d = dev->data;
devh = usb_open (d);
if (usb_control_msg (devh, reqtype, request,
value, idx, data, size, 20) < 0)
{
usb_close (devh);
return GRUB_USB_ERR_STALL;
}
usb_close (devh);
return GRUB_USB_ERR_NONE;
}
grub_usb_err_t
grub_usb_bulk_read (grub_usb_device_t dev,
int endpoint, grub_size_t size, char *data)
{
usb_dev_handle *devh;
struct usb_device *d = dev->data;
devh = usb_open (d);
if (usb_claim_interface (devh, 0) < 1)
{
usb_close (devh);
return GRUB_USB_ERR_STALL;
}
if (usb_bulk_read (devh, endpoint, data, size, 20) < 1)
{
usb_close (devh);
return GRUB_USB_ERR_STALL;
}
usb_release_interface (devh, 0);
usb_close (devh);
return GRUB_USB_ERR_NONE;
}
grub_usb_err_t
grub_usb_bulk_write (grub_usb_device_t dev,
int endpoint, grub_size_t size, char *data)
{
usb_dev_handle *devh;
struct usb_device *d = dev->data;
devh = usb_open (d);
if (usb_claim_interface (devh, 0) < 0)
goto fail;
if (usb_bulk_write (devh, endpoint, data, size, 20) < 0)
goto fail;
if (usb_release_interface (devh, 0) < 0)
goto fail;
usb_close (devh);
return GRUB_USB_ERR_NONE;
fail:
usb_close (devh);
return GRUB_USB_ERR_STALL;
}
GRUB_MOD_INIT (libusb)
{
usb_init();
usb_find_busses();
usb_find_devices();
if (grub_libusb_devices ())
return;
grub_usb_controller_dev_register (&usb_controller);
return;
}
GRUB_MOD_FINI (libusb)
{
return;
}

View File

@@ -314,7 +314,7 @@ grub_ohci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
grub_memset ((void *) o->ed_ctrl, 0, sizeof (struct grub_ohci_ed)
* GRUB_OHCI_CTRL_EDS);
for (j=0; j < GRUB_OHCI_CTRL_EDS; j++)
o->ed_ctrl[j].target = grub_cpu_to_le32_compile_time (1 << 14); /* skip */
o->ed_ctrl[j].target = grub_cpu_to_le32 (1 << 14); /* skip */
grub_dprintf ("ohci", "EDs-C: chunk=%p, virt=%p, phys=0x%02x\n",
o->ed_ctrl_chunk, o->ed_ctrl, o->ed_ctrl_addr);
@@ -329,7 +329,7 @@ grub_ohci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
/* Preset EDs */
grub_memset ((void*)o->ed_bulk, 0, sizeof(struct grub_ohci_ed) * GRUB_OHCI_BULK_EDS);
for (j=0; j < GRUB_OHCI_BULK_EDS; j++)
o->ed_bulk[j].target = grub_cpu_to_le32_compile_time (1 << 14); /* skip */
o->ed_bulk[j].target = grub_cpu_to_le32 (1 << 14); /* skip */
grub_dprintf ("ohci", "EDs-B: chunk=%p, virt=%p, phys=0x%02x\n",
o->ed_bulk_chunk, o->ed_bulk, o->ed_bulk_addr);
@@ -750,10 +750,7 @@ grub_ohci_setup_transfer (grub_usb_controller_t dev,
{
cdata->td_head_virt = grub_ohci_alloc_td (o);
if (!cdata->td_head_virt)
{
grub_free (cdata);
return GRUB_USB_ERR_INTERNAL; /* We don't need de-allocate ED */
}
return GRUB_USB_ERR_INTERNAL; /* We don't need de-allocate ED */
/* We can set td_head only when ED is not active, i.e.
* when it is newly allocated. */
cdata->ed_virt->td_head
@@ -1352,10 +1349,10 @@ grub_ohci_fini_hw (int noreturn __attribute__ ((unused)))
/* Set skip in all EDs */
if (o->ed_bulk)
for (i=0; i < GRUB_OHCI_BULK_EDS; i++)
o->ed_bulk[i].target |= grub_cpu_to_le32_compile_time (1 << 14); /* skip */
o->ed_bulk[i].target |= grub_cpu_to_le32 (1 << 14); /* skip */
if (o->ed_ctrl)
for (i=0; i < GRUB_OHCI_CTRL_EDS; i++)
o->ed_ctrl[i].target |= grub_cpu_to_le32_compile_time (1 << 14); /* skip */
o->ed_ctrl[i].target |= grub_cpu_to_le32 (1 << 14); /* skip */
/* We should wait for next SOF to be sure that all EDs are
* unaccessed by OHCI. But OHCI can be non-functional, so

View File

@@ -625,7 +625,9 @@ grub_uhci_check_transfer (grub_usb_controller_t dev,
return GRUB_USB_ERR_NONE;
}
if (errtd && !(errtd->ctrl_status & (1 << 23)))
grub_dprintf ("uhci", "t status=0x%02x\n", errtd->ctrl_status);
if (!(errtd->ctrl_status & (1 << 23)))
{
grub_usb_err_t err = GRUB_USB_ERR_NONE;

View File

@@ -31,7 +31,7 @@ grub_usb_bulk_maxpacket (grub_usb_device_t dev,
struct grub_usb_desc_endp *endpoint)
{
/* Use the maximum packet size given in the endpoint descriptor. */
if (dev->initialized && endpoint && (unsigned int) endpoint->maxpacket)
if (dev->initialized && endpoint)
return endpoint->maxpacket;
return 64;
@@ -311,8 +311,8 @@ grub_usb_bulk_finish_readwrite (grub_usb_transfer_t transfer)
transfer->size + 1);
grub_free (transfer->transactions);
grub_dma_free (transfer->data_chunk);
grub_free (transfer);
grub_dma_free (transfer->data_chunk);
}
static grub_usb_err_t

View File

@@ -131,8 +131,6 @@ grub_acpi_get_rsdpv1 (void)
return grub_machine_acpi_get_rsdpv1 ();
}
#if defined (__i386__) || defined (__x86_64__)
static inline int
iszero (grub_uint8_t *reg, int size)
{
@@ -143,6 +141,7 @@ iszero (grub_uint8_t *reg, int size)
return 1;
}
#if defined (__i386__) || defined (__x86_64__)
/* Context for grub_acpi_create_ebda. */
struct grub_acpi_create_ebda_ctx {
int ebda_len;
@@ -180,10 +179,8 @@ grub_acpi_create_ebda (void)
struct grub_acpi_rsdp_v20 *v2;
ebda = (grub_uint8_t *) (grub_addr_t) ((*((grub_uint16_t *)0x40e)) << 4);
grub_dprintf ("acpi", "EBDA @%p\n", ebda);
if (ebda)
ebda_kb_len = *(grub_uint16_t *) ebda;
grub_dprintf ("acpi", "EBDA length 0x%x\n", ebda_kb_len);
if (ebda_kb_len > 16)
ebda_kb_len = 0;
ctx.ebda_len = (ebda_kb_len + 1) << 10;
@@ -230,7 +227,7 @@ grub_acpi_create_ebda (void)
grub_dprintf ("acpi", "Copying rsdpv2 to %p\n", target);
v2inebda = target;
target += v2->length;
target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
v2 = 0;
break;
}
@@ -249,7 +246,7 @@ grub_acpi_create_ebda (void)
grub_dprintf ("acpi", "Copying rsdpv1 to %p\n", target);
v1inebda = target;
target += sizeof (struct grub_acpi_rsdp_v10);
target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
v1 = 0;
break;
}
@@ -268,7 +265,7 @@ grub_acpi_create_ebda (void)
grub_memcpy (target, v2, v2->length);
v2inebda = target;
target += v2->length;
target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
v2 = 0;
break;
}
@@ -285,7 +282,7 @@ grub_acpi_create_ebda (void)
grub_memcpy (target, v1, sizeof (struct grub_acpi_rsdp_v10));
v1inebda = target;
target += sizeof (struct grub_acpi_rsdp_v10);
target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1);
v1 = 0;
break;
}
@@ -497,8 +494,6 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
if (! rsdp)
rsdp = grub_machine_acpi_get_rsdpv1 ();
grub_dprintf ("acpi", "RSDP @%p\n", rsdp);
if (rsdp)
{
grub_uint32_t *entry_ptr;

View File

@@ -135,49 +135,6 @@ skip_data_ref_object (const grub_uint8_t *ptr, const grub_uint8_t *end)
}
}
static inline grub_uint32_t
skip_term (const grub_uint8_t *ptr, const grub_uint8_t *end)
{
grub_uint32_t add;
const grub_uint8_t *ptr0 = ptr;
switch(*ptr)
{
case GRUB_ACPI_OPCODE_ADD:
case GRUB_ACPI_OPCODE_AND:
case GRUB_ACPI_OPCODE_CONCAT:
case GRUB_ACPI_OPCODE_CONCATRES:
case GRUB_ACPI_OPCODE_DIVIDE:
case GRUB_ACPI_OPCODE_INDEX:
case GRUB_ACPI_OPCODE_LSHIFT:
case GRUB_ACPI_OPCODE_MOD:
case GRUB_ACPI_OPCODE_MULTIPLY:
case GRUB_ACPI_OPCODE_NAND:
case GRUB_ACPI_OPCODE_NOR:
case GRUB_ACPI_OPCODE_OR:
case GRUB_ACPI_OPCODE_RSHIFT:
case GRUB_ACPI_OPCODE_SUBTRACT:
case GRUB_ACPI_OPCODE_TOSTRING:
case GRUB_ACPI_OPCODE_XOR:
/*
* Parameters for these opcodes: TermArg, TermArg Target, see ACPI
* spec r5.0, page 828f.
*/
ptr++;
ptr += add = skip_term (ptr, end);
if (!add)
return 0;
ptr += add = skip_term (ptr, end);
if (!add)
return 0;
ptr += skip_name_string (ptr, end);
break;
default:
return skip_data_ref_object (ptr, end);
}
return ptr - ptr0;
}
static inline grub_uint32_t
skip_ext_op (const grub_uint8_t *ptr, const grub_uint8_t *end)
{
@@ -199,10 +156,10 @@ skip_ext_op (const grub_uint8_t *ptr, const grub_uint8_t *end)
ptr++;
ptr += skip_name_string (ptr, end);
ptr++;
ptr += add = skip_term (ptr, end);
ptr += add = skip_data_ref_object (ptr, end);
if (!add)
return 0;
ptr += add = skip_term (ptr, end);
ptr += add = skip_data_ref_object (ptr, end);
if (!add)
return 0;
break;
@@ -223,7 +180,6 @@ skip_ext_op (const grub_uint8_t *ptr, const grub_uint8_t *end)
return ptr - ptr0;
}
static int
get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end,
grub_uint8_t *scope, int scope_len)
@@ -258,8 +214,8 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end,
}
case GRUB_ACPI_OPCODE_NAME:
ptr++;
if ((!scope || grub_memcmp (scope, "\\", scope_len) == 0) &&
(grub_memcmp (ptr, "_S5_", 4) == 0 || grub_memcmp (ptr, "\\_S5_", 4) == 0))
if ((!scope || memcmp (scope, "\\", scope_len) == 0) &&
(memcmp (ptr, "_S5_", 4) == 0 || memcmp (ptr, "\\_S5_", 4) == 0))
{
int ll;
grub_uint8_t *ptr2 = ptr;
@@ -294,17 +250,6 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end,
if (!add)
return -1;
break;
case GRUB_ACPI_OPCODE_ALIAS:
ptr++;
/* We need to skip two name strings */
ptr += add = skip_name_string (ptr, end);
if (!add)
return -1;
ptr += add = skip_name_string (ptr, end);
if (!add)
return -1;
break;
case GRUB_ACPI_OPCODE_SCOPE:
{
int scope_sleep_type;

View File

@@ -23,8 +23,6 @@
#include <grub/i18n.h>
#include <grub/disk.h>
GRUB_MOD_LICENSE ("GPLv3+");
static grub_err_t
grub_rescue_cmd_info (struct grub_command *cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),

View File

@@ -52,7 +52,6 @@ grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)),
grub_efi_configuration_table_t *t;
unsigned int i;
grub_printf ("Address: %p\n", st);
grub_printf ("Signature: %016" PRIxGRUB_UINT64_T " revision: %08x\n",
st->hdr.signature, st->hdr.revision);
{

View File

@@ -476,8 +476,8 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
be at least 12 bytes and aligned on a 4-byte boundary. */
for (header = buffer;
((char *) header <=
(char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12));
header += step)
(char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12))
|| (header = 0); header += step)
{
if (header[0] == magic
&& !(grub_le_to_cpu32 (header[0])
@@ -485,12 +485,11 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
+ grub_le_to_cpu32 (header[2])
+ (type == IS_MULTIBOOT2
? grub_le_to_cpu32 (header[3]) : 0)))
{
ret = 1;
break;
}
break;
}
if (header != 0)
ret = 1;
grub_free (buffer);
break;
}

View File

@@ -18,7 +18,6 @@
#include <grub/fileid.h>
#include <grub/elfload.h>
#include <grub/misc.h>
#pragma GCC diagnostic ignored "-Wcast-align"
@@ -40,10 +39,10 @@ grub_file_check_netbsdXX (grub_elf_t elf)
return 0;
if (grub_file_seek (elf->file, elf->ehdr.ehdrXX.e_shoff) == (grub_off_t) -1)
goto fail;
return 0;
if (grub_file_read (elf->file, s0, shsize) != (grub_ssize_t) shsize)
goto fail;
return 0;
s = (Elf_Shdr *) ((char *) s0 + elf->ehdr.ehdrXX.e_shstrndx * shentsize);
stroff = s->sh_offset;
@@ -54,21 +53,18 @@ grub_file_check_netbsdXX (grub_elf_t elf)
char name[sizeof(".note.netbsd.ident")];
grub_memset (name, 0, sizeof (name));
if (grub_file_seek (elf->file, stroff + s->sh_name) == (grub_off_t) -1)
goto fail;
return grub_errno;
if (grub_file_read (elf->file, name, sizeof (name)) != (grub_ssize_t) sizeof (name))
{
if (grub_errno)
goto fail;
return grub_errno;
continue;
}
if (grub_memcmp (name, ".note.netbsd.ident",
sizeof(".note.netbsd.ident")) != 0)
continue;
grub_free (s0);
return 1;
}
fail:
grub_free (s0);
return 0;
}

View File

@@ -101,7 +101,7 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
}
/* Check if it is valid. */
if (mbr.signature != grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE))
if (mbr.signature != grub_cpu_to_le16 (GRUB_PC_PARTITION_SIGNATURE))
{
grub_device_close (dev);
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature");
@@ -216,7 +216,7 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
first_sector--;
mbr.entries[0].flag = 0;
mbr.entries[0].type = GRUB_PC_PARTITION_TYPE_GPT_DISK;
mbr.entries[0].start = grub_cpu_to_le32_compile_time (1);
mbr.entries[0].start = grub_cpu_to_le32 (1);
lba_to_chs (1,
&(mbr.entries[0].start_sector),
&(mbr.entries[0].start_cylinder),
@@ -227,7 +227,7 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
&(mbr.entries[0].end_head));
mbr.entries[0].length = grub_cpu_to_le32 (first_sector);
mbr.signature = grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE);
mbr.signature = grub_cpu_to_le16 (GRUB_PC_PARTITION_SIGNATURE);
if (grub_disk_write (dev->disk, 0, 0, sizeof (mbr), &mbr))
{
@@ -235,8 +235,6 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
return grub_errno;
}
grub_device_close (dev);
grub_printf_ (N_("New MBR is written to `%s'\n"), args[0]);
return GRUB_ERR_NONE;

View File

@@ -329,7 +329,6 @@ grub_cmd_hdparm (grub_extcmd_context_t ctxt, int argc, char **args)
break;
}
default:
grub_disk_close (disk);
return grub_error (GRUB_ERR_IO, "not an ATA device");
}

View File

@@ -39,17 +39,9 @@ static const char *descs[] = {
[2] = "before RAM init",
[3] = "after RAM init",
[4] = "end of romstage",
[5] = "start of verified boot",
[6] = "end of verified boot",
[8] = "start of RAM copy",
[9] = "end of RAM copy",
[10] = "start of ramstage",
[11] = "start of bootblock",
[12] = "end of bootblock",
[13] = "starting to load romstage",
[14] = "finished loading romstage",
[15] = "starting LZMA decompress (ignore for x86)",
[16] = "finished LZMA decompress (ignore for x86)",
[30] = "device enumerate",
[40] = "device configure",
[50] = "device enable",

View File

@@ -29,15 +29,14 @@ grub_machine_acpi_get_rsdpv1 (void)
grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4);
ebda_len = * (grub_uint16_t *) ebda;
if (! ebda_len) /* FIXME do we really need this check? */
goto scan_bios;
if (! ebda_len)
return 0;
for (ptr = ebda; ptr < ebda + 0x400; ptr += 16)
if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0)
return (struct grub_acpi_rsdp_v10 *) ptr;
scan_bios:
grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000;
ptr += 16)
@@ -57,8 +56,8 @@ grub_machine_acpi_get_rsdpv2 (void)
grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4);
ebda_len = * (grub_uint16_t *) ebda;
if (! ebda_len) /* FIXME do we really need this check? */
goto scan_bios;
if (! ebda_len)
return 0;
for (ptr = ebda; ptr < ebda + 0x400; ptr += 16)
if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
@@ -68,7 +67,6 @@ grub_machine_acpi_get_rsdpv2 (void)
== 0)
return (struct grub_acpi_rsdp_v20 *) ptr;
scan_bios:
grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000;
ptr += 16)

View File

@@ -107,14 +107,6 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
return grub_errno;
}
if (!tempo)
{
grub_file_close (file);
grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid tempo in %s"),
args[0]);
return grub_errno;
}
tempo = grub_le_to_cpu32 (tempo);
grub_dprintf ("play","tempo = %d\n", tempo);
@@ -139,13 +131,6 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)),
tempo = grub_strtoul (args[0], &end, 0);
if (!tempo)
{
grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid tempo in %s"),
args[0]);
return grub_errno;
}
if (*end)
/* Was not a number either, assume it was supposed to be a file name. */
return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), args[0]);

View File

@@ -292,7 +292,7 @@ find_key_code (char *key)
{
unsigned i;
for (i = 0; i < ARRAY_SIZE(keysym_table); i++)
for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
{
if (keysym_table[i].unshifted_name
&& grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
@@ -311,7 +311,7 @@ find_ascii_code (char *key)
{
unsigned i;
for (i = 0; i < ARRAY_SIZE(keysym_table); i++)
for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
{
if (keysym_table[i].unshifted_name
&& grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
@@ -352,13 +352,15 @@ grub_cmd_sendkey (grub_extcmd_context_t ctxt, int argc, char **args)
{
unsigned i;
for (i = 0; i < ARRAY_SIZE(simple_flag_offsets); i++)
for (i = 0; i < sizeof (simple_flag_offsets)
/ sizeof (simple_flag_offsets[0]); i++)
grub_sendkey_set_simple_flag (simple_flag_offsets[i],
grub_sendkey_parse_op(state[i]));
}
/* Set noled. */
noled = (state[ARRAY_SIZE(simple_flag_offsets)].set);
noled = (state[sizeof (simple_flag_offsets)
/ sizeof (simple_flag_offsets[0])].set);
return GRUB_ERR_NONE;
}

View File

@@ -173,10 +173,8 @@ grub_term_map_key (grub_keyboard_key_t code, int status)
key = map_key_core (code, status, &alt_gr_consumed);
if (key == 0 || key == GRUB_TERM_SHIFT) {
if (key == 0 || key == GRUB_TERM_SHIFT)
grub_printf ("Unknown key 0x%x detected\n", code);
return GRUB_TERM_NO_KEY;
}
if (status & GRUB_TERM_STATUS_CAPS)
{

View File

@@ -57,20 +57,14 @@ legacy_file (const char *filename)
file = grub_file_open (filename);
if (! file)
{
grub_free (suffix);
return grub_errno;
}
return grub_errno;
menu = grub_env_get_menu ();
if (! menu)
{
menu = grub_zalloc (sizeof (*menu));
if (! menu)
{
grub_free (suffix);
return grub_errno;
}
return grub_errno;
grub_env_set_menu (menu);
}
@@ -83,7 +77,6 @@ legacy_file (const char *filename)
if (!buf && grub_errno)
{
grub_file_close (file);
grub_free (suffix);
return grub_errno;
}
@@ -180,8 +173,6 @@ legacy_file (const char *filename)
if (!args)
{
grub_file_close (file);
grub_free (suffix);
grub_free (entrysrc);
return grub_errno;
}
args[0] = entryname;
@@ -385,8 +376,6 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
if (part && grub_strcmp (part->partmap->name, "msdos") == 0)
bsd_slice = part->number;
}
if (dev)
grub_device_close (dev);
}
/* k*BSD didn't really work well with grub-legacy. */
@@ -591,7 +580,7 @@ check_password_md5_real (const char *entered,
GRUB_MD_MD5->write (ctx, entered, enteredlen);
digest = GRUB_MD_MD5->read (ctx);
GRUB_MD_MD5->final (ctx);
grub_memcpy (alt_result, digest, MD5_HASHLEN);
memcpy (alt_result, digest, MD5_HASHLEN);
GRUB_MD_MD5->init (ctx);
GRUB_MD_MD5->write (ctx, entered, enteredlen);
@@ -607,7 +596,7 @@ check_password_md5_real (const char *entered,
for (i = 0; i < 1000; i++)
{
grub_memcpy (alt_result, digest, 16);
memcpy (alt_result, digest, 16);
GRUB_MD_MD5->init (ctx);
if ((i & 1) != 0)

View File

@@ -263,7 +263,7 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
for (q = p->next; q; q = q->next)
{
grub_disk_addr_t s1, s2;
grub_disk_addr_t e1, e2;
grub_disk_addr_t e1, e2, t;
s1 = p->sector;
e1 = s1 + ((p->length + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
@@ -271,7 +271,16 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
s2 = q->sector;
e2 = s2 + ((q->length + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
if (s1 < e2 && s2 < e1)
if (s2 > s1)
{
t = s2;
s2 = s1;
s1 = t;
t = e2;
e2 = e1;
e1 = t;
}
if (e1 > s2)
{
/* This might be actually valid, but it is unbelievable that
any filesystem makes such a silly allocation. */

View File

@@ -37,7 +37,7 @@ struct find_node_context
grub_uint64_t inode_found;
char *dirname;
enum
{ FOUND_NONE, FOUND_FILE, FOUND_DIR } found;
{ NONE, FILE, DIR } found;
};
static int
@@ -53,7 +53,7 @@ find_inode (const char *filename,
&& grub_strcasecmp (ctx->dirname, filename) == 0)))
{
ctx->inode_found = info->inode;
ctx->found = info->dir ? FOUND_DIR : FOUND_FILE;
ctx->found = info->dir ? DIR : FILE;
}
return 0;
}
@@ -106,7 +106,7 @@ grub_mac_bless_inode (grub_device_t dev, grub_uint32_t inode, int is_dir,
ablk_size = grub_be_to_cpu32 (volheader.hfs.blksz);
ablk_start = grub_be_to_cpu16 (volheader.hfs.first_block);
embedded_offset = (ablk_start
+ ((grub_uint64_t) extent_start)
+ extent_start
* (ablk_size >> GRUB_DISK_SECTOR_BITS));
err =
@@ -175,7 +175,7 @@ grub_mac_bless_file (grub_device_t dev, const char *path_in, int intel)
grub_free (path);
return grub_mac_bless_inode (dev, (grub_uint32_t) ctx.inode_found,
(ctx.found == FOUND_DIR), intel);
(ctx.found == DIR), intel);
}
static grub_err_t
@@ -183,7 +183,7 @@ grub_cmd_macbless (grub_command_t cmd, int argc, char **args)
{
char *device_name;
char *path = 0;
grub_device_t dev = 0;
grub_device_t dev;
grub_err_t err;
if (argc != 1)
@@ -197,12 +197,13 @@ grub_cmd_macbless (grub_command_t cmd, int argc, char **args)
else
path = path + 1;
if (!path || *path == 0 || !dev)
if (!path || *path == 0 || !device_name)
{
if (dev)
grub_device_close (dev);
grub_free (device_name);
grub_free (path);
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
}

View File

@@ -57,7 +57,6 @@ get_uuid (const char *name, char **uuid, int getnative)
if (!dev->disk)
{
grub_dprintf ("nativedisk", "Skipping non-disk\n");
grub_device_close (dev);
return 0;
}
@@ -91,7 +90,6 @@ get_uuid (const char *name, char **uuid, int getnative)
case GRUB_DISK_DEVICE_MEMDISK_ID:
grub_dprintf ("nativedisk", "Skipping native disk %s\n",
dev->disk->name);
grub_device_close (dev);
return 0;
/* FIXME: those probably need special handling. */

View File

@@ -243,19 +243,11 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
}
if (argc == 1)
{
err = show_help (dev);
grub_device_close (dev);
return err;
}
return show_help (dev);
for (i = 1; i < argc; i++)
if (grub_strcmp (args[i], "help") == 0)
{
err = show_help (dev);
grub_device_close (dev);
return err;
}
return show_help (dev);
parsed = (int *) grub_zalloc (argc * sizeof (int));
@@ -282,11 +274,8 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
break;
}
if (! cur)
{
grub_device_close (dev);
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"),
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"),
args[i]);
}
ptool = cur;
pargs = (struct grub_parttool_args *)
grub_zalloc (ptool->nargs * sizeof (struct grub_parttool_args));

View File

@@ -104,10 +104,7 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)),
pass->c = grub_strtoul (ptr, &ptr, 0);
if (grub_errno)
{
grub_free (pass);
return grub_errno;
}
return grub_errno;
if (*ptr != '.')
{
grub_free (pass);

View File

@@ -210,10 +210,10 @@ try (struct search_ctx *ctx)
/* Cache entry was outdated. Remove it. */
if (!ctx->count)
{
*prev = cache_ent->next;
grub_free (cache_ent->key);
grub_free (cache_ent->value);
grub_free (cache_ent);
*prev = cache_ent->next;
}
}

View File

@@ -175,10 +175,7 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
var = "root";
}
else
{
grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
goto out;
}
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
if (state[SEARCH_LABEL].set)
grub_search_label (id, var, state[SEARCH_NO_FLOPPY].set,
@@ -190,10 +187,8 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
grub_search_fs_file (id, var, state[SEARCH_NO_FLOPPY].set,
hints, nhints);
else
grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
out:
grub_free (hints);
return grub_errno;
}

View File

@@ -50,7 +50,7 @@ static const struct grub_arg_option options[] =
N_("root directory of the syslinux disk [default=/]."),
N_("DIR"), ARG_TYPE_STRING},
{"cwd", 'c', 0,
N_("current directory of syslinux [default is parent directory of input file]."),
N_("current directory of the syslinux [default is parent directory of input file]."),
N_("DIR"), ARG_TYPE_STRING},
{"isolinux", 'i', 0, N_("assume input is an isolinux configuration file."), 0, 0},
{"pxelinux", 'p', 0, N_("assume input is a pxelinux configuration file."), 0, 0},
@@ -119,10 +119,7 @@ syslinux_file (grub_extcmd_context_t ctxt, const char *filename)
{
menu = grub_zalloc (sizeof (*menu));
if (! menu)
{
grub_free (result);
return grub_errno;
}
return grub_errno;
grub_env_set_menu (menu);
}

View File

@@ -332,7 +332,7 @@ test_parse (char **args, int *argn, int argc)
get_fileinfo (args[*argn + 1], &ctx);
update_val (ctx.file_exists && ctx.file_info.dir, &ctx);
(*argn) += 2;
continue;
return ctx.or || ctx.and;
}
if (grub_strcmp (args[*argn], "-e") == 0)
@@ -340,7 +340,7 @@ test_parse (char **args, int *argn, int argc)
get_fileinfo (args[*argn + 1], &ctx);
update_val (ctx.file_exists, &ctx);
(*argn) += 2;
continue;
return ctx.or || ctx.and;
}
if (grub_strcmp (args[*argn], "-f") == 0)
@@ -349,7 +349,7 @@ test_parse (char **args, int *argn, int argc)
/* FIXME: check for other types. */
update_val (ctx.file_exists && ! ctx.file_info.dir, &ctx);
(*argn) += 2;
continue;
return ctx.or || ctx.and;
}
if (grub_strcmp (args[*argn], "-s") == 0)
@@ -362,7 +362,7 @@ test_parse (char **args, int *argn, int argc)
grub_file_close (file);
grub_errno = GRUB_ERR_NONE;
(*argn) += 2;
continue;
return ctx.or || ctx.and;
}
/* String tests. */

View File

@@ -80,7 +80,7 @@ grub_cmd_tr (grub_extcmd_context_t ctxt, int argc, char **args)
} else if (argc > 3)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many parameters");
if (!s1 || !s2 || !input)
if (argc <= 0 && (!s1 || !s2 || !input))
return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing parameters");
if (grub_strlen (s1) != grub_strlen (s2))

View File

@@ -33,13 +33,6 @@
GRUB_MOD_LICENSE ("GPLv3+");
struct grub_verified
{
grub_file_t file;
void *buf;
};
typedef struct grub_verified *grub_verified_t;
enum
{
OPTION_SKIP_SIG = 0
@@ -308,7 +301,7 @@ grub_load_public_key (grub_file_t f)
if (!sk)
goto fail;
grub_memset (fingerprint_context, 0, GRUB_MD_SHA1->contextsize);
grub_memset (fingerprint_context, 0, sizeof (fingerprint_context));
GRUB_MD_SHA1->init (fingerprint_context);
GRUB_MD_SHA1->write (fingerprint_context, "\x99", 1);
len_be = grub_cpu_to_be16 (len);
@@ -454,7 +447,7 @@ grub_verify_signature_real (char *buf, grub_size_t size,
grub_err_t err;
grub_size_t i;
gcry_mpi_t mpis[10];
grub_uint8_t type = 0;
grub_uint8_t type;
err = read_packet_header (sig, &type, &len);
if (err)
@@ -809,39 +802,19 @@ grub_cmd_verify_signature (grub_extcmd_context_t ctxt,
static int sec = 0;
static void
verified_free (grub_verified_t verified)
{
if (verified)
{
grub_free (verified->buf);
grub_free (verified);
}
}
static grub_ssize_t
verified_read (struct grub_file *file, char *buf, grub_size_t len)
{
grub_verified_t verified = file->data;
grub_memcpy (buf, (char *) verified->buf + file->offset, len);
grub_memcpy (buf, (char *) file->data + file->offset, len);
return len;
}
static grub_err_t
verified_close (struct grub_file *file)
{
grub_verified_t verified = file->data;
grub_file_close (verified->file);
verified_free (verified);
grub_free (file->data);
file->data = 0;
/* device and name are freed by parent */
file->device = 0;
file->name = 0;
return grub_errno;
return GRUB_ERR_NONE;
}
struct grub_fs verified_fs =
@@ -859,13 +832,10 @@ grub_pubkey_open (grub_file_t io, const char *filename)
grub_err_t err;
grub_file_filter_t curfilt[GRUB_FILE_FILTER_MAX];
grub_file_t ret;
grub_verified_t verified;
if (!sec)
return io;
if (io->device->disk &&
(io->device->disk->dev->id == GRUB_DISK_DEVICE_MEMDISK_ID
|| io->device->disk->dev->id == GRUB_DISK_DEVICE_PROCFS_ID))
if (io->device->disk && io->device->disk->id == GRUB_DISK_DEVICE_MEMDISK_ID)
return io;
fsuf = grub_malloc (grub_strlen (filename) + sizeof (".sig"));
if (!fsuf)
@@ -885,10 +855,7 @@ grub_pubkey_open (grub_file_t io, const char *filename)
ret = grub_malloc (sizeof (*ret));
if (!ret)
{
grub_file_close (sig);
return NULL;
}
return NULL;
*ret = *io;
ret->fs = &verified_fs;
@@ -897,46 +864,29 @@ grub_pubkey_open (grub_file_t io, const char *filename)
{
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"big file signature isn't implemented yet");
grub_file_close (sig);
grub_free (ret);
return NULL;
}
verified = grub_malloc (sizeof (*verified));
if (!verified)
ret->data = grub_malloc (ret->size);
if (!ret->data)
{
grub_file_close (sig);
grub_free (ret);
return NULL;
}
verified->buf = grub_malloc (ret->size);
if (!verified->buf)
{
grub_file_close (sig);
grub_free (verified);
grub_free (ret);
return NULL;
}
if (grub_file_read (io, verified->buf, ret->size) != (grub_ssize_t) ret->size)
if (grub_file_read (io, ret->data, ret->size) != (grub_ssize_t) ret->size)
{
if (!grub_errno)
grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"),
filename);
grub_file_close (sig);
verified_free (verified);
grub_free (ret);
return NULL;
}
err = grub_verify_signature_real (verified->buf, ret->size, 0, sig, NULL);
err = grub_verify_signature_real (ret->data, ret->size, 0, sig, NULL);
grub_file_close (sig);
if (err)
{
verified_free (verified);
grub_free (ret);
return NULL;
}
verified->file = io;
ret->data = verified;
return NULL;
io->device = 0;
io->name = 0;
grub_file_close (io);
return ret;
}

View File

@@ -245,10 +245,7 @@ match_devices_iter (const char *name, void *data)
t = grub_realloc (ctx->devs, sizeof (char*) * (ctx->ndev + 2));
if (! t)
{
grub_free (buffer);
return 1;
}
return 1;
ctx->devs = t;
ctx->devs[ctx->ndev++] = buffer;
@@ -293,8 +290,7 @@ struct match_files_ctx
/* Helper for match_files. */
static int
match_files_iter (const char *name,
const struct grub_dirhook_info *info __attribute__((unused)),
match_files_iter (const char *name, const struct grub_dirhook_info *info,
void *data)
{
struct match_files_ctx *ctx = data;

View File

@@ -72,13 +72,13 @@ AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src, grub_uint8_t * dst,
grub_size_t i;
grub_uint8_t *bufblock;
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN || hash->mdlen == 0)
return GPG_ERR_INV_ARG;
bufblock = grub_zalloc (blocksize);
if (bufblock == NULL)
return GPG_ERR_OUT_OF_MEMORY;
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN)
return GPG_ERR_INV_ARG;
grub_memset (bufblock, 0, blocksize);
for (i = 0; i < blocknumbers - 1; i++)
{

View File

@@ -194,11 +194,13 @@ grub_ahci_pciinit (grub_pci_device_t dev,
return 0;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word (addr, grub_pci_read_word (addr)
| GRUB_PCI_COMMAND_MEM_ENABLED | GRUB_PCI_COMMAND_BUS_MASTER);
grub_pci_write_word (addr, grub_pci_read_word (addr) |
GRUB_PCI_COMMAND_IO_ENABLED
| GRUB_PCI_COMMAND_MEM_ENABLED
| GRUB_PCI_COMMAND_BUS_MASTER);
hba = grub_pci_device_map_range (dev, bar & GRUB_PCI_ADDR_MEM_MASK,
sizeof (*hba));
sizeof (hba));
grub_dprintf ("ahci", "dev: %x:%x.%x\n", dev.bus, dev.device, dev.function);
grub_dprintf ("ahci", "tfd[0]: %x\n",
@@ -322,7 +324,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
grub_dprintf ("ahci", "GLC:%x\n", hba->global_control);
nports = (GRUB_AHCI_HBA_CAP_NPORTS_MASK) + 1;
nports = (hba->cap & GRUB_AHCI_HBA_CAP_NPORTS_MASK) + 1;
grub_dprintf ("ahci", "%d AHCI ports, PI = 0x%x\n", nports,
hba->ports_implemented);
@@ -355,10 +357,10 @@ grub_ahci_pciinit (grub_pci_device_t dev,
if (adevs[i])
{
adevs[i]->hba->ports[adevs[i]->port].sata_error = adevs[i]->hba->ports[adevs[i]->port].sata_error;
grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->command_list_chunk = grub_memalign_dma32 (1024, sizeof (struct grub_ahci_cmd_head) * 32);
adevs[i]->command_list_chunk = grub_memalign_dma32 (1024, sizeof (struct grub_ahci_cmd_head));
if (!adevs[i]->command_list_chunk)
{
adevs[i] = 0;
@@ -376,12 +378,6 @@ grub_ahci_pciinit (grub_pci_device_t dev,
adevs[i]->command_list = grub_dma_get_virt (adevs[i]->command_list_chunk);
adevs[i]->command_table = grub_dma_get_virt (adevs[i]->command_table_chunk);
grub_memset ((void *) adevs[i]->command_list, 0,
sizeof (struct grub_ahci_cmd_table));
grub_memset ((void *) adevs[i]->command_table, 0,
sizeof (struct grub_ahci_cmd_head) * 32);
adevs[i]->command_list->command_table_base
= grub_dma_get_phys (adevs[i]->command_table_chunk);
@@ -440,7 +436,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
adevs[i]->hba->ports[adevs[i]->port].intstatus = ~0;
// adevs[i]->hba->ports[adevs[i]->port].fbs = 0;
grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->rfis = grub_memalign_dma32 (4096,
@@ -454,7 +450,6 @@ grub_ahci_pciinit (grub_pci_device_t dev,
adevs[i]->hba->ports[adevs[i]->port].fis_base = grub_dma_get_phys (adevs[i]->rfis);
adevs[i]->hba->ports[adevs[i]->port].command_list_base
= grub_dma_get_phys (adevs[i]->command_list_chunk);
adevs[i]->hba->ports[adevs[i]->port].command_issue = 0;
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_FRE;
}
@@ -480,7 +475,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
for (i = 0; i < nports; i++)
if (adevs[i])
{
grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
fr_running |= (1 << i);
@@ -488,7 +483,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_POWER_ON;
adevs[i]->hba->ports[adevs[i]->port].command |= 1 << 28;
grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
}
@@ -515,26 +510,26 @@ grub_ahci_pciinit (grub_pci_device_t dev,
for (i = 0; i < nports; i++)
if (adevs[i])
{
grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port,
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_POWER_ON;
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_SPIN_UP;
grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port,
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->hba->ports[adevs[i]->port].sata_error = ~0;
grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port,
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
grub_dprintf ("ahci", "port %d, offset: %x, tfd:%x, CMD: %x\n", adevs[i]->port,
grub_dprintf ("ahci", "offset: %x, tfd:%x, CMD: %x\n",
(int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data -
(char *) adevs[i]->hba),
adevs[i]->hba->ports[adevs[i]->port].task_file_data,
adevs[i]->hba->ports[adevs[i]->port].command);
grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port,
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
}
@@ -542,19 +537,17 @@ grub_ahci_pciinit (grub_pci_device_t dev,
for (i = 0; i < nports; i++)
if (adevs[i])
{
grub_dprintf ("ahci", "port %d, offset: %x, tfd:%x, CMD: %x\n", adevs[i]->port,
grub_dprintf ("ahci", "offset: %x, tfd:%x, CMD: %x\n",
(int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data -
(char *) adevs[i]->hba),
adevs[i]->hba->ports[adevs[i]->port].task_file_data,
adevs[i]->hba->ports[adevs[i]->port].command);
grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
grub_dprintf ("ahci", "err: %x\n",
adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->hba->ports[adevs[i]->port].command
= (adevs[i]->hba->ports[adevs[i]->port].command & 0x0fffffff) | (1 << 28)
| GRUB_AHCI_HBA_PORT_CMD_SPIN_UP
| GRUB_AHCI_HBA_PORT_CMD_POWER_ON;
= (adevs[i]->hba->ports[adevs[i]->port].command & 0x0fffffff) | (1 << 28) | 2 | 4;
/* struct grub_disk_ata_pass_through_parms parms2;
grub_memset (&parms2, 0, sizeof (parms2));
@@ -567,14 +560,14 @@ grub_ahci_pciinit (grub_pci_device_t dev,
while (grub_get_time_ms () < endtime)
{
for (i = 0; i < nports; i++)
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & (GRUB_ATA_STATUS_BUSY | GRUB_ATA_STATUS_DRQ)))
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & 0x88))
break;
if (i == nports)
break;
}
for (i = 0; i < nports; i++)
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & (GRUB_ATA_STATUS_BUSY | GRUB_ATA_STATUS_DRQ)))
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & 0x88))
{
grub_dprintf ("ahci", "port %d is busy\n", i);
failed_adevs[i] = adevs[i];
@@ -603,9 +596,6 @@ grub_ahci_pciinit (grub_pci_device_t dev,
failed_adevs[i] = adevs[i];
adevs[i] = 0;
}
grub_dprintf ("ahci", "cleaning up failed devs\n");
for (i = 0; i < nports; i++)
if (failed_adevs[i] && (fr_running & (1 << i)))
failed_adevs[i]->hba->ports[failed_adevs[i]->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE;
@@ -631,10 +621,6 @@ grub_ahci_pciinit (grub_pci_device_t dev,
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].sig >> 16) == 0xeb14)
adevs[i]->atapi = 1;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word (addr, grub_pci_read_word (addr)
| GRUB_PCI_COMMAND_BUS_MASTER);
for (i = 0; i < nports; i++)
if (adevs[i])
{
@@ -861,12 +847,6 @@ grub_ahci_reset_port (struct grub_ahci_device *dev, int force)
{
struct grub_disk_ata_pass_through_parms parms2;
dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
dev->hba->ports[dev->port].command_issue = 0;
dev->command_list[0].config = 0;
dev->command_table[0].prdt[0].unused = 0;
dev->command_table[0].prdt[0].size = 0;
dev->command_table[0].prdt[0].data_base = 0;
endtime = grub_get_time_ms () + 1000;
while ((dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_CR))
if (grub_get_time_ms () > endtime)
@@ -934,10 +914,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
if (parms->size > GRUB_AHCI_PRDT_MAX_CHUNK_LENGTH)
return grub_error (GRUB_ERR_BUG, "too big data buffer");
if (parms->size)
bufc = grub_memalign_dma32 (1024, parms->size + (parms->size & 1));
else
bufc = grub_memalign_dma32 (1024, 512);
bufc = grub_memalign_dma32 (1024, parms->size + (parms->size & 1));
grub_dprintf ("ahci", "AHCI tfd = %x, CL=%p\n",
dev->hba->ports[dev->port].task_file_data,
@@ -947,7 +924,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
= (5 << GRUB_AHCI_CONFIG_CFIS_LENGTH_SHIFT)
// | GRUB_AHCI_CONFIG_CLEAR_R_OK
| (0 << GRUB_AHCI_CONFIG_PMP_SHIFT)
| ((parms->size ? 1 : 0) << GRUB_AHCI_CONFIG_PRDT_LENGTH_SHIFT)
| (1 << GRUB_AHCI_CONFIG_PRDT_LENGTH_SHIFT)
| (parms->cmdsize ? GRUB_AHCI_CONFIG_ATAPI : 0)
| (parms->write ? GRUB_AHCI_CONFIG_WRITE : GRUB_AHCI_CONFIG_READ)
| (parms->taskfile.cmd == 8 ? (1 << 8) : 0);
@@ -1004,7 +981,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
if (parms->write)
grub_memcpy ((char *) grub_dma_get_virt (bufc), parms->buffer, parms->size);
grub_dprintf ("ahci", "AHCI command scheduled\n");
grub_dprintf ("ahci", "AHCI command schedulded\n");
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
grub_dprintf ("ahci", "AHCI inten = %x\n",
@@ -1024,7 +1001,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data);
endtime = grub_get_time_ms () + (spinup ? 20000 : 20000);
endtime = grub_get_time_ms () + (spinup ? 10000 : 5000);
while ((dev->hba->ports[dev->port].command_issue & 1))
if (grub_get_time_ms () > endtime)
{

View File

@@ -216,12 +216,6 @@ grub_ata_setaddress (struct grub_ata *dev,
unsigned int head;
unsigned int sect;
if (dev->sectors_per_track == 0
|| dev->heads == 0)
return grub_error (GRUB_ERR_OUT_OF_RANGE,
"sector %d cannot be addressed "
"using CHS addressing", sector);
/* Calculate the sector, cylinder and head to use. */
sect = ((grub_uint32_t) sector % dev->sectors_per_track) + 1;
cylinder = (((grub_uint32_t) sector / dev->sectors_per_track)

View File

@@ -110,23 +110,20 @@ grub_crypto_pcbc_decrypt (grub_crypto_cipher_handle_t cipher,
{
grub_uint8_t *inptr, *outptr, *end;
grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
grub_size_t blocksize;
if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
return GPG_ERR_INV_ARG;
if (!cipher->cipher->decrypt)
return GPG_ERR_NOT_SUPPORTED;
blocksize = cipher->cipher->blocksize;
if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0)
|| ((size & (blocksize - 1)) != 0))
return GPG_ERR_INV_ARG;
if (blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
if (size % cipher->cipher->blocksize != 0)
return GPG_ERR_INV_ARG;
end = (grub_uint8_t *) in + size;
for (inptr = in, outptr = out; inptr < end;
inptr += blocksize, outptr += blocksize)
inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize)
{
grub_memcpy (ivt, inptr, blocksize);
grub_memcpy (ivt, inptr, cipher->cipher->blocksize);
cipher->cipher->decrypt (cipher->ctx, outptr, inptr);
grub_crypto_xor (outptr, outptr, iv, blocksize);
grub_crypto_xor (iv, ivt, outptr, blocksize);
grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize);
grub_crypto_xor (iv, ivt, outptr, cipher->cipher->blocksize);
}
return GPG_ERR_NO_ERROR;
}
@@ -138,23 +135,20 @@ grub_crypto_pcbc_encrypt (grub_crypto_cipher_handle_t cipher,
{
grub_uint8_t *inptr, *outptr, *end;
grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
grub_size_t blocksize;
if (!cipher->cipher->encrypt)
return GPG_ERR_NOT_SUPPORTED;
blocksize = cipher->cipher->blocksize;
if (blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
return GPG_ERR_INV_ARG;
if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0)
|| ((size & (blocksize - 1)) != 0))
if (!cipher->cipher->decrypt)
return GPG_ERR_NOT_SUPPORTED;
if (size % cipher->cipher->blocksize != 0)
return GPG_ERR_INV_ARG;
end = (grub_uint8_t *) in + size;
for (inptr = in, outptr = out; inptr < end;
inptr += blocksize, outptr += blocksize)
inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize)
{
grub_memcpy (ivt, inptr, blocksize);
grub_crypto_xor (outptr, outptr, iv, blocksize);
grub_memcpy (ivt, inptr, cipher->cipher->blocksize);
grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize);
cipher->cipher->encrypt (cipher->ctx, outptr, inptr);
grub_crypto_xor (iv, ivt, outptr, blocksize);
grub_crypto_xor (iv, ivt, outptr, cipher->cipher->blocksize);
}
return GPG_ERR_NO_ERROR;
}
@@ -378,13 +372,11 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
break;
case GRUB_CRYPTODISK_MODE_ECB:
if (do_encrypt)
err = grub_crypto_ecb_encrypt (dev->cipher, data + i, data + i,
(1U << dev->log_sector_size));
grub_crypto_ecb_encrypt (dev->cipher, data + i, data + i,
(1U << dev->log_sector_size));
else
err = grub_crypto_ecb_decrypt (dev->cipher, data + i, data + i,
(1U << dev->log_sector_size));
if (err)
return err;
grub_crypto_ecb_decrypt (dev->cipher, data + i, data + i,
(1U << dev->log_sector_size));
break;
default:
return GPG_ERR_NOT_IMPLEMENTED;
@@ -770,26 +762,25 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name,
void
grub_util_cryptodisk_get_abstraction (grub_disk_t disk,
void (*cb) (const char *val, void *data),
void *data)
void (*cb) (const char *val))
{
grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data;
cb ("cryptodisk", data);
cb (dev->modname, data);
cb ("cryptodisk");
cb (dev->modname);
if (dev->cipher)
cb (dev->cipher->cipher->modname, data);
cb (dev->cipher->cipher->modname);
if (dev->secondary_cipher)
cb (dev->secondary_cipher->cipher->modname, data);
cb (dev->secondary_cipher->cipher->modname);
if (dev->essiv_cipher)
cb (dev->essiv_cipher->cipher->modname, data);
cb (dev->essiv_cipher->cipher->modname);
if (dev->hash)
cb (dev->hash->modname, data);
cb (dev->hash->modname);
if (dev->essiv_hash)
cb (dev->essiv_hash->modname, data);
cb (dev->essiv_hash->modname);
if (dev->iv_hash)
cb (dev->iv_hash->modname, data);
cb (dev->iv_hash->modname);
}
const char *
@@ -964,43 +955,33 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args)
grub_disk_t disk;
grub_cryptodisk_t dev;
char *diskname;
char *disklast = NULL;
grub_size_t len;
char *disklast;
search_uuid = NULL;
check_boot = state[2].set;
diskname = args[0];
len = grub_strlen (diskname);
if (len && diskname[0] == '(' && diskname[len - 1] == ')')
if (diskname[0] == '(' && *(disklast = &diskname[grub_strlen (diskname) - 1]) == ')')
{
disklast = &diskname[len - 1];
*disklast = '\0';
diskname++;
disk = grub_disk_open (diskname + 1);
*disklast = ')';
}
disk = grub_disk_open (diskname);
else
disk = grub_disk_open (diskname);
if (!disk)
{
if (disklast)
*disklast = ')';
return grub_errno;
}
return grub_errno;
dev = grub_cryptodisk_get_by_source_disk (disk);
if (dev)
{
grub_dprintf ("cryptodisk", "already mounted as crypto%lu\n", dev->id);
grub_disk_close (disk);
if (disklast)
*disklast = ')';
return GRUB_ERR_NONE;
}
err = grub_cryptodisk_scan_device_real (diskname, disk);
err = grub_cryptodisk_scan_device_real (args[0], disk);
grub_disk_close (disk);
if (disklast)
*disklast = ')';
return err;
}

View File

@@ -71,12 +71,10 @@ is_lv_readable (struct grub_diskfilter_lv *lv, int easily)
case GRUB_DISKFILTER_RAID6:
if (!easily)
need--;
/* Fallthrough. */
case GRUB_DISKFILTER_RAID4:
case GRUB_DISKFILTER_RAID5:
if (!easily)
need--;
/* Fallthrough. */
case GRUB_DISKFILTER_STRIPED:
break;
@@ -356,8 +354,7 @@ grub_diskfilter_memberlist (grub_disk_t disk)
void
grub_diskfilter_get_partmap (grub_disk_t disk,
void (*cb) (const char *pm, void *data),
void *data)
void (*cb) (const char *pm))
{
struct grub_diskfilter_lv *lv = disk->data;
struct grub_diskfilter_pv *pv;
@@ -379,7 +376,7 @@ grub_diskfilter_get_partmap (grub_disk_t disk,
continue;
}
for (s = 0; pv->partmaps[s]; s++)
cb (pv->partmaps[s], data);
cb (pv->partmaps[s]);
}
}
@@ -485,96 +482,6 @@ grub_diskfilter_read_node (const struct grub_diskfilter_node *node,
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown node '%s'", node->name);
}
static grub_err_t
validate_segment (struct grub_diskfilter_segment *seg);
static grub_err_t
validate_lv (struct grub_diskfilter_lv *lv)
{
unsigned int i;
if (!lv)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown volume");
if (!lv->vg || lv->vg->extent_size == 0)
return grub_error (GRUB_ERR_READ_ERROR, "invalid volume");
for (i = 0; i < lv->segment_count; i++)
{
grub_err_t err;
err = validate_segment (&lv->segments[i]);
if (err)
return err;
}
return GRUB_ERR_NONE;
}
static grub_err_t
validate_node (const struct grub_diskfilter_node *node)
{
/* Check whether we actually know the physical volume we want to
read from. */
if (node->pv)
return GRUB_ERR_NONE;
if (node->lv)
return validate_lv (node->lv);
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown node '%s'", node->name);
}
static grub_err_t
validate_segment (struct grub_diskfilter_segment *seg)
{
grub_err_t err;
if (seg->stripe_size == 0 || seg->node_count == 0)
return grub_error(GRUB_ERR_BAD_FS, "invalid segment");
switch (seg->type)
{
case GRUB_DISKFILTER_RAID10:
{
grub_uint8_t near, far;
near = seg->layout & 0xFF;
far = (seg->layout >> 8) & 0xFF;
if ((seg->layout >> 16) == 0 && far == 0)
return grub_error(GRUB_ERR_BAD_FS, "invalid segment");
if (near > seg->node_count)
return grub_error(GRUB_ERR_BAD_FS, "invalid segment");
break;
}
case GRUB_DISKFILTER_STRIPED:
case GRUB_DISKFILTER_MIRROR:
break;
case GRUB_DISKFILTER_RAID4:
case GRUB_DISKFILTER_RAID5:
if (seg->node_count <= 1)
return grub_error(GRUB_ERR_BAD_FS, "invalid segment");
break;
case GRUB_DISKFILTER_RAID6:
if (seg->node_count <= 2)
return grub_error(GRUB_ERR_BAD_FS, "invalid segment");
break;
default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"unsupported RAID level %d", seg->type);
}
unsigned i;
for (i = 0; i < seg->node_count; i++)
{
err = validate_node (&seg->nodes[i]);
if (err)
return err;
}
return GRUB_ERR_NONE;
}
static grub_err_t
read_segment (struct grub_diskfilter_segment *seg, grub_disk_addr_t sector,
grub_size_t size, char *buf)
@@ -586,7 +493,6 @@ read_segment (struct grub_diskfilter_segment *seg, grub_disk_addr_t sector,
if (seg->node_count == 1)
return grub_diskfilter_read_node (&seg->nodes[0],
sector, size, buf);
/* Fallthrough. */
case GRUB_DISKFILTER_MIRROR:
case GRUB_DISKFILTER_RAID10:
{
@@ -941,23 +847,6 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg)
for (lv = vg->lvs; lv; lv = lv->next)
{
grub_err_t err;
/* RAID 1 and single-disk RAID 0 don't use a chunksize but code
assumes one so set one. */
for (i = 0; i < lv->segment_count; i++)
{
if (lv->segments[i].type == 1)
lv->segments[i].stripe_size = 64;
if (lv->segments[i].type == GRUB_DISKFILTER_STRIPED
&& lv->segments[i].node_count == 1
&& lv->segments[i].stripe_size == 0)
lv->segments[i].stripe_size = 64;
}
err = validate_lv(lv);
if (err)
return err;
lv->number = lv_num++;
if (lv->fullname)
@@ -998,6 +887,12 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg)
lv->fullname = tmp;
}
}
/* RAID 1 doesn't use a chunksize but code assumes one so set
one. */
for (i = 0; i < lv->segment_count; i++)
if (lv->segments[i].type == 1)
lv->segments[i].stripe_size = 64;
lv->vg = vg;
}
/* Add our new array to the list. */
vg->next = array_list;
@@ -1007,7 +902,7 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg)
struct grub_diskfilter_vg *
grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
const char *name, grub_uint64_t disk_size,
char *name, grub_uint64_t disk_size,
grub_uint64_t stripe_size,
int layout, int level)
{
@@ -1030,11 +925,6 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
n = layout & 0xFF;
if (n == 1)
n = (layout >> 8) & 0xFF;
if (n == 0)
{
grub_free (uuid);
return NULL;
}
totsize = grub_divmod64 (nmemb * disk_size, n, 0);
}
@@ -1048,7 +938,6 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
break;
default:
grub_free (uuid);
return NULL;
}
@@ -1062,7 +951,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
array->lvs->segments->extent_count = totsize;
}
if (array->lvs && array->lvs->segments
if (array->lvs->segments
&& array->lvs->segments->raid_member_size > disk_size)
array->lvs->segments->raid_member_size = disk_size;
@@ -1071,10 +960,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
}
array = grub_zalloc (sizeof (*array));
if (!array)
{
grub_free (uuid);
return NULL;
}
return NULL;
array->uuid = uuid;
array->uuid_len = uuidlen;
if (name)
@@ -1096,16 +982,8 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
goto fail;
array->lvs->segment_count = 1;
array->lvs->visible = 1;
if (array->name)
{
array->lvs->name = grub_strdup (array->name);
if (!array->lvs->name)
goto fail;
array->lvs->fullname = grub_strdup (array->name);
if (!array->lvs->fullname)
goto fail;
}
array->lvs->vg = array;
array->lvs->name = array->name;
array->lvs->fullname = array->name;
array->lvs->idname = grub_malloc (sizeof ("mduuid/") + 2 * uuidlen);
if (!array->lvs->idname)
@@ -1155,26 +1033,13 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
return array;
fail:
if (array->lvs)
{
grub_free (array->lvs->name);
grub_free (array->lvs->fullname);
grub_free (array->lvs->idname);
if (array->lvs->segments)
{
grub_free (array->lvs->segments->nodes);
grub_free (array->lvs->segments);
}
grub_free (array->lvs);
}
grub_free (array->lvs);
while (array->pvs)
{
pv = array->pvs->next;
grub_free (array->pvs);
array->pvs = pv;
}
grub_free (array->name);
grub_free (array->uuid);
grub_free (array);
return NULL;
}
@@ -1277,9 +1142,10 @@ free_array (void)
{
unsigned i;
vg->lvs = lv->next;
grub_free (lv->fullname);
grub_free (lv->name);
grub_free (lv->idname);
if (lv->name != lv->fullname)
grub_free (lv->fullname);
if (lv->name != vg->name)
grub_free (lv->name);
for (i = 0; i < lv->segment_count; i++)
grub_free (lv->segments[i].nodes);
grub_free (lv->segments);

View File

@@ -99,8 +99,6 @@ grub_dmraid_nv_detect (grub_disk_t disk,
struct grub_nv_super sb;
int level;
grub_uint64_t disk_size;
grub_uint32_t capacity;
grub_uint8_t total_volumes;
char *uuid;
if (disk->partition)
@@ -126,17 +124,11 @@ grub_dmraid_nv_detect (grub_disk_t disk,
return NULL;
}
capacity = grub_le_to_cpu32 (sb.capacity);
total_volumes = sb.array.total_volumes;
switch (sb.array.raid_level)
{
case NV_LEVEL_0:
level = 0;
if (total_volumes == 0)
/* Not RAID. */
return NULL;
disk_size = capacity / total_volumes;
disk_size = sb.capacity / sb.array.total_volumes;
break;
case NV_LEVEL_1:
@@ -146,10 +138,7 @@ grub_dmraid_nv_detect (grub_disk_t disk,
case NV_LEVEL_5:
level = 5;
if (total_volumes == 0 || total_volumes == 1)
/* Not RAID. */
return NULL;
disk_size = capacity / (total_volumes - 1);
disk_size = sb.capacity / (sb.array.total_volumes - 1);
break;
default:
@@ -172,7 +161,7 @@ grub_dmraid_nv_detect (grub_disk_t disk,
return grub_diskfilter_make_raid (sizeof (sb.array.signature),
uuid, sb.array.total_volumes,
"nv", disk_size,
NULL, disk_size,
sb.array.stripe_block_size,
GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC,
level);

View File

@@ -43,6 +43,47 @@ static struct grub_efidisk_data *fd_devices;
static struct grub_efidisk_data *hd_devices;
static struct grub_efidisk_data *cd_devices;
/* Duplicate a device path. */
static grub_efi_device_path_t *
duplicate_device_path (const grub_efi_device_path_t *dp)
{
grub_efi_device_path_t *p;
grub_size_t total_size = 0;
for (p = (grub_efi_device_path_t *) dp;
;
p = GRUB_EFI_NEXT_DEVICE_PATH (p))
{
total_size += GRUB_EFI_DEVICE_PATH_LENGTH (p);
if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (p))
break;
}
p = grub_malloc (total_size);
if (! p)
return 0;
grub_memcpy (p, dp, total_size);
return p;
}
/* Return the device path node right before the end node. */
static grub_efi_device_path_t *
find_last_device_path (const grub_efi_device_path_t *dp)
{
grub_efi_device_path_t *next, *p;
if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
return 0;
for (p = (grub_efi_device_path_t *) dp, next = GRUB_EFI_NEXT_DEVICE_PATH (p);
! GRUB_EFI_END_ENTIRE_DEVICE_PATH (next);
p = next, next = GRUB_EFI_NEXT_DEVICE_PATH (next))
;
return p;
}
static struct grub_efidisk_data *
make_devices (void)
{
@@ -69,7 +110,7 @@ make_devices (void)
if (! dp)
continue;
ldp = grub_efi_find_last_device_path (dp);
ldp = find_last_device_path (dp);
if (! ldp)
/* This is empty. Why? */
continue;
@@ -109,11 +150,11 @@ find_parent_device (struct grub_efidisk_data *devices,
grub_efi_device_path_t *dp, *ldp;
struct grub_efidisk_data *parent;
dp = grub_efi_duplicate_device_path (d->device_path);
dp = duplicate_device_path (d->device_path);
if (! dp)
return 0;
ldp = grub_efi_find_last_device_path (dp);
ldp = find_last_device_path (dp);
ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
ldp->length = sizeof (*ldp);
@@ -139,11 +180,11 @@ is_child (struct grub_efidisk_data *child,
grub_efi_device_path_t *dp, *ldp;
int ret;
dp = grub_efi_duplicate_device_path (child->device_path);
dp = duplicate_device_path (child->device_path);
if (! dp)
return 0;
ldp = grub_efi_find_last_device_path (dp);
ldp = find_last_device_path (dp);
ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
ldp->length = sizeof (*ldp);
@@ -166,8 +207,8 @@ add_device (struct grub_efidisk_data **devices, struct grub_efidisk_data *d)
{
int ret;
ret = grub_efi_compare_device_paths (grub_efi_find_last_device_path ((*p)->device_path),
grub_efi_find_last_device_path (d->device_path));
ret = grub_efi_compare_device_paths (find_last_device_path ((*p)->device_path),
find_last_device_path (d->device_path));
if (ret == 0)
ret = grub_efi_compare_device_paths ((*p)->device_path,
d->device_path);
@@ -628,6 +669,7 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
case 'h':
/* If this is the whole disk, just return its own data. */
grub_printf ("parent handle = %p\n", d->handle);
if (! disk->partition)
return d->handle;
@@ -638,13 +680,24 @@ grub_efidisk_get_device_handle (grub_disk_t disk)
struct grub_efidisk_data *c;
devices = make_devices ();
FOR_CHILDREN (c, devices)
grub_efi_print_device_path (d->device_path);
for (c = devices; c; c = c->next)
{
grub_efi_hard_drive_device_path_t *hd;
hd = (grub_efi_hard_drive_device_path_t *) c->last_device_path;
if ((GRUB_EFI_DEVICE_PATH_TYPE (c->last_device_path)
grub_efi_print_device_path (c->device_path);
grub_printf ("part %d = %x, %x, %x, %x, %x, %x\n",
is_child (c, d),
(int) GRUB_EFI_DEVICE_PATH_TYPE (c->last_device_path),
(int) GRUB_EFI_DEVICE_PATH_SUBTYPE (c->last_device_path),
(int) hd->partition_start, (int) hd->partition_size,
(int) grub_partition_get_start (disk->partition),
(int) grub_partition_get_len (disk->partition));
if (is_child (c, d)
&& (GRUB_EFI_DEVICE_PATH_TYPE (c->last_device_path)
== GRUB_EFI_MEDIA_DEVICE_PATH_TYPE)
&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (c->last_device_path)
== GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)
@@ -754,7 +807,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
if (! dp)
return 0;
ldp = grub_efi_find_last_device_path (dp);
ldp = find_last_device_path (dp);
if (! ldp)
return 0;
@@ -762,6 +815,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE
|| GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE))
{
int is_cdrom = 0;
struct grub_efidisk_get_device_name_ctx ctx;
char *dev_name;
grub_efi_device_path_t *dup_dp;
@@ -769,19 +823,22 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
/* It is necessary to duplicate the device path so that GRUB
can overwrite it. */
dup_dp = grub_efi_duplicate_device_path (dp);
dup_dp = duplicate_device_path (dp);
if (! dup_dp)
return 0;
while (1)
{
grub_efi_device_path_t *dup_ldp;
dup_ldp = grub_efi_find_last_device_path (dup_dp);
dup_ldp = find_last_device_path (dup_dp);
if (!(GRUB_EFI_DEVICE_PATH_TYPE (dup_ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE
|| GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)))
break;
if (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE)
is_cdrom = 1;
dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
dup_ldp->length = sizeof (*dup_ldp);
@@ -816,13 +873,10 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
if (! ctx.partition_name)
{
/* No partition found. In most cases partition is embed in
the root path anyway, so this is not critical.
This happens only if partition is on partmap that GRUB
doesn't need to access root.
*/
grub_disk_close (parent);
return grub_strdup (device_name);
if (is_cdrom)
return grub_strdup (device_name);
return 0;
}
dev_name = grub_xasprintf ("%s,%s", parent->name,

View File

@@ -212,8 +212,7 @@ grub_util_get_geli_uuid (const char *dev)
s = grub_util_get_fd_size (fd, dev, &log_secsize);
s >>= log_secsize;
if (grub_util_fd_seek (fd, (s << log_secsize) - 512) < 0)
grub_util_error ("%s", _("couldn't read ELI metadata"));
grub_util_fd_seek (fd, (s << log_secsize) - 512);
uuid = xmalloc (GRUB_MD_SHA256->mdlen * 2 + 1);
if (grub_util_fd_read (fd, (void *) &hdr, 512) < 0)
@@ -226,16 +225,13 @@ grub_util_get_geli_uuid (const char *dev)
/* Look for GELI magic sequence. */
if (grub_memcmp (header->magic, GELI_MAGIC, sizeof (GELI_MAGIC))
|| grub_le_to_cpu32 (header->version) > 7
|| grub_le_to_cpu32 (header->version) > 5
|| grub_le_to_cpu32 (header->version) < 1)
grub_util_error ("%s", _("wrong ELI magic or version"));
err = make_uuid ((void *) &hdr, uuid);
if (err)
{
grub_free (uuid);
return NULL;
}
return NULL;
return uuid;
}
@@ -269,7 +265,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
/* Look for GELI magic sequence. */
if (grub_memcmp (header.magic, GELI_MAGIC, sizeof (GELI_MAGIC))
|| grub_le_to_cpu32 (header.version) > 7
|| grub_le_to_cpu32 (header.version) > 5
|| grub_le_to_cpu32 (header.version) < 1)
{
grub_dprintf ("geli", "wrong magic %02x\n", header.magic[0]);
@@ -336,29 +332,19 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
{
secondary_cipher = grub_crypto_cipher_open (ciph);
if (!secondary_cipher)
{
grub_crypto_cipher_close (cipher);
return NULL;
}
return NULL;
}
if (grub_le_to_cpu16 (header.keylen) > 1024)
{
grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid keysize %d",
grub_le_to_cpu16 (header.keylen));
grub_crypto_cipher_close (cipher);
grub_crypto_cipher_close (secondary_cipher);
return NULL;
}
newdev = grub_zalloc (sizeof (struct grub_cryptodisk));
if (!newdev)
{
grub_crypto_cipher_close (cipher);
grub_crypto_cipher_close (secondary_cipher);
return NULL;
}
return NULL;
newdev->cipher = cipher;
newdev->secondary_cipher = secondary_cipher;
newdev->offset = 0;
@@ -405,7 +391,6 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
grub_uint8_t geomkey[GRUB_CRYPTO_MAX_MDLEN];
grub_uint8_t verify_key[GRUB_CRYPTO_MAX_MDLEN];
grub_uint8_t zero[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
grub_uint8_t geli_cipher_key[64];
char passphrase[MAX_PASSPHRASE] = "";
unsigned i;
gcry_err_code_t gcry_err;
@@ -529,19 +514,6 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
continue;
grub_printf_ (N_("Slot %d opened\n"), i);
if (grub_le_to_cpu32 (header.version) >= 7)
{
/* GELI >=7 uses the cipher_key */
grub_memcpy (geli_cipher_key, candidate_key.cipher_key,
sizeof (candidate_key.cipher_key));
}
else
{
/* GELI <=6 uses the iv_key */
grub_memcpy (geli_cipher_key, candidate_key.iv_key,
sizeof (candidate_key.iv_key));
}
/* Set the master key. */
if (!dev->rekey)
{
@@ -558,13 +530,13 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev)
grub_size_t real_keysize = keysize;
if (grub_le_to_cpu16 (header.alg) == 0x16)
real_keysize *= 2;
grub_memcpy (dev->rekey_key, geli_cipher_key,
sizeof (geli_cipher_key));
/* For a reason I don't know, the IV key is used in rekeying. */
grub_memcpy (dev->rekey_key, candidate_key.iv_key,
sizeof (candidate_key.iv_key));
dev->rekey_derived_size = real_keysize;
dev->last_rekey = -1;
COMPILE_TIME_ASSERT (sizeof (dev->rekey_key)
>= sizeof (geli_cipher_key));
>= sizeof (candidate_key.iv_key));
}
dev->iv_prefix_len = sizeof (candidate_key.iv_key);

View File

@@ -382,8 +382,7 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
/* Some buggy BIOSes doesn't return the total sectors
correctly but returns zero. So if it is zero, compute
it by C/H/S returned by the LBA BIOS call. */
total_sectors = ((grub_uint64_t) drp->cylinders)
* drp->heads * drp->sectors;
total_sectors = drp->cylinders * drp->heads * drp->sectors;
if (drp->bytes_per_sector
&& !(drp->bytes_per_sector & (drp->bytes_per_sector - 1))
&& drp->bytes_per_sector >= 512
@@ -420,14 +419,8 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
}
}
if (data->sectors == 0)
data->sectors = 63;
if (data->heads == 0)
data->heads = 255;
if (! total_sectors)
total_sectors = ((grub_uint64_t) data->cylinders)
* data->heads * data->sectors;
total_sectors = data->cylinders * data->heads * data->sectors;
}
disk->total_sectors = total_sectors;
@@ -462,14 +455,6 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk,
{
struct grub_biosdisk_data *data = disk->data;
/* VirtualBox fails with sectors above 2T on CDs.
Since even BD-ROMS are never that big anyway, return error. */
if ((data->flags & GRUB_BIOSDISK_FLAG_CDROM)
&& (sector >> 32))
return grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("attempt to read or write outside of disk `%s'"),
disk->name);
if (data->flags & GRUB_BIOSDISK_FLAG_LBA)
{
struct grub_biosdisk_dap *dap;

View File

@@ -113,11 +113,6 @@ grub_nand_open (const char *name, grub_disk_t disk)
}
data->block_size = (args.size1 >> GRUB_DISK_SECTOR_BITS);
if (!data->block_size)
{
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "invalid block size");
goto fail;
}
INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
args.method = (grub_ieee1275_cell_t) "size";

View File

@@ -34,8 +34,7 @@ struct ofdisk_hash_ent
char *open_path;
char *grub_devpath;
int is_boot;
int is_removable;
int block_size_fails;
int is_cdrom;
/* Pointer to shortest available name on nodes representing canonical names,
otherwise NULL. */
const char *shortest;
@@ -43,10 +42,6 @@ struct ofdisk_hash_ent
struct ofdisk_hash_ent *next;
};
static grub_err_t
grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size,
struct ofdisk_hash_ent *op);
#define OFDISK_HASH_SZ 8
static struct ofdisk_hash_ent *ofdisk_hash[OFDISK_HASH_SZ];
@@ -128,7 +123,7 @@ ofdisk_hash_add_real (char *devpath)
}
static int
check_string_removable (const char *str)
check_string_cdrom (const char *str)
{
const char *ptr = grub_strrchr (str, '/');
@@ -136,7 +131,7 @@ check_string_removable (const char *str)
ptr++;
else
ptr = str;
return (grub_strncmp (ptr, "cdrom", 5) == 0 || grub_strncmp (ptr, "fd", 2) == 0);
return (grub_strncmp (ptr, "cdrom", 5) == 0);
}
static struct ofdisk_hash_ent *
@@ -152,8 +147,8 @@ ofdisk_hash_add (char *devpath, char *curcan)
{
p->shortest = p->devpath;
p->grub_shortest = p->grub_devpath;
if (check_string_removable (devpath))
p->is_removable = 1;
if (check_string_cdrom (devpath))
p->is_cdrom = 1;
return p;
}
@@ -163,8 +158,8 @@ ofdisk_hash_add (char *devpath, char *curcan)
else
grub_free (curcan);
if (check_string_removable (devpath) || check_string_removable (curcan))
pcan->is_removable = 1;
if (check_string_cdrom (devpath) || check_string_cdrom (curcan))
pcan->is_cdrom = 1;
if (!pcan)
grub_errno = GRUB_ERR_NONE;
@@ -335,7 +330,7 @@ grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
}
}
if (!ent->is_boot && ent->is_removable)
if (!ent->is_boot && ent->is_cdrom)
continue;
if (hook (ent->grub_shortest, hook_data))
@@ -380,8 +375,6 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
/* XXX: This should be large enough for any possible case. */
char prop[64];
grub_ssize_t actual;
grub_uint32_t block_size = 0;
grub_err_t err;
if (grub_strncmp (name, "ieee1275/", sizeof ("ieee1275/") - 1) != 0)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
@@ -412,6 +405,14 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a block device");
}
grub_uint32_t block_size = 0;
if (grub_ofdisk_get_block_size (devpath, &block_size) == 0)
{
for (disk->log_sector_size = 0;
(1U << disk->log_sector_size) < block_size;
disk->log_sector_size++);
}
/* XXX: There is no property to read the number of blocks. There
should be a property `#blocks', but it is not there. Perhaps it
is possible to use seek for this. */
@@ -422,31 +423,14 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
op = ofdisk_hash_find (devpath);
if (!op)
op = ofdisk_hash_add (devpath, NULL);
else
grub_free (devpath);
if (!op)
{
grub_free (devpath);
return grub_errno;
}
return grub_errno;
disk->id = (unsigned long) op;
disk->data = op->open_path;
err = grub_ofdisk_get_block_size (devpath, &block_size, op);
if (err)
{
grub_free (devpath);
return err;
}
if (block_size != 0)
{
for (disk->log_sector_size = 0;
(1U << disk->log_sector_size) < block_size;
disk->log_sector_size++);
}
else
disk->log_sector_size = 9;
}
grub_free (devpath);
return 0;
}
@@ -605,9 +589,8 @@ grub_ofdisk_init (void)
grub_disk_dev_register (&grub_ofdisk_dev);
}
static grub_err_t
grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size,
struct ofdisk_hash_ent *op)
grub_err_t
grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size)
{
struct size_args_ieee1275
{
@@ -629,34 +612,20 @@ grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size,
if (! last_ihandle)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
*block_size = 0;
if (op->block_size_fails >= 2)
return GRUB_ERR_NONE;
INIT_IEEE1275_COMMON (&args_ieee1275.common, "call-method", 2, 2);
args_ieee1275.method = (grub_ieee1275_cell_t) "block-size";
args_ieee1275.ihandle = last_ihandle;
args_ieee1275.result = 1;
if (IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1)
{
grub_dprintf ("disk", "can't get block size: failed call-method\n");
op->block_size_fails++;
}
else if (args_ieee1275.result)
{
grub_dprintf ("disk", "can't get block size: %lld\n",
(long long) args_ieee1275.result);
op->block_size_fails++;
}
else if (args_ieee1275.size1
&& !(args_ieee1275.size1 & (args_ieee1275.size1 - 1))
&& args_ieee1275.size1 >= 512 && args_ieee1275.size1 <= 16384)
{
op->block_size_fails = 0;
*block_size = GRUB_DISK_SECTOR_SIZE;
if ((IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1) || (args_ieee1275.result))
grub_dprintf ("disk", "can't get block size\n");
else
if (args_ieee1275.size1
&& !(args_ieee1275.size1 & (args_ieee1275.size1 - 1))
&& args_ieee1275.size1 >= 512 && args_ieee1275.size1 <= 16384)
*block_size = args_ieee1275.size1;
}
return 0;
}

View File

@@ -963,7 +963,7 @@ grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors,
if (embed_type != GRUB_EMBED_PCBIOS)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"LDM currently supports only PC-BIOS embedding");
"LDM curently supports only PC-BIOS embedding");
if (disk->partition)
return grub_error (GRUB_ERR_BUG, "disk isn't LDM");
pv = grub_diskfilter_get_pv_from_disk (disk, &vg);

View File

@@ -143,7 +143,6 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
{
grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid keysize %d",
grub_be_to_cpu32 (header.keyBytes));
grub_crypto_cipher_close (cipher);
return NULL;
}
@@ -182,10 +181,9 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
}
if (cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES)
{
grub_crypto_cipher_close (cipher);
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported XTS block size: %d",
cipher->cipher->blocksize);
grub_crypto_cipher_close (cipher);
grub_crypto_cipher_close (secondary_cipher);
return NULL;
}
if (secondary_cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES)
@@ -193,7 +191,6 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
grub_crypto_cipher_close (cipher);
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported XTS block size: %d",
secondary_cipher->cipher->blocksize);
grub_crypto_cipher_close (secondary_cipher);
return NULL;
}
}
@@ -203,9 +200,9 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
cipheriv = ciphermode + sizeof ("lrw-") - 1;
if (cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES)
{
grub_crypto_cipher_close (cipher);
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported LRW block size: %d",
cipher->cipher->blocksize);
grub_crypto_cipher_close (cipher);
return NULL;
}
}
@@ -228,7 +225,6 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
|| cipher->cipher->blocksize == 0)
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported benbi blocksize: %d",
cipher->cipher->blocksize);
/* FIXME should we return an error here? */
for (benbi_log = 0;
(cipher->cipher->blocksize << benbi_log) < GRUB_DISK_SECTOR_SIZE;
benbi_log++);
@@ -247,7 +243,6 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
if (!essiv_hash)
{
grub_crypto_cipher_close (cipher);
grub_crypto_cipher_close (secondary_cipher);
grub_error (GRUB_ERR_FILE_NOT_FOUND,
"Couldn't load %s hash", hash_str);
return NULL;
@@ -256,14 +251,12 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
if (!essiv_cipher)
{
grub_crypto_cipher_close (cipher);
grub_crypto_cipher_close (secondary_cipher);
return NULL;
}
}
else
{
grub_crypto_cipher_close (cipher);
grub_crypto_cipher_close (secondary_cipher);
grub_error (GRUB_ERR_BAD_ARGUMENT, "Unknown IV mode: %s",
cipheriv);
return NULL;
@@ -283,12 +276,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
newdev = grub_zalloc (sizeof (struct grub_cryptodisk));
if (!newdev)
{
grub_crypto_cipher_close (cipher);
grub_crypto_cipher_close (essiv_cipher);
grub_crypto_cipher_close (secondary_cipher);
return NULL;
}
return NULL;
newdev->cipher = cipher;
newdev->offset = grub_be_to_cpu32 (header.payloadOffset);
newdev->source_disk = NULL;
@@ -463,7 +451,6 @@ luks_recover_key (grub_disk_t source,
return GRUB_ERR_NONE;
}
grub_free (split_key);
return GRUB_ACCESS_DENIED;
}

View File

@@ -160,7 +160,7 @@ grub_lvm_detect (grub_disk_t disk,
"we don't support multiple LVM data areas");
#ifdef GRUB_UTIL
grub_util_info ("we don't support multiple LVM data areas");
grub_util_info ("we don't support multiple LVM data areas\n");
#endif
goto fail;
}
@@ -189,7 +189,7 @@ grub_lvm_detect (grub_disk_t disk,
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"unknown LVM metadata header");
#ifdef GRUB_UTIL
grub_util_info ("unknown LVM metadata header");
grub_util_info ("unknown LVM metadata header\n");
#endif
goto fail2;
}
@@ -213,7 +213,7 @@ grub_lvm_detect (grub_disk_t disk,
if (q == metadatabuf + mda_size)
{
#ifdef GRUB_UTIL
grub_util_info ("error parsing metadata");
grub_util_info ("error parsing metadata\n");
#endif
goto fail2;
}
@@ -230,7 +230,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("couldn't find ID");
grub_util_info ("couldn't find ID\n");
#endif
goto fail3;
}
@@ -258,7 +258,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("unknown extent size");
grub_util_info ("unknown extent size\n");
#endif
goto fail4;
}
@@ -306,7 +306,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("unknown pe_start");
grub_util_info ("unknown pe_start\n");
#endif
goto pvs_fail;
}
@@ -315,7 +315,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("error parsing pe_start");
grub_util_info ("error parsing pe_start\n");
#endif
goto pvs_fail;
}
@@ -333,10 +333,10 @@ grub_lvm_detect (grub_disk_t disk,
}
}
p = grub_strstr (p, "logical_volumes {");
p = grub_strstr (p, "logical_volumes");
if (p)
{
p += sizeof ("logical_volumes {") - 1;
p += sizeof ("logical_volumes = ") - 1;
/* And add all the lvs to the volume group. */
while (1)
@@ -402,7 +402,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("couldn't find ID");
grub_util_info ("couldn't find ID\n");
#endif
goto lvs_fail;
}
@@ -422,11 +422,11 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("unknown segment_count");
grub_util_info ("unknown segment_count\n");
#endif
goto lvs_fail;
}
lv->segments = grub_zalloc (sizeof (*seg) * lv->segment_count);
lv->segments = grub_malloc (sizeof (*seg) * lv->segment_count);
seg = lv->segments;
for (i = 0; i < lv->segment_count; i++)
@@ -436,7 +436,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("unknown segment");
grub_util_info ("unknown segment\n");
#endif
goto lvs_segment_fail;
}
@@ -445,7 +445,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("unknown start_extent");
grub_util_info ("unknown start_extent\n");
#endif
goto lvs_segment_fail;
}
@@ -453,7 +453,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("unknown extent_count");
grub_util_info ("unknown extent_count\n");
#endif
goto lvs_segment_fail;
}
@@ -475,7 +475,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("unknown stripe_count");
grub_util_info ("unknown stripe_count\n");
#endif
goto lvs_segment_fail;
}
@@ -491,7 +491,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("unknown stripes");
grub_util_info ("unknown stripes\n");
#endif
goto lvs_segment_fail2;
}
@@ -533,7 +533,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("unknown mirror_count");
grub_util_info ("unknown mirror_count\n");
#endif
goto lvs_segment_fail;
}
@@ -545,7 +545,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("unknown mirrors");
grub_util_info ("unknown mirrors\n");
#endif
goto lvs_segment_fail2;
}
@@ -577,17 +577,13 @@ grub_lvm_detect (grub_disk_t disk,
if (is_pvmove)
seg->node_count = 1;
}
else if (grub_memcmp (p, "raid", sizeof ("raid") - 1) == 0
&& ((p[sizeof ("raid") - 1] >= '4'
&& p[sizeof ("raid") - 1] <= '6')
|| p[sizeof ("raid") - 1] == '1')
else if (grub_memcmp (p, "raid", sizeof ("raid") - 1)
== 0 && (p[sizeof ("raid") - 1] >= '4'
&& p[sizeof ("raid") - 1] <= '6')
&& p[sizeof ("raidX") - 1] == '"')
{
switch (p[sizeof ("raid") - 1])
{
case '1':
seg->type = GRUB_DISKFILTER_MIRROR;
break;
case '4':
seg->type = GRUB_DISKFILTER_RAID4;
seg->layout = GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC;
@@ -607,23 +603,21 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("unknown device_count");
grub_util_info ("unknown device_count\n");
#endif
goto lvs_segment_fail;
}
if (seg->type != GRUB_DISKFILTER_MIRROR)
seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = ");
if (p == NULL)
{
seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = ");
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("unknown stripe_size");
grub_util_info ("unknown stripe_size\n");
#endif
goto lvs_segment_fail;
}
goto lvs_segment_fail;
}
seg->nodes = grub_zalloc (sizeof (seg->nodes[0])
* seg->node_count);
@@ -631,7 +625,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL)
{
#ifdef GRUB_UTIL
grub_util_info ("unknown raids");
grub_util_info ("unknown mirrors\n");
#endif
goto lvs_segment_fail2;
}
@@ -678,7 +672,7 @@ grub_lvm_detect (grub_disk_t disk,
p2 = grub_strchr (p, '"');
if (p2)
*p2 = 0;
grub_util_info ("unknown LVM type %s", p);
grub_util_info ("unknown LVM type %s\n", p);
if (p2)
*p2 ='"';
#endif

View File

@@ -33,16 +33,16 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define grub_md_to_cpu64 grub_be_to_cpu64
#define grub_md_to_cpu32 grub_be_to_cpu32
#define grub_md_to_cpu16 grub_be_to_cpu16
#define grub_cpu_to_md64_compile_time grub_cpu_to_be64_compile_time
#define grub_cpu_to_md32_compile_time grub_cpu_to_be32_compile_time
#define grub_cpu_to_md16_compile_time grub_cpu_to_be16_compile_time
#define grub_cpu_to_md64_compile_time grub_cpu_to_be64
#define grub_cpu_to_md32_compile_time grub_cpu_to_be32
#define grub_cpu_to_md16_compile_time grub_cpu_to_be16
#else
#define grub_md_to_cpu64 grub_le_to_cpu64
#define grub_md_to_cpu32 grub_le_to_cpu32
#define grub_md_to_cpu16 grub_le_to_cpu16
#define grub_cpu_to_md64_compile_time grub_cpu_to_le64_compile_time
#define grub_cpu_to_md32_compile_time grub_cpu_to_le32_compile_time
#define grub_cpu_to_md16_compile_time grub_cpu_to_le16_compile_time
#define grub_cpu_to_md64_compile_time grub_cpu_to_le64
#define grub_cpu_to_md32_compile_time grub_cpu_to_le32
#define grub_cpu_to_md16_compile_time grub_cpu_to_le16
#endif
#define RESERVED_BYTES (64 * 1024)

View File

@@ -63,16 +63,6 @@ grub_raid6_init_table (void)
}
}
static unsigned
mod_255 (unsigned x)
{
while (x > 0xff)
x = (x >> 8) + (x & 0xff);
if (x == 0xff)
return 0;
return x;
}
static grub_err_t
grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p,
char *buf, grub_disk_addr_t sector, grub_size_t size)
@@ -172,11 +162,11 @@ grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p,
grub_crypto_xor (qbuf, qbuf, buf, size);
c = mod_255((255 ^ bad1)
+ (255 ^ powx_inv[(powx[bad2 + (bad1 ^ 255)] ^ 1)]));
c = ((255 ^ bad1)
+ (255 ^ powx_inv[(powx[bad2 + (bad1 ^ 255)] ^ 1)])) % 255;
grub_raid_block_mulx (c, qbuf, size);
c = mod_255((unsigned) bad2 + c);
c = ((unsigned) bad2 + c) % 255;
grub_raid_block_mulx (c, pbuf, size);
grub_crypto_xor (pbuf, pbuf, qbuf, size);

View File

@@ -201,7 +201,7 @@ grub_scsi_read_capacity16 (grub_scsi_t scsi)
rc.opcode = grub_scsi_cmd_read_capacity16;
rc.lun = (scsi->lun << GRUB_SCSI_LUN_SHIFT) | 0x10;
rc.logical_block_addr = 0;
rc.alloc_len = grub_cpu_to_be32_compile_time (sizeof (rcd));
rc.alloc_len = grub_cpu_to_be32 (sizeof (rcd));
rc.PMI = 0;
rc.control = 0;
@@ -615,10 +615,9 @@ grub_scsi_open (const char *name, grub_disk_t disk)
if (scsi->blocksize & (scsi->blocksize - 1) || !scsi->blocksize)
{
grub_error (GRUB_ERR_IO, "invalid sector size %d",
scsi->blocksize);
grub_free (scsi);
return grub_errno;
return grub_error (GRUB_ERR_IO, "invalid sector size %d",
scsi->blocksize);
}
for (disk->log_sector_size = 0;
(1U << disk->log_sector_size) < scsi->blocksize;

View File

@@ -307,7 +307,7 @@ grub_usbms_transfer_bo (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd,
/* Setup the request. */
grub_memset (&cbw, 0, sizeof (cbw));
cbw.signature = grub_cpu_to_le32_compile_time (0x43425355);
cbw.signature = grub_cpu_to_le32 (0x43425355);
cbw.tag = tag;
cbw.transfer_length = grub_cpu_to_le32 (size);
cbw.flags = (!read_write) << GRUB_USBMS_DIRECTION_BIT;
@@ -414,7 +414,7 @@ CheckCSW:
/* If phase error or not valid signature, do bulk-only reset device. */
if ((status.status == 2) ||
(status.signature != grub_cpu_to_le32_compile_time(0x53425355)))
(status.signature != grub_cpu_to_le32(0x53425355)))
{ /* Bulk-only reset device. */
grub_dprintf ("usb", "Bulk-only reset device - bad status\n");
grub_usbms_reset (dev);

View File

@@ -40,7 +40,6 @@ struct virtdisk
grub_xen_evtchn_t evtchn;
void *dma_page;
grub_xen_grant_t dma_grant;
struct virtdisk *compat_next;
};
#define xen_wmb() mb()
@@ -48,7 +47,6 @@ struct virtdisk
static struct virtdisk *virtdisks;
static grub_size_t vdiskcnt;
struct virtdisk *compat_head;
static int
grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
@@ -68,32 +66,20 @@ grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
static grub_err_t
grub_virtdisk_open (const char *name, grub_disk_t disk)
{
int i;
grub_size_t i;
grub_uint32_t secsize;
char fdir[200];
char *buf;
int num = -1;
struct virtdisk *vd;
/* For compatibility with pv-grub legacy menu.lst accept hdX as disk name */
if (name[0] == 'h' && name[1] == 'd' && name[2])
{
num = grub_strtoul (name + 2, 0, 10);
if (grub_errno)
{
grub_errno = 0;
num = -1;
}
}
for (i = 0, vd = compat_head; vd; vd = vd->compat_next, i++)
if (i == num || grub_strcmp (name, vd->fullname) == 0)
for (i = 0; i < vdiskcnt; i++)
if (grub_strcmp (name, virtdisks[i].fullname) == 0)
break;
if (!vd)
if (i == vdiskcnt)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a virtdisk");
disk->data = vd;
disk->id = vd - virtdisks;
disk->data = &virtdisks[i];
disk->id = i;
grub_snprintf (fdir, sizeof (fdir), "%s/sectors", vd->backend_dir);
grub_snprintf (fdir, sizeof (fdir), "%s/sectors", virtdisks[i].backend_dir);
buf = grub_xenstore_get_file (fdir, NULL);
if (!buf)
return grub_errno;
@@ -101,7 +87,8 @@ grub_virtdisk_open (const char *name, grub_disk_t disk)
if (grub_errno)
return grub_errno;
grub_snprintf (fdir, sizeof (fdir), "%s/sector-size", vd->backend_dir);
grub_snprintf (fdir, sizeof (fdir), "%s/sector-size",
virtdisks[i].backend_dir);
buf = grub_xenstore_get_file (fdir, NULL);
if (!buf)
return grub_errno;
@@ -277,7 +264,6 @@ fill (const char *dir, void *data)
grub_err_t err;
void *buf;
struct evtchn_alloc_unbound alloc_unbound;
struct virtdisk **prev = &compat_head, *vd = compat_head;
/* Shouldn't happen unles some hotplug happened. */
if (vdiskcnt >= *ctr)
@@ -388,19 +374,6 @@ fill (const char *dir, void *data)
virtdisks[vdiskcnt].frontend_dir = grub_strdup (fdir);
/* For compatibility with pv-grub maintain linked list sorted by handle
value in increasing order. This allows mapping of (hdX) disk names
from legacy menu.lst */
while (vd)
{
if (vd->handle > virtdisks[vdiskcnt].handle)
break;
prev = &vd->compat_next;
vd = vd->compat_next;
}
virtdisks[vdiskcnt].compat_next = vd;
*prev = &virtdisks[vdiskcnt];
vdiskcnt++;
return 0;

View File

@@ -21,7 +21,6 @@
#include <grub/err.h>
#include <grub/mm.h>
#include <grub/types.h>
#include <grub/misc.h>
#include <grub/efiemu/efiemu.h>
#include <grub/crypto.h>

View File

@@ -777,7 +777,6 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
if (grub_file_read (font->file, glyph->bitmap, len) != len)
{
remove_font (font);
grub_free (glyph);
return 0;
}
}
@@ -1286,7 +1285,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
- grub_font_get_xheight (combining_glyphs[i]->font) - 1;
if (space <= 0)
space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8;
/* Fallthrough. */
case GRUB_UNICODE_STACK_ATTACHED_ABOVE:
do_blit (combining_glyphs[i], targetx,
-(ctx.bounds.height + ctx.bounds.y + space
@@ -1327,7 +1326,6 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
+ combining_glyphs[i]->height);
if (space <= 0)
space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8;
/* Fallthrough. */
case GRUB_UNICODE_STACK_ATTACHED_BELOW:
do_blit (combining_glyphs[i], targetx, -(ctx.bounds.y - space),

View File

@@ -34,12 +34,12 @@ canonicalize (char *name)
iptr++;
if (iptr[0] == '.' && (iptr[1] == '/' || iptr[1] == 0))
{
iptr++;
iptr += 2;
continue;
}
if (iptr[0] == '.' && iptr[1] == '.' && (iptr[2] == '/' || iptr[2] == 0))
{
iptr += 2;
iptr += 3;
if (optr == name)
continue;
for (optr -= 2; optr >= name && *optr != '/'; optr--);
@@ -249,10 +249,9 @@ grub_archelp_open (struct grub_archelp_data *data,
while (1)
{
grub_uint32_t mode;
grub_int32_t mtime;
int restart;
if (arcops->find_file (data, &fn, &mtime, &mode))
if (arcops->find_file (data, &fn, NULL, &mode))
goto fail;
if (mode == GRUB_ARCHELP_ATTR_END)

View File

@@ -29,7 +29,6 @@
#include <grub/dl.h>
#include <grub/types.h>
#include <grub/i18n.h>
#include <grub/fshelp.h>
GRUB_MOD_LICENSE ("GPLv3+");
@@ -562,10 +561,10 @@ iterate_in_b_tree (grub_disk_t disk,
}
static int
bfs_strcmp (const char *a, const char *b, grub_size_t alen)
bfs_strcmp (const char *a, const char *b, grub_size_t alen, grub_size_t blen)
{
char ac, bc;
while (*b && alen)
while (blen && alen)
{
if (*a != *b)
break;
@@ -573,10 +572,11 @@ bfs_strcmp (const char *a, const char *b, grub_size_t alen)
a++;
b++;
alen--;
blen--;
}
ac = alen ? *a : 0;
bc = *b;
bc = blen ? *b : 0;
#ifdef MODE_AFS
return (int) (grub_int8_t) ac - (int) (grub_int8_t) bc;
@@ -589,6 +589,7 @@ static grub_err_t
find_in_b_tree (grub_disk_t disk,
const struct grub_bfs_superblock *sb,
const struct grub_bfs_inode *ino, const char *name,
grub_size_t name_len,
grub_uint64_t * res)
{
struct grub_bfs_btree_header head;
@@ -636,7 +637,7 @@ find_in_b_tree (grub_disk_t disk,
end = grub_bfs_to_cpu16 (keylen_idx[(i | (1 << j))]);
if (grub_bfs_to_cpu_treehead (node->total_key_len) <= end)
end = grub_bfs_to_cpu_treehead (node->total_key_len);
cmp = bfs_strcmp (key_data + start, name, end - start);
cmp = bfs_strcmp (key_data + start, name, end - start, name_len);
if (cmp == 0 && level == 0)
{
*res = grub_bfs_to_cpu64 (key_values[i | (1 << j)].val);
@@ -657,7 +658,7 @@ find_in_b_tree (grub_disk_t disk,
end = grub_bfs_to_cpu16 (keylen_idx[0]);
if (grub_bfs_to_cpu_treehead (node->total_key_len) <= end)
end = grub_bfs_to_cpu_treehead (node->total_key_len);
cmp = bfs_strcmp (key_data, name, end);
cmp = bfs_strcmp (key_data, name, end, name_len);
if (cmp == 0 && level == 0)
{
*res = grub_bfs_to_cpu64 (key_values[0].val);
@@ -706,119 +707,127 @@ find_in_b_tree (grub_disk_t disk,
}
}
struct grub_fshelp_node
{
grub_disk_t disk;
const struct grub_bfs_superblock *sb;
struct grub_bfs_inode ino;
};
static grub_err_t
lookup_file (grub_fshelp_node_t dir,
const char *name,
grub_fshelp_node_t *foundnode,
enum grub_fshelp_filetype *foundtype)
hop_level (grub_disk_t disk,
const struct grub_bfs_superblock *sb,
struct grub_bfs_inode *ino, const char *name,
const char *name_end)
{
grub_err_t err;
struct grub_bfs_inode *new_ino;
grub_uint64_t res = 0;
err = find_in_b_tree (dir->disk, dir->sb, &dir->ino, name, &res);
if (((grub_bfs_to_cpu32 (ino->mode) & ATTR_TYPE) != ATTR_DIR))
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
err = find_in_b_tree (disk, sb, ino, name, name_end - name, &res);
if (err)
return err;
*foundnode = grub_malloc (sizeof (struct grub_fshelp_node));
if (!*foundnode)
return grub_errno;
(*foundnode)->disk = dir->disk;
(*foundnode)->sb = dir->sb;
new_ino = &(*foundnode)->ino;
if (grub_disk_read (dir->disk, res
<< (grub_bfs_to_cpu32 (dir->sb->log2_bsize)
- GRUB_DISK_SECTOR_BITS), 0,
sizeof (*new_ino), (char *) new_ino))
{
grub_free (*foundnode);
return grub_errno;
}
switch (grub_bfs_to_cpu32 (new_ino->mode) & ATTR_TYPE)
{
default:
case ATTR_REG:
*foundtype = GRUB_FSHELP_REG;
break;
case ATTR_DIR:
*foundtype = GRUB_FSHELP_DIR;
break;
case ATTR_LNK:
*foundtype = GRUB_FSHELP_SYMLINK;
break;
}
return GRUB_ERR_NONE;
}
static char *
read_symlink (grub_fshelp_node_t node)
{
char *alloc = NULL;
grub_err_t err;
#ifndef MODE_AFS
if (!(grub_bfs_to_cpu32 (node->ino.flags) & LONG_SYMLINK))
{
alloc = grub_malloc (sizeof (node->ino.inplace_link) + 1);
if (!alloc)
{
return NULL;
}
grub_memcpy (alloc, node->ino.inplace_link,
sizeof (node->ino.inplace_link));
alloc[sizeof (node->ino.inplace_link)] = 0;
}
else
#endif
{
grub_size_t symsize = grub_bfs_to_cpu64 (node->ino.size);
alloc = grub_malloc (symsize + 1);
if (!alloc)
return NULL;
err = read_bfs_file (node->disk, node->sb, &node->ino, 0, alloc, symsize, 0, 0);
if (err)
{
grub_free (alloc);
return NULL;
}
alloc[symsize] = 0;
}
return alloc;
return grub_disk_read (disk, res
<< (grub_bfs_to_cpu32 (sb->log2_bsize)
- GRUB_DISK_SECTOR_BITS), 0,
sizeof (*ino), (char *) ino);
}
static grub_err_t
find_file (const char *path, grub_disk_t disk,
const struct grub_bfs_superblock *sb, struct grub_bfs_inode *ino,
enum grub_fshelp_filetype exptype)
const struct grub_bfs_superblock *sb, struct grub_bfs_inode *ino)
{
const char *ptr, *next = path;
char *alloc = NULL;
char *wptr;
grub_err_t err;
struct grub_fshelp_node root = {
.disk = disk,
.sb = sb,
};
struct grub_fshelp_node *found;
struct grub_bfs_inode old_ino;
unsigned symlinks_max = 32;
err = read_extent (disk, sb, &sb->root_dir, 0, 0, &root.ino,
sizeof (root.ino));
err = read_extent (disk, sb, &sb->root_dir, 0, 0, ino,
sizeof (*ino));
if (err)
return err;
err = grub_fshelp_find_file_lookup (path, &root, &found, lookup_file, read_symlink, exptype);
if (!err)
grub_memcpy (ino, &found->ino, sizeof (*ino));
if (&root != found)
grub_free (found);
return err;
while (1)
{
ptr = next;
while (*ptr == '/')
ptr++;
if (*ptr == 0)
{
grub_free (alloc);
return GRUB_ERR_NONE;
}
for (next = ptr; *next && *next != '/'; next++);
grub_memcpy (&old_ino, ino, sizeof (old_ino));
err = hop_level (disk, sb, ino, ptr, next);
if (err)
return err;
if (((grub_bfs_to_cpu32 (ino->mode) & ATTR_TYPE) == ATTR_LNK))
{
char *old_alloc = alloc;
if (--symlinks_max == 0)
{
grub_free (alloc);
return grub_error (GRUB_ERR_SYMLINK_LOOP,
N_("too deep nesting of symlinks"));
}
#ifndef MODE_AFS
if (grub_bfs_to_cpu32 (ino->flags) & LONG_SYMLINK)
#endif
{
grub_size_t symsize = grub_bfs_to_cpu64 (ino->size);
alloc = grub_malloc (grub_strlen (next)
+ symsize + 1);
if (!alloc)
{
grub_free (alloc);
return grub_errno;
}
grub_free (old_alloc);
err = read_bfs_file (disk, sb, ino, 0, alloc, symsize, 0, 0);
if (err)
{
grub_free (alloc);
return err;
}
alloc[symsize] = 0;
}
#ifndef MODE_AFS
else
{
alloc = grub_malloc (grub_strlen (next)
+ sizeof (ino->inplace_link) + 1);
if (!alloc)
{
grub_free (alloc);
return grub_errno;
}
grub_free (old_alloc);
grub_memcpy (alloc, ino->inplace_link,
sizeof (ino->inplace_link));
alloc[sizeof (ino->inplace_link)] = 0;
}
#endif
if (alloc[0] == '/')
{
err = read_extent (disk, sb, &sb->root_dir, 0, 0, ino,
sizeof (*ino));
if (err)
{
grub_free (alloc);
return err;
}
}
else
grub_memcpy (ino, &old_ino, sizeof (old_ino));
wptr = alloc + grub_strlen (alloc);
if (next)
wptr = grub_stpcpy (wptr, next);
*wptr = 0;
next = alloc;
continue;
}
}
}
static grub_err_t
@@ -900,9 +909,11 @@ grub_bfs_dir (grub_device_t device, const char *path,
{
struct grub_bfs_inode ino;
err = find_file (path, device->disk, &ctx.sb, &ino, GRUB_FSHELP_DIR);
err = find_file (path, device->disk, &ctx.sb, &ino);
if (err)
return err;
if (((grub_bfs_to_cpu32 (ino.mode) & ATTR_TYPE) != ATTR_DIR))
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
iterate_in_b_tree (device->disk, &ctx.sb, &ino, grub_bfs_dir_iter,
&ctx);
}
@@ -923,9 +934,11 @@ grub_bfs_open (struct grub_file *file, const char *name)
{
struct grub_bfs_inode ino;
struct grub_bfs_data *data;
err = find_file (name, file->device->disk, &sb, &ino, GRUB_FSHELP_REG);
err = find_file (name, file->device->disk, &sb, &ino);
if (err)
return err;
if (((grub_bfs_to_cpu32 (ino.mode) & ATTR_TYPE) != ATTR_REG))
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
data = grub_zalloc (sizeof (struct grub_bfs_data));
if (!data)
@@ -1021,7 +1034,7 @@ read_bfs_attr (grub_disk_t disk,
if (err)
return -1;
err = find_in_b_tree (disk, sb, ino, name, &res);
err = find_in_b_tree (disk, sb, ino, name, grub_strlen (name), &res);
if (err)
return -1;
grub_disk_read (disk, res

View File

@@ -680,8 +680,6 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
grub_uint64_t stripen;
grub_uint64_t stripe_offset;
grub_uint64_t off = addr - grub_le_to_cpu64 (key->offset);
grub_uint64_t chunk_stripe_length;
grub_uint16_t nstripes;
unsigned redundancy = 1;
unsigned i, j;
@@ -692,17 +690,15 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
"couldn't find the chunk descriptor");
}
nstripes = grub_le_to_cpu16 (chunk->nstripes) ? : 1;
chunk_stripe_length = grub_le_to_cpu64 (chunk->stripe_length) ? : 512;
grub_dprintf ("btrfs", "chunk 0x%" PRIxGRUB_UINT64_T
"+0x%" PRIxGRUB_UINT64_T
" (%d stripes (%d substripes) of %"
PRIxGRUB_UINT64_T ")\n",
grub_le_to_cpu64 (key->offset),
grub_le_to_cpu64 (chunk->size),
nstripes,
grub_le_to_cpu16 (chunk->nstripes),
grub_le_to_cpu16 (chunk->nsubstripes),
chunk_stripe_length);
grub_le_to_cpu64 (chunk->stripe_length));
switch (grub_le_to_cpu64 (chunk->type)
& ~GRUB_BTRFS_CHUNK_TYPE_BITS_DONTCARE)
@@ -712,10 +708,8 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
grub_uint64_t stripe_length;
grub_dprintf ("btrfs", "single\n");
stripe_length = grub_divmod64 (grub_le_to_cpu64 (chunk->size),
nstripes,
grub_le_to_cpu16 (chunk->nstripes),
NULL);
if (stripe_length == 0)
stripe_length = 512;
stripen = grub_divmod64 (off, stripe_length, &stripe_offset);
csize = (stripen + 1) * stripe_length - off;
break;
@@ -736,34 +730,33 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
grub_uint64_t low;
grub_dprintf ("btrfs", "RAID0\n");
middle = grub_divmod64 (off,
chunk_stripe_length,
grub_le_to_cpu64 (chunk->stripe_length),
&low);
high = grub_divmod64 (middle, nstripes,
high = grub_divmod64 (middle, grub_le_to_cpu16 (chunk->nstripes),
&stripen);
stripe_offset =
low + chunk_stripe_length * high;
csize = chunk_stripe_length - low;
low + grub_le_to_cpu64 (chunk->stripe_length) * high;
csize = grub_le_to_cpu64 (chunk->stripe_length) - low;
break;
}
case GRUB_BTRFS_CHUNK_TYPE_RAID10:
{
grub_uint64_t middle, high;
grub_uint64_t low;
grub_uint16_t nsubstripes;
nsubstripes = grub_le_to_cpu16 (chunk->nsubstripes) ? : 1;
middle = grub_divmod64 (off,
chunk_stripe_length,
grub_le_to_cpu64 (chunk->stripe_length),
&low);
high = grub_divmod64 (middle,
nstripes / nsubstripes ? : 1,
grub_le_to_cpu16 (chunk->nstripes)
/ grub_le_to_cpu16 (chunk->nsubstripes),
&stripen);
stripen *= nsubstripes;
redundancy = nsubstripes;
stripe_offset = low + chunk_stripe_length
stripen *= grub_le_to_cpu16 (chunk->nsubstripes);
redundancy = grub_le_to_cpu16 (chunk->nsubstripes);
stripe_offset = low + grub_le_to_cpu64 (chunk->stripe_length)
* high;
csize = chunk_stripe_length - low;
csize = grub_le_to_cpu64 (chunk->stripe_length) - low;
break;
}
default:
@@ -1058,7 +1051,7 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data,
data->extend = data->extstart + grub_le_to_cpu64 (data->extent->size);
if (data->extent->type == GRUB_BTRFS_EXTENT_REGULAR
&& (char *) data->extent + elemsize
&& (char *) &data->extent + elemsize
>= (char *) &data->extent->filled + sizeof (data->extent->filled))
data->extend =
data->extstart + grub_le_to_cpu64 (data->extent->filled);
@@ -1208,7 +1201,7 @@ get_root (struct grub_btrfs_data *data, struct grub_btrfs_key *key,
struct grub_btrfs_key key_out, key_in;
struct grub_btrfs_root_item ri;
key_in.object_id = grub_cpu_to_le64_compile_time (GRUB_BTRFS_ROOT_VOL_OBJECTID);
key_in.object_id = GRUB_BTRFS_ROOT_VOL_OBJECTID;
key_in.offset = 0;
key_in.type = GRUB_BTRFS_ITEM_TYPE_ROOT_ITEM;
err = lower_bound (data, &key_in, &key_out,

View File

@@ -74,7 +74,8 @@ grub_cbfs_find_file (struct grub_archelp_data *data, char **name,
(void) mtime;
offset = grub_be_to_cpu32 (hd.offset);
*mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME;
if (mode)
*mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME;
namesize = offset;
if (namesize >= sizeof (hd))
@@ -143,14 +144,11 @@ static struct grub_archelp_data *
grub_cbfs_mount (grub_disk_t disk)
{
struct cbfs_file hd;
struct grub_archelp_data *data = NULL;
struct grub_archelp_data *data;
grub_uint32_t ptr;
grub_off_t header_off;
struct cbfs_header head;
if (grub_disk_get_size (disk) == GRUB_DISK_SIZE_UNKNOWN)
goto fail;
if (grub_disk_read (disk, grub_disk_get_size (disk) - 1,
GRUB_DISK_SECTOR_SIZE - sizeof (ptr),
sizeof (ptr), &ptr))
@@ -195,7 +193,6 @@ grub_cbfs_mount (grub_disk_t disk)
return data;
fail:
grub_free (data);
grub_error (GRUB_ERR_BAD_FS, "not a cbfs filesystem");
return 0;
}

View File

@@ -61,15 +61,8 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name,
modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode));
namesize = read_number (hd.namesize, ARRAY_SIZE (hd.namesize));
/* Don't allow negative numbers. */
if (namesize >= 0x80000000)
{
/* Probably a corruption, don't attempt to recover. */
*mode = GRUB_ARCHELP_ATTR_END;
return GRUB_ERR_NONE;
}
*mode = modeval;
if (mode)
*mode = modeval;
*name = grub_malloc (namesize + 1);
if (*name == NULL)

View File

@@ -100,7 +100,6 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* Extents used */
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
/* The set of back-incompatible features this driver DOES support. Add (OR)
@@ -108,7 +107,6 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define EXT2_DRIVER_SUPPORTED_INCOMPAT ( EXT2_FEATURE_INCOMPAT_FILETYPE \
| EXT4_FEATURE_INCOMPAT_EXTENTS \
| EXT4_FEATURE_INCOMPAT_FLEX_BG \
| EXT2_FEATURE_INCOMPAT_META_BG \
| EXT4_FEATURE_INCOMPAT_64BIT)
/* List of rationales for the ignored "incompatible" features:
* needs_recovery: Not really back-incompatible - was added as such to forbid
@@ -116,13 +114,8 @@ GRUB_MOD_LICENSE ("GPLv3+");
* journal because they will ignore the journal, but the next
* ext3 driver to mount the volume will find the journal and
* replay it, potentially corrupting the metadata written by
* the ext2 drivers. Safe to ignore for this RO driver.
* mmp: Not really back-incompatible - was added as such to
* avoid multiple read-write mounts. Safe to ignore for this
* RO driver.
*/
#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER \
| EXT4_FEATURE_INCOMPAT_MMP)
* the ext2 drivers. Safe to ignore for this RO driver. */
#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER )
#define EXT3_JOURNAL_MAGIC_NUMBER 0xc03b3998U
@@ -338,68 +331,16 @@ static grub_dl_t my_mod;
/* Check is a = b^x for some x. */
static inline int
is_power_of (grub_uint64_t a, grub_uint32_t b)
{
grub_uint64_t c;
/* Prevent overflow assuming b < 8. */
if (a >= (1LL << 60))
return 0;
for (c = 1; c <= a; c *= b);
return (c == a);
}
static inline int
group_has_super_block (struct grub_ext2_data *data, grub_uint64_t group)
{
if (!(data->sblock.feature_ro_compat
& grub_cpu_to_le32_compile_time(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)))
return 1;
/* Algorithm looked up in Linux source. */
if (group <= 1)
return 1;
/* Even number is never a power of odd number. */
if (!(group & 1))
return 0;
return (is_power_of(group, 7) || is_power_of(group, 5) ||
is_power_of(group, 3));
}
/* Read into BLKGRP the blockgroup descriptor of blockgroup GROUP of
the mounted filesystem DATA. */
inline static grub_err_t
grub_ext2_blockgroup (struct grub_ext2_data *data, grub_uint64_t group,
grub_ext2_blockgroup (struct grub_ext2_data *data, int group,
struct grub_ext2_block_group *blkgrp)
{
grub_uint64_t full_offset = (group << data->log_group_desc_size);
grub_uint64_t block, offset;
block = (full_offset >> LOG2_BLOCK_SIZE (data));
offset = (full_offset & ((1 << LOG2_BLOCK_SIZE (data)) - 1));
if ((data->sblock.feature_incompat
& grub_cpu_to_le32_compile_time (EXT2_FEATURE_INCOMPAT_META_BG))
&& block >= grub_le_to_cpu32(data->sblock.first_meta_bg))
{
grub_uint64_t first_block_group;
/* Find the first block group for which a descriptor
is stored in given block. */
first_block_group = (block << (LOG2_BLOCK_SIZE (data)
- data->log_group_desc_size));
block = (first_block_group
* grub_le_to_cpu32(data->sblock.blocks_per_group));
if (group_has_super_block (data, first_block_group))
block++;
}
else
/* Superblock. */
block++;
return grub_disk_read (data->disk,
((grub_le_to_cpu32 (data->sblock.first_data_block)
+ block)
<< LOG2_EXT2_BLOCK_SIZE (data)), offset,
((grub_le_to_cpu32 (data->sblock.first_data_block) + 1)
<< LOG2_EXT2_BLOCK_SIZE (data)),
group << data->log_group_desc_size,
sizeof (struct grub_ext2_block_group), blkgrp);
}
@@ -538,16 +479,11 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
shift = 2;
goto indirect;
}
grub_error (GRUB_ERR_BAD_FS,
"ext2fs doesn't support quadruple indirect blocks");
return -1;
return grub_error (GRUB_ERR_BAD_FS,
"ext2fs doesn't support quadruple indirect blocks");
indirect:
do {
/* If the indirect block is zero, all child blocks are absent
(i.e. filled with zeros.) */
if (indir == 0)
return 0;
if (grub_disk_read (data->disk,
((grub_disk_addr_t) grub_le_to_cpu32 (indir))
<< log2_blksz,
@@ -555,7 +491,7 @@ indirect:
& ((1 << log_perblock) - 1))
* sizeof (indir),
sizeof (indir), &indir))
return -1;
return grub_errno;
} while (shift--);
return grub_le_to_cpu32 (indir);
@@ -637,12 +573,7 @@ grub_ext2_mount (grub_disk_t disk)
/* Make sure this is an ext2 filesystem. */
if (data->sblock.magic != grub_cpu_to_le16_compile_time (EXT2_MAGIC)
|| grub_le_to_cpu32 (data->sblock.log2_block_size) >= 16
|| data->sblock.inodes_per_group == 0
/* 20 already means 1GiB blocks. We don't want to deal with blocks overflowing int32. */
|| grub_le_to_cpu32 (data->sblock.log2_block_size) > 20
|| EXT2_INODE_SIZE (data) == 0
|| EXT2_BLOCK_SIZE (data) / EXT2_INODE_SIZE (data) == 0)
|| grub_le_to_cpu32 (data->sblock.log2_block_size) >= 16)
{
grub_error (GRUB_ERR_BAD_FS, "not an ext2 filesystem");
goto fail;

View File

@@ -31,7 +31,6 @@
#else
#include <grub/exfat.h>
#endif
#include <grub/fshelp.h>
#include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+");
@@ -174,6 +173,8 @@ struct grub_fat_data
#ifndef MODE_EXFAT
grub_uint32_t root_sector;
grub_uint32_t num_root_sectors;
#else
int is_contiguous;
#endif
int cluster_bits;
@@ -181,22 +182,13 @@ struct grub_fat_data
grub_uint32_t cluster_sector;
grub_uint32_t num_clusters;
grub_uint32_t uuid;
};
struct grub_fshelp_node {
grub_disk_t disk;
struct grub_fat_data *data;
grub_uint8_t attr;
grub_ssize_t file_size;
grub_uint32_t file_cluster;
grub_uint32_t cur_cluster_num;
grub_uint32_t cur_cluster;
#ifdef MODE_EXFAT
int is_contiguous;
#endif
grub_uint32_t uuid;
};
static grub_dl_t my_mod;
@@ -435,6 +427,13 @@ grub_fat_mount (grub_disk_t disk)
(void) magic;
#endif
/* Start from the root directory. */
data->file_cluster = data->root_cluster;
data->cur_cluster_num = ~0U;
data->attr = GRUB_FAT_ATTR_DIRECTORY;
#ifdef MODE_EXFAT
data->is_contiguous = 0;
#endif
return data;
fail:
@@ -445,7 +444,7 @@ grub_fat_mount (grub_disk_t disk)
}
static grub_ssize_t
grub_fat_read_data (grub_disk_t disk, grub_fshelp_node_t node,
grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
grub_disk_read_hook_t read_hook, void *read_hook_data,
grub_off_t offset, grub_size_t len, char *buf)
{
@@ -458,13 +457,13 @@ grub_fat_read_data (grub_disk_t disk, grub_fshelp_node_t node,
#ifndef MODE_EXFAT
/* This is a special case. FAT12 and FAT16 doesn't have the root directory
in clusters. */
if (node->file_cluster == ~0U)
if (data->file_cluster == ~0U)
{
size = (node->data->num_root_sectors << GRUB_DISK_SECTOR_BITS) - offset;
size = (data->num_root_sectors << GRUB_DISK_SECTOR_BITS) - offset;
if (size > len)
size = len;
if (grub_disk_read (disk, node->data->root_sector, offset, size, buf))
if (grub_disk_read (disk, data->root_sector, offset, size, buf))
return -1;
return size;
@@ -472,12 +471,12 @@ grub_fat_read_data (grub_disk_t disk, grub_fshelp_node_t node,
#endif
#ifdef MODE_EXFAT
if (node->is_contiguous)
if (data->is_contiguous)
{
/* Read the data here. */
sector = (node->data->cluster_sector
+ ((node->file_cluster - 2)
<< node->data->cluster_bits));
sector = (data->cluster_sector
+ ((data->file_cluster - 2)
<< data->cluster_bits));
disk->read_hook = read_hook;
disk->read_hook_data = read_hook_data;
@@ -492,53 +491,53 @@ grub_fat_read_data (grub_disk_t disk, grub_fshelp_node_t node,
#endif
/* Calculate the logical cluster number and offset. */
logical_cluster_bits = (node->data->cluster_bits
logical_cluster_bits = (data->cluster_bits
+ GRUB_DISK_SECTOR_BITS);
logical_cluster = offset >> logical_cluster_bits;
offset &= (1ULL << logical_cluster_bits) - 1;
if (logical_cluster < node->cur_cluster_num)
if (logical_cluster < data->cur_cluster_num)
{
node->cur_cluster_num = 0;
node->cur_cluster = node->file_cluster;
data->cur_cluster_num = 0;
data->cur_cluster = data->file_cluster;
}
while (len)
{
while (logical_cluster > node->cur_cluster_num)
while (logical_cluster > data->cur_cluster_num)
{
/* Find next cluster. */
grub_uint32_t next_cluster;
grub_uint32_t fat_offset;
switch (node->data->fat_size)
switch (data->fat_size)
{
case 32:
fat_offset = node->cur_cluster << 2;
fat_offset = data->cur_cluster << 2;
break;
case 16:
fat_offset = node->cur_cluster << 1;
fat_offset = data->cur_cluster << 1;
break;
default:
/* case 12: */
fat_offset = node->cur_cluster + (node->cur_cluster >> 1);
fat_offset = data->cur_cluster + (data->cur_cluster >> 1);
break;
}
/* Read the FAT. */
if (grub_disk_read (disk, node->data->fat_sector, fat_offset,
(node->data->fat_size + 7) >> 3,
if (grub_disk_read (disk, data->fat_sector, fat_offset,
(data->fat_size + 7) >> 3,
(char *) &next_cluster))
return -1;
next_cluster = grub_le_to_cpu32 (next_cluster);
switch (node->data->fat_size)
switch (data->fat_size)
{
case 16:
next_cluster &= 0xFFFF;
break;
case 12:
if (node->cur_cluster & 1)
if (data->cur_cluster & 1)
next_cluster >>= 4;
next_cluster &= 0x0FFF;
@@ -546,27 +545,27 @@ grub_fat_read_data (grub_disk_t disk, grub_fshelp_node_t node,
}
grub_dprintf ("fat", "fat_size=%d, next_cluster=%u\n",
node->data->fat_size, next_cluster);
data->fat_size, next_cluster);
/* Check the end. */
if (next_cluster >= node->data->cluster_eof_mark)
if (next_cluster >= data->cluster_eof_mark)
return ret;
if (next_cluster < 2 || next_cluster >= node->data->num_clusters)
if (next_cluster < 2 || next_cluster >= data->num_clusters)
{
grub_error (GRUB_ERR_BAD_FS, "invalid cluster %u",
next_cluster);
return -1;
}
node->cur_cluster = next_cluster;
node->cur_cluster_num++;
data->cur_cluster = next_cluster;
data->cur_cluster_num++;
}
/* Read the data here. */
sector = (node->data->cluster_sector
+ ((node->cur_cluster - 2)
<< node->data->cluster_bits));
sector = (data->cluster_sector
+ ((data->cur_cluster - 2)
<< data->cluster_bits));
size = (1 << logical_cluster_bits) - offset;
if (size > len)
size = len;
@@ -632,7 +631,7 @@ grub_fat_iterate_fini (struct grub_fat_iterate_context *ctxt)
#ifdef MODE_EXFAT
static grub_err_t
grub_fat_iterate_dir_next (grub_fshelp_node_t node,
grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
struct grub_fat_iterate_context *ctxt)
{
grub_memset (&ctxt->dir, 0, sizeof (ctxt->dir));
@@ -642,7 +641,7 @@ grub_fat_iterate_dir_next (grub_fshelp_node_t node,
ctxt->offset += sizeof (dir);
if (grub_fat_read_data (node->disk, node, 0, 0, ctxt->offset, sizeof (dir),
if (grub_fat_read_data (disk, data, 0, 0, ctxt->offset, sizeof (dir),
(char *) &dir)
!= sizeof (dir))
break;
@@ -664,7 +663,7 @@ grub_fat_iterate_dir_next (grub_fshelp_node_t node,
{
struct grub_fat_dir_entry sec;
ctxt->offset += sizeof (sec);
if (grub_fat_read_data (node->disk, node, 0, 0,
if (grub_fat_read_data (disk, data, 0, 0,
ctxt->offset, sizeof (sec), (char *) &sec)
!= sizeof (sec))
break;
@@ -728,7 +727,7 @@ grub_fat_iterate_dir_next (grub_fshelp_node_t node,
#else
static grub_err_t
grub_fat_iterate_dir_next (grub_fshelp_node_t node,
grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
struct grub_fat_iterate_context *ctxt)
{
char *filep = 0;
@@ -743,7 +742,7 @@ grub_fat_iterate_dir_next (grub_fshelp_node_t node,
ctxt->offset += sizeof (ctxt->dir);
/* Read a directory entry. */
if (grub_fat_read_data (node->disk, node, 0, 0,
if (grub_fat_read_data (disk, data, 0, 0,
ctxt->offset, sizeof (ctxt->dir),
(char *) &ctxt->dir)
!= sizeof (ctxt->dir) || ctxt->dir.name[0] == 0)
@@ -830,9 +829,7 @@ grub_fat_iterate_dir_next (grub_fshelp_node_t node,
i--;
}
/* XXX should we check that dir position is 0 or 1? */
if (i > 2 || filep[0] != '.' || (i == 2 && filep[1] != '.'))
*filep++ = '.';
*filep++ = '.';
for (i = 8; i < 11 && ctxt->dir.name[i]; i++)
*filep++ = grub_tolower (ctxt->dir.name[i]);
@@ -854,20 +851,62 @@ grub_fat_iterate_dir_next (grub_fshelp_node_t node,
#endif
static grub_err_t lookup_file (grub_fshelp_node_t node,
const char *name,
grub_fshelp_node_t *foundnode,
enum grub_fshelp_filetype *foundtype)
/* Find the underlying directory or file in PATH and return the
next path. If there is no next path or an error occurs, return NULL.
If HOOK is specified, call it with each file name. */
static char *
grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
const char *path, const char *origpath,
grub_fs_dir_hook_t hook, void *hook_data)
{
grub_err_t err;
char *dirname, *dirp;
int call_hook;
int found = 0;
struct grub_fat_iterate_context ctxt;
grub_err_t err;
if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
return 0;
}
/* Extract a directory name. */
while (*path == '/')
path++;
dirp = grub_strchr (path, '/');
if (dirp)
{
unsigned len = dirp - path;
dirname = grub_malloc (len + 1);
if (! dirname)
goto fail;
grub_memcpy (dirname, path, len);
dirname[len] = '\0';
}
else
/* This is actually a file. */
dirname = grub_strdup (path);
call_hook = (! dirp && hook);
err = grub_fat_iterate_init (&ctxt);
if (err)
return err;
while (!(err = grub_fat_iterate_dir_next (node, &ctxt)))
{
grub_free (dirname);
return 0;
}
while (!(err = grub_fat_iterate_dir_next (disk, data, &ctxt)))
{
struct grub_dirhook_info info;
grub_memset (&info, 0, sizeof (info));
info.dir = !! (ctxt.dir.attr & GRUB_FAT_ATTR_DIRECTORY);
info.case_insensitive = 1;
#ifdef MODE_EXFAT
if (!ctxt.dir.have_stream)
@@ -876,33 +915,33 @@ static grub_err_t lookup_file (grub_fshelp_node_t node,
if (ctxt.dir.attr & GRUB_FAT_ATTR_VOLUME_ID)
continue;
#endif
if (grub_strcasecmp (name, ctxt.filename) == 0)
if (*dirname == '\0' && call_hook)
{
*foundnode = grub_malloc (sizeof (struct grub_fshelp_node));
if (!*foundnode)
return grub_errno;
(*foundnode)->attr = ctxt.dir.attr;
if (hook (ctxt.filename, &info, hook_data))
break;
else
continue;
}
if (grub_strcasecmp (dirname, ctxt.filename) == 0)
{
found = 1;
data->attr = ctxt.dir.attr;
#ifdef MODE_EXFAT
(*foundnode)->file_size = ctxt.dir.file_size;
(*foundnode)->file_cluster = ctxt.dir.first_cluster;
(*foundnode)->is_contiguous = ctxt.dir.is_contiguous;
data->file_size = ctxt.dir.file_size;
data->file_cluster = ctxt.dir.first_cluster;
data->is_contiguous = ctxt.dir.is_contiguous;
#else
(*foundnode)->file_size = grub_le_to_cpu32 (ctxt.dir.file_size);
(*foundnode)->file_cluster = ((grub_le_to_cpu16 (ctxt.dir.first_cluster_high) << 16)
data->file_size = grub_le_to_cpu32 (ctxt.dir.file_size);
data->file_cluster = ((grub_le_to_cpu16 (ctxt.dir.first_cluster_high) << 16)
| grub_le_to_cpu16 (ctxt.dir.first_cluster_low));
/* If directory points to root, starting cluster is 0 */
if (!(*foundnode)->file_cluster)
(*foundnode)->file_cluster = node->data->root_cluster;
#endif
(*foundnode)->cur_cluster_num = ~0U;
(*foundnode)->data = node->data;
(*foundnode)->disk = node->disk;
data->cur_cluster_num = ~0U;
*foundtype = ((*foundnode)->attr & GRUB_FAT_ATTR_DIRECTORY) ? GRUB_FSHELP_DIR : GRUB_FSHELP_REG;
if (call_hook)
hook (ctxt.filename, &info, hook_data);
grub_fat_iterate_fini (&ctxt);
return GRUB_ERR_NONE;
break;
}
}
@@ -910,8 +949,13 @@ static grub_err_t lookup_file (grub_fshelp_node_t node,
if (err == GRUB_ERR_EOF)
err = 0;
return err;
if (grub_errno == GRUB_ERR_NONE && ! found && !call_hook)
grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
fail:
grub_free (dirname);
return found ? dirp : 0;
}
static grub_err_t
@@ -920,9 +964,9 @@ grub_fat_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
{
struct grub_fat_data *data = 0;
grub_disk_t disk = device->disk;
grub_fshelp_node_t found = NULL;
grub_err_t err;
struct grub_fat_iterate_context ctxt;
grub_size_t len;
char *dirname = 0;
char *p;
grub_dl_ref (my_mod);
@@ -930,53 +974,27 @@ grub_fat_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
if (! data)
goto fail;
struct grub_fshelp_node root = {
.data = data,
.disk = disk,
.attr = GRUB_FAT_ATTR_DIRECTORY,
.file_size = 0,
.file_cluster = data->root_cluster,
.cur_cluster_num = ~0U,
.cur_cluster = 0,
#ifdef MODE_EXFAT
.is_contiguous = 0,
#endif
};
err = grub_fshelp_find_file_lookup (path, &root, &found, lookup_file, NULL, GRUB_FSHELP_DIR);
if (err)
/* Make sure that DIRNAME terminates with '/'. */
len = grub_strlen (path);
dirname = grub_malloc (len + 1 + 1);
if (! dirname)
goto fail;
grub_memcpy (dirname, path, len);
p = dirname + len;
if (path[len - 1] != '/')
*p++ = '/';
*p = '\0';
p = dirname;
err = grub_fat_iterate_init (&ctxt);
if (err)
goto fail;
while (!(err = grub_fat_iterate_dir_next (found, &ctxt)))
do
{
struct grub_dirhook_info info;
grub_memset (&info, 0, sizeof (info));
info.dir = !! (ctxt.dir.attr & GRUB_FAT_ATTR_DIRECTORY);
info.case_insensitive = 1;
#ifdef MODE_EXFAT
if (!ctxt.dir.have_stream)
continue;
#else
if (ctxt.dir.attr & GRUB_FAT_ATTR_VOLUME_ID)
continue;
#endif
if (hook (ctxt.filename, &info, hook_data))
break;
p = grub_fat_find_dir (disk, data, p, path, hook, hook_data);
}
grub_fat_iterate_fini (&ctxt);
if (err == GRUB_ERR_EOF)
err = 0;
while (p && grub_errno == GRUB_ERR_NONE);
fail:
if (found != &root)
grub_free (found);
grub_free (dirname);
grub_free (data);
grub_dl_unref (my_mod);
@@ -988,43 +1006,35 @@ static grub_err_t
grub_fat_open (grub_file_t file, const char *name)
{
struct grub_fat_data *data = 0;
grub_fshelp_node_t found = NULL;
grub_err_t err;
grub_disk_t disk = file->device->disk;
char *p = (char *) name;
grub_dl_ref (my_mod);
data = grub_fat_mount (disk);
data = grub_fat_mount (file->device->disk);
if (! data)
goto fail;
struct grub_fshelp_node root = {
.data = data,
.disk = disk,
.attr = GRUB_FAT_ATTR_DIRECTORY,
.file_size = 0,
.file_cluster = data->root_cluster,
.cur_cluster_num = ~0U,
.cur_cluster = 0,
#ifdef MODE_EXFAT
.is_contiguous = 0,
#endif
};
do
{
p = grub_fat_find_dir (file->device->disk, data, p, name, 0, 0);
if (grub_errno != GRUB_ERR_NONE)
goto fail;
}
while (p);
err = grub_fshelp_find_file_lookup (name, &root, &found, lookup_file, NULL, GRUB_FSHELP_REG);
if (err)
goto fail;
if (data->attr & GRUB_FAT_ATTR_DIRECTORY)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
goto fail;
}
file->data = found;
file->size = found->file_size;
file->data = data;
file->size = data->file_size;
return GRUB_ERR_NONE;
fail:
if (found != &root)
grub_free (found);
grub_free (data);
grub_dl_unref (my_mod);
@@ -1043,10 +1053,7 @@ grub_fat_read (grub_file_t file, char *buf, grub_size_t len)
static grub_err_t
grub_fat_close (grub_file_t file)
{
grub_fshelp_node_t node = file->data;
grub_free (node->data);
grub_free (node);
grub_free (file->data);
grub_dl_unref (my_mod);
@@ -1059,29 +1066,20 @@ grub_fat_label (grub_device_t device, char **label)
{
struct grub_fat_dir_entry dir;
grub_ssize_t offset = -sizeof(dir);
struct grub_fat_data *data;
grub_disk_t disk = device->disk;
struct grub_fshelp_node root = {
.disk = disk,
.attr = GRUB_FAT_ATTR_DIRECTORY,
.file_size = 0,
.cur_cluster_num = ~0U,
.cur_cluster = 0,
.is_contiguous = 0,
};
root.data = grub_fat_mount (disk);
if (! root.data)
data = grub_fat_mount (disk);
if (! data)
return grub_errno;
root.file_cluster = root.data->root_cluster;
*label = NULL;
while (1)
{
offset += sizeof (dir);
if (grub_fat_read_data (disk, &root, 0, 0,
if (grub_fat_read_data (disk, data, 0, 0,
offset, sizeof (dir), (char *) &dir)
!= sizeof (dir))
break;
@@ -1101,7 +1099,7 @@ grub_fat_label (grub_device_t device, char **label)
* GRUB_MAX_UTF8_PER_UTF16 + 1);
if (!*label)
{
grub_free (root.data);
grub_free (data);
return grub_errno;
}
chc = dir.type_specific.volume_label.character_count;
@@ -1113,7 +1111,7 @@ grub_fat_label (grub_device_t device, char **label)
}
}
grub_free (root.data);
grub_free (data);
return grub_errno;
}
@@ -1122,32 +1120,30 @@ grub_fat_label (grub_device_t device, char **label)
static grub_err_t
grub_fat_label (grub_device_t device, char **label)
{
struct grub_fat_data *data;
grub_disk_t disk = device->disk;
grub_err_t err;
struct grub_fat_iterate_context ctxt;
struct grub_fshelp_node root = {
.disk = disk,
.attr = GRUB_FAT_ATTR_DIRECTORY,
.file_size = 0,
.cur_cluster_num = ~0U,
.cur_cluster = 0,
};
*label = 0;
grub_dl_ref (my_mod);
root.data = grub_fat_mount (disk);
if (! root.data)
data = grub_fat_mount (disk);
if (! data)
goto fail;
root.file_cluster = root.data->root_cluster;
if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
return 0;
}
err = grub_fat_iterate_init (&ctxt);
if (err)
goto fail;
while (!(err = grub_fat_iterate_dir_next (&root, &ctxt)))
while (!(err = grub_fat_iterate_dir_next (disk, data, &ctxt)))
if ((ctxt.dir.attr & ~GRUB_FAT_ATTR_ARCHIVE) == GRUB_FAT_ATTR_VOLUME_ID)
{
*label = grub_strdup (ctxt.filename);
@@ -1160,7 +1156,7 @@ grub_fat_label (grub_device_t device, char **label)
grub_dl_unref (my_mod);
grub_free (root.data);
grub_free (data);
return grub_errno;
}

View File

@@ -30,287 +30,169 @@ GRUB_MOD_LICENSE ("GPLv3+");
typedef int (*iterate_dir_func) (grub_fshelp_node_t dir,
grub_fshelp_iterate_dir_hook_t hook,
void *data);
typedef grub_err_t (*lookup_file_func) (grub_fshelp_node_t dir,
const char *name,
grub_fshelp_node_t *foundnode,
enum grub_fshelp_filetype *foundtype);
typedef char *(*read_symlink_func) (grub_fshelp_node_t node);
struct stack_element {
struct stack_element *parent;
grub_fshelp_node_t node;
enum grub_fshelp_filetype type;
};
/* Context for grub_fshelp_find_file. */
struct grub_fshelp_find_file_ctx
{
/* Inputs. */
const char *path;
grub_fshelp_node_t rootnode;
/* Global options. */
grub_fshelp_node_t rootnode, currroot, currnode, oldnode;
enum grub_fshelp_filetype foundtype;
int symlinknest;
/* Current file being traversed and its parents. */
struct stack_element *currnode;
const char *name;
const char *next;
enum grub_fshelp_filetype type;
};
/* Helper for find_file_iter. */
static void
free_node (grub_fshelp_node_t node, struct grub_fshelp_find_file_ctx *ctx)
{
if (node != ctx->rootnode)
if (node != ctx->rootnode && node != ctx->currroot)
grub_free (node);
}
static void
pop_element (struct grub_fshelp_find_file_ctx *ctx)
{
struct stack_element *el;
el = ctx->currnode;
ctx->currnode = el->parent;
free_node (el->node, ctx);
grub_free (el);
}
static void
free_stack (struct grub_fshelp_find_file_ctx *ctx)
{
while (ctx->currnode)
pop_element (ctx);
}
static void
go_up_a_level (struct grub_fshelp_find_file_ctx *ctx)
{
if (!ctx->currnode->parent)
return;
pop_element (ctx);
}
static grub_err_t
push_node (struct grub_fshelp_find_file_ctx *ctx, grub_fshelp_node_t node, enum grub_fshelp_filetype filetype)
{
struct stack_element *nst;
nst = grub_malloc (sizeof (*nst));
if (!nst)
return grub_errno;
nst->node = node;
nst->type = filetype & ~GRUB_FSHELP_CASE_INSENSITIVE;
nst->parent = ctx->currnode;
ctx->currnode = nst;
return GRUB_ERR_NONE;
}
static grub_err_t
go_to_root (struct grub_fshelp_find_file_ctx *ctx)
{
free_stack (ctx);
return push_node (ctx, ctx->rootnode, GRUB_FSHELP_DIR);
}
struct grub_fshelp_find_file_iter_ctx
{
const char *name;
grub_fshelp_node_t *foundnode;
enum grub_fshelp_filetype *foundtype;
};
/* Helper for grub_fshelp_find_file. */
static int
find_file_iter (const char *filename, enum grub_fshelp_filetype filetype,
grub_fshelp_node_t node, void *data)
{
struct grub_fshelp_find_file_iter_ctx *ctx = data;
struct grub_fshelp_find_file_ctx *ctx = data;
if (filetype == GRUB_FSHELP_UNKNOWN ||
((filetype & GRUB_FSHELP_CASE_INSENSITIVE)
? grub_strcasecmp (ctx->name, filename)
: grub_strcmp (ctx->name, filename)))
? grub_strncasecmp (ctx->name, filename, ctx->next - ctx->name)
: grub_strncmp (ctx->name, filename, ctx->next - ctx->name))
|| filename[ctx->next - ctx->name])
{
grub_free (node);
return 0;
}
/* The node is found, stop iterating over the nodes. */
*ctx->foundnode = node;
*ctx->foundtype = filetype;
ctx->type = filetype & ~GRUB_FSHELP_CASE_INSENSITIVE;
ctx->oldnode = ctx->currnode;
ctx->currnode = node;
return 1;
}
static grub_err_t
directory_find_file (grub_fshelp_node_t node, const char *name, grub_fshelp_node_t *foundnode,
enum grub_fshelp_filetype *foundtype, iterate_dir_func iterate_dir)
{
int found;
struct grub_fshelp_find_file_iter_ctx ctx = {
.foundnode = foundnode,
.foundtype = foundtype,
.name = name
};
found = iterate_dir (node, find_file_iter, &ctx);
if (! found)
{
if (grub_errno)
return grub_errno;
}
return GRUB_ERR_NONE;
}
static grub_err_t
find_file (char *currpath,
iterate_dir_func iterate_dir, lookup_file_func lookup_file,
read_symlink_func read_symlink,
find_file (const char *currpath, grub_fshelp_node_t currroot,
grub_fshelp_node_t *currfound,
iterate_dir_func iterate_dir, read_symlink_func read_symlink,
struct grub_fshelp_find_file_ctx *ctx)
{
char *name, *next;
grub_err_t err;
for (name = currpath; ; name = next)
ctx->currroot = currroot;
ctx->name = currpath;
ctx->type = GRUB_FSHELP_DIR;
ctx->currnode = currroot;
ctx->oldnode = currroot;
for (;;)
{
char c;
grub_fshelp_node_t foundnode = NULL;
enum grub_fshelp_filetype foundtype = 0;
int found;
/* Remove all leading slashes. */
while (*name == '/')
name++;
while (*ctx->name == '/')
ctx->name++;
/* Found the node! */
if (! *name)
return 0;
if (! *ctx->name)
{
*currfound = ctx->currnode;
ctx->foundtype = ctx->type;
return 0;
}
/* Extract the actual part from the pathname. */
for (next = name; *next && *next != '/'; next++);
for (ctx->next = ctx->name; *ctx->next && *ctx->next != '/'; ctx->next++);
/* At this point it is expected that the current node is a
directory, check if this is true. */
if (ctx->currnode->type != GRUB_FSHELP_DIR)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
/* Don't rely on fs providing actual . in the listing. */
if (next - name == 1 && name[0] == '.')
continue;
/* Don't rely on fs providing actual .. in the listing. */
if (next - name == 2 && name[0] == '.' && name[1] == '.')
if (ctx->type != GRUB_FSHELP_DIR)
{
go_up_a_level (ctx);
continue;
free_node (ctx->currnode, ctx);
ctx->currnode = 0;
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
}
/* Iterate over the directory. */
c = *next;
*next = '\0';
if (lookup_file)
err = lookup_file (ctx->currnode->node, name, &foundnode, &foundtype);
else
err = directory_find_file (ctx->currnode->node, name, &foundnode, &foundtype, iterate_dir);
*next = c;
found = iterate_dir (ctx->currnode, find_file_iter, ctx);
if (! found)
{
free_node (ctx->currnode, ctx);
ctx->currnode = 0;
if (grub_errno)
return grub_errno;
if (err)
return err;
break;
}
if (!foundnode)
break;
push_node (ctx, foundnode, foundtype);
/* Read in the symlink and follow it. */
if (ctx->currnode->type == GRUB_FSHELP_SYMLINK)
if (ctx->type == GRUB_FSHELP_SYMLINK)
{
char *symlink;
const char *next;
/* Test if the symlink does not loop. */
if (++ctx->symlinknest == 8)
return grub_error (GRUB_ERR_SYMLINK_LOOP,
N_("too deep nesting of symlinks"));
{
free_node (ctx->currnode, ctx);
free_node (ctx->oldnode, ctx);
ctx->currnode = 0;
ctx->oldnode = 0;
return grub_error (GRUB_ERR_SYMLINK_LOOP,
N_("too deep nesting of symlinks"));
}
symlink = read_symlink (ctx->currnode->node);
symlink = read_symlink (ctx->currnode);
free_node (ctx->currnode, ctx);
ctx->currnode = 0;
if (!symlink)
return grub_errno;
{
free_node (ctx->oldnode, ctx);
ctx->oldnode = 0;
return grub_errno;
}
/* The symlink is an absolute path, go back to the root inode. */
if (symlink[0] == '/')
{
err = go_to_root (ctx);
if (err)
return err;
free_node (ctx->oldnode, ctx);
ctx->oldnode = ctx->rootnode;
}
else
{
/* Get from symlink to containing directory. */
go_up_a_level (ctx);
}
/* Lookup the node the symlink points to. */
find_file (symlink, iterate_dir, lookup_file, read_symlink, ctx);
next = ctx->next;
find_file (symlink, ctx->oldnode, &ctx->currnode,
iterate_dir, read_symlink, ctx);
ctx->next = next;
ctx->type = ctx->foundtype;
grub_free (symlink);
if (grub_errno)
return grub_errno;
{
free_node (ctx->oldnode, ctx);
ctx->oldnode = 0;
return grub_errno;
}
}
if (ctx->oldnode != ctx->currnode)
{
free_node (ctx->oldnode, ctx);
ctx->oldnode = 0;
}
ctx->name = ctx->next;
}
return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"),
ctx->path);
}
static grub_err_t
grub_fshelp_find_file_real (const char *path, grub_fshelp_node_t rootnode,
grub_fshelp_node_t *foundnode,
iterate_dir_func iterate_dir,
lookup_file_func lookup_file,
read_symlink_func read_symlink,
enum grub_fshelp_filetype expecttype)
{
struct grub_fshelp_find_file_ctx ctx = {
.path = path,
.rootnode = rootnode,
.symlinknest = 0,
.currnode = 0
};
grub_err_t err;
enum grub_fshelp_filetype foundtype;
char *duppath;
if (!path || path[0] != '/')
{
return grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path);
}
err = go_to_root (&ctx);
if (err)
return err;
duppath = grub_strdup (path);
if (!duppath)
return grub_errno;
err = find_file (duppath, iterate_dir, lookup_file, read_symlink, &ctx);
grub_free (duppath);
if (err)
{
free_stack (&ctx);
return err;
}
*foundnode = ctx.currnode->node;
foundtype = ctx.currnode->type;
/* Avoid the node being freed. */
ctx.currnode->node = 0;
free_stack (&ctx);
/* Check if the node that was found was of the expected type. */
if (expecttype == GRUB_FSHELP_REG && foundtype != expecttype)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
else if (expecttype == GRUB_FSHELP_DIR && foundtype != expecttype)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
return 0;
}
/* Lookup the node PATH. The node ROOTNODE describes the root of the
directory tree. The node found is returned in FOUNDNODE, which is
either a ROOTNODE or a new malloc'ed node. ITERATE_DIR is used to
@@ -325,23 +207,31 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
read_symlink_func read_symlink,
enum grub_fshelp_filetype expecttype)
{
return grub_fshelp_find_file_real (path, rootnode, foundnode,
iterate_dir, NULL,
read_symlink, expecttype);
struct grub_fshelp_find_file_ctx ctx = {
.path = path,
.rootnode = rootnode,
.foundtype = GRUB_FSHELP_DIR,
.symlinknest = 0
};
grub_err_t err;
}
if (!path || path[0] != '/')
{
grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path);
return grub_errno;
}
grub_err_t
grub_fshelp_find_file_lookup (const char *path, grub_fshelp_node_t rootnode,
grub_fshelp_node_t *foundnode,
lookup_file_func lookup_file,
read_symlink_func read_symlink,
enum grub_fshelp_filetype expecttype)
{
return grub_fshelp_find_file_real (path, rootnode, foundnode,
NULL, lookup_file,
read_symlink, expecttype);
err = find_file (path, rootnode, foundnode, iterate_dir, read_symlink, &ctx);
if (err)
return err;
/* Check if the node that was found was of the expected type. */
if (expecttype == GRUB_FSHELP_REG && ctx.foundtype != expecttype)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
else if (expecttype == GRUB_FSHELP_DIR && ctx.foundtype != expecttype)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
return 0;
}
/* Read LEN bytes from the file NODE on disk DISK into the buffer BUF,
@@ -362,13 +252,6 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
grub_disk_addr_t i, blockcnt;
int blocksize = 1 << (log2blocksize + GRUB_DISK_SECTOR_BITS);
if (pos > filesize)
{
grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("attempt to read past the end of file"));
return -1;
}
/* Adjust LEN so it we can't read past the end of the file. */
if (pos + len > filesize)
len = filesize - pos;

314
grub-core/fs/greffs.c Normal file
View File

@@ -0,0 +1,314 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2013 Free Software Foundation, Inc.
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/misc.h>
#include <grub/disk.h>
#include <grub/archelp.h>
#include <grub/file.h>
#include <grub/mm.h>
#include <grub/dl.h>
#include <grub/i18n.h>
#include <grub/greffs.h>
GRUB_MOD_LICENSE ("GPLv3+");
struct grub_greffs_data
{
grub_uint32_t dofs;
};
static grub_err_t
get_string (grub_disk_t disk,
const struct grub_greffs_header *head,
grub_uint32_t fn,
char **buf, grub_size_t *size)
{
grub_uint32_t desc[2];
grub_size_t read_size;
if (grub_disk_read (disk, 0,
grub_cpu_to_le32 (head->string_ptrs_offset)
+ fn * sizeof (desc[0]), sizeof (desc), &desc))
return grub_errno;
read_size = desc[1] - desc[0];
if (*size < read_size + 1)
{
grub_free (*buf);
*size = (read_size + 4) * 2;
*buf = grub_malloc (*size);
if (!*buf)
{
*size = 0;
return grub_errno;
}
}
if (grub_disk_read (disk, 0, desc[0], read_size, *buf))
return grub_errno;
(*buf)[read_size] = '\0';
return GRUB_ERR_NONE;
}
static grub_err_t
find_file (grub_disk_t disk,
struct grub_greffs_header *head,
const char *name_in, grub_uint32_t *f, int exact)
{
grub_uint32_t num_files, cur_file = 0;
int i;
char *buf = NULL;
grub_size_t buf_size = 0;
grub_err_t err;
num_files = grub_le_to_cpu32 (head->nfiles);
for (i = 31; i >= 0; i--)
{
int cmp;
if ((cur_file | (1 << i)) > num_files)
continue;
err = get_string (disk, head, (cur_file | (1 << i)) - 1, &buf, &buf_size);
if (err)
{
grub_free (buf);
return err;
}
cmp = grub_strcmp (buf, name_in);
if (cmp <= 0)
cur_file |= (1 << i);
if (cmp == 0)
{
grub_free (buf);
*f = cur_file - 1;
return GRUB_ERR_NONE;
}
}
grub_free (buf);
if (!exact)
{
*f = cur_file;
return GRUB_ERR_NONE;
}
return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"),
name_in);
}
static char *
canonicalize (const char *name_in, int make_dir)
{
const char *iptr;
char *out, *optr;
out = grub_malloc (grub_strlen (name_in) + 2);
if (!out)
return NULL;
for (iptr = name_in, optr = out; *iptr; )
{
while (*iptr == '/')
iptr++;
if (iptr[0] == '.' && (iptr[1] == '/' || iptr[1] == 0))
{
iptr += 2;
continue;
}
if (iptr[0] == '.' && iptr[1] == '.' && (iptr[2] == '/' || iptr[2] == 0))
{
iptr += 3;
if (optr == out)
continue;
for (optr -= 2; optr >= out && *optr != '/'; optr--);
optr++;
continue;
}
while (*iptr && *iptr != '/')
*optr++ = *iptr++;
if (*iptr)
*optr++ = *iptr++;
else if (make_dir && optr != out)
*optr++ = '/';
}
*optr = 0;
return out;
}
static grub_err_t
grub_greffs_dir (grub_device_t device, const char *path_in,
grub_fs_dir_hook_t hook, void *hook_data)
{
grub_err_t err;
grub_uint32_t cur_file, num_files;
char *buf = 0;
grub_size_t buf_size = 0;
char *can;
grub_size_t len;
struct grub_greffs_header head;
if (grub_disk_read (device->disk, 0, 0, sizeof (head), &head))
return grub_error (GRUB_ERR_BAD_FS, "not a greffs filesystem");
if (grub_memcmp (head.magic, GRUB_GREFFS_MAGIC, sizeof (head.magic)) != 0)
return grub_error (GRUB_ERR_BAD_FS, "not a greffs filesystem");
can = canonicalize (path_in, 1);
if (!can)
return grub_errno;
if (can[0] == '\0')
cur_file = 0;
else
{
err = find_file (device->disk, &head, can, &cur_file, 0);
if (err)
goto fail;
}
num_files = grub_le_to_cpu32 (head.nfiles);
len = grub_strlen (can);
while (cur_file < num_files)
{
char *p, *n;
struct grub_dirhook_info info;
err = get_string (device->disk, &head, cur_file, &buf, &buf_size);
if (err)
goto fail;
if (grub_memcmp (can, buf, len) != 0)
break;
grub_memset (&info, 0, sizeof (info));
n = buf + len;
while (*n == '/')
n++;
p = grub_strchr (n, '/');
if (p)
*p = 0;
info.dir = (p != NULL);
if (hook (n, &info, hook_data))
goto fail;
if (!p)
cur_file++;
else
{
*p = '/' + 1;
p[1] = '\0';
err = find_file (device->disk, &head, buf, &cur_file, 0);
if (err)
goto fail;
}
}
fail:
grub_free (buf);
grub_free (can);
return grub_errno;
}
static grub_err_t
grub_greffs_open (grub_file_t file, const char *name_in)
{
struct grub_greffs_header head;
struct grub_greffs_data *data;
struct grub_greffs_inode inode;
grub_err_t err;
grub_uint32_t cur_file;
char *can;
if (grub_disk_read (file->device->disk, 0, 0, sizeof (head), &head))
return grub_error (GRUB_ERR_BAD_FS, "not a greffs filesystem");
if (grub_memcmp (head.magic, GRUB_GREFFS_MAGIC, sizeof (head.magic)) != 0)
return grub_error (GRUB_ERR_BAD_FS, "not a greffs filesystem");
can = canonicalize (name_in, 0);
if (!can)
return grub_errno;
err = find_file (file->device->disk, &head, can, &cur_file, 1);
grub_free (can);
if (err)
return err;
data = grub_malloc (sizeof (*data));
if (!data)
return grub_errno;
if (grub_disk_read (file->device->disk,
0, grub_le_to_cpu32 (head.inodes_offset)
+ sizeof (inode) * cur_file, sizeof (inode), &inode))
return grub_error (GRUB_ERR_BAD_FS, "not a greffs filesystem");
data->dofs = grub_cpu_to_le32 (inode.start);
file->size = grub_cpu_to_le32 (inode.size);
file->data = data;
return GRUB_ERR_NONE;
}
static grub_ssize_t
grub_greffs_read (grub_file_t file, char *buf, grub_size_t len)
{
struct grub_greffs_data *data;
grub_ssize_t ret;
data = file->data;
file->device->disk->read_hook = file->read_hook;
file->device->disk->read_hook_data = file->read_hook_data;
ret = (grub_disk_read (file->device->disk, 0, data->dofs + file->offset,
len, buf)) ? -1 : (grub_ssize_t) len;
file->device->disk->read_hook = 0;
return ret;
}
static grub_err_t
grub_greffs_close (grub_file_t file)
{
struct grub_greffs_data *data;
data = file->data;
grub_free (data);
return grub_errno;
}
static struct grub_fs grub_greffs_fs = {
.name = "greffs",
.dir = grub_greffs_dir,
.open = grub_greffs_open,
.read = grub_greffs_read,
.close = grub_greffs_close,
#ifdef GRUB_UTIL
.reserved_first_sector = 0,
.blocklist_install = 0,
#endif
};
GRUB_MOD_INIT (greffs)
{
grub_fs_register (&grub_greffs_fs);
}
GRUB_MOD_FINI (greffs)
{
grub_fs_unregister (&grub_greffs_fs);
}

View File

@@ -29,7 +29,6 @@
#include <grub/types.h>
#include <grub/hfs.h>
#include <grub/i18n.h>
#include <grub/fshelp.h>
GRUB_MOD_LICENSE ("GPLv3+");
@@ -331,7 +330,6 @@ grub_hfs_mount (grub_disk_t disk)
/* Check if this is a HFS filesystem. */
if (grub_be_to_cpu16 (data->sblock.magic) != GRUB_HFS_MAGIC
|| data->sblock.blksz == 0
|| (data->sblock.blksz & grub_cpu_to_be32_compile_time (0xc00001ff)))
{
grub_error (GRUB_ERR_BAD_FS, "not an HFS filesystem");
@@ -369,14 +367,9 @@ grub_hfs_mount (grub_disk_t disk)
data->cat_root = grub_be_to_cpu32 (treehead.head.root_node);
data->cat_size = grub_be_to_cpu16 (treehead.head.node_size);
if (data->cat_size == 0
|| data->blksz < data->cat_size
|| data->blksz < data->ext_size)
goto fail;
/* Lookup the root directory node in the catalog tree using the
volume name. */
key.parent_dir = grub_cpu_to_be32_compile_time (1);
key.parent_dir = grub_cpu_to_be32 (1);
key.strlen = data->sblock.volname[0];
grub_strcpy ((char *) key.str, (char *) (data->sblock.volname + 1));
@@ -693,7 +686,6 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
int i;
struct grub_hfs_extent *dat;
int blk;
grub_uint16_t reccnt;
dat = (struct grub_hfs_extent *) (type == 0
? (&data->sblock.catalog_recs)
@@ -712,12 +704,8 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
return grub_errno;
}
reccnt = grub_be_to_cpu16 (node->node.reccnt);
if (reccnt > (nodesize >> 1))
reccnt = (nodesize >> 1);
/* Iterate over all records in this node. */
for (i = 0; i < reccnt; i++)
for (i = 0; i < grub_be_to_cpu16 (node->node.reccnt); i++)
{
int pos = (nodesize >> 1) - 1 - i;
struct pointer
@@ -725,19 +713,16 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
grub_uint8_t keylen;
grub_uint8_t key;
} GRUB_PACKED *pnt;
grub_uint16_t off = grub_be_to_cpu16 (node->offsets[pos]);
if (off > nodesize - sizeof(*pnt))
continue;
pnt = (struct pointer *) (off + node->rawnode);
if (nodesize < (grub_size_t) off + pnt->keylen + 1)
continue;
pnt = (struct pointer *) (grub_be_to_cpu16 (node->offsets[pos])
+ node->rawnode);
struct grub_hfs_record rec =
{
&pnt->key,
pnt->keylen,
&pnt->key + pnt->keylen +(pnt->keylen + 1) % 2,
nodesize - off - pnt->keylen - 1
nodesize - grub_be_to_cpu16 (node->offsets[pos])
- pnt->keylen - 1
};
if (node_hook (&node->node, &rec, hook_arg))
@@ -1126,81 +1111,90 @@ utf8_to_macroman (grub_uint8_t *to, const char *from)
return optr - to;
}
union grub_hfs_anyrec {
struct grub_hfs_filerec frec;
struct grub_hfs_dirrec dir;
};
struct grub_fshelp_node
{
struct grub_hfs_data *data;
union grub_hfs_anyrec fdrec;
grub_uint32_t inode;
};
static grub_err_t
lookup_file (grub_fshelp_node_t dir,
const char *name,
grub_fshelp_node_t *foundnode,
enum grub_fshelp_filetype *foundtype)
{
struct grub_hfs_catalog_key key;
grub_ssize_t slen;
union grub_hfs_anyrec fdrec;
key.parent_dir = grub_cpu_to_be32 (dir->inode);
slen = utf8_to_macroman (key.str, name);
if (slen < 0)
/* Not found */
return GRUB_ERR_NONE;
key.strlen = slen;
/* Lookup this node. */
if (! grub_hfs_find_node (dir->data, (char *) &key, dir->data->cat_root,
0, (char *) &fdrec.frec, sizeof (fdrec.frec)))
/* Not found */
return GRUB_ERR_NONE;
*foundnode = grub_malloc (sizeof (struct grub_fshelp_node));
if (!*foundnode)
return grub_errno;
(*foundnode)->inode = grub_be_to_cpu32 (fdrec.dir.dirid);
(*foundnode)->fdrec = fdrec;
(*foundnode)->data = dir->data;
*foundtype = (fdrec.frec.type == GRUB_HFS_FILETYPE_DIR) ? GRUB_FSHELP_DIR : GRUB_FSHELP_REG;
return GRUB_ERR_NONE;
}
/* Find a file or directory with the pathname PATH in the filesystem
DATA. Return the file record in RETDATA when it is non-zero.
Return the directory number in RETINODE when it is non-zero. */
static grub_err_t
grub_hfs_find_dir (struct grub_hfs_data *data, const char *path,
grub_fshelp_node_t *found,
enum grub_fshelp_filetype exptype)
struct grub_hfs_filerec *retdata, int *retinode)
{
struct grub_fshelp_node root = {
.data = data,
.inode = data->rootdir,
.fdrec = {
.frec = {
.type = GRUB_HFS_FILETYPE_DIR
}
}
};
grub_err_t err;
int inode = data->rootdir;
char *next;
char *origpath;
union {
struct grub_hfs_filerec frec;
struct grub_hfs_dirrec dir;
} fdrec;
err = grub_fshelp_find_file_lookup (path, &root, found, lookup_file, NULL, exptype);
fdrec.frec.type = GRUB_HFS_FILETYPE_DIR;
if (&root == *found)
if (path[0] != '/')
{
*found = grub_malloc (sizeof (root));
if (!*found)
return grub_errno;
grub_memcpy (*found, &root, sizeof (root));
grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path);
return 0;
}
return err;
origpath = grub_strdup (path);
if (!origpath)
return grub_errno;
path = origpath;
while (*path == '/')
path++;
while (path && grub_strlen (path))
{
grub_ssize_t slen;
if (fdrec.frec.type != GRUB_HFS_FILETYPE_DIR)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
goto fail;
}
/* Isolate a part of the path. */
next = grub_strchr (path, '/');
if (next)
{
while (*next == '/')
*(next++) = '\0';
}
struct grub_hfs_catalog_key key;
key.parent_dir = grub_cpu_to_be32 (inode);
slen = utf8_to_macroman (key.str, path);
if (slen < 0)
{
grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path);
goto fail;
}
key.strlen = slen;
/* Lookup this node. */
if (! grub_hfs_find_node (data, (char *) &key, data->cat_root,
0, (char *) &fdrec.frec, sizeof (fdrec.frec)))
{
grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
goto fail;
}
if (grub_errno)
goto fail;
inode = grub_be_to_cpu32 (fdrec.dir.dirid);
path = next;
}
if (retdata)
grub_memcpy (retdata, &fdrec.frec, sizeof (fdrec.frec));
if (retinode)
*retinode = inode;
fail:
grub_free (origpath);
return grub_errno;
}
struct grub_hfs_dir_hook_ctx
@@ -1258,14 +1252,16 @@ static grub_err_t
grub_hfs_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
void *hook_data)
{
int inode;
struct grub_hfs_data *data;
struct grub_hfs_filerec frec;
struct grub_hfs_dir_hook_ctx ctx =
{
.hook = hook,
.hook_data = hook_data
};
grub_fshelp_node_t found = NULL;
grub_dl_ref (my_mod);
data = grub_hfs_mount (device->disk);
@@ -1273,13 +1269,18 @@ grub_hfs_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
goto fail;
/* First the directory ID for the directory. */
if (grub_hfs_find_dir (data, path, &found, GRUB_FSHELP_DIR))
if (grub_hfs_find_dir (data, path, &frec, &inode))
goto fail;
grub_hfs_iterate_dir (data, data->cat_root, found->inode, grub_hfs_dir_hook, &ctx);
if (frec.type != GRUB_HFS_FILETYPE_DIR)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
goto fail;
}
grub_hfs_iterate_dir (data, data->cat_root, inode, grub_hfs_dir_hook, &ctx);
fail:
grub_free (found);
grub_free (data);
grub_dl_unref (my_mod);
@@ -1293,35 +1294,35 @@ static grub_err_t
grub_hfs_open (struct grub_file *file, const char *name)
{
struct grub_hfs_data *data;
grub_fshelp_node_t found = NULL;
struct grub_hfs_filerec frec;
grub_dl_ref (my_mod);
data = grub_hfs_mount (file->device->disk);
if (!data)
{
grub_dl_unref (my_mod);
return grub_errno;
}
if (grub_hfs_find_dir (data, name, &found, GRUB_FSHELP_REG))
if (grub_hfs_find_dir (data, name, &frec, 0))
{
grub_free (data);
grub_dl_unref (my_mod);
return grub_errno;
}
grub_memcpy (data->extents, found->fdrec.frec.extents, sizeof (grub_hfs_datarecord_t));
file->size = grub_be_to_cpu32 (found->fdrec.frec.size);
data->size = grub_be_to_cpu32 (found->fdrec.frec.size);
data->fileid = grub_be_to_cpu32 (found->fdrec.frec.fileid);
if (frec.type != GRUB_HFS_FILETYPE_FILE)
{
grub_free (data);
grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
grub_dl_unref (my_mod);
return grub_errno;
}
grub_memcpy (data->extents, frec.extents, sizeof (grub_hfs_datarecord_t));
file->size = grub_be_to_cpu32 (frec.size);
data->size = grub_be_to_cpu32 (frec.size);
data->fileid = grub_be_to_cpu32 (frec.fileid);
file->offset = 0;
file->data = data;
grub_free (found);
return 0;
}

View File

@@ -336,9 +336,6 @@ grub_hfsplus_mount (grub_disk_t disk)
data->case_sensitive = ((magic == GRUB_HFSPLUSX_MAGIC) &&
(header.key_compare == GRUB_HFSPLUSX_BINARYCOMPARE));
if (data->catalog_tree.nodesize < 2)
goto fail;
if (grub_hfsplus_read_file (&data->extoverflow_tree.file, 0, 0,
sizeof (struct grub_hfsplus_btnode),
sizeof (header), (char *) &header) <= 0)
@@ -353,9 +350,6 @@ grub_hfsplus_mount (grub_disk_t disk)
data->extoverflow_tree.root = grub_be_to_cpu32 (header.root);
data->extoverflow_tree.nodesize = grub_be_to_cpu16 (header.nodesize);
if (data->extoverflow_tree.nodesize < 2)
goto fail;
if (grub_hfsplus_read_file (&data->attr_tree.file, 0, 0,
sizeof (struct grub_hfsplus_btnode),
sizeof (header), (char *) &header) <= 0)
@@ -729,10 +723,7 @@ list_nodes (void *record, void *hook_arg)
/* If the name is obviously invalid, skip this node. */
if (catkey->name[i] == 0)
{
grub_free (filename);
return 0;
}
return 0;
}
*grub_utf16_to_utf8 ((grub_uint8_t *) filename, catkey->name,
@@ -754,10 +745,7 @@ list_nodes (void *record, void *hook_arg)
callback function. */
node = grub_malloc (sizeof (*node));
if (!node)
{
grub_free (filename);
return 1;
}
return 1;
node->data = ctx->dir->data;
node->compressed = 0;
node->cbuf = 0;
@@ -792,8 +780,8 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
};
struct grub_hfsplus_key_internal intern;
struct grub_hfsplus_btnode *node = NULL;
grub_disk_addr_t ptr = 0;
struct grub_hfsplus_btnode *node;
grub_disk_addr_t ptr;
{
struct grub_fshelp_node *fsnode;
@@ -976,8 +964,8 @@ grub_hfsplus_label (grub_device_t device, char **label)
struct grub_hfsplus_catkey *catkey;
int i, label_len;
struct grub_hfsplus_key_internal intern;
struct grub_hfsplus_btnode *node = NULL;
grub_disk_addr_t ptr = 0;
struct grub_hfsplus_btnode *node;
grub_disk_addr_t ptr;
*label = 0;

View File

@@ -959,15 +959,14 @@ grub_iso9660_read (grub_file_t file, char *buf, grub_size_t len)
{
struct grub_iso9660_data *data =
(struct grub_iso9660_data *) file->data;
grub_err_t err;
/* XXX: The file is stored in as a single extent. */
data->disk->read_hook = file->read_hook;
data->disk->read_hook_data = file->read_hook_data;
err = read_node (data->node, file->offset, len, buf);
read_node (data->node, file->offset, len, buf);
data->disk->read_hook = NULL;
if (err || grub_errno)
if (grub_errno)
return -1;
return len;

View File

@@ -65,6 +65,7 @@ typedef grub_uint16_t grub_minix_uintn_t;
#define grub_minix_to_cpu_n grub_minix_to_cpu16
#endif
#define GRUB_MINIX_INODE_BLKSZ(data) sizeof (grub_minix_uintn_t)
#ifdef MODE_MINIX3
typedef grub_uint32_t grub_minix_ino_t;
#define grub_minix_to_cpu_ino grub_minix_to_cpu32
@@ -82,6 +83,19 @@ typedef grub_uint16_t grub_minix_ino_t;
#define GRUB_MINIX_INODE_DINDIR_ZONE(data) (grub_minix_to_cpu_n \
(data->inode.double_indir_zone))
#ifndef MODE_MINIX3
#define GRUB_MINIX_LOG2_ZONESZ (GRUB_MINIX_LOG2_BSIZE \
+ grub_minix_to_cpu16 (data->sblock.log2_zone_size))
#endif
#define GRUB_MINIX_ZONESZ ((grub_uint64_t) data->block_size << \
(GRUB_DISK_SECTOR_BITS + grub_minix_to_cpu16 (data->sblock.log2_zone_size)))
#ifdef MODE_MINIX3
#define GRUB_MINIX_ZONE2SECT(zone) ((zone) * data->block_size)
#else
#define GRUB_MINIX_ZONE2SECT(zone) ((zone) << GRUB_MINIX_LOG2_ZONESZ)
#endif
#ifdef MODE_MINIX3
struct grub_minix_sblock
@@ -158,7 +172,6 @@ struct grub_minix_data
{
struct grub_minix_sblock sblock;
struct grub_minix_inode inode;
grub_uint32_t block_per_zone;
grub_minix_ino_t ino;
int linknest;
grub_disk_t disk;
@@ -171,32 +184,15 @@ static grub_dl_t my_mod;
static grub_err_t grub_minix_find_file (struct grub_minix_data *data,
const char *path);
#ifdef MODE_MINIX3
static inline grub_disk_addr_t
grub_minix_zone2sect (struct grub_minix_data *data, grub_minix_uintn_t zone)
{
return ((grub_disk_addr_t) zone) * data->block_size;
}
#else
static inline grub_disk_addr_t
grub_minix_zone2sect (struct grub_minix_data *data, grub_minix_uintn_t zone)
{
int log2_zonesz = (GRUB_MINIX_LOG2_BSIZE
+ grub_minix_to_cpu16 (data->sblock.log2_zone_size));
return (((grub_disk_addr_t) zone) << log2_zonesz);
}
#endif
/* Read the block pointer in ZONE, on the offset NUM. */
static grub_minix_uintn_t
grub_get_indir (struct grub_minix_data *data,
grub_get_indir (struct grub_minix_data *data,
grub_minix_uintn_t zone,
grub_minix_uintn_t num)
{
grub_minix_uintn_t indirn;
grub_disk_read (data->disk,
grub_minix_zone2sect(data, zone),
GRUB_MINIX_ZONE2SECT(zone),
sizeof (grub_minix_uintn_t) * num,
sizeof (grub_minix_uintn_t), (char *) &indirn);
return grub_minix_to_cpu_n (indirn);
@@ -206,6 +202,8 @@ static grub_minix_uintn_t
grub_minix_get_file_block (struct grub_minix_data *data, unsigned int blk)
{
grub_minix_uintn_t indir;
const grub_uint32_t block_per_zone = (GRUB_MINIX_ZONESZ
/ GRUB_MINIX_INODE_BLKSZ (data));
/* Direct block. */
if (blk < GRUB_MINIX_INODE_DIR_BLOCKS)
@@ -213,33 +211,33 @@ grub_minix_get_file_block (struct grub_minix_data *data, unsigned int blk)
/* Indirect block. */
blk -= GRUB_MINIX_INODE_DIR_BLOCKS;
if (blk < data->block_per_zone)
if (blk < block_per_zone)
{
indir = grub_get_indir (data, GRUB_MINIX_INODE_INDIR_ZONE (data), blk);
return indir;
}
/* Double indirect block. */
blk -= data->block_per_zone;
if (blk < (grub_uint64_t) data->block_per_zone * (grub_uint64_t) data->block_per_zone)
blk -= block_per_zone;
if (blk < block_per_zone * block_per_zone)
{
indir = grub_get_indir (data, GRUB_MINIX_INODE_DINDIR_ZONE (data),
blk / data->block_per_zone);
blk / block_per_zone);
indir = grub_get_indir (data, indir, blk % data->block_per_zone);
indir = grub_get_indir (data, indir, blk % block_per_zone);
return indir;
}
#if defined (MODE_MINIX3) || defined (MODE_MINIX2)
blk -= data->block_per_zone * data->block_per_zone;
if (blk < ((grub_uint64_t) data->block_per_zone * (grub_uint64_t) data->block_per_zone
* (grub_uint64_t) data->block_per_zone))
blk -= block_per_zone * block_per_zone;
if (blk < ((grub_uint64_t) block_per_zone * (grub_uint64_t) block_per_zone
* (grub_uint64_t) block_per_zone))
{
indir = grub_get_indir (data, grub_minix_to_cpu_n (data->inode.triple_indir_zone),
(blk / data->block_per_zone) / data->block_per_zone);
indir = grub_get_indir (data, indir, (blk / data->block_per_zone) % data->block_per_zone);
indir = grub_get_indir (data, indir, blk % data->block_per_zone);
(blk / block_per_zone) / block_per_zone);
indir = grub_get_indir (data, indir, (blk / block_per_zone) % block_per_zone);
indir = grub_get_indir (data, indir, blk % block_per_zone);
return indir;
}
@@ -264,13 +262,6 @@ grub_minix_read_file (struct grub_minix_data *data,
grub_uint32_t posblock;
grub_uint32_t blockoff;
if (pos > GRUB_MINIX_INODE_SIZE (data))
{
grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("attempt to read past the end of file"));
return -1;
}
/* Adjust len so it we can't read past the end of the file. */
if (len + pos > GRUB_MINIX_INODE_SIZE (data))
len = GRUB_MINIX_INODE_SIZE (data) - pos;
@@ -287,7 +278,7 @@ grub_minix_read_file (struct grub_minix_data *data,
for (i = posblock; i < blockcnt; i++)
{
grub_minix_uintn_t blknr;
grub_disk_addr_t blknr;
grub_uint64_t blockend = data->block_size << GRUB_DISK_SECTOR_BITS;
grub_off_t skipfirst = 0;
@@ -316,7 +307,7 @@ grub_minix_read_file (struct grub_minix_data *data,
data->disk->read_hook = read_hook;
data->disk->read_hook_data = read_hook_data;
grub_disk_read (data->disk,
grub_minix_zone2sect(data, blknr),
GRUB_MINIX_ZONE2SECT(blknr),
skipfirst, blockend, buf);
data->disk->read_hook = 0;
if (grub_errno)
@@ -342,8 +333,7 @@ grub_minix_read_inode (struct grub_minix_data *data, grub_minix_ino_t ino)
/* The first inode in minix is inode 1. */
ino--;
block = grub_minix_zone2sect (data,
2 + grub_minix_to_cpu16 (sblock->inode_bmap_size)
block = GRUB_MINIX_ZONE2SECT (2 + grub_minix_to_cpu16 (sblock->inode_bmap_size)
+ grub_minix_to_cpu16 (sblock->zone_bmap_size));
block += ino / (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix_inode));
int offs = (ino % (GRUB_DISK_SECTOR_SIZE
@@ -518,12 +508,6 @@ grub_minix_mount (grub_disk_t disk)
data->block_size = 2;
#endif
data->block_per_zone = (((grub_uint64_t) data->block_size << \
(GRUB_DISK_SECTOR_BITS + grub_minix_to_cpu16 (data->sblock.log2_zone_size)))
/ sizeof (grub_minix_uintn_t));
if (!data->block_per_zone)
goto fail;
return data;
fail:

View File

@@ -724,10 +724,6 @@ grub_nilfs2_valid_sb (struct grub_nilfs2_super_block *sbp)
if (grub_le_to_cpu32 (sbp->s_rev_level) != NILFS_SUPORT_REV)
return 0;
/* 20 already means 1GiB blocks. We don't want to deal with blocks overflowing int32. */
if (grub_le_to_cpu32 (sbp->s_log_block_size) > 20)
return 0;
return 1;
}

View File

@@ -618,10 +618,7 @@ list_file (struct grub_ntfs_file *diro, grub_uint8_t *pos,
ustr = get_utf8 (np, ns);
if (ustr == NULL)
{
grub_free (fdiro);
return 0;
}
return 0;
if (namespace)
type |= GRUB_FSHELP_CASE_INSENSITIVE;
@@ -920,16 +917,12 @@ grub_ntfs_mount (grub_disk_t disk)
if (bpb.clusters_per_mft > 0)
data->mft_size = ((grub_disk_addr_t) bpb.clusters_per_mft) << data->log_spc;
else if (-bpb.clusters_per_mft < GRUB_NTFS_BLK_SHR || -bpb.clusters_per_mft >= 31)
goto fail;
else
data->mft_size = 1ULL << (-bpb.clusters_per_mft - GRUB_NTFS_BLK_SHR);
if (bpb.clusters_per_index > 0)
data->idx_size = (((grub_disk_addr_t) bpb.clusters_per_index)
<< data->log_spc);
else if (-bpb.clusters_per_index < GRUB_NTFS_BLK_SHR || -bpb.clusters_per_index >= 31)
goto fail;
else
data->idx_size = 1ULL << (-bpb.clusters_per_index - GRUB_NTFS_BLK_SHR);

Some files were not shown because too many files have changed in this diff Show More