merge trunk
This commit is contained in:
commit
92882f28b6
101 changed files with 6425 additions and 580 deletions
|
@ -131,5 +131,6 @@ grub-core/gnulib/unistd.h
|
|||
grub-core/gnulib/warn-on-use.h
|
||||
grub-core/gnulib/wchar.h
|
||||
grub-core/gnulib/wctype.h
|
||||
grub-core/rs_decoder.S
|
||||
widthspec.bin
|
||||
widthspec.h
|
||||
|
|
647
ChangeLog
647
ChangeLog
|
@ -1,3 +1,650 @@
|
|||
2011-01-04 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/disk/i386/pc/biosdisk.c (GRUB_MOD_INIT): Workaround buggy
|
||||
BIOSes.
|
||||
|
||||
2011-01-04 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/lib/reed_solomon.c (grub_reed_solomon_add_redundancy):
|
||||
Prevent overflow.
|
||||
(grub_reed_solomon_recover): Likewise.
|
||||
|
||||
2011-01-04 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/lib/reed_solomon.c (main) [TEST]: Reactivate normal test.
|
||||
|
||||
2011-01-04 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/lib/reed_solomon.c (scratch) [! STANDALONE]: Remove leftover
|
||||
variable.
|
||||
|
||||
2011-01-04 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* grub-core/commands/legacycfg.c (GRUB_MOD_INIT): Fix typo in
|
||||
descriptions of extract_legacy_entries_source and
|
||||
extract_legacy_entries_configfile.
|
||||
Reported by: Seung Soo, Ha.
|
||||
|
||||
2011-01-03 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* grub-core/bus/pci.c (grub_pci_iterate): Skip remaining functions
|
||||
on devices that do not implement function 0.
|
||||
|
||||
2011-01-03 Dave Vasilevsky <dave@vasilevsky.ca>
|
||||
|
||||
* grub-core/fs/hfsplus.c: Make parent unsigned.
|
||||
(grub_hfsplus_cmp_catkey): Don't compare using subtraction, it
|
||||
overflows.
|
||||
(grub_hfsplus_cmp_extkey): Likewise
|
||||
|
||||
2011-01-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub-install.in: Correctly use bootloader_id and not
|
||||
GRUB_DISTRIBUTOR on efibootmgr line.
|
||||
|
||||
2011-01-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub-mkfont.c (main): Report errors in FT_New_Face.
|
||||
|
||||
2010-12-31 Ian Campbell <ijc@hellion.org.uk>
|
||||
|
||||
* util/grub.d/20_linux_xen.in (linux_entry): Correctly capitalize
|
||||
Xen and reorder menu item wording to make it clearer that this entry
|
||||
will launch Xen. Print separate messages when loading Xen and
|
||||
Linux.
|
||||
|
||||
2010-12-31 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/partmap/amiga.c (GRUB_AMIGA_PART_MAGIC): New define.
|
||||
(amiga_partition_map_iterate): Check "PART" magic to avoid a very long
|
||||
loop in case of incorrect amiga partmap.
|
||||
|
||||
2010-12-31 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/partmap/amiga.c (GRUB_AMIGA_RDSK_MAGIC): New define.
|
||||
(amiga_partition_map_iterate): Use grub_memcmp instead of grub_strcmp.
|
||||
Reported by:EHeM.
|
||||
|
||||
2010-12-31 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/loader/i386/bsdXX.c (grub_openbsd_find_ramdisk): Silence
|
||||
spurious warning.
|
||||
Reported by: crocket
|
||||
|
||||
2010-12-27 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/loader/xnu.c (grub_cmd_xnu_kernel) [! GRUB_MACHINE_EFI]:
|
||||
Preload EFIemu.
|
||||
(grub_cmd_xnu_kernel64) [! GRUB_MACHINE_EFI]: Likewise.
|
||||
|
||||
2010-12-27 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/loader/xnu.c (grub_cmd_xnu_kext): Abort if no kernel
|
||||
is loaded
|
||||
(grub_cmd_xnu_kextdir): Likewise.
|
||||
(grub_cmd_xnu_splash): Likewise.
|
||||
|
||||
2010-12-27 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Avoid using Reed-Solomon with 0 redundancy.
|
||||
|
||||
* grub-core/kern/i386/pc/startup.S: Remove 0-data check.
|
||||
* grub-core/lib/reed_solomon.c (decode_block): Do not proceed on 0 data
|
||||
or 0 redundancy.
|
||||
(grub_reed_solomon_add_redundancy): Do not proceed with 0 redundancy.
|
||||
(grub_reed_solomon_recover): Likewise.
|
||||
|
||||
2010-12-27 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Don't use disk subsystem in freebsd_boot.
|
||||
|
||||
* grub-core/loader/i386/bsd.c (freebsd_bootdev): New variable.
|
||||
(freebsd_biosdev): Likewise.
|
||||
(grub_freebsd_boot): Use freebsd_bootdev and freebsd_biosdev.
|
||||
(grub_cmd_freebsd): Set freebsd_bootdev and freebsd_biosdev.
|
||||
|
||||
2010-12-26 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Handling of files of unknown size is currently limited. They can't be
|
||||
used e.g. for initrd or modules. Moreover gzip handling of not
|
||||
easily seekable files is buggy. Disable unknown file size for now. May
|
||||
be inefficient but works.
|
||||
|
||||
* grub-core/io/gzio.c (test_header): Always retrieve the file size.
|
||||
* grub-core/io/xzio.c (grub_xzio_open): Likewise.
|
||||
|
||||
2010-12-25 Mirko Parthey <mirko.parthey@informatik.tu-chemnitz.de>
|
||||
|
||||
* grub-core/boot/i386/pc/boot.S: Fix %es:%bx pointing to nowhere on
|
||||
floppy probe.
|
||||
|
||||
2010-12-25 Jeroen Dekkers <jeroen@dekkers.ch>
|
||||
|
||||
* grub-core/disk/raid.c (insert_array): Don't add spurious members.
|
||||
|
||||
2010-12-25 Shea Levy <shlevy>
|
||||
|
||||
* grub-core/genmod.sh.in: Use @OBJCOPY@ rather than objcopy.
|
||||
|
||||
2010-12-25 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub.d/30_os-prober.in: Don't emit drivemap directive for
|
||||
Windows Server 2008.
|
||||
Reported by: Devin Giddings.
|
||||
|
||||
2010-12-25 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/commands/acpihalt.c (grub_acpi_halt): Sleep for 1.5 before
|
||||
writing an error message because of async power management.
|
||||
* grub-core/kern/mips/yeeloong/init.c (grub_halt): Likewise.
|
||||
(grub_reboot): Likewise.
|
||||
|
||||
2010-12-23 Jordan Uggla <jordan.uggla@gmail.com>
|
||||
|
||||
* tests/util/grub-shell.in: Suppress "ACPI shutdown failed" error to
|
||||
keep unit tests from failing when they shouldn't.
|
||||
|
||||
2010-12-21 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* include/grub/offsets.h (GRUB_KERNEL_I386_PC_RAW_SIZE): The
|
||||
previous patch increased the size of the RS code by 20 bytes (at
|
||||
least with gcc-4.4), so increase this by 20 bytes to match.
|
||||
(GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART): Likewise.
|
||||
|
||||
2010-12-21 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* grub-core/lib/reed_solomon.c (gauss_solve): Fix size of standalone
|
||||
scratch area. Make sure to initialise chosen in standalone mode as
|
||||
well as non-standalone.
|
||||
Reported by: Robert Hooker and Andy Whitcroft.
|
||||
Tested by: Andy Whitcroft.
|
||||
|
||||
2010-12-21 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* grub-core/commands/echo.c (grub_cmd_echo): Make UTF-8-clean by
|
||||
constructing a new unescaped string and passing it to grub_xputs in
|
||||
one go, rather than passing characters to grub_printf one at a time.
|
||||
|
||||
2010-12-21 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* grub-core/fs/udf.c (read_string): Pacify GCC warning by
|
||||
initialising utf16.
|
||||
|
||||
2010-12-21 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub-mkconfig_lib.in (gettext_quoted): Add clarifying
|
||||
comment. Add an extra layer of quotation, requiring the output of
|
||||
this function to be used in a printf format string.
|
||||
(gettext_printf): New function.
|
||||
* util/grub.d/10_hurd.in: Use gettext_printf where appropriate.
|
||||
Extract translatable strings from here-documents and use a temporary
|
||||
variable instead, so that xgettext can find them.
|
||||
* util/grub.d/10_kfreebsd.in: Likewise.
|
||||
* util/grub.d/10_linux.in: Likewise.
|
||||
* util/grub.d/20_linux_xen.in: Likewise.
|
||||
|
||||
* po/grub.d.sed: New file.
|
||||
* po/Makefile.in.in ($(DOMAIN).pot-update): Extract gettext_printf
|
||||
arguments. Set c-format flags on all strings extracted from
|
||||
util/grub.d/ (xgettext refuses to include these itself for strings
|
||||
it extracted from a shell file, but these really are c-format).
|
||||
|
||||
2010-12-20 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_add_module):
|
||||
Avoid next pointing to nowhere.
|
||||
|
||||
2010-12-19 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/fs/affs.c (grub_affs_mount): Read data->bblock.rootblock
|
||||
rather than assuming than rootblock is exactly in the middle.
|
||||
(grub_affs_label): Likewise.
|
||||
|
||||
2010-12-19 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/fs/affs.c (grub_affs_fs) [GRUB_UTIL]: Explicitly set
|
||||
reserved_first_sector to 0.
|
||||
* grub-core/fs/cpio.c (grub_cpio_fs) [GRUB_UTIL]: Likewise.
|
||||
* grub-core/fs/sfs.c (grub_sfs_fs) [GRUB_UTIL]: Likewise.
|
||||
* grub-core/fs/xfs.c (grub_xfs_fs) [GRUB_UTIL]: Likewise.
|
||||
|
||||
2010-12-19 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Fix handling of UTF-16 UDF labels.
|
||||
|
||||
* grub-core/fs/udf.c (grub_udf_iterate_dir): Move string-parsing part
|
||||
(read_string): .. here.
|
||||
(grub_udf_label): Use read_string.
|
||||
|
||||
2010-12-19 BVK Chaitanya <bvk.groups@gmail.com>
|
||||
|
||||
* grub-core/normal/menu_entry.c (run): Execute commands from menu
|
||||
editor under argument scope.
|
||||
Reported by: Jordan Uggla
|
||||
|
||||
2010-12-18 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub-mkfont.c (main): Handle errors from FT_Set_Pixel_Sizes.
|
||||
|
||||
2010-12-18 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* grub-core/normal/term.c (print_more): Make \r or \n scroll one
|
||||
line, and other keys scroll an entire page (previous handling was
|
||||
for \r and \n to scroll a page and other keys to scroll two lines).
|
||||
|
||||
2010-12-18 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi):
|
||||
Set ptrdest to correct get_physical_target_address rather than
|
||||
incorrect get_virtual_current_address.
|
||||
|
||||
2010-12-18 kashyap garimella <garimella.kashyap@gmail.com>
|
||||
|
||||
* grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_load): Use
|
||||
correct cat to grub_uint8_t * rather than grub_uint32_t *.
|
||||
|
||||
2010-12-10 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* .bzrignore: Ignore grub-core/rs_decoder.S.
|
||||
|
||||
2010-12-10 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* grub-core/gettext/gettext.c (grub_gettext_init_ext): Factor out
|
||||
.mo/.mo.gz opening sequence to ...
|
||||
(grub_mofile_open_lang): ... here.
|
||||
(grub_gettext_init_ext): If opening ll_CC fails, try ll.
|
||||
* util/grub.d/00_header.in (grub_lang): Include country part of
|
||||
locale.
|
||||
Reported by: Mario Limonciello.
|
||||
|
||||
2010-12-09 Robert Millan <rmh@gnu.org>
|
||||
|
||||
* NEWS: Document addition of ZFS support.
|
||||
|
||||
2010-12-04 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* grub-core/kern/i386/pc/startup.S (grub_console_getkey): Use `>> 1'
|
||||
rather than `/ 2', as the latter requires -Wa,--divide which would
|
||||
require bumping our minimum binutils version.
|
||||
|
||||
2010-12-03 BVK Chaitanya <bvk.groups@gmail.com>
|
||||
|
||||
* util/grub-script-check.c (main): Print script line number on
|
||||
error.
|
||||
|
||||
2010-12-01 Robert Millan <rmh@gnu.org>
|
||||
|
||||
* grub-core/fs/zfs/zfs.c: New file.
|
||||
* grub-core/fs/zfs/zfs_fletcher.c: Likewise.
|
||||
* grub-core/fs/zfs/zfs_lzjb.c: Likewise.
|
||||
* grub-core/fs/zfs/zfs_sha256.c: Likewise.
|
||||
* grub-core/fs/zfs/zfsinfo.c: Likewise.
|
||||
|
||||
* include/grub/zfs/dmu.h: Likewise.
|
||||
* include/grub/zfs/dmu_objset.h: Likewise.
|
||||
* include/grub/zfs/dnode.h: Likewise.
|
||||
* include/grub/zfs/dsl_dataset.h: Likewise.
|
||||
* include/grub/zfs/dsl_dir.h: Likewise.
|
||||
* include/grub/zfs/sa_impl.h: Likewise.
|
||||
* include/grub/zfs/spa.h: Likewise.
|
||||
* include/grub/zfs/uberblock_impl.h: Likewise.
|
||||
* include/grub/zfs/vdev_impl.h: Likewise.
|
||||
* include/grub/zfs/zap_impl.h: Likewise.
|
||||
* include/grub/zfs/zap_leaf.h: Likewise.
|
||||
* include/grub/zfs/zfs.h: Likewise.
|
||||
* include/grub/zfs/zfs_acl.h: Likewise.
|
||||
* include/grub/zfs/zfs_znode.h: Likewise.
|
||||
* include/grub/zfs/zil.h: Likewise.
|
||||
* include/grub/zfs/zio.h: Likewise.
|
||||
* include/grub/zfs/zio_checksum.h: Likewise.
|
||||
|
||||
* Makefile.util.def: Build ZFS into libgrubmods.
|
||||
* grub-core/Makefile.core.def: Build zfs.mod.
|
||||
|
||||
2010-11-30 Szymon Janc <szymon@janc.net.pl>
|
||||
|
||||
* grub-core/commands/regexp.c (grub_cmd_regexp): Remove unused
|
||||
variable.
|
||||
* grub-core/commands/wildcard.c (match_files): Likewise.
|
||||
|
||||
2010-11-30 Robert Millan <rmh@gnu.org>
|
||||
|
||||
* grub-core/loader/i386/bsd.c
|
||||
(grub_cmd_freebsd_loadenv, grub_cmd_freebsd_module_elf): Check
|
||||
whether kernel is loaded using grub_loader_is_loaded(), rather
|
||||
than `kernel_type', which may still be `KERNEL_TYPE_NONE' under
|
||||
certain error conditions.
|
||||
|
||||
2010-11-30 Robert Millan <rmh@gnu.org>
|
||||
|
||||
* grub-core/commands/echo.c: Include `<grub/term.h>'.
|
||||
(grub_cmd_echo): Call grub_refresh() after printing a message.
|
||||
|
||||
2010-11-26 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Avoid using tricks for initialising endian variables.
|
||||
|
||||
* grub-core/partmap/gpt.c (grub_gpt_partition_type_bios_boot):
|
||||
Make const.
|
||||
(GRUB_MOD_INIT): Don't byte-swap.
|
||||
* include/grub/gpt_partition.h (GRUB_GPT_PARTITION_TYPE_BIOS_BOOT):
|
||||
Use grub_cpu_to_le16_compile_time and grub_cpu_to_le32_compile_time.
|
||||
* include/grub/types.h (grub_swap_bytes16_compile_time): New macro.
|
||||
(grub_swap_bytes32_compile_time): Likewise.
|
||||
(grub_cpu_to_le32_compile_time): Likewise.
|
||||
(grub_cpu_to_le16_compile_time): Likewise.
|
||||
|
||||
2010-11-26 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub-setup.c (setup): Stop recommending --force. People who
|
||||
understand the dangers of blocklists are able to find this option
|
||||
anyway and the ones who don't shouldn't use it anyway.
|
||||
|
||||
2010-11-26 Robert Millan <rmh@gnu.org>
|
||||
|
||||
* grub-core/term/i386/pc/vga_text.c (VGA_TEXT_SCREEN): Beautify.
|
||||
Update all users.
|
||||
|
||||
2010-11-26 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
Fix LVM-on-RAID probing.
|
||||
|
||||
* util/grub-probe.c (probe): Remember which disk was detected as
|
||||
RAID (perhaps an LVM physical volume). Use that disk's raidname
|
||||
rather than that of the top-level disk.
|
||||
|
||||
2010-11-25 BVK Chaitanya <bvk.groups@gmail.com>
|
||||
|
||||
Fix cmdline argument quotes for setparams command of menuentry
|
||||
definitions.
|
||||
|
||||
* grub-core/commands/menuentry.c (setparams_prefix): Use single
|
||||
quotes for arguments.
|
||||
* grub-core/lib/legacy_parse.c (grub_legacy_escape): Use
|
||||
grub_strchrsub function instead.
|
||||
|
||||
* include/grub/misc.h (grub_strchrsub): New function.
|
||||
|
||||
2010-11-24 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/deviceiter.c (grub_util_iterate_devices): Save a bit of
|
||||
effort by skipping "." and ".." entries up-front.
|
||||
Suggested by: Michael Lazarev.
|
||||
|
||||
2010-11-24 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* grub-core/Makefile.core.def (xz_decompress): Move -lgcc from
|
||||
ldflags to ldadd, to fix link line ordering.
|
||||
(none_decompress): Likewise.
|
||||
|
||||
2010-11-24 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* grub-core/Makefile.core.def (kernel): Add kern/emu/cache.S for emu
|
||||
platforms.
|
||||
(grub-emu-lite): Remove kern/emu/cache.S.
|
||||
|
||||
2010-11-23 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/deviceiter.c (compare_devices): If the by-id link for a
|
||||
device couldn't be resolved, fall back to sorting by the by-id link
|
||||
rather than segfaulting.
|
||||
Reported and tested by: Daniel Mierswa.
|
||||
|
||||
2010-11-23 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* Makefile.util.def (grub-menulst2cfg): List libraries in ldadd, not
|
||||
ldflags, to fix link line ordering.
|
||||
|
||||
2010-11-23 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* grub-core/Makefile.am (gentrigtables): Put -lm after $<; some
|
||||
linkers are picky about this.
|
||||
|
||||
2010-11-23 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* grub-core/Makefile.am (command.lst): Adjust sed expression
|
||||
ordering so that extended and priority commands aren't treated as
|
||||
ordinary commands.
|
||||
|
||||
2010-11-23 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* include/grub/gpt_partition.h (GRUB_GPT_PARTITION_TYPE_BIOS_BOOT):
|
||||
Remove byte-swapping function calls, which are not valid in
|
||||
structure initialisers.
|
||||
* grub-core/partmap/gpt.c (grub_gpt_partition_type_bios_boot): Make
|
||||
non-const.
|
||||
(GRUB_MOD_INIT): Byte-swap data1, data2, and data3 fields of
|
||||
grub_gpt_partition_type_bios_boot.
|
||||
|
||||
2010-11-22 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
Fix test program build on GNU/kFreeBSD.
|
||||
|
||||
* Makefile.util.def (example_unit_test): Add `$(LIBZFS)
|
||||
$(LIBNVPAIR)' library dependencies.
|
||||
|
||||
2010-11-22 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub-install.in: Fix parsing of --grub-mkrelpath= option.
|
||||
|
||||
2010-11-22 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* util/grub-install.in: Remove excessive quoting that broke
|
||||
installations to RAID devices.
|
||||
|
||||
2010-11-19 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/loader/i386/linux.c (grub_cmd_linux): Pass correctly the
|
||||
bootloader version instead of 0.
|
||||
|
||||
2010-11-19 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Fix spurious
|
||||
warning.
|
||||
|
||||
2010-11-19 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/disk/mdraid1x_linux.c (grub_mdraid_detect): Don't try to
|
||||
retrieve the metadat sector if size isn't known.
|
||||
* grub-core/disk/mdraid_linux.c (grub_mdraid_detect): Likewise.
|
||||
|
||||
2010-11-18 Robert Millan <rmh@gnu.org>
|
||||
|
||||
* grub-core/fs/btrfs.c (grub_btrfs_mount): Replace grub_strncmp()
|
||||
with grub_memcmp().
|
||||
|
||||
2010-11-18 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/normal/menu_entry.c (print_up): Fix displacement of up
|
||||
arrow.
|
||||
Reported by: Jordan Uggla.
|
||||
|
||||
2010-11-16 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Make better UTF compliant.
|
||||
|
||||
* grub-core/normal/charset.c (grub_utf8_to_utf16): Handle 6- and 7-byte
|
||||
sequences as incorrect.
|
||||
(grub_is_valid_utf8): Likewise.
|
||||
(grub_utf8_to_ucs4): Likewise.
|
||||
(grub_ucs4_to_utf8): Handle codepoints outside of BMP.
|
||||
(grub_ucs4_to_utf8_alloc): Likewise.
|
||||
* include/grub/charset.h (grub_utf16_to_utf8): Likewise.
|
||||
|
||||
2010-11-16 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Make legacy_source behave like source.
|
||||
|
||||
* grub-core/commands/legacycfg.c (legacy_file): Don't call
|
||||
grub_show_menu.
|
||||
(grub_cmd_legacy_source): Call grub_show_menu if needed.
|
||||
|
||||
2010-11-16 Colin Watson <cjwatson@debian.org>
|
||||
|
||||
* conf/Makefile.common (CFLAGS_GNULIB): Add -Wno-unused-parameter.
|
||||
(-Wunused implies -Wunused-parameter, but not vice versa).
|
||||
|
||||
2010-11-16 Colin Watson <cjwatson@ubuntu.com>
|
||||
|
||||
* configure.ac: Make error messages less confusing by testing for
|
||||
-Wtrampolines rather than -Wno-trampolines (since -Wno-* is always
|
||||
accepted, but produces a diagnostic if something else is wrong).
|
||||
|
||||
2010-11-15 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/term/at_keyboard.c (grub_keyboard_controller_read)
|
||||
[GRUB_MACHINE_MIPS_YEELOONG || GRUB_MACHINE_QEMU]: ifdef-ed out
|
||||
(now unused).
|
||||
(grub_keyboard_controller_init)
|
||||
[GRUB_MACHINE_MIPS_YEELOONG || GRUB_MACHINE_QEMU]: Don't attempt to
|
||||
read the initial state since controller isn't inited yet.
|
||||
|
||||
2010-11-15 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/lib/relocator.c (malloc_in_range): Take into account that
|
||||
allocate_regbeg may need to create new chunk header.
|
||||
|
||||
2010-11-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Fix quoting in legacy parser.
|
||||
|
||||
* grub-core/lib/legacy_parse.c (grub_legacy_escape): Correctly handle
|
||||
single quotes.
|
||||
(grub_legacy_parse): Likewise.
|
||||
Reported by: Jordan Uggla.
|
||||
Tested by: Jordan Uggla.
|
||||
|
||||
2010-11-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Don't add -lgcc on i386 and x86_64.
|
||||
|
||||
* configure.ac (LIBS): Don't add -lgcc on i386 and x86_64.
|
||||
* conf/Makefile.common (LDADD_KERNEL): Likewise.
|
||||
* grub-core/Makefile.core.def (kernel): Use LDADD_KERNEL.
|
||||
|
||||
2010-11-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* configure.ac: Add -Wno-trampolines when supported.
|
||||
|
||||
2010-11-14 Modestas Vainius <modax@debian.org>
|
||||
|
||||
* grub-core/kern/emu/getroot.c (grub_util_is_dmraid): Recognise ddf1_
|
||||
fakeraid.
|
||||
|
||||
2010-11-14 Giuseppe Caizzone <acaizzo@gmail.com>
|
||||
|
||||
Add generic logical block size support for UDF.
|
||||
|
||||
* grub-core/fs/udf.c (GRUB_UDF_LOG2_BLKSIZE): Removed.
|
||||
(GRUB_UDF_BLKSZ): Removed.
|
||||
(struct grub_udf_data): New field "lbshift" to hold the logical block
|
||||
size of the file system in log2 format. All users updated.
|
||||
(sblocklist): Change type to unsigned.
|
||||
(grub_udf_mount): Change type of "sblklist" to unsigned.
|
||||
Move AVDP search before VRS recognition, because the latter requires
|
||||
knowledge of the logical block size, which is detected during the
|
||||
former.
|
||||
Detect and validate logical block size during AVDP search, adding
|
||||
support for block sizes 512, 1024 and 4096.
|
||||
Make VRS recognition independent of block size.
|
||||
|
||||
2010-11-14 Giuseppe Caizzone <acaizzo@gmail.com>
|
||||
|
||||
Properly handle deleted files on UDF.
|
||||
|
||||
* grub-core/fs/udf.c (grub_udf_iterate_dir): Skip directory entries
|
||||
whose "characteristics" field has the bit GRUB_UDF_FID_CHAR_DELETED
|
||||
set.
|
||||
|
||||
2010-11-14 Giuseppe Caizzone <acaizzo@gmail.com>
|
||||
|
||||
Support reading files larger than 2 GiB.
|
||||
|
||||
* grub-core/fs/udf.c (grub_udf_iterate_dir): Change type of variable
|
||||
"offset" to grub_off_t.
|
||||
(grub_udf_read_file): Likewise for parameter "pos".
|
||||
|
||||
2010-11-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* docs/grub.texi (Changes from GRUB Legacy): Note when save_env is
|
||||
unavailable.
|
||||
(Simple configuration): Refer to Changes from GRUB Legacy about
|
||||
save_env availability.
|
||||
|
||||
2010-11-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub-install.in: Ignore empty partition table detection
|
||||
instead of trying to include part_ module.
|
||||
|
||||
2010-11-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/disk/lvm.c (GRUB_MOD_FINI): Reset the vg_list. Fixes
|
||||
LVM on RAID support.
|
||||
|
||||
2010-11-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Properly define WORDS_BIGENDIAN in wrapped environments.
|
||||
|
||||
* grub-core/lib/libgcrypt_wrap/cipher_wrap.h (WORDS_BIGENDIAN): New
|
||||
definition.
|
||||
* grub-core/lib/posix_wrap/sys/types.h (WORDS_BIGENDIAN): Likewise.
|
||||
|
||||
Reported by: Manoel Rebelo Abranches.
|
||||
Tested by: Manoel Rebelo Abranches.
|
||||
|
||||
2010-11-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub-mkconfig.in: Fix quoting.
|
||||
|
||||
2010-11-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Support big ext2 files.
|
||||
|
||||
* grub-core/fs/ext2.c (grub_ext2_inode): Rename dir_acl to size_high.
|
||||
(grub_ext2_read_block): Support triple indirect blocks.
|
||||
(grub_ext2_read_file): Use 64-bit types and read size_high.
|
||||
(grub_ext2_open): Read size_high.
|
||||
Reported by: Ximin Luo.
|
||||
Tested by: Manoel Rebelo Abranches.
|
||||
|
||||
2010-11-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub-install.in: Handle filenames containing spaces.
|
||||
Reported by: Jordan Uggla.
|
||||
Tested by: Jordan Uggla.
|
||||
|
||||
2010-11-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* util/grub-mkconfig.in (grub_script_check): New variable.
|
||||
Use grub_script_check instead of grub-script-check.
|
||||
Reported by: Barry Jackson.
|
||||
|
||||
2010-11-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* docs/grub.texi (menu): Correct the order.
|
||||
Reported by: D. Hugh Redelmeier.
|
||||
|
||||
2010-11-12 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/i386/pc/startup.S (multiboot_trampoline): Add missing
|
||||
jump.
|
||||
|
||||
2010-11-08 Manoel Rebelo Abranches <mrabran@br.ibm.com>
|
||||
|
||||
* include/grub/elfload.h (grub_elf32_size): New parameter.
|
||||
All users updated.
|
||||
Return maximum segments alignment.
|
||||
(grub_elf64_size): Likewise.
|
||||
* kern/elf.c (grub_elf32_size): New parameter. All users updated.
|
||||
Return maximum segments alignment.
|
||||
(grub_elf64_size): Likewise.
|
||||
* grub-core/loader/powerpc/ieee1275/linux.c:
|
||||
(grub_linux_claimmap_iterate): New function. Uses the
|
||||
"available" property in the "memory" node for memory allocation
|
||||
for kernel in the PowerPC loader.
|
||||
(grub_linux_load32): Correctly find linux entry point offset.
|
||||
(grub_linux_load64): Likewise.
|
||||
|
||||
2010-11-07 Robert Millan <rmh@gnu.org>
|
||||
|
||||
On mips-yeeloong, build with -march=loongson2f when this flag is
|
||||
|
|
|
@ -70,6 +70,10 @@ library = {
|
|||
common = grub-core/fs/ufs2.c;
|
||||
common = grub-core/fs/ufs.c;
|
||||
common = grub-core/fs/xfs.c;
|
||||
common = grub-core/fs/zfs/zfs.c;
|
||||
common = grub-core/fs/zfs/zfs_lzjb.c;
|
||||
common = grub-core/fs/zfs/zfs_sha256.c;
|
||||
common = grub-core/fs/zfs/zfs_fletcher.c;
|
||||
common = grub-core/lib/arg.c;
|
||||
common = grub-core/lib/crypto.c;
|
||||
common = grub-core/lib/envblk.c;
|
||||
|
@ -607,7 +611,7 @@ program = {
|
|||
ldadd = libgrubmods.a;
|
||||
ldadd = libgrubkern.a;
|
||||
ldadd = grub-core/gnulib/libgnu.a;
|
||||
ldadd = '$(LIBDEVMAPPER)';
|
||||
ldadd = '$(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)';
|
||||
};
|
||||
|
||||
program = {
|
||||
|
@ -620,5 +624,5 @@ program = {
|
|||
ldadd = libgrubmods.a;
|
||||
ldadd = libgrubkern.a;
|
||||
ldadd = grub-core/gnulib/libgnu.a;
|
||||
ldflags = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)';
|
||||
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR)';
|
||||
};
|
||||
|
|
4
NEWS
4
NEWS
|
@ -51,9 +51,7 @@ New in 1.99:
|
|||
|
||||
* Add `sendkey' command (i386-pc only).
|
||||
|
||||
* ZFS support in `grub-install' and `grub-mkconfig'. Note: complete
|
||||
functionality requires external ZFS implementation (available from
|
||||
grub-extras).
|
||||
* ZFS support.
|
||||
|
||||
* Support 1.x versions of mdadm metadata.
|
||||
|
||||
|
|
|
@ -45,7 +45,24 @@ CPPFLAGS_DEFAULT += -I$(top_srcdir)/include
|
|||
CPPFLAGS_DEFAULT += -I$(top_builddir)/include
|
||||
CCASFLAGS_DEFAULT = -DASM_FILE=1
|
||||
|
||||
LDADD_KERNEL = -lgcc
|
||||
LDADD_KERNEL =
|
||||
|
||||
if ! COND_i386_pc
|
||||
if ! COND_i386_efi
|
||||
if ! COND_i386_qemu
|
||||
if ! COND_i386_coreboot
|
||||
if ! COND_i386_multiboot
|
||||
if ! COND_i386_ieee1275
|
||||
if ! COND_x86_64_efi
|
||||
LDADD_KERNEL += -lgcc
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding
|
||||
LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib -Wl,-N -static-libgcc
|
||||
CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
|
||||
|
@ -80,7 +97,7 @@ platformdir = $(pkglibrootdir)/$(target_cpu)-$(platform)
|
|||
CFLAGS_GCRY = -Wno-error -Wno-missing-field-initializers
|
||||
CPPFLAGS_GCRY = -I$(top_srcdir)/grub-core/lib/libgcrypt_wrap
|
||||
|
||||
CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused
|
||||
CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter
|
||||
CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/gnulib -I$(top_srcdir)/grub-core/gnulib
|
||||
|
||||
CFLAGS_POSIX = -fno-builtin
|
||||
|
|
22
configure.ac
22
configure.ac
|
@ -579,8 +579,11 @@ else
|
|||
CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
|
||||
fi
|
||||
CPPFLAGS="$TARGET_CPPFLAGS"
|
||||
LDFLAGS="$TARGET_LDFLAGS"
|
||||
if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 ; then
|
||||
LIBS=
|
||||
else
|
||||
LIBS=-lgcc
|
||||
fi
|
||||
|
||||
grub_ASM_USCORE
|
||||
if test x$grub_cv_asm_uscore = xyes; then
|
||||
|
@ -668,6 +671,23 @@ if test x"$grub_cv_cc_isystem" = xyes ; then
|
|||
fi
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK([whether -Wno-trampolines work], [grub_cv_cc_wnotrampolines], [
|
||||
SAVED_CFLAGS="$CFLAGS"
|
||||
# Test for -Wtrampolines rather than -Wno-trampolines to reduce confusion
|
||||
# in the event of later failures (since -Wno-* is always accepted, but
|
||||
# produces a diagnostic if something else is wrong).
|
||||
CFLAGS="$TARGET_CFLAGS -Wtrampolines"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
|
||||
int va_arg_func (int fixed, va_list args);]], [[]])],
|
||||
[grub_cv_cc_wnotrampolines=yes],
|
||||
[grub_cv_cc_wnotrampolines=no])
|
||||
CFLAGS="$SAVED_CFLAGS"
|
||||
])
|
||||
|
||||
if test x"$grub_cv_cc_wnotrampolines" = xyes ; then
|
||||
TARGET_CFLAGS="$TARGET_CFLAGS -Wno-trampolines"
|
||||
fi
|
||||
|
||||
# Restore the flags.
|
||||
CC="$tmp_CC"
|
||||
CFLAGS="$tmp_CFLAGS"
|
||||
|
|
|
@ -109,8 +109,8 @@ This edition documents version @value{VERSION}.
|
|||
@menu
|
||||
* Overview:: What exactly GRUB is and how to use it
|
||||
* History:: From maggot to house fly
|
||||
* Features:: GRUB features
|
||||
* Changes from GRUB Legacy:: Differences from previous versions
|
||||
* Features:: GRUB features
|
||||
* Role of a boot loader:: The role of a boot loader
|
||||
@end menu
|
||||
|
||||
|
@ -227,7 +227,9 @@ scripting language: variables, conditionals, and loops are available.
|
|||
@item
|
||||
A small amount of persistent storage is available across reboots, using the
|
||||
@command{save_env} and @command{load_env} commands in GRUB and the
|
||||
@command{grub-editenv} utility.
|
||||
@command{grub-editenv} utility. For safety reasons this storage is only
|
||||
available when installed on plain disk (no LVM or RAID), using non-checksumming
|
||||
filesystem (no ZFS) and using BIOS or EFI functions (no ATA, USB or IEEE1275)
|
||||
|
||||
@item
|
||||
GRUB 2 has more reliable ways to find its own files and those of target
|
||||
|
@ -1032,6 +1034,8 @@ it as a new default entry for use by future runs of GRUB. This is only
|
|||
useful if @samp{GRUB_DEFAULT=saved}; it is a separate option because
|
||||
@samp{GRUB_DEFAULT=saved} is useful without this option, in conjunction with
|
||||
@command{grub-set-default} or @command{grub-reboot}. Unset by default.
|
||||
The remarks of @pxref{Changes from GRUB Legacy} on the availability
|
||||
of @samp{save_env} apply.
|
||||
|
||||
@item GRUB_TIMEOUT
|
||||
Boot the default entry this many seconds after the menu is displayed, unless
|
||||
|
|
|
@ -30,7 +30,7 @@ CCASFLAGS_LIBRARY += $(CCASFLAGS_PLATFORM)
|
|||
|
||||
# gentrigtables
|
||||
gentrigtables: gentrigtables.c
|
||||
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(CPPFLAGS) -lm $<
|
||||
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(CPPFLAGS) $< -lm
|
||||
CLEANFILES += gentrigtables
|
||||
|
||||
# trigtables.c
|
||||
|
@ -237,9 +237,9 @@ command.lst: $(MARKER_FILES)
|
|||
(for pp in $^; do \
|
||||
b=`basename $$pp .marker`; \
|
||||
sed -n \
|
||||
-e "/COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" \
|
||||
-e "/EXTCOMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
|
||||
-e "/P1COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" $$pp; \
|
||||
-e "/P1COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/*\1: $$b/;p;}" \
|
||||
-e "/COMMAND_LIST_MARKER *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $$b/;p;}" $$pp; \
|
||||
done) | sort -u > $@
|
||||
platform_DATA += command.lst
|
||||
CLEANFILES += command.lst
|
||||
|
|
|
@ -27,6 +27,8 @@ kernel = {
|
|||
i386_qemu_ldflags = '$(TARGET_IMG_LDFLAGS)';
|
||||
i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x8200';
|
||||
|
||||
ldadd = '$(LDADD_KERNEL)';
|
||||
|
||||
i386_coreboot_ldflags = '-Wl,-Ttext=0x8200';
|
||||
i386_multiboot_ldflags = '-Wl,-Ttext=0x8200';
|
||||
i386_ieee1275_ldflags = '-Wl,-Ttext=0x10000';
|
||||
|
@ -39,10 +41,6 @@ kernel = {
|
|||
emu_cflags = '$(CFLAGS_GNULIB)';
|
||||
emu_cppflags = '$(CPPFLAGS_GNULIB)';
|
||||
|
||||
mips_ldadd = '-lgcc';
|
||||
powerpc_ldadd = '-lgcc';
|
||||
sparc64_ldadd = '-lgcc';
|
||||
|
||||
i386_pc_startup = kern/i386/pc/startup.S;
|
||||
i386_efi_startup = kern/i386/efi/startup.S;
|
||||
x86_64_efi_startup = kern/x86_64/efi/startup.S;
|
||||
|
@ -164,6 +162,7 @@ kernel = {
|
|||
emu = disk/host.c;
|
||||
emu = gnulib/progname.c;
|
||||
emu = gnulib/error.c;
|
||||
emu = kern/emu/cache.S;
|
||||
emu = kern/emu/console.c;
|
||||
emu = kern/emu/getroot.c;
|
||||
emu = kern/emu/hostdisk.c;
|
||||
|
@ -210,7 +209,6 @@ program = {
|
|||
name = grub-emu-lite;
|
||||
|
||||
emu = kern/emu/lite.c;
|
||||
emu = kern/emu/cache.S;
|
||||
emu_nodist = symlist.c;
|
||||
|
||||
ldadd = 'kernel.img$(EXEEXT)';
|
||||
|
@ -302,7 +300,8 @@ image = {
|
|||
mips_cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1 -DGRUB_MACHINE_LINK_ADDR=0x80200000';
|
||||
|
||||
objcopyflags = '-O binary';
|
||||
ldflags = '-lgcc -static-libgcc -Wl,-Ttext,0x80100000';
|
||||
ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
|
||||
ldadd = '-lgcc';
|
||||
cflags = '-static-libgcc';
|
||||
enable = mips;
|
||||
};
|
||||
|
@ -315,7 +314,8 @@ image = {
|
|||
mips_cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1 -DGRUB_MACHINE_LINK_ADDR=0x80200000';
|
||||
|
||||
objcopyflags = '-O binary';
|
||||
ldflags = '-lgcc -static-libgcc -Wl,-Ttext,0x80100000';
|
||||
ldflags = '-static-libgcc -Wl,-Ttext,0x80100000';
|
||||
ldadd = '-lgcc';
|
||||
cflags = '-static-libgcc';
|
||||
enable = mips;
|
||||
};
|
||||
|
@ -1007,6 +1007,19 @@ module = {
|
|||
common = fs/xfs.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = zfs;
|
||||
common = fs/zfs/zfs.c;
|
||||
common = fs/zfs/zfs_lzjb.c;
|
||||
common = fs/zfs/zfs_sha256.c;
|
||||
common = fs/zfs/zfs_fletcher.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = zfsinfo;
|
||||
common = fs/zfs/zfsinfo.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = pxe;
|
||||
i386_pc = fs/i386/pc/pxe.c;
|
||||
|
|
|
@ -459,6 +459,8 @@ fd_probe_error_string: .asciz "Floppy"
|
|||
1:
|
||||
/* perform read */
|
||||
movw $GRUB_BOOT_MACHINE_BUFFER_SEG, %bx
|
||||
movw %bx, %es
|
||||
xorw %bx, %bx
|
||||
movw $0x201, %ax
|
||||
movb $0, %ch
|
||||
movb $0, %dh
|
||||
|
|
|
@ -90,7 +90,14 @@ grub_pci_iterate (grub_pci_iteratefunc_t hook)
|
|||
|
||||
/* Check if there is a device present. */
|
||||
if (id >> 16 == 0xFFFF)
|
||||
continue;
|
||||
{
|
||||
if (dev.function == 0)
|
||||
/* Devices are required to implement function 0, so if
|
||||
it's missing then there is no device here. */
|
||||
break;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
/* Skip ghosts. */
|
||||
|
|
|
@ -36,6 +36,7 @@ typedef uint8_t grub_uint8_t;
|
|||
|
||||
#ifndef GRUB_DSDT_TEST
|
||||
#include <grub/misc.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/cpu/io.h>
|
||||
#endif
|
||||
|
||||
|
@ -324,6 +325,8 @@ grub_acpi_halt (void)
|
|||
}
|
||||
}
|
||||
|
||||
grub_millisleep (1500);
|
||||
|
||||
grub_printf ("ACPI shutdown failed\n");
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* echo.c - Command to display a line of text */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2006,2007,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -21,6 +21,7 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/extcmd.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/term.h>
|
||||
|
||||
static const struct grub_arg_option options[] =
|
||||
{
|
||||
|
@ -43,8 +44,14 @@ grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args)
|
|||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
char *arg = *args;
|
||||
/* Unescaping results in a string no longer than the original. */
|
||||
char *unescaped = grub_malloc (grub_strlen (arg) + 1);
|
||||
char *p = unescaped;
|
||||
args++;
|
||||
|
||||
if (!unescaped)
|
||||
return grub_errno;
|
||||
|
||||
while (*arg)
|
||||
{
|
||||
/* In case `-e' is used, parse backslashes. */
|
||||
|
@ -57,11 +64,11 @@ grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args)
|
|||
switch (*arg)
|
||||
{
|
||||
case '\\':
|
||||
grub_printf ("\\");
|
||||
*p++ = '\\';
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
grub_printf ("\a");
|
||||
*p++ = '\a';
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
|
@ -69,23 +76,23 @@ grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args)
|
|||
break;
|
||||
|
||||
case 'f':
|
||||
grub_printf ("\f");
|
||||
*p++ = '\f';
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
grub_printf ("\n");
|
||||
*p++ = '\n';
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
grub_printf ("\r");
|
||||
*p++ = '\r';
|
||||
break;
|
||||
|
||||
case 't':
|
||||
grub_printf ("\t");
|
||||
*p++ = '\t';
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
grub_printf ("\v");
|
||||
*p++ = '\v';
|
||||
break;
|
||||
}
|
||||
arg++;
|
||||
|
@ -94,10 +101,14 @@ grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args)
|
|||
|
||||
/* This was not an escaped character, or escaping is not
|
||||
enabled. */
|
||||
grub_printf ("%c", *arg);
|
||||
*p++ = *arg;
|
||||
arg++;
|
||||
}
|
||||
|
||||
*p = '\0';
|
||||
grub_xputs (unescaped);
|
||||
grub_free (unescaped);
|
||||
|
||||
/* If another argument follows, insert a space. */
|
||||
if (i != argc - 1)
|
||||
grub_printf (" " );
|
||||
|
@ -106,6 +117,8 @@ grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args)
|
|||
if (newline)
|
||||
grub_printf ("\n");
|
||||
|
||||
grub_refresh ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -177,9 +177,6 @@ legacy_file (const char *filename)
|
|||
grub_free (suffix);
|
||||
grub_free (entrysrc);
|
||||
|
||||
if (menu && menu->size)
|
||||
grub_show_menu (menu, 1);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
@ -194,8 +191,8 @@ grub_cmd_legacy_source (struct grub_command *cmd,
|
|||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
|
||||
|
||||
extractor = (cmd->name[0] == 'e');
|
||||
new_env = (cmd->name[extractor ? sizeof ("extract_legacy_entries_") - 1
|
||||
: sizeof ("legacy_") - 1] == 'c');
|
||||
new_env = (cmd->name[extractor ? (sizeof ("extract_legacy_entries_") - 1)
|
||||
: (sizeof ("legacy_") - 1)] == 'c');
|
||||
|
||||
if (new_env)
|
||||
grub_cls ();
|
||||
|
@ -207,8 +204,15 @@ grub_cmd_legacy_source (struct grub_command *cmd,
|
|||
|
||||
ret = legacy_file (args[0]);
|
||||
|
||||
if (new_env && !extractor)
|
||||
grub_env_context_close ();
|
||||
if (new_env)
|
||||
{
|
||||
grub_menu_t menu;
|
||||
menu = grub_env_get_menu ();
|
||||
if (menu && menu->size)
|
||||
grub_show_menu (menu, 1);
|
||||
if (!extractor)
|
||||
grub_env_context_close ();
|
||||
}
|
||||
if (extractor)
|
||||
grub_env_extractor_close (!new_env);
|
||||
|
||||
|
@ -761,12 +765,12 @@ GRUB_MOD_INIT(legacycfg)
|
|||
= grub_register_command ("extract_legacy_entries_source",
|
||||
grub_cmd_legacy_source,
|
||||
N_("FILE"),
|
||||
N_("Parse legacy config in same context taking onl entries"));
|
||||
N_("Parse legacy config in same context taking only menu entries"));
|
||||
cmd_configfile_extract
|
||||
= grub_register_command ("extract_legacy_entries_configfile",
|
||||
grub_cmd_legacy_source,
|
||||
N_("FILE"),
|
||||
N_("Parse legacy config in new context taking onl entries"));
|
||||
N_("Parse legacy config in new context taking only menu entries"));
|
||||
|
||||
cmd_kernel = grub_register_command ("legacy_kernel",
|
||||
grub_cmd_legacy_kernel,
|
||||
|
|
|
@ -206,20 +206,6 @@ setparams_prefix (int argc, char **args)
|
|||
char *p;
|
||||
char *result;
|
||||
grub_size_t len = 10;
|
||||
static const char *escape_characters = "\"\\";
|
||||
|
||||
auto char *strescpy (char *, const char *, const char *);
|
||||
char * strescpy (char *d, const char *s, const char *escapes)
|
||||
{
|
||||
while (*s)
|
||||
{
|
||||
if (grub_strchr (escapes, *s))
|
||||
*d++ = '\\';
|
||||
*d++ = *s++;
|
||||
}
|
||||
*d = '\0';
|
||||
return d;
|
||||
}
|
||||
|
||||
/* Count resulting string length */
|
||||
for (i = 0; i < argc; i++)
|
||||
|
@ -227,7 +213,7 @@ setparams_prefix (int argc, char **args)
|
|||
len += 3; /* 3 = 1 space + 2 quotes */
|
||||
p = args[i];
|
||||
while (*p)
|
||||
len += grub_strchr (escape_characters, *p++) ? 2 : 1;
|
||||
len += (*p++ == '\'' ? 3 : 1);
|
||||
}
|
||||
|
||||
result = grub_malloc (len + 2);
|
||||
|
@ -235,17 +221,17 @@ setparams_prefix (int argc, char **args)
|
|||
return 0;
|
||||
|
||||
grub_strcpy (result, "setparams");
|
||||
i = 9;
|
||||
p = result + 9;
|
||||
|
||||
for (j = 0; j < argc; j++)
|
||||
{
|
||||
result[i++] = ' ';
|
||||
result[i++] = '"';
|
||||
i = strescpy (result + i, args[j], escape_characters) - result;
|
||||
result[i++] = '"';
|
||||
*p++ = ' ';
|
||||
*p++ = '\'';
|
||||
p = grub_strchrsub (p, args[j], '\'', "'\\''");
|
||||
*p++ = '\'';
|
||||
}
|
||||
result[i++] = '\n';
|
||||
result[i] = '\0';
|
||||
*p++ = '\n';
|
||||
*p = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,6 @@ set_matches (char **varnames, char *str, grub_size_t nmatches,
|
|||
static grub_err_t
|
||||
grub_cmd_regexp (grub_extcmd_context_t ctxt, int argc, char **args)
|
||||
{
|
||||
int argn = 0;
|
||||
regex_t regex;
|
||||
int ret;
|
||||
grub_size_t s;
|
||||
|
|
|
@ -266,7 +266,6 @@ match_files (const char *prefix, const char *suffix, const char *end,
|
|||
const regex_t *regexp)
|
||||
{
|
||||
int i;
|
||||
int error;
|
||||
char **files;
|
||||
unsigned nfile;
|
||||
char *dir;
|
||||
|
@ -440,8 +439,6 @@ wildcard_expand (const char *s, char ***strs)
|
|||
|
||||
else if (*start == '/') /* no device part */
|
||||
{
|
||||
char **r;
|
||||
unsigned n;
|
||||
char *root;
|
||||
char *prefix;
|
||||
|
||||
|
|
|
@ -624,6 +624,11 @@ GRUB_MOD_INIT(biosdisk)
|
|||
((cdrp->media_type & GRUB_BIOSDISK_CDTYPE_MASK)
|
||||
== GRUB_BIOSDISK_CDTYPE_NO_EMUL))
|
||||
cd_drive = cdrp->drive_no;
|
||||
/* Since diskboot.S rejects devices over 0x90 it must be a CD booted with
|
||||
cdboot.S
|
||||
*/
|
||||
if (grub_boot_drive >= 0x90)
|
||||
cd_drive = grub_boot_drive;
|
||||
|
||||
grub_disk_dev_register (&grub_biosdisk_dev);
|
||||
}
|
||||
|
|
|
@ -762,5 +762,6 @@ GRUB_MOD_INIT(lvm)
|
|||
GRUB_MOD_FINI(lvm)
|
||||
{
|
||||
grub_disk_dev_unregister (&grub_lvm_dev);
|
||||
vg_list = NULL;
|
||||
/* FIXME: free the lvm list. */
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ static grub_err_t
|
|||
grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array,
|
||||
grub_disk_addr_t *start_sector)
|
||||
{
|
||||
grub_disk_addr_t sector;
|
||||
grub_disk_addr_t sector = 0;
|
||||
grub_uint64_t size;
|
||||
struct grub_raid_super_1x sb;
|
||||
grub_uint8_t minor_version;
|
||||
|
@ -123,6 +123,9 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array,
|
|||
|
||||
for (minor_version = 0; minor_version < 3; ++minor_version)
|
||||
{
|
||||
if (size == GRUB_DISK_SIZE_UNKNOWN && minor_version == 0)
|
||||
continue;
|
||||
|
||||
switch (minor_version)
|
||||
{
|
||||
case 0:
|
||||
|
|
|
@ -170,6 +170,8 @@ grub_mdraid_detect (grub_disk_t disk, struct grub_raid_array *array,
|
|||
|
||||
/* The sector where the mdraid 0.90 superblock is stored, if available. */
|
||||
size = grub_disk_get_size (disk);
|
||||
if (size == GRUB_DISK_SIZE_UNKNOWN)
|
||||
return grub_error (GRUB_ERR_OUT_OF_RANGE, "not 0.9x raid");
|
||||
sector = NEW_SIZE_SECTORS (size);
|
||||
|
||||
if (grub_disk_read (disk, sector, 0, SB_BYTES, &sb))
|
||||
|
|
|
@ -522,14 +522,16 @@ insert_array (grub_disk_t disk, struct grub_raid_array *new_array,
|
|||
/* We found more members of the array than the array
|
||||
actually has according to its superblock. This shouldn't
|
||||
happen normally. */
|
||||
grub_dprintf ("raid", "array->nr_devs > array->total_devs (%d)?!?",
|
||||
array->total_devs);
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"superfluous RAID member (%d found)",
|
||||
array->total_devs);
|
||||
|
||||
if (array->members[new_array->index].device != NULL)
|
||||
/* We found multiple devices with the same number. Again,
|
||||
this shouldn't happen. */
|
||||
grub_dprintf ("raid", "Found two disks with the number %d?!?",
|
||||
new_array->number);
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"found two disks with the number %d",
|
||||
new_array->number);
|
||||
|
||||
if (new_array->disk_size < array->disk_size)
|
||||
array->disk_size = new_array->disk_size;
|
||||
|
|
|
@ -208,7 +208,7 @@ grub_affs_mount (grub_disk_t disk)
|
|||
rblock = (struct grub_affs_rblock *) rootblock;
|
||||
|
||||
/* Read the rootblock. */
|
||||
grub_disk_read (disk, (disk->total_sectors >> 1) + blocksize, 0,
|
||||
grub_disk_read (disk, grub_be_to_cpu32 (data->bblock.rootblock), 0,
|
||||
GRUB_DISK_SECTOR_SIZE * 16, rootblock);
|
||||
if (grub_errno)
|
||||
goto fail;
|
||||
|
@ -240,7 +240,7 @@ grub_affs_mount (grub_disk_t disk)
|
|||
data->disk = disk;
|
||||
data->htsize = grub_be_to_cpu32 (rblock->htsize);
|
||||
data->diropen.data = data;
|
||||
data->diropen.block = (disk->total_sectors >> 1);
|
||||
data->diropen.block = grub_be_to_cpu32 (data->bblock.rootblock);
|
||||
|
||||
grub_free (rootblock);
|
||||
|
||||
|
@ -507,7 +507,7 @@ grub_affs_label (grub_device_t device, char **label)
|
|||
{
|
||||
/* The rootblock maps quite well on a file header block, it's
|
||||
something we can use here. */
|
||||
grub_disk_read (data->disk, disk->total_sectors >> 1,
|
||||
grub_disk_read (data->disk, grub_be_to_cpu32 (data->bblock.rootblock),
|
||||
data->blocksize * (GRUB_DISK_SECTOR_SIZE
|
||||
- GRUB_AFFS_FILE_LOCATION),
|
||||
sizeof (file), &file);
|
||||
|
@ -535,6 +535,9 @@ static struct grub_fs grub_affs_fs =
|
|||
.read = grub_affs_read,
|
||||
.close = grub_affs_close,
|
||||
.label = grub_affs_label,
|
||||
#ifdef GRUB_UTIL
|
||||
.reserved_first_sector = 0,
|
||||
#endif
|
||||
.next = 0
|
||||
};
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ grub_btrfs_mount (grub_disk_t disk)
|
|||
&data->sblock) != GRUB_ERR_NONE)
|
||||
goto fail;
|
||||
|
||||
if (grub_strncmp ((char *) data->sblock.signature, BTRFS_SIGNATURE, sizeof (BTRFS_SIGNATURE) - 1))
|
||||
if (grub_memcmp ((char *) data->sblock.signature, BTRFS_SIGNATURE, sizeof (BTRFS_SIGNATURE) - 1))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "not a Btrfs filesystem");
|
||||
goto fail;
|
||||
|
|
|
@ -354,6 +354,9 @@ static struct grub_fs grub_cpio_fs = {
|
|||
.open = grub_cpio_open,
|
||||
.read = grub_cpio_read,
|
||||
.close = grub_cpio_close,
|
||||
#ifdef GRUB_UTIL
|
||||
.reserved_first_sector = 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef MODE_USTAR
|
||||
|
|
|
@ -229,7 +229,7 @@ struct grub_ext2_inode
|
|||
};
|
||||
grub_uint32_t version;
|
||||
grub_uint32_t acl;
|
||||
grub_uint32_t dir_acl;
|
||||
grub_uint32_t size_high;
|
||||
grub_uint32_t fragment_addr;
|
||||
grub_uint32_t osd2[3];
|
||||
};
|
||||
|
@ -470,10 +470,41 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
|
|||
blknr = grub_le_to_cpu32 (indir[rblock % perblock]);
|
||||
}
|
||||
/* triple indirect. */
|
||||
else if (fileblock < INDIRECT_BLOCKS + blksz / 4 * (blksz / 4 + 1)
|
||||
+ (blksz / 4) * (blksz / 4) * (blksz / 4 + 1))
|
||||
{
|
||||
unsigned int perblock = blksz / 4;
|
||||
unsigned int rblock = fileblock - (INDIRECT_BLOCKS + blksz / 4
|
||||
* (blksz / 4 + 1));
|
||||
grub_uint32_t indir[blksz / 4];
|
||||
|
||||
if (grub_disk_read (data->disk,
|
||||
((grub_disk_addr_t)
|
||||
grub_le_to_cpu32 (inode->blocks.triple_indir_block))
|
||||
<< log2_blksz,
|
||||
0, blksz, indir))
|
||||
return grub_errno;
|
||||
|
||||
if (grub_disk_read (data->disk,
|
||||
((grub_disk_addr_t)
|
||||
grub_le_to_cpu32 (indir[(rblock / perblock) / perblock]))
|
||||
<< log2_blksz,
|
||||
0, blksz, indir))
|
||||
return grub_errno;
|
||||
|
||||
if (grub_disk_read (data->disk,
|
||||
((grub_disk_addr_t)
|
||||
grub_le_to_cpu32 (indir[(rblock / perblock) % perblock]))
|
||||
<< log2_blksz,
|
||||
0, blksz, indir))
|
||||
return grub_errno;
|
||||
|
||||
blknr = grub_le_to_cpu32 (indir[rblock % perblock]);
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"ext2fs doesn't support triple indirect blocks");
|
||||
"ext2fs doesn't support quadruple indirect blocks");
|
||||
}
|
||||
|
||||
return blknr;
|
||||
|
@ -485,11 +516,12 @@ static grub_ssize_t
|
|||
grub_ext2_read_file (grub_fshelp_node_t node,
|
||||
void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
|
||||
unsigned offset, unsigned length),
|
||||
int pos, grub_size_t len, char *buf)
|
||||
grub_off_t pos, grub_size_t len, char *buf)
|
||||
{
|
||||
return grub_fshelp_read_file (node->data->disk, node, read_hook,
|
||||
pos, len, buf, grub_ext2_read_block,
|
||||
node->inode.size,
|
||||
grub_cpu_to_le32 (node->inode.size)
|
||||
| (((grub_off_t) grub_cpu_to_le32 (node->inode.size_high)) << 32),
|
||||
LOG2_EXT2_BLOCK_SIZE (node->data));
|
||||
|
||||
}
|
||||
|
@ -756,6 +788,7 @@ grub_ext2_open (struct grub_file *file, const char *name)
|
|||
grub_free (fdiro);
|
||||
|
||||
file->size = grub_le_to_cpu32 (data->inode->size);
|
||||
file->size |= ((grub_off_t) grub_le_to_cpu32 (data->inode->size_high)) << 32;
|
||||
file->data = data;
|
||||
file->offset = 0;
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ enum grub_hfsplus_filetype
|
|||
/* Internal representation of a catalog key. */
|
||||
struct grub_hfsplus_catkey_internal
|
||||
{
|
||||
int parent;
|
||||
grub_uint32_t parent;
|
||||
char *name;
|
||||
};
|
||||
|
||||
|
@ -520,9 +520,12 @@ grub_hfsplus_cmp_catkey (struct grub_hfsplus_key *keya,
|
|||
int i;
|
||||
int diff;
|
||||
|
||||
diff = grub_be_to_cpu32 (catkey_a->parent) - catkey_b->parent;
|
||||
if (diff)
|
||||
return diff;
|
||||
/* Safe unsigned comparison */
|
||||
grub_uint32_t aparent = grub_be_to_cpu32 (catkey_a->parent);
|
||||
if (aparent > catkey_b->parent)
|
||||
return 1;
|
||||
if (aparent < catkey_b->parent)
|
||||
return -1;
|
||||
|
||||
/* Change the filename in keya so the endianness is correct. */
|
||||
for (i = 0; i < grub_be_to_cpu16 (catkey_a->namelen); i++)
|
||||
|
@ -555,15 +558,21 @@ grub_hfsplus_cmp_extkey (struct grub_hfsplus_key *keya,
|
|||
{
|
||||
struct grub_hfsplus_extkey *extkey_a = &keya->extkey;
|
||||
struct grub_hfsplus_extkey_internal *extkey_b = &keyb->extkey;
|
||||
int diff;
|
||||
grub_uint32_t akey;
|
||||
|
||||
diff = grub_be_to_cpu32 (extkey_a->fileid) - extkey_b->fileid;
|
||||
|
||||
if (diff)
|
||||
return diff;
|
||||
|
||||
diff = grub_be_to_cpu32 (extkey_a->start) - extkey_b->start;
|
||||
return diff;
|
||||
/* Safe unsigned comparison */
|
||||
akey = grub_be_to_cpu32 (extkey_a->fileid);
|
||||
if (akey > extkey_b->fileid)
|
||||
return 1;
|
||||
if (akey < extkey_b->fileid)
|
||||
return -1;
|
||||
|
||||
akey = grub_be_to_cpu32 (extkey_a->start);
|
||||
if (akey > extkey_b->start)
|
||||
return 1;
|
||||
if (akey < extkey_b->start)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *
|
||||
|
|
|
@ -579,6 +579,9 @@ static struct grub_fs grub_sfs_fs =
|
|||
.read = grub_sfs_read,
|
||||
.close = grub_sfs_close,
|
||||
.label = grub_sfs_label,
|
||||
#ifdef GRUB_UTIL
|
||||
.reserved_first_sector = 0,
|
||||
#endif
|
||||
.next = 0
|
||||
};
|
||||
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
#define U32 grub_le_to_cpu32
|
||||
#define U64 grub_le_to_cpu64
|
||||
|
||||
#define GRUB_UDF_LOG2_BLKSZ 2
|
||||
#define GRUB_UDF_BLKSZ 2048
|
||||
|
||||
#define GRUB_UDF_TAG_IDENT_PVD 0x0001
|
||||
#define GRUB_UDF_TAG_IDENT_AVDP 0x0002
|
||||
#define GRUB_UDF_TAG_IDENT_VDP 0x0003
|
||||
|
@ -336,6 +333,13 @@ struct grub_udf_lvd
|
|||
grub_uint8_t part_maps[1608];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct grub_udf_aed
|
||||
{
|
||||
struct grub_udf_tag tag;
|
||||
grub_uint32_t prev_ae;
|
||||
grub_uint32_t ae_len;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct grub_udf_data
|
||||
{
|
||||
grub_disk_t disk;
|
||||
|
@ -343,7 +347,7 @@ struct grub_udf_data
|
|||
struct grub_udf_pd pds[GRUB_UDF_MAX_PDS];
|
||||
struct grub_udf_partmap *pms[GRUB_UDF_MAX_PMS];
|
||||
struct grub_udf_long_ad root_icb;
|
||||
int npd, npm;
|
||||
int npd, npm, lbshift;
|
||||
};
|
||||
|
||||
struct grub_fshelp_node
|
||||
|
@ -389,7 +393,7 @@ grub_udf_read_icb (struct grub_udf_data *data,
|
|||
if (grub_errno)
|
||||
return grub_errno;
|
||||
|
||||
if (grub_disk_read (data->disk, block << GRUB_UDF_LOG2_BLKSZ, 0,
|
||||
if (grub_disk_read (data->disk, block << data->lbshift, 0,
|
||||
sizeof (struct grub_udf_file_entry),
|
||||
&node->fe))
|
||||
return grub_errno;
|
||||
|
@ -406,19 +410,26 @@ grub_udf_read_icb (struct grub_udf_data *data,
|
|||
static grub_disk_addr_t
|
||||
grub_udf_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
|
||||
{
|
||||
char *buf = NULL;
|
||||
char *ptr;
|
||||
int len;
|
||||
grub_ssize_t len;
|
||||
grub_disk_addr_t filebytes;
|
||||
|
||||
if (U16 (node->fe.tag.tag_ident) == GRUB_UDF_TAG_IDENT_FE)
|
||||
switch (U16 (node->fe.tag.tag_ident))
|
||||
{
|
||||
case GRUB_UDF_TAG_IDENT_FE:
|
||||
ptr = (char *) &node->fe.ext_attr[0] + U32 (node->fe.ext_attr_length);
|
||||
len = U32 (node->fe.alloc_descs_length);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
|
||||
case GRUB_UDF_TAG_IDENT_EFE:
|
||||
ptr = (char *) &node->efe.ext_attr[0] + U32 (node->efe.ext_attr_length);
|
||||
len = U32 (node->efe.alloc_descs_length);
|
||||
break;
|
||||
|
||||
default:
|
||||
grub_error (GRUB_ERR_BAD_FS, "invalid file entry");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((U16 (node->fe.icbtag.flags) & GRUB_UDF_ICBTAG_FLAG_AD_MASK)
|
||||
|
@ -426,43 +437,115 @@ grub_udf_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
|
|||
{
|
||||
struct grub_udf_short_ad *ad = (struct grub_udf_short_ad *) ptr;
|
||||
|
||||
len /= sizeof (struct grub_udf_short_ad);
|
||||
filebytes = fileblock * GRUB_UDF_BLKSZ;
|
||||
while (len > 0)
|
||||
filebytes = fileblock * U32 (node->data->lvd.bsize);
|
||||
while (len >= (grub_ssize_t) sizeof (struct grub_udf_short_ad))
|
||||
{
|
||||
if (filebytes < U32 (ad->length))
|
||||
return ((U32 (ad->position) & GRUB_UDF_EXT_MASK) ? 0 :
|
||||
(grub_udf_get_block (node->data,
|
||||
node->part_ref,
|
||||
ad->position)
|
||||
+ (filebytes / GRUB_UDF_BLKSZ)));
|
||||
grub_uint32_t adlen = U32 (ad->length) & 0x3fffffff;
|
||||
grub_uint32_t adtype = U32 (ad->length) >> 30;
|
||||
if (adtype == 3)
|
||||
{
|
||||
struct grub_udf_aed *extension;
|
||||
grub_disk_addr_t sec = grub_udf_get_block(node->data,
|
||||
node->part_ref,
|
||||
ad->position);
|
||||
if (!buf)
|
||||
{
|
||||
buf = grub_malloc (U32 (node->data->lvd.bsize));
|
||||
if (!buf)
|
||||
return 0;
|
||||
}
|
||||
if (grub_disk_read (node->data->disk, sec << node->data->lbshift,
|
||||
0, adlen, buf))
|
||||
goto fail;
|
||||
|
||||
filebytes -= U32 (ad->length);
|
||||
extension = (struct grub_udf_aed *) buf;
|
||||
if (U16 (extension->tag.tag_ident) != GRUB_UDF_TAG_IDENT_AED)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "invalid aed tag");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
len = U32 (extension->ae_len);
|
||||
ad = (struct grub_udf_short_ad *)
|
||||
(buf + sizeof (struct grub_udf_aed));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (filebytes < adlen)
|
||||
{
|
||||
grub_uint32_t ad_pos = ad->position;
|
||||
grub_free (buf);
|
||||
return ((U32 (ad_pos) & GRUB_UDF_EXT_MASK) ? 0 :
|
||||
(grub_udf_get_block (node->data, node->part_ref, ad_pos)
|
||||
+ (filebytes >> (GRUB_DISK_SECTOR_BITS
|
||||
+ node->data->lbshift))));
|
||||
}
|
||||
|
||||
filebytes -= adlen;
|
||||
ad++;
|
||||
len--;
|
||||
len -= sizeof (struct grub_udf_short_ad);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
struct grub_udf_long_ad *ad = (struct grub_udf_long_ad *) ptr;
|
||||
|
||||
len /= sizeof (struct grub_udf_long_ad);
|
||||
filebytes = fileblock * GRUB_UDF_BLKSZ;
|
||||
while (len > 0)
|
||||
filebytes = fileblock * U32 (node->data->lvd.bsize);
|
||||
while (len >= (grub_ssize_t) sizeof (struct grub_udf_long_ad))
|
||||
{
|
||||
if (filebytes < U32 (ad->length))
|
||||
return ((U32 (ad->block.block_num) & GRUB_UDF_EXT_MASK) ? 0 :
|
||||
(grub_udf_get_block (node->data,
|
||||
ad->block.part_ref,
|
||||
ad->block.block_num)
|
||||
+ (filebytes / GRUB_UDF_BLKSZ)));
|
||||
grub_uint32_t adlen = U32 (ad->length) & 0x3fffffff;
|
||||
grub_uint32_t adtype = U32 (ad->length) >> 30;
|
||||
if (adtype == 3)
|
||||
{
|
||||
struct grub_udf_aed *extension;
|
||||
grub_disk_addr_t sec = grub_udf_get_block(node->data,
|
||||
ad->block.part_ref,
|
||||
ad->block.block_num);
|
||||
if (!buf)
|
||||
{
|
||||
buf = grub_malloc (U32 (node->data->lvd.bsize));
|
||||
if (!buf)
|
||||
return 0;
|
||||
}
|
||||
if (grub_disk_read (node->data->disk, sec << node->data->lbshift,
|
||||
0, adlen, buf))
|
||||
goto fail;
|
||||
|
||||
filebytes -= U32 (ad->length);
|
||||
extension = (struct grub_udf_aed *) buf;
|
||||
if (U16 (extension->tag.tag_ident) != GRUB_UDF_TAG_IDENT_AED)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "invalid aed tag");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
len = U32 (extension->ae_len);
|
||||
ad = (struct grub_udf_long_ad *)
|
||||
(buf + sizeof (struct grub_udf_aed));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (filebytes < adlen)
|
||||
{
|
||||
grub_uint32_t ad_block_num = ad->block.block_num;
|
||||
grub_uint32_t ad_part_ref = ad->block.part_ref;
|
||||
grub_free (buf);
|
||||
return ((U32 (ad_block_num) & GRUB_UDF_EXT_MASK) ? 0 :
|
||||
(grub_udf_get_block (node->data, ad_part_ref,
|
||||
ad_block_num)
|
||||
+ (filebytes >> (GRUB_DISK_SECTOR_BITS
|
||||
+ node->data->lbshift))));
|
||||
}
|
||||
|
||||
filebytes -= adlen;
|
||||
ad++;
|
||||
len--;
|
||||
len -= sizeof (struct grub_udf_long_ad);
|
||||
}
|
||||
}
|
||||
|
||||
fail:
|
||||
if (buf)
|
||||
grub_free (buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -471,7 +554,7 @@ grub_udf_read_file (grub_fshelp_node_t node,
|
|||
void NESTED_FUNC_ATTR
|
||||
(*read_hook) (grub_disk_addr_t sector,
|
||||
unsigned offset, unsigned length),
|
||||
int pos, grub_size_t len, char *buf)
|
||||
grub_off_t pos, grub_size_t len, char *buf)
|
||||
{
|
||||
switch (U16 (node->fe.icbtag.flags) & GRUB_UDF_ICBTAG_FLAG_AD_MASK)
|
||||
{
|
||||
|
@ -496,21 +579,21 @@ grub_udf_read_file (grub_fshelp_node_t node,
|
|||
}
|
||||
|
||||
return grub_fshelp_read_file (node->data->disk, node, read_hook,
|
||||
pos, len, buf, grub_udf_read_block,
|
||||
U64 (node->fe.file_size),
|
||||
GRUB_UDF_LOG2_BLKSZ);
|
||||
pos, len, buf, grub_udf_read_block,
|
||||
U64 (node->fe.file_size),
|
||||
node->data->lbshift);
|
||||
}
|
||||
|
||||
static int sblocklist[] = { 256, 512, 0 };
|
||||
static unsigned sblocklist[] = { 256, 512, 0 };
|
||||
|
||||
static struct grub_udf_data *
|
||||
grub_udf_mount (grub_disk_t disk)
|
||||
{
|
||||
struct grub_udf_data *data = 0;
|
||||
struct grub_udf_fileset root_fs;
|
||||
int *sblklist = sblocklist;
|
||||
grub_uint32_t block;
|
||||
int i;
|
||||
unsigned *sblklist;
|
||||
grub_uint32_t block, vblock;
|
||||
int i, lbshift;
|
||||
|
||||
data = grub_malloc (sizeof (struct grub_udf_data));
|
||||
if (!data)
|
||||
|
@ -518,12 +601,48 @@ grub_udf_mount (grub_disk_t disk)
|
|||
|
||||
data->disk = disk;
|
||||
|
||||
/* Search for Anchor Volume Descriptor Pointer (AVDP)
|
||||
* and determine logical block size. */
|
||||
block = 0;
|
||||
for (lbshift = 0; lbshift < 4; lbshift++)
|
||||
{
|
||||
for (sblklist = sblocklist; *sblklist; sblklist++)
|
||||
{
|
||||
struct grub_udf_avdp avdp;
|
||||
|
||||
if (grub_disk_read (disk, *sblklist << lbshift, 0,
|
||||
sizeof (struct grub_udf_avdp), &avdp))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (U16 (avdp.tag.tag_ident) == GRUB_UDF_TAG_IDENT_AVDP &&
|
||||
U32 (avdp.tag.tag_location) == *sblklist)
|
||||
{
|
||||
block = U32 (avdp.vds.start);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (block)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!block)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
|
||||
goto fail;
|
||||
}
|
||||
data->lbshift = lbshift;
|
||||
|
||||
/* Search for Volume Recognition Sequence (VRS). */
|
||||
for (block = 16;; block++)
|
||||
for (vblock = (32767 >> (lbshift + GRUB_DISK_SECTOR_BITS)) + 1;;
|
||||
vblock += (2047 >> (lbshift + GRUB_DISK_SECTOR_BITS)) + 1)
|
||||
{
|
||||
struct grub_udf_vrs vrs;
|
||||
|
||||
if (grub_disk_read (disk, block << GRUB_UDF_LOG2_BLKSZ, 0,
|
||||
if (grub_disk_read (disk, vblock << lbshift, 0,
|
||||
sizeof (struct grub_udf_vrs), &vrs))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
|
||||
|
@ -545,39 +664,13 @@ grub_udf_mount (grub_disk_t disk)
|
|||
}
|
||||
}
|
||||
|
||||
/* Search for Anchor Volume Descriptor Pointer (AVDP). */
|
||||
while (1)
|
||||
{
|
||||
struct grub_udf_avdp avdp;
|
||||
|
||||
if (grub_disk_read (disk, *sblklist << GRUB_UDF_LOG2_BLKSZ, 0,
|
||||
sizeof (struct grub_udf_avdp), &avdp))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (U16 (avdp.tag.tag_ident) == GRUB_UDF_TAG_IDENT_AVDP)
|
||||
{
|
||||
block = U32 (avdp.vds.start);
|
||||
break;
|
||||
}
|
||||
|
||||
sblklist++;
|
||||
if (*sblklist == 0)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
data->npd = data->npm = 0;
|
||||
/* Locate Partition Descriptor (PD) and Logical Volume Descriptor (LVD). */
|
||||
while (1)
|
||||
{
|
||||
struct grub_udf_tag tag;
|
||||
|
||||
if (grub_disk_read (disk, block << GRUB_UDF_LOG2_BLKSZ, 0,
|
||||
if (grub_disk_read (disk, block << lbshift, 0,
|
||||
sizeof (struct grub_udf_tag), &tag))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
|
||||
|
@ -593,7 +686,7 @@ grub_udf_mount (grub_disk_t disk)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
if (grub_disk_read (disk, block << GRUB_UDF_LOG2_BLKSZ, 0,
|
||||
if (grub_disk_read (disk, block << lbshift, 0,
|
||||
sizeof (struct grub_udf_pd),
|
||||
&data->pds[data->npd]))
|
||||
{
|
||||
|
@ -609,7 +702,7 @@ grub_udf_mount (grub_disk_t disk)
|
|||
|
||||
struct grub_udf_partmap *ppm;
|
||||
|
||||
if (grub_disk_read (disk, block << GRUB_UDF_LOG2_BLKSZ, 0,
|
||||
if (grub_disk_read (disk, block << lbshift, 0,
|
||||
sizeof (struct grub_udf_lvd),
|
||||
&data->lvd))
|
||||
{
|
||||
|
@ -673,7 +766,7 @@ grub_udf_mount (grub_disk_t disk)
|
|||
if (grub_errno)
|
||||
goto fail;
|
||||
|
||||
if (grub_disk_read (disk, block << GRUB_UDF_LOG2_BLKSZ, 0,
|
||||
if (grub_disk_read (disk, block << lbshift, 0,
|
||||
sizeof (struct grub_udf_fileset), &root_fs))
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FS, "not an UDF filesystem");
|
||||
|
@ -695,6 +788,43 @@ fail:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static char *
|
||||
read_string (grub_uint8_t *raw, grub_size_t sz)
|
||||
{
|
||||
grub_uint16_t *utf16 = NULL;
|
||||
char *ret;
|
||||
grub_size_t utf16len = 0;
|
||||
|
||||
if (raw[0] != 8 && raw[0] != 16)
|
||||
return NULL;
|
||||
|
||||
if (raw[0] == 8)
|
||||
{
|
||||
unsigned i;
|
||||
utf16len = sz - 1;
|
||||
utf16 = grub_malloc (utf16len * sizeof (utf16[0]));
|
||||
if (!utf16)
|
||||
return NULL;
|
||||
for (i = 0; i < utf16len; i++)
|
||||
utf16[i] = raw[i + 1];
|
||||
}
|
||||
if (raw[0] == 16)
|
||||
{
|
||||
unsigned i;
|
||||
utf16len = (sz - 1) / 2;
|
||||
utf16 = grub_malloc (utf16len * sizeof (utf16[0]));
|
||||
if (!utf16)
|
||||
return NULL;
|
||||
for (i = 0; i < utf16len; i++)
|
||||
utf16[i] = (raw[2 * i + 1] << 8) | raw[2*i + 2];
|
||||
}
|
||||
ret = grub_malloc (utf16len * 3 + 1);
|
||||
if (ret)
|
||||
*grub_utf16_to_utf8 ((grub_uint8_t *) ret, utf16, utf16len) = '\0';
|
||||
grub_free (utf16);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
grub_udf_iterate_dir (grub_fshelp_node_t dir,
|
||||
int NESTED_FUNC_ATTR
|
||||
|
@ -704,7 +834,7 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir,
|
|||
{
|
||||
grub_fshelp_node_t child;
|
||||
struct grub_udf_file_ident dirent;
|
||||
grub_uint32_t offset = 0;
|
||||
grub_off_t offset = 0;
|
||||
|
||||
child = grub_malloc (sizeof (struct grub_fshelp_node));
|
||||
if (!child)
|
||||
|
@ -729,57 +859,47 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir,
|
|||
return 0;
|
||||
}
|
||||
|
||||
child = grub_malloc (sizeof (struct grub_fshelp_node));
|
||||
if (!child)
|
||||
return 0;
|
||||
|
||||
if (grub_udf_read_icb (dir->data, &dirent.icb, child))
|
||||
return 0;
|
||||
|
||||
offset += sizeof (dirent) + U16 (dirent.imp_use_length);
|
||||
if (dirent.characteristics & GRUB_UDF_FID_CHAR_PARENT)
|
||||
if (!(dirent.characteristics & GRUB_UDF_FID_CHAR_DELETED))
|
||||
{
|
||||
/* This is the parent directory. */
|
||||
if (hook ("..", GRUB_FSHELP_DIR, child))
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
enum grub_fshelp_filetype type;
|
||||
grub_uint8_t raw[dirent.file_ident_length];
|
||||
grub_uint16_t utf16[dirent.file_ident_length - 1];
|
||||
grub_uint8_t filename[dirent.file_ident_length * 2];
|
||||
grub_size_t utf16len = 0;
|
||||
|
||||
type = ((dirent.characteristics & GRUB_UDF_FID_CHAR_DIRECTORY) ?
|
||||
(GRUB_FSHELP_DIR) : (GRUB_FSHELP_REG));
|
||||
|
||||
if ((grub_udf_read_file (dir, 0, offset,
|
||||
dirent.file_ident_length,
|
||||
(char *) raw))
|
||||
!= dirent.file_ident_length)
|
||||
child = grub_malloc (sizeof (struct grub_fshelp_node));
|
||||
if (!child)
|
||||
return 0;
|
||||
|
||||
if (raw[0] == 8)
|
||||
if (grub_udf_read_icb (dir->data, &dirent.icb, child))
|
||||
return 0;
|
||||
|
||||
if (dirent.characteristics & GRUB_UDF_FID_CHAR_PARENT)
|
||||
{
|
||||
unsigned i;
|
||||
utf16len = dirent.file_ident_length - 1;
|
||||
for (i = 0; i < utf16len; i++)
|
||||
utf16[i] = raw[i + 1];
|
||||
/* This is the parent directory. */
|
||||
if (hook ("..", GRUB_FSHELP_DIR, child))
|
||||
return 1;
|
||||
}
|
||||
if (raw[0] == 16)
|
||||
else
|
||||
{
|
||||
unsigned i;
|
||||
utf16len = (dirent.file_ident_length - 1) / 2;
|
||||
for (i = 0; i < utf16len; i++)
|
||||
utf16[i] = (raw[2 * i + 1] << 8) | raw[2*i + 2];
|
||||
}
|
||||
if (raw[0] == 8 || raw[0] == 16)
|
||||
{
|
||||
*grub_utf16_to_utf8 (filename, utf16, utf16len) = '\0';
|
||||
|
||||
if (hook ((char *) filename, type, child))
|
||||
return 1;
|
||||
enum grub_fshelp_filetype type;
|
||||
char *filename;
|
||||
grub_uint8_t raw[dirent.file_ident_length];
|
||||
|
||||
type = ((dirent.characteristics & GRUB_UDF_FID_CHAR_DIRECTORY) ?
|
||||
(GRUB_FSHELP_DIR) : (GRUB_FSHELP_REG));
|
||||
|
||||
if ((grub_udf_read_file (dir, 0, offset,
|
||||
dirent.file_ident_length,
|
||||
(char *) raw))
|
||||
!= dirent.file_ident_length)
|
||||
return 0;
|
||||
|
||||
filename = read_string (raw, dirent.file_ident_length);
|
||||
if (!filename)
|
||||
grub_print_error ();
|
||||
|
||||
if (filename && hook (filename, type, child))
|
||||
{
|
||||
grub_free (filename);
|
||||
return 1;
|
||||
}
|
||||
grub_free (filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -908,7 +1028,7 @@ grub_udf_label (grub_device_t device, char **label)
|
|||
|
||||
if (data)
|
||||
{
|
||||
*label = grub_strdup ((char *) &data->lvd.ident[1]);
|
||||
*label = read_string (data->lvd.ident, sizeof (data->lvd.ident));
|
||||
grub_free (data);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -808,6 +808,9 @@ static struct grub_fs grub_xfs_fs =
|
|||
.close = grub_xfs_close,
|
||||
.label = grub_xfs_label,
|
||||
.uuid = grub_xfs_uuid,
|
||||
#ifdef GRUB_UTIL
|
||||
.reserved_first_sector = 0,
|
||||
#endif
|
||||
.next = 0
|
||||
};
|
||||
|
||||
|
|
2543
grub-core/fs/zfs/zfs.c
Normal file
2543
grub-core/fs/zfs/zfs.c
Normal file
File diff suppressed because it is too large
Load diff
84
grub-core/fs/zfs/zfs_fletcher.c
Normal file
84
grub-core/fs/zfs/zfs_fletcher.c
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc.
|
||||
* Copyright 2007 Sun Microsystems, Inc.
|
||||
*
|
||||
* GRUB is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/err.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/zfs/zfs.h>
|
||||
#include <grub/zfs/zio.h>
|
||||
#include <grub/zfs/dnode.h>
|
||||
#include <grub/zfs/uberblock_impl.h>
|
||||
#include <grub/zfs/vdev_impl.h>
|
||||
#include <grub/zfs/zio_checksum.h>
|
||||
#include <grub/zfs/zap_impl.h>
|
||||
#include <grub/zfs/zap_leaf.h>
|
||||
#include <grub/zfs/zfs_znode.h>
|
||||
#include <grub/zfs/dmu.h>
|
||||
#include <grub/zfs/dmu_objset.h>
|
||||
#include <grub/zfs/dsl_dir.h>
|
||||
#include <grub/zfs/dsl_dataset.h>
|
||||
|
||||
void
|
||||
fletcher_2(const void *buf, grub_uint64_t size, grub_zfs_endian_t endian,
|
||||
zio_cksum_t *zcp)
|
||||
{
|
||||
const grub_uint64_t *ip = buf;
|
||||
const grub_uint64_t *ipend = ip + (size / sizeof (grub_uint64_t));
|
||||
grub_uint64_t a0, b0, a1, b1;
|
||||
|
||||
for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2)
|
||||
{
|
||||
a0 += grub_zfs_to_cpu64 (ip[0], endian);
|
||||
a1 += grub_zfs_to_cpu64 (ip[1], endian);
|
||||
b0 += a0;
|
||||
b1 += a1;
|
||||
}
|
||||
|
||||
zcp->zc_word[0] = grub_cpu_to_zfs64 (a0, endian);
|
||||
zcp->zc_word[1] = grub_cpu_to_zfs64 (a1, endian);
|
||||
zcp->zc_word[2] = grub_cpu_to_zfs64 (b0, endian);
|
||||
zcp->zc_word[3] = grub_cpu_to_zfs64 (b1, endian);
|
||||
}
|
||||
|
||||
void
|
||||
fletcher_4 (const void *buf, grub_uint64_t size, grub_zfs_endian_t endian,
|
||||
zio_cksum_t *zcp)
|
||||
{
|
||||
const grub_uint32_t *ip = buf;
|
||||
const grub_uint32_t *ipend = ip + (size / sizeof (grub_uint32_t));
|
||||
grub_uint64_t a, b, c, d;
|
||||
|
||||
for (a = b = c = d = 0; ip < ipend; ip++)
|
||||
{
|
||||
a += grub_zfs_to_cpu32 (ip[0], endian);;
|
||||
b += a;
|
||||
c += b;
|
||||
d += c;
|
||||
}
|
||||
|
||||
zcp->zc_word[0] = grub_cpu_to_zfs64 (a, endian);
|
||||
zcp->zc_word[1] = grub_cpu_to_zfs64 (b, endian);
|
||||
zcp->zc_word[2] = grub_cpu_to_zfs64 (c, endian);
|
||||
zcp->zc_word[3] = grub_cpu_to_zfs64 (d, endian);
|
||||
}
|
||||
|
93
grub-core/fs/zfs/zfs_lzjb.c
Normal file
93
grub-core/fs/zfs/zfs_lzjb.c
Normal file
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc.
|
||||
* Copyright 2007 Sun Microsystems, Inc.
|
||||
*
|
||||
* GRUB is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/err.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/zfs/zfs.h>
|
||||
#include <grub/zfs/zio.h>
|
||||
#include <grub/zfs/dnode.h>
|
||||
#include <grub/zfs/uberblock_impl.h>
|
||||
#include <grub/zfs/vdev_impl.h>
|
||||
#include <grub/zfs/zio_checksum.h>
|
||||
#include <grub/zfs/zap_impl.h>
|
||||
#include <grub/zfs/zap_leaf.h>
|
||||
#include <grub/zfs/zfs_znode.h>
|
||||
#include <grub/zfs/dmu.h>
|
||||
#include <grub/zfs/dmu_objset.h>
|
||||
#include <grub/zfs/dsl_dir.h>
|
||||
#include <grub/zfs/dsl_dataset.h>
|
||||
|
||||
#define MATCH_BITS 6
|
||||
#define MATCH_MIN 3
|
||||
#define OFFSET_MASK ((1 << (16 - MATCH_BITS)) - 1)
|
||||
|
||||
/*
|
||||
* Decompression Entry - lzjb
|
||||
*/
|
||||
#ifndef NBBY
|
||||
#define NBBY 8
|
||||
#endif
|
||||
|
||||
grub_err_t
|
||||
lzjb_decompress (void *s_start, void *d_start, grub_size_t s_len,
|
||||
grub_size_t d_len);
|
||||
|
||||
grub_err_t
|
||||
lzjb_decompress (void *s_start, void *d_start, grub_size_t s_len,
|
||||
grub_size_t d_len)
|
||||
{
|
||||
grub_uint8_t *src = s_start;
|
||||
grub_uint8_t *dst = d_start;
|
||||
grub_uint8_t *d_end = (grub_uint8_t *) d_start + d_len;
|
||||
grub_uint8_t *s_end = (grub_uint8_t *) s_start + s_len;
|
||||
grub_uint8_t *cpy, copymap = 0;
|
||||
int copymask = 1 << (NBBY - 1);
|
||||
|
||||
while (dst < d_end && src < s_end)
|
||||
{
|
||||
if ((copymask <<= 1) == (1 << NBBY))
|
||||
{
|
||||
copymask = 1;
|
||||
copymap = *src++;
|
||||
}
|
||||
if (src >= s_end)
|
||||
return grub_error (GRUB_ERR_BAD_FS, "lzjb decompression failed");
|
||||
if (copymap & copymask)
|
||||
{
|
||||
int mlen = (src[0] >> (NBBY - MATCH_BITS)) + MATCH_MIN;
|
||||
int offset = ((src[0] << NBBY) | src[1]) & OFFSET_MASK;
|
||||
src += 2;
|
||||
cpy = dst - offset;
|
||||
if (src > s_end || cpy < (grub_uint8_t *) d_start)
|
||||
return grub_error (GRUB_ERR_BAD_FS, "lzjb decompression failed");
|
||||
while (--mlen >= 0 && dst < d_end)
|
||||
*dst++ = *cpy++;
|
||||
}
|
||||
else
|
||||
*dst++ = *src++;
|
||||
}
|
||||
if (dst < d_end)
|
||||
return grub_error (GRUB_ERR_BAD_FS, "lzjb decompression failed");
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
143
grub-core/fs/zfs/zfs_sha256.c
Normal file
143
grub-core/fs/zfs/zfs_sha256.c
Normal file
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc.
|
||||
* Copyright 2007 Sun Microsystems, Inc.
|
||||
*
|
||||
* GRUB is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/err.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/zfs/zfs.h>
|
||||
#include <grub/zfs/zio.h>
|
||||
#include <grub/zfs/dnode.h>
|
||||
#include <grub/zfs/uberblock_impl.h>
|
||||
#include <grub/zfs/vdev_impl.h>
|
||||
#include <grub/zfs/zio_checksum.h>
|
||||
#include <grub/zfs/zap_impl.h>
|
||||
#include <grub/zfs/zap_leaf.h>
|
||||
#include <grub/zfs/zfs_znode.h>
|
||||
#include <grub/zfs/dmu.h>
|
||||
#include <grub/zfs/dmu_objset.h>
|
||||
#include <grub/zfs/dsl_dir.h>
|
||||
#include <grub/zfs/dsl_dataset.h>
|
||||
|
||||
/*
|
||||
* SHA-256 checksum, as specified in FIPS 180-2, available at:
|
||||
* http://csrc.nist.gov/cryptval
|
||||
*
|
||||
* This is a very compact implementation of SHA-256.
|
||||
* It is designed to be simple and portable, not to be fast.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The literal definitions according to FIPS180-2 would be:
|
||||
*
|
||||
* Ch(x, y, z) (((x) & (y)) ^ ((~(x)) & (z)))
|
||||
* Maj(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
|
||||
*
|
||||
* We use logical equivalents which require one less op.
|
||||
*/
|
||||
#define Ch(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
|
||||
#define Maj(x, y, z) (((x) & (y)) ^ ((z) & ((x) ^ (y))))
|
||||
#define Rot32(x, s) (((x) >> s) | ((x) << (32 - s)))
|
||||
#define SIGMA0(x) (Rot32(x, 2) ^ Rot32(x, 13) ^ Rot32(x, 22))
|
||||
#define SIGMA1(x) (Rot32(x, 6) ^ Rot32(x, 11) ^ Rot32(x, 25))
|
||||
#define sigma0(x) (Rot32(x, 7) ^ Rot32(x, 18) ^ ((x) >> 3))
|
||||
#define sigma1(x) (Rot32(x, 17) ^ Rot32(x, 19) ^ ((x) >> 10))
|
||||
|
||||
static const grub_uint32_t SHA256_K[64] = {
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
|
||||
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
||||
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
||||
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
|
||||
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
||||
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
|
||||
0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
||||
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
||||
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
||||
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
|
||||
0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
||||
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
|
||||
0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
||||
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
||||
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
||||
};
|
||||
|
||||
static void
|
||||
SHA256Transform(grub_uint32_t *H, const grub_uint8_t *cp)
|
||||
{
|
||||
grub_uint32_t a, b, c, d, e, f, g, h, t, T1, T2, W[64];
|
||||
|
||||
for (t = 0; t < 16; t++, cp += 4)
|
||||
W[t] = (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | cp[3];
|
||||
|
||||
for (t = 16; t < 64; t++)
|
||||
W[t] = sigma1(W[t - 2]) + W[t - 7] +
|
||||
sigma0(W[t - 15]) + W[t - 16];
|
||||
|
||||
a = H[0]; b = H[1]; c = H[2]; d = H[3];
|
||||
e = H[4]; f = H[5]; g = H[6]; h = H[7];
|
||||
|
||||
for (t = 0; t < 64; t++) {
|
||||
T1 = h + SIGMA1(e) + Ch(e, f, g) + SHA256_K[t] + W[t];
|
||||
T2 = SIGMA0(a) + Maj(a, b, c);
|
||||
h = g; g = f; f = e; e = d + T1;
|
||||
d = c; c = b; b = a; a = T1 + T2;
|
||||
}
|
||||
|
||||
H[0] += a; H[1] += b; H[2] += c; H[3] += d;
|
||||
H[4] += e; H[5] += f; H[6] += g; H[7] += h;
|
||||
}
|
||||
|
||||
void
|
||||
zio_checksum_SHA256(const void *buf, grub_uint64_t size,
|
||||
grub_zfs_endian_t endian, zio_cksum_t *zcp)
|
||||
{
|
||||
grub_uint32_t H[8] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
|
||||
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 };
|
||||
grub_uint8_t pad[128];
|
||||
unsigned padsize = size & 63;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < size - padsize; i += 64)
|
||||
SHA256Transform(H, (grub_uint8_t *)buf + i);
|
||||
|
||||
for (i = 0; i < padsize; i++)
|
||||
pad[i] = ((grub_uint8_t *)buf)[i];
|
||||
|
||||
for (pad[padsize++] = 0x80; (padsize & 63) != 56; padsize++)
|
||||
pad[padsize] = 0;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
pad[padsize++] = (size << 3) >> (56 - 8 * i);
|
||||
|
||||
for (i = 0; i < padsize; i += 64)
|
||||
SHA256Transform(H, pad + i);
|
||||
|
||||
zcp->zc_word[0] = grub_cpu_to_zfs64 ((grub_uint64_t)H[0] << 32 | H[1],
|
||||
endian);
|
||||
zcp->zc_word[1] = grub_cpu_to_zfs64 ((grub_uint64_t)H[2] << 32 | H[3],
|
||||
endian);
|
||||
zcp->zc_word[2] = grub_cpu_to_zfs64 ((grub_uint64_t)H[4] << 32 | H[5],
|
||||
endian);
|
||||
zcp->zc_word[3] = grub_cpu_to_zfs64 ((grub_uint64_t)H[6] << 32 | H[7],
|
||||
endian);
|
||||
}
|
412
grub-core/fs/zfs/zfsinfo.c
Normal file
412
grub-core/fs/zfs/zfsinfo.c
Normal file
|
@ -0,0 +1,412 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc.
|
||||
* Copyright 2008 Sun Microsystems, Inc.
|
||||
*
|
||||
* GRUB is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/zfs/zfs.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/env.h>
|
||||
|
||||
static inline void
|
||||
print_tabs (int n)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
grub_printf (" ");
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
print_state (char *nvlist, int tab)
|
||||
{
|
||||
grub_uint64_t ival;
|
||||
int isok = 1;
|
||||
|
||||
print_tabs (tab);
|
||||
grub_printf ("State: ");
|
||||
|
||||
if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_REMOVED, &ival))
|
||||
{
|
||||
grub_printf ("removed ");
|
||||
isok = 0;
|
||||
}
|
||||
|
||||
if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_FAULTED, &ival))
|
||||
{
|
||||
grub_printf ("faulted ");
|
||||
isok = 0;
|
||||
}
|
||||
|
||||
if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_OFFLINE, &ival))
|
||||
{
|
||||
grub_printf ("offline ");
|
||||
isok = 0;
|
||||
}
|
||||
|
||||
if (grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_FAULTED, &ival))
|
||||
grub_printf ("degraded ");
|
||||
|
||||
if (isok)
|
||||
grub_printf ("online");
|
||||
grub_printf ("\n");
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
print_vdev_info (char *nvlist, int tab)
|
||||
{
|
||||
char *type = 0;
|
||||
|
||||
type = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_TYPE);
|
||||
|
||||
if (!type)
|
||||
{
|
||||
print_tabs (tab);
|
||||
grub_printf ("Incorrect VDEV: no type available\n");
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
if (grub_strcmp (type, VDEV_TYPE_DISK) == 0)
|
||||
{
|
||||
char *bootpath = 0;
|
||||
char *path = 0;
|
||||
char *devid = 0;
|
||||
|
||||
print_tabs (tab);
|
||||
grub_printf ("Leaf VDEV\n");
|
||||
|
||||
print_state (nvlist, tab);
|
||||
|
||||
bootpath =
|
||||
grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_PHYS_PATH);
|
||||
print_tabs (tab);
|
||||
if (!bootpath)
|
||||
grub_printf ("Bootpath: unavailable\n");
|
||||
else
|
||||
grub_printf ("Bootpath: %s\n", bootpath);
|
||||
|
||||
path = grub_zfs_nvlist_lookup_string (nvlist, "path");
|
||||
print_tabs (tab);
|
||||
if (!path)
|
||||
grub_printf ("Path: unavailable\n");
|
||||
else
|
||||
grub_printf ("Path: %s\n", path);
|
||||
|
||||
devid = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_DEVID);
|
||||
print_tabs (tab);
|
||||
if (!devid)
|
||||
grub_printf ("Devid: unavailable\n");
|
||||
else
|
||||
grub_printf ("Devid: %s\n", devid);
|
||||
grub_free (bootpath);
|
||||
grub_free (devid);
|
||||
grub_free (path);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
if (grub_strcmp (type, VDEV_TYPE_MIRROR) == 0)
|
||||
{
|
||||
int nelm, i;
|
||||
|
||||
nelm = grub_zfs_nvlist_lookup_nvlist_array_get_nelm
|
||||
(nvlist, ZPOOL_CONFIG_CHILDREN);
|
||||
|
||||
print_tabs (tab);
|
||||
if (nelm <= 0)
|
||||
{
|
||||
grub_printf ("Incorrect mirror VDEV\n");
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
grub_printf ("Mirror VDEV with %d children\n", nelm);
|
||||
print_state (nvlist, tab);
|
||||
|
||||
for (i = 0; i < nelm; i++)
|
||||
{
|
||||
char *child;
|
||||
|
||||
child = grub_zfs_nvlist_lookup_nvlist_array
|
||||
(nvlist, ZPOOL_CONFIG_CHILDREN, i);
|
||||
|
||||
print_tabs (tab);
|
||||
if (!child)
|
||||
{
|
||||
grub_printf ("Mirror VDEV element %d isn't correct\n", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
grub_printf ("Mirror VDEV element %d:\n", i);
|
||||
print_vdev_info (child, tab + 1);
|
||||
|
||||
grub_free (child);
|
||||
}
|
||||
}
|
||||
|
||||
print_tabs (tab);
|
||||
grub_printf ("Unknown VDEV type: %s\n", type);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
get_bootpath (char *nvlist, char **bootpath, char **devid)
|
||||
{
|
||||
char *type = 0;
|
||||
|
||||
type = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_TYPE);
|
||||
|
||||
if (!type)
|
||||
return grub_errno;
|
||||
|
||||
if (grub_strcmp (type, VDEV_TYPE_DISK) == 0)
|
||||
{
|
||||
*bootpath = grub_zfs_nvlist_lookup_string (nvlist,
|
||||
ZPOOL_CONFIG_PHYS_PATH);
|
||||
*devid = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_DEVID);
|
||||
if (!*bootpath || !*devid)
|
||||
{
|
||||
grub_free (*bootpath);
|
||||
grub_free (*devid);
|
||||
*bootpath = 0;
|
||||
*devid = 0;
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
if (grub_strcmp (type, VDEV_TYPE_MIRROR) == 0)
|
||||
{
|
||||
int nelm, i;
|
||||
|
||||
nelm = grub_zfs_nvlist_lookup_nvlist_array_get_nelm
|
||||
(nvlist, ZPOOL_CONFIG_CHILDREN);
|
||||
|
||||
for (i = 0; i < nelm; i++)
|
||||
{
|
||||
char *child;
|
||||
|
||||
child = grub_zfs_nvlist_lookup_nvlist_array (nvlist,
|
||||
ZPOOL_CONFIG_CHILDREN,
|
||||
i);
|
||||
|
||||
get_bootpath (child, bootpath, devid);
|
||||
|
||||
grub_free (child);
|
||||
|
||||
if (*bootpath && *devid)
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static char *poolstates[] = {
|
||||
[POOL_STATE_ACTIVE] = "active",
|
||||
[POOL_STATE_EXPORTED] = "exported",
|
||||
[POOL_STATE_DESTROYED] = "destroyed",
|
||||
[POOL_STATE_SPARE] = "reserved for hot spare",
|
||||
[POOL_STATE_L2CACHE] = "level 2 ARC device",
|
||||
[POOL_STATE_UNINITIALIZED] = "uninitialized",
|
||||
[POOL_STATE_UNAVAIL] = "unavailable",
|
||||
[POOL_STATE_POTENTIALLY_ACTIVE] = "potentially active"
|
||||
};
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_zfsinfo (grub_command_t cmd __attribute__ ((unused)), int argc,
|
||||
char **args)
|
||||
{
|
||||
grub_device_t dev;
|
||||
char *devname;
|
||||
grub_err_t err;
|
||||
char *nvlist = 0;
|
||||
char *nv = 0;
|
||||
char *poolname;
|
||||
grub_uint64_t guid;
|
||||
grub_uint64_t pool_state;
|
||||
int found;
|
||||
|
||||
if (argc < 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "device name required");
|
||||
|
||||
if (args[0][0] == '(' && args[0][grub_strlen (args[0]) - 1] == ')')
|
||||
{
|
||||
devname = grub_strdup (args[0] + 1);
|
||||
if (devname)
|
||||
devname[grub_strlen (devname) - 1] = 0;
|
||||
}
|
||||
else
|
||||
devname = grub_strdup (args[0]);
|
||||
if (!devname)
|
||||
return grub_errno;
|
||||
|
||||
dev = grub_device_open (devname);
|
||||
grub_free (devname);
|
||||
if (!dev)
|
||||
return grub_errno;
|
||||
|
||||
err = grub_zfs_fetch_nvlist (dev, &nvlist);
|
||||
|
||||
grub_device_close (dev);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
poolname = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_POOL_NAME);
|
||||
if (!poolname)
|
||||
grub_printf ("Pool name: unavailable\n");
|
||||
else
|
||||
grub_printf ("Pool name: %s\n", poolname);
|
||||
|
||||
found =
|
||||
grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_GUID, &guid);
|
||||
if (!found)
|
||||
grub_printf ("Pool GUID: unavailable\n");
|
||||
else
|
||||
grub_printf ("Pool GUID: %016llx\n", (long long unsigned) guid);
|
||||
|
||||
found = grub_zfs_nvlist_lookup_uint64 (nvlist, ZPOOL_CONFIG_POOL_STATE,
|
||||
&pool_state);
|
||||
if (!found)
|
||||
grub_printf ("Unable to retrieve pool state\n");
|
||||
else if (pool_state >= ARRAY_SIZE (poolstates))
|
||||
grub_printf ("Unrecognized pool state\n");
|
||||
else
|
||||
grub_printf ("Pool state: %s\n", poolstates[pool_state]);
|
||||
|
||||
nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE);
|
||||
|
||||
if (!nv)
|
||||
grub_printf ("No vdev tree available\n");
|
||||
else
|
||||
print_vdev_info (nv, 1);
|
||||
|
||||
grub_free (nv);
|
||||
grub_free (nvlist);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_zfs_bootfs (grub_command_t cmd __attribute__ ((unused)), int argc,
|
||||
char **args)
|
||||
{
|
||||
grub_device_t dev;
|
||||
char *devname;
|
||||
grub_err_t err;
|
||||
char *nvlist = 0;
|
||||
char *nv = 0;
|
||||
char *bootpath = 0, *devid = 0;
|
||||
char *fsname;
|
||||
char *bootfs;
|
||||
char *poolname;
|
||||
grub_uint64_t mdnobj;
|
||||
|
||||
if (argc < 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "filesystem name required");
|
||||
|
||||
devname = grub_file_get_device_name (args[0]);
|
||||
if (grub_errno)
|
||||
return grub_errno;
|
||||
|
||||
dev = grub_device_open (devname);
|
||||
grub_free (devname);
|
||||
if (!dev)
|
||||
return grub_errno;
|
||||
|
||||
err = grub_zfs_fetch_nvlist (dev, &nvlist);
|
||||
|
||||
fsname = grub_strchr (args[0], ')');
|
||||
if (fsname)
|
||||
fsname++;
|
||||
else
|
||||
fsname = args[0];
|
||||
|
||||
if (!err)
|
||||
err = grub_zfs_getmdnobj (dev, fsname, &mdnobj);
|
||||
|
||||
grub_device_close (dev);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
poolname = grub_zfs_nvlist_lookup_string (nvlist, ZPOOL_CONFIG_POOL_NAME);
|
||||
if (!poolname)
|
||||
{
|
||||
if (!grub_errno)
|
||||
grub_error (GRUB_ERR_BAD_FS, "No poolname found");
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE);
|
||||
|
||||
if (nv)
|
||||
get_bootpath (nv, &bootpath, &devid);
|
||||
|
||||
grub_free (nv);
|
||||
grub_free (nvlist);
|
||||
|
||||
if (bootpath && devid)
|
||||
{
|
||||
bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu bootpath=%s diskdevid=%s",
|
||||
poolname, (unsigned long long) mdnobj,
|
||||
bootpath, devid);
|
||||
if (!bootfs)
|
||||
return grub_errno;
|
||||
}
|
||||
else
|
||||
{
|
||||
bootfs = grub_xasprintf ("zfs-bootfs=%s/%llu",
|
||||
poolname, (unsigned long long) mdnobj);
|
||||
if (!bootfs)
|
||||
return grub_errno;
|
||||
}
|
||||
if (argc >= 2)
|
||||
grub_env_set (args[1], bootfs);
|
||||
else
|
||||
grub_printf ("%s\n", bootfs);
|
||||
|
||||
grub_free (bootfs);
|
||||
grub_free (poolname);
|
||||
grub_free (bootpath);
|
||||
grub_free (devid);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
static grub_command_t cmd_info, cmd_bootfs;
|
||||
|
||||
GRUB_MOD_INIT (zfsinfo)
|
||||
{
|
||||
cmd_info = grub_register_command ("zfsinfo", grub_cmd_zfsinfo,
|
||||
"zfsinfo DEVICE",
|
||||
"Print ZFS info about DEVICE.");
|
||||
cmd_bootfs = grub_register_command ("zfs-bootfs", grub_cmd_zfs_bootfs,
|
||||
"zfs-bootfs FILESYSTEM [VARIABLE]",
|
||||
"Print ZFS-BOOTFSOBJ or set it to VARIABLE");
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI (zfsinfo)
|
||||
{
|
||||
grub_unregister_command (cmd_info);
|
||||
grub_unregister_command (cmd_bootfs);
|
||||
}
|
|
@ -35,7 +35,7 @@ deps=`grep ^$modname: $moddep | sed s@^.*:@@`
|
|||
rm -f $tmpfile $outfile
|
||||
|
||||
# stripout .modname and .moddeps sections from input module
|
||||
objcopy -R .modname -R .moddeps $infile $tmpfile
|
||||
@OBJCOPY@ -R .modname -R .moddeps $infile $tmpfile
|
||||
|
||||
# Attach .modname and .moddeps sections
|
||||
t1=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
||||
|
@ -45,9 +45,9 @@ t2=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
|
|||
for dep in $deps; do printf "$dep\0" >> $t2; done
|
||||
|
||||
if test -n "$deps"; then
|
||||
objcopy --add-section .modname=$t1 --add-section .moddeps=$t2 $tmpfile
|
||||
@OBJCOPY@ --add-section .modname=$t1 --add-section .moddeps=$t2 $tmpfile
|
||||
else
|
||||
objcopy --add-section .modname=$t1 $tmpfile
|
||||
@OBJCOPY@ --add-section .modname=$t1 $tmpfile
|
||||
fi
|
||||
rm -f $t1 $t2
|
||||
|
||||
|
|
|
@ -261,24 +261,16 @@ grub_mofile_open (const char *filename)
|
|||
return fd_mo;
|
||||
}
|
||||
|
||||
/* Returning grub_file_t would be more natural, but grub_mofile_open assigns
|
||||
to fd_mo anyway ... */
|
||||
static void
|
||||
grub_gettext_init_ext (const char *lang)
|
||||
grub_mofile_open_lang (const char *locale_dir, const char *locale)
|
||||
{
|
||||
char *mo_file;
|
||||
char *locale_dir;
|
||||
|
||||
locale_dir = grub_env_get ("locale_dir");
|
||||
if (locale_dir == NULL)
|
||||
{
|
||||
grub_dprintf ("gettext", "locale_dir variable is not set up.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fd_mo = NULL;
|
||||
|
||||
/* mo_file e.g.: /boot/grub/locale/ca.mo */
|
||||
|
||||
mo_file = grub_xasprintf ("%s/%s.mo", locale_dir, lang);
|
||||
mo_file = grub_xasprintf ("%s/%s.mo", locale_dir, locale);
|
||||
if (!mo_file)
|
||||
return;
|
||||
|
||||
|
@ -295,6 +287,38 @@ grub_gettext_init_ext (const char *lang)
|
|||
return;
|
||||
fd_mo = grub_mofile_open (mo_file);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
grub_gettext_init_ext (const char *locale)
|
||||
{
|
||||
char *locale_dir;
|
||||
|
||||
locale_dir = grub_env_get ("locale_dir");
|
||||
if (locale_dir == NULL)
|
||||
{
|
||||
grub_dprintf ("gettext", "locale_dir variable is not set up.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fd_mo = NULL;
|
||||
|
||||
grub_mofile_open_lang (locale_dir, locale);
|
||||
|
||||
/* ll_CC didn't work, so try ll. */
|
||||
if (fd_mo == NULL)
|
||||
{
|
||||
char *lang = grub_strdup (locale);
|
||||
char *underscore = grub_strchr (lang, '_');
|
||||
|
||||
if (underscore)
|
||||
{
|
||||
*underscore = '\0';
|
||||
grub_mofile_open_lang (locale_dir, lang);
|
||||
}
|
||||
|
||||
grub_free (lang);
|
||||
}
|
||||
|
||||
if (fd_mo)
|
||||
{
|
||||
|
|
|
@ -212,19 +212,18 @@ test_header (grub_file_t file)
|
|||
|
||||
gzio->data_offset = grub_file_tell (gzio->file);
|
||||
|
||||
grub_file_seek (gzio->file, grub_file_size (gzio->file) - 4);
|
||||
|
||||
if (grub_file_seekable (gzio->file))
|
||||
{
|
||||
if (grub_file_read (gzio->file, &orig_len, 4) != 4)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FILE_TYPE, "unsupported gzip format");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/* FIXME: this does not handle files whose original size is over 4GB.
|
||||
But how can we know the real original size? */
|
||||
file->size = grub_le_to_cpu32 (orig_len);
|
||||
/* FIXME: don't do this on not easily seekable files. */
|
||||
{
|
||||
grub_file_seek (gzio->file, grub_file_size (gzio->file) - 4);
|
||||
if (grub_file_read (gzio->file, &orig_len, 4) != 4)
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_FILE_TYPE, "unsupported gzip format");
|
||||
return 0;
|
||||
}
|
||||
/* FIXME: this does not handle files whose original size is over 4GB.
|
||||
But how can we know the real original size? */
|
||||
file->size = grub_le_to_cpu32 (orig_len);
|
||||
}
|
||||
|
||||
initialize_tables (file);
|
||||
|
||||
|
|
|
@ -222,7 +222,8 @@ grub_xzio_open (grub_file_t io)
|
|||
xzio->buf.out_pos = 0;
|
||||
xzio->buf.out_size = XZBUFSIZ;
|
||||
|
||||
if (!test_header (file) || !(grub_file_seekable (io) && test_footer (file)))
|
||||
/* FIXME: don't test footer on not easily seekable files. */
|
||||
if (!test_header (file) || !test_footer (file))
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_file_seek (io, 0);
|
||||
|
|
|
@ -171,11 +171,12 @@ grub_elf32_phdr_iterate (grub_elf_t elf,
|
|||
|
||||
/* Calculate the amount of memory spanned by the segments. */
|
||||
grub_size_t
|
||||
grub_elf32_size (grub_elf_t elf, Elf32_Addr *base)
|
||||
grub_elf32_size (grub_elf_t elf, Elf32_Addr *base, grub_uint32_t *max_align)
|
||||
{
|
||||
Elf32_Addr segments_start = (Elf32_Addr) -1;
|
||||
Elf32_Addr segments_end = 0;
|
||||
int nr_phdrs = 0;
|
||||
grub_uint32_t curr_align = 1;
|
||||
|
||||
/* Run through the program headers to calculate the total memory size we
|
||||
* should claim. */
|
||||
|
@ -192,6 +193,8 @@ grub_elf32_size (grub_elf_t elf, Elf32_Addr *base)
|
|||
segments_start = phdr->p_paddr;
|
||||
if (phdr->p_paddr + phdr->p_memsz > segments_end)
|
||||
segments_end = phdr->p_paddr + phdr->p_memsz;
|
||||
if (curr_align < phdr->p_align)
|
||||
curr_align = phdr->p_align;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -215,7 +218,8 @@ grub_elf32_size (grub_elf_t elf, Elf32_Addr *base)
|
|||
|
||||
if (base)
|
||||
*base = segments_start;
|
||||
|
||||
if (max_align)
|
||||
*max_align = curr_align;
|
||||
return segments_end - segments_start;
|
||||
}
|
||||
|
||||
|
@ -290,7 +294,6 @@ grub_elf32_load (grub_elf_t _elf, grub_elf32_load_hook_t _load_hook,
|
|||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 64-bit */
|
||||
|
||||
|
@ -357,16 +360,17 @@ grub_elf64_phdr_iterate (grub_elf_t elf,
|
|||
|
||||
/* Calculate the amount of memory spanned by the segments. */
|
||||
grub_size_t
|
||||
grub_elf64_size (grub_elf_t elf, Elf64_Addr *base)
|
||||
grub_elf64_size (grub_elf_t elf, Elf64_Addr *base, grub_uint64_t *max_align)
|
||||
{
|
||||
Elf64_Addr segments_start = (Elf64_Addr) -1;
|
||||
Elf64_Addr segments_end = 0;
|
||||
int nr_phdrs = 0;
|
||||
grub_uint64_t curr_align = 1;
|
||||
|
||||
/* Run through the program headers to calculate the total memory size we
|
||||
* should claim. */
|
||||
auto int NESTED_FUNC_ATTR calcsize (grub_elf_t _elf, Elf64_Phdr *phdr, void *_arg);
|
||||
int NESTED_FUNC_ATTR calcsize (grub_elf_t _elf __attribute__ ((unused)),
|
||||
int NESTED_FUNC_ATTR calcsize (grub_elf_t _elf __attribute__ ((unused)),
|
||||
Elf64_Phdr *phdr,
|
||||
void *_arg __attribute__ ((unused)))
|
||||
{
|
||||
|
@ -378,6 +382,8 @@ grub_elf64_size (grub_elf_t elf, Elf64_Addr *base)
|
|||
segments_start = phdr->p_paddr;
|
||||
if (phdr->p_paddr + phdr->p_memsz > segments_end)
|
||||
segments_end = phdr->p_paddr + phdr->p_memsz;
|
||||
if (curr_align < phdr->p_align)
|
||||
curr_align = phdr->p_align;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -401,11 +407,11 @@ grub_elf64_size (grub_elf_t elf, Elf64_Addr *base)
|
|||
|
||||
if (base)
|
||||
*base = segments_start;
|
||||
|
||||
if (max_align)
|
||||
*max_align = curr_align;
|
||||
return segments_end - segments_start;
|
||||
}
|
||||
|
||||
|
||||
/* Load every loadable segment into memory specified by `_load_hook'. */
|
||||
grub_err_t
|
||||
grub_elf64_load (grub_elf_t _elf, grub_elf64_load_hook_t _load_hook,
|
||||
|
|
|
@ -151,8 +151,6 @@ LOCAL (codestart):
|
|||
addl $(GRUB_KERNEL_MACHINE_RAW_SIZE - GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART), %edx
|
||||
movl reed_solomon_redundancy, %ecx
|
||||
leal _start + GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART, %eax
|
||||
testl %edx, %edx
|
||||
jz post_reed_solomon
|
||||
call EXT_C (grub_reed_solomon_recover)
|
||||
jmp post_reed_solomon
|
||||
|
||||
|
@ -224,6 +222,7 @@ multiboot_trampoline:
|
|||
movb $0xFF, %dh
|
||||
/* enter the usual booting */
|
||||
call prot_to_real
|
||||
jmp LOCAL (codestart)
|
||||
|
||||
post_reed_solomon:
|
||||
|
||||
|
@ -649,7 +648,7 @@ FUNCTION(grub_console_getkey)
|
|||
jae 2f
|
||||
movl %edx, %eax
|
||||
leal LOCAL(bypass_table), %edi
|
||||
movl $((LOCAL(bypass_table_end) - LOCAL(bypass_table)) / 2), %ecx
|
||||
movl $((LOCAL(bypass_table_end) - LOCAL(bypass_table)) >> 1), %ecx
|
||||
repne scasw
|
||||
jz 3f
|
||||
|
||||
|
|
|
@ -223,6 +223,8 @@ grub_halt (void)
|
|||
grub_outb (grub_inb (GRUB_CPU_LOONGSON_GPIOCFG)
|
||||
& ~GRUB_CPU_LOONGSON_SHUTDOWN_GPIO, GRUB_CPU_LOONGSON_GPIOCFG);
|
||||
|
||||
grub_millisleep (1500);
|
||||
|
||||
grub_printf ("Shutdown failed\n");
|
||||
grub_refresh ();
|
||||
while (1);
|
||||
|
@ -239,6 +241,8 @@ grub_reboot (void)
|
|||
{
|
||||
grub_write_ec (GRUB_MACHINE_EC_COMMAND_REBOOT);
|
||||
|
||||
grub_millisleep (1500);
|
||||
|
||||
grub_printf ("Reboot failed\n");
|
||||
grub_refresh ();
|
||||
while (1);
|
||||
|
|
|
@ -322,24 +322,23 @@ struct legacy_command legacy_commands[] =
|
|||
char *
|
||||
grub_legacy_escape (const char *in, grub_size_t len)
|
||||
{
|
||||
const char *ptr;
|
||||
char *ret, *outptr;
|
||||
char *ptr;
|
||||
char *ret;
|
||||
char saved;
|
||||
int overhead = 0;
|
||||
for (ptr = in; ptr < in + len && *ptr; ptr++)
|
||||
if (*ptr == '\'' || *ptr == '\\')
|
||||
overhead++;
|
||||
|
||||
for (ptr = (char*)in; ptr < in + len && *ptr; ptr++)
|
||||
if (*ptr == '\'')
|
||||
overhead += 3;
|
||||
ret = grub_malloc (ptr - in + overhead + 1);
|
||||
if (!ret)
|
||||
return NULL;
|
||||
outptr = ret;
|
||||
for (ptr = in; ptr < in + len && *ptr; ptr++)
|
||||
{
|
||||
if (*ptr == '\'' || *ptr == '\\')
|
||||
*outptr++ = '\\';
|
||||
|
||||
*outptr++ = *ptr;
|
||||
}
|
||||
*outptr++ = 0;
|
||||
|
||||
ptr = (char*)in;
|
||||
saved = ptr[len];
|
||||
ptr[len] = '\0';
|
||||
grub_strchrsub (ret, ptr, '\'', "'\\''");
|
||||
ptr[len] = saved;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -622,12 +621,13 @@ grub_legacy_parse (const char *buf, char **entryname, char **suffix)
|
|||
{
|
||||
for (; *ptr && grub_isspace (*ptr); ptr++);
|
||||
for (; *ptr && !grub_isspace (*ptr); ptr++)
|
||||
if (*ptr == '\\' || *ptr == '\'')
|
||||
overhead++;
|
||||
if (*ptr == '\'')
|
||||
overhead += 3;
|
||||
if (*ptr)
|
||||
ptr++;
|
||||
overhead += 3;
|
||||
}
|
||||
|
||||
outptr0 = args[i] = grub_malloc (overhead + (ptr - curarg));
|
||||
if (!outptr0)
|
||||
return NULL;
|
||||
|
@ -641,9 +641,15 @@ grub_legacy_parse (const char *buf, char **entryname, char **suffix)
|
|||
*outptr++ = '\'';
|
||||
for (; *ptr && !grub_isspace (*ptr); ptr++)
|
||||
{
|
||||
if (*ptr == '\\' || *ptr == '\'')
|
||||
*outptr++ = '\\';
|
||||
*outptr++ = *ptr;
|
||||
if (*ptr == '\'')
|
||||
{
|
||||
*outptr++ = '\'';
|
||||
*outptr++ = '\\';
|
||||
*outptr++ = '\'';
|
||||
*outptr++ = '\'';
|
||||
}
|
||||
else
|
||||
*outptr++ = *ptr;
|
||||
}
|
||||
*outptr++ = '\'';
|
||||
if (*ptr)
|
||||
|
|
|
@ -25,6 +25,12 @@
|
|||
#include <grub/dl.h>
|
||||
#include <grub/crypto.h>
|
||||
|
||||
#ifdef GRUB_CPU_WORDS_BIGENDIAN
|
||||
#define WORDS_BIGENDIAN
|
||||
#else
|
||||
#undef WORDS_BIGENDIAN
|
||||
#endif
|
||||
|
||||
#define __GNU_LIBRARY__
|
||||
|
||||
#define DIM ARRAY_SIZE
|
||||
|
|
|
@ -32,4 +32,10 @@ typedef grub_uint16_t uint16_t;
|
|||
typedef grub_uint32_t uint32_t;
|
||||
typedef grub_uint64_t uint64_t;
|
||||
|
||||
#ifdef GRUB_CPU_WORDS_BIGENDIAN
|
||||
#define WORDS_BIGENDIAN
|
||||
#else
|
||||
#undef WORDS_BIGENDIAN
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#ifdef TEST
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define xmalloc malloc
|
||||
#define grub_memset memset
|
||||
#define grub_memcpy memcpy
|
||||
|
@ -25,8 +27,6 @@
|
|||
|
||||
#ifndef STANDALONE
|
||||
#ifdef TEST
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
typedef unsigned int grub_size_t;
|
||||
typedef unsigned char grub_uint8_t;
|
||||
typedef unsigned short grub_uint16_t;
|
||||
|
@ -45,6 +45,7 @@ typedef unsigned char grub_uint8_t;
|
|||
typedef unsigned short grub_uint16_t;
|
||||
#else
|
||||
#include <grub/types.h>
|
||||
#include <grub/misc.h>
|
||||
#endif
|
||||
void
|
||||
grub_reed_solomon_recover (void *ptr_, grub_size_t s, grub_size_t rs);
|
||||
|
@ -59,7 +60,9 @@ typedef grub_uint16_t gf_double_t;
|
|||
static char *gf_invert __attribute__ ((section(".text"))) = (void *) 0x100000;
|
||||
static char *scratch __attribute__ ((section(".text"))) = (void *) 0x100100;
|
||||
#else
|
||||
#if defined (STANDALONE)
|
||||
static char *scratch;
|
||||
#endif
|
||||
static grub_uint8_t gf_invert[256];
|
||||
#endif
|
||||
|
||||
|
@ -207,11 +210,12 @@ gauss_solve (gf_single_t *eq, int n, int m, gf_single_t *sol)
|
|||
|
||||
#ifndef STANDALONE
|
||||
chosen = xmalloc (n * sizeof (int));
|
||||
grub_memset (chosen, -1, n * sizeof (int));
|
||||
#else
|
||||
chosen = (void *) scratch;
|
||||
scratch += n;
|
||||
scratch += n * sizeof (int);
|
||||
#endif
|
||||
for (i = 0; i < n; i++)
|
||||
chosen[i] = -1;
|
||||
for (i = 0; i < m; i++)
|
||||
sol[i] = 0;
|
||||
gauss_eliminate (eq, n, m, chosen);
|
||||
|
@ -228,7 +232,7 @@ gauss_solve (gf_single_t *eq, int n, int m, gf_single_t *sol)
|
|||
#ifndef STANDALONE
|
||||
free (chosen);
|
||||
#else
|
||||
scratch -= n;
|
||||
scratch -= n * sizeof (int);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -370,6 +374,10 @@ decode_block (gf_single_t *ptr, grub_size_t s,
|
|||
grub_size_t rr = (rs + SECTOR_SIZE - 1 - i) / SECTOR_SIZE;
|
||||
gf_single_t m[ds + rr];
|
||||
|
||||
/* Nothing to do. */
|
||||
if (!ds || !rr)
|
||||
continue;
|
||||
|
||||
for (j = 0; j < (int) ds; j++)
|
||||
m[j] = ptr[SECTOR_SIZE * j + i];
|
||||
for (j = 0; j < (int) rr; j++)
|
||||
|
@ -412,6 +420,10 @@ grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size,
|
|||
gf_single_t *ptr = buffer;
|
||||
gf_single_t *rptr = ptr + s;
|
||||
|
||||
/* Nothing to do. */
|
||||
if (!rs)
|
||||
return;
|
||||
|
||||
while (s > 0)
|
||||
{
|
||||
grub_size_t tt;
|
||||
|
@ -421,8 +433,8 @@ grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size,
|
|||
tt = cs + crs;
|
||||
if (tt > MAX_BLOCK_SIZE)
|
||||
{
|
||||
cs = (cs * MAX_BLOCK_SIZE) / tt;
|
||||
crs = (crs * MAX_BLOCK_SIZE) / tt;
|
||||
cs = ((cs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
|
||||
crs = ((crs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
|
||||
}
|
||||
encode_block (ptr, cs, rptr, crs);
|
||||
ptr += cs;
|
||||
|
@ -439,6 +451,10 @@ grub_reed_solomon_recover (void *ptr_, grub_size_t s, grub_size_t rs)
|
|||
gf_single_t *ptr = ptr_;
|
||||
gf_single_t *rptr = ptr + s;
|
||||
|
||||
/* Nothing to do. */
|
||||
if (!rs)
|
||||
return;
|
||||
|
||||
#if defined (STANDALONE)
|
||||
init_inverts ();
|
||||
#endif
|
||||
|
@ -452,8 +468,8 @@ grub_reed_solomon_recover (void *ptr_, grub_size_t s, grub_size_t rs)
|
|||
tt = cs + crs;
|
||||
if (tt > MAX_BLOCK_SIZE)
|
||||
{
|
||||
cs = cs * MAX_BLOCK_SIZE / tt;
|
||||
crs = crs * MAX_BLOCK_SIZE / tt;
|
||||
cs = ((cs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
|
||||
crs = ((crs * (MAX_BLOCK_SIZE / 512)) / tt) * 512;
|
||||
}
|
||||
decode_block (ptr, cs, rptr, crs);
|
||||
ptr += cs;
|
||||
|
@ -485,14 +501,10 @@ main (int argc, char **argv)
|
|||
fseek (in, 0, SEEK_END);
|
||||
s = ftell (in);
|
||||
fseek (in, 0, SEEK_SET);
|
||||
rs = 1024 * ((s + MAX_BLOCK_SIZE - 1) / (MAX_BLOCK_SIZE - 1024));
|
||||
rs = s / 3;
|
||||
buf = xmalloc (s + rs + SECTOR_SIZE);
|
||||
fread (buf, 1, s, in);
|
||||
|
||||
s = 0x5fbb;
|
||||
rs = 0x6af9;
|
||||
|
||||
#if 0
|
||||
grub_reed_solomon_add_redundancy (buf, s, rs);
|
||||
|
||||
out = fopen ("tst_rs.bin", "wb");
|
||||
|
@ -504,9 +516,6 @@ main (int argc, char **argv)
|
|||
out = fopen ("tst_dam.bin", "wb");
|
||||
fwrite (buf, 1, s + rs, out);
|
||||
fclose (out);
|
||||
#endif
|
||||
s = 0x5fbb;
|
||||
rs = 0x6af9;
|
||||
grub_reed_solomon_recover (buf, s, rs);
|
||||
|
||||
out = fopen ("tst_rec.bin", "wb");
|
||||
|
|
|
@ -597,7 +597,8 @@ malloc_in_range (struct grub_relocator *rel,
|
|||
events[N].hancestor = pa;
|
||||
N++;
|
||||
events[N].type = REG_BEG_END;
|
||||
events[N].pos = grub_vtop (p + p->size) - sizeof (*r);
|
||||
events[N].pos = grub_vtop (p + p->size) - sizeof (*r)
|
||||
- sizeof (struct grub_mm_header);
|
||||
N++;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -521,6 +521,8 @@ grub_netbsd_list_modules (void)
|
|||
/* This function would be here but it's under different license. */
|
||||
#include "bsd_pagetable.c"
|
||||
|
||||
static grub_uint32_t freebsd_bootdev, freebsd_biosdev;
|
||||
|
||||
static grub_err_t
|
||||
grub_freebsd_boot (void)
|
||||
{
|
||||
|
@ -528,7 +530,6 @@ grub_freebsd_boot (void)
|
|||
grub_uint8_t *p, *p0;
|
||||
grub_addr_t p_target;
|
||||
grub_size_t p_size = 0;
|
||||
grub_uint32_t bootdev, biosdev, unit, slice, part;
|
||||
grub_err_t err;
|
||||
grub_size_t tag_buf_len = 0;
|
||||
|
||||
|
@ -564,11 +565,7 @@ grub_freebsd_boot (void)
|
|||
bi.version = FREEBSD_BOOTINFO_VERSION;
|
||||
bi.length = sizeof (bi);
|
||||
|
||||
grub_bsd_get_device (&biosdev, &unit, &slice, &part);
|
||||
bootdev = (FREEBSD_B_DEVMAGIC + ((slice + 1) << FREEBSD_B_SLICESHIFT) +
|
||||
(unit << FREEBSD_B_UNITSHIFT) + (part << FREEBSD_B_PARTSHIFT));
|
||||
|
||||
bi.boot_device = biosdev;
|
||||
bi.boot_device = freebsd_biosdev;
|
||||
|
||||
p_size = 0;
|
||||
grub_env_iterate (iterate_env_count);
|
||||
|
@ -741,7 +738,7 @@ grub_freebsd_boot (void)
|
|||
state.ebp = stack_target;
|
||||
stack[0] = entry; /* "Return" address. */
|
||||
stack[1] = bootflags | FREEBSD_RB_BOOTINFO;
|
||||
stack[2] = bootdev;
|
||||
stack[2] = freebsd_bootdev;
|
||||
stack[3] = 0;
|
||||
stack[4] = 0;
|
||||
stack[5] = 0;
|
||||
|
@ -1371,6 +1368,8 @@ grub_cmd_freebsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
|
|||
|
||||
if (grub_bsd_load (argc, argv) == GRUB_ERR_NONE)
|
||||
{
|
||||
grub_uint32_t unit, slice, part;
|
||||
|
||||
kern_end = ALIGN_PAGE (kern_end);
|
||||
if (is_elf_kernel)
|
||||
{
|
||||
|
@ -1414,6 +1413,10 @@ grub_cmd_freebsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
|
|||
if (err)
|
||||
return err;
|
||||
}
|
||||
grub_bsd_get_device (&freebsd_biosdev, &unit, &slice, &part);
|
||||
freebsd_bootdev = (FREEBSD_B_DEVMAGIC + ((slice + 1) << FREEBSD_B_SLICESHIFT) +
|
||||
(unit << FREEBSD_B_UNITSHIFT) + (part << FREEBSD_B_PARTSHIFT));
|
||||
|
||||
grub_loader_set (grub_freebsd_boot, grub_bsd_unload, 0);
|
||||
}
|
||||
|
||||
|
@ -1611,7 +1614,7 @@ grub_cmd_freebsd_loadenv (grub_command_t cmd __attribute__ ((unused)),
|
|||
char *buf = 0, *curr, *next;
|
||||
int len;
|
||||
|
||||
if (kernel_type == KERNEL_TYPE_NONE)
|
||||
if (! grub_loader_is_loaded ())
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"you need to load the kernel first");
|
||||
|
||||
|
@ -1844,7 +1847,7 @@ grub_cmd_freebsd_module_elf (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_file_t file = 0;
|
||||
grub_err_t err;
|
||||
|
||||
if (kernel_type == KERNEL_TYPE_NONE)
|
||||
if (! grub_loader_is_loaded ())
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||
"you need to load the kernel first");
|
||||
|
||||
|
|
|
@ -511,7 +511,7 @@ SUFFIX(grub_openbsd_find_ramdisk) (grub_file_t file,
|
|||
grub_err_t err;
|
||||
Elf_Ehdr e;
|
||||
Elf_Shdr *s;
|
||||
char *shdr;
|
||||
char *shdr = NULL;
|
||||
|
||||
err = read_headers (file, &e, &shdr);
|
||||
if (err)
|
||||
|
|
|
@ -655,7 +655,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
|
|||
goto fail;
|
||||
}
|
||||
|
||||
params->type_of_loader = (LINUX_LOADER_ID_GRUB << 4);
|
||||
params->type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE;
|
||||
|
||||
/* These two are used (instead of cmd_line_ptr) by older versions of Linux,
|
||||
and otherwise ignored. */
|
||||
|
|
|
@ -141,7 +141,7 @@ grub_multiboot_load (grub_file_t file)
|
|||
}
|
||||
|
||||
if (header->bss_end_addr)
|
||||
grub_memset ((grub_uint32_t *) source + load_size, 0,
|
||||
grub_memset ((grub_uint8_t *) source + load_size, 0,
|
||||
header->bss_end_addr - header->load_addr - load_size);
|
||||
|
||||
grub_multiboot_payload_eip = header->entry_addr;
|
||||
|
@ -441,7 +441,7 @@ grub_multiboot_make_mbi (grub_uint32_t *target)
|
|||
if (err)
|
||||
return err;
|
||||
ptrorig = get_virtual_current_address (ch);
|
||||
ptrdest = (grub_addr_t) get_virtual_current_address (ch);
|
||||
ptrdest = get_physical_target_address (ch);
|
||||
|
||||
*target = ptrdest;
|
||||
|
||||
|
@ -641,6 +641,7 @@ grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
|
|||
return grub_errno;
|
||||
newmod->start = start;
|
||||
newmod->size = size;
|
||||
newmod->next = 0;
|
||||
|
||||
for (i = 0; i < argc; i++)
|
||||
len += grub_strlen (argv[i]) + 1;
|
||||
|
|
|
@ -91,7 +91,7 @@ grub_linux_load32 (grub_elf_t elf, void **extra_mem, grub_size_t extra_size)
|
|||
/* Linux's entry point incorrectly contains a virtual address. */
|
||||
entry_addr = elf->ehdr.ehdr32.e_entry;
|
||||
|
||||
linux_size = grub_elf32_size (elf, &base);
|
||||
linux_size = grub_elf32_size (elf, &base, 0);
|
||||
if (linux_size == 0)
|
||||
return grub_errno;
|
||||
target_addr = base;
|
||||
|
@ -146,7 +146,7 @@ grub_linux_load64 (grub_elf_t elf, void **extra_mem, grub_size_t extra_size)
|
|||
/* Linux's entry point incorrectly contains a virtual address. */
|
||||
entry_addr = elf->ehdr.ehdr64.e_entry;
|
||||
|
||||
linux_size = grub_elf64_size (elf, &base);
|
||||
linux_size = grub_elf64_size (elf, &base, 0);
|
||||
if (linux_size == 0)
|
||||
return grub_errno;
|
||||
target_addr = base;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <grub/ieee1275/ieee1275.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/memory.h>
|
||||
|
||||
#define ELF32_LOADMASK (0xc0000000UL)
|
||||
#define ELF64_LOADMASK (0xc000000000000000ULL)
|
||||
|
@ -45,6 +46,51 @@ static char *linux_args;
|
|||
typedef void (*kernel_entry_t) (void *, unsigned long, int (void *),
|
||||
unsigned long, unsigned long);
|
||||
|
||||
static grub_addr_t
|
||||
grub_linux_claimmap_iterate (grub_addr_t target, grub_size_t size,
|
||||
grub_size_t align)
|
||||
{
|
||||
grub_addr_t found_addr = (grub_addr_t) -1;
|
||||
|
||||
auto int NESTED_FUNC_ATTR alloc_mem (grub_uint64_t addr, grub_uint64_t len,
|
||||
grub_memory_type_t type);
|
||||
int NESTED_FUNC_ATTR alloc_mem (grub_uint64_t addr, grub_uint64_t len,
|
||||
grub_memory_type_t type)
|
||||
{
|
||||
grub_uint64_t end = addr + len;
|
||||
addr = ALIGN_UP (addr, align);
|
||||
target = ALIGN_UP (target, align);
|
||||
|
||||
/* Target above the memory chunk. */
|
||||
if (type != GRUB_MEMORY_AVAILABLE || target > end)
|
||||
return 0;
|
||||
|
||||
/* Target inside the memory chunk. */
|
||||
if (target >= addr && target < end && size <= end - target)
|
||||
{
|
||||
if (grub_claimmap (target, size) == GRUB_ERR_NONE)
|
||||
{
|
||||
found_addr = target;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/* Target below the memory chunk. */
|
||||
if (target < addr && addr + size <= end)
|
||||
{
|
||||
if (grub_claimmap (addr, size) == GRUB_ERR_NONE)
|
||||
{
|
||||
found_addr = addr;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_machine_mmap_iterate (alloc_mem);
|
||||
|
||||
return found_addr;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_linux_boot (void)
|
||||
{
|
||||
|
@ -102,34 +148,30 @@ grub_linux_unload (void)
|
|||
static grub_err_t
|
||||
grub_linux_load32 (grub_elf_t elf)
|
||||
{
|
||||
Elf32_Addr entry;
|
||||
int found_addr = 0;
|
||||
Elf32_Addr base_addr;
|
||||
grub_addr_t seg_addr;
|
||||
grub_uint32_t align;
|
||||
int offset;
|
||||
|
||||
/* Linux's entry point incorrectly contains a virtual address. */
|
||||
entry = elf->ehdr.ehdr32.e_entry & ~ELF32_LOADMASK;
|
||||
if (entry == 0)
|
||||
entry = 0x01400000;
|
||||
|
||||
linux_size = grub_elf32_size (elf, 0);
|
||||
linux_size = grub_elf32_size (elf, &base_addr, &align);
|
||||
if (linux_size == 0)
|
||||
return grub_errno;
|
||||
/* Pad it; the kernel scribbles over memory beyond its load address. */
|
||||
linux_size += 0x100000;
|
||||
|
||||
offset = elf->ehdr.ehdr32.e_entry - base_addr;
|
||||
/* Linux's incorrectly contains a virtual address. */
|
||||
base_addr &= ~ELF32_LOADMASK;
|
||||
|
||||
/* On some systems, firmware occupies the memory we're trying to use.
|
||||
* Happily, Linux can be loaded anywhere (it relocates itself). Iterate
|
||||
* until we find an open area. */
|
||||
for (linux_addr = entry; linux_addr < entry + 200 * 0x100000; linux_addr += 0x100000)
|
||||
{
|
||||
grub_dprintf ("loader", "Attempting to claim at 0x%x, size 0x%x.\n",
|
||||
linux_addr, linux_size);
|
||||
found_addr = grub_claimmap (linux_addr, linux_size);
|
||||
if (found_addr != -1)
|
||||
break;
|
||||
}
|
||||
if (found_addr == -1)
|
||||
seg_addr = grub_linux_claimmap_iterate (base_addr & ~ELF32_LOADMASK, linux_size, align);
|
||||
if (seg_addr == (grub_addr_t) -1)
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't claim memory");
|
||||
|
||||
linux_addr = seg_addr + offset;
|
||||
|
||||
/* Now load the segments into the area we claimed. */
|
||||
auto grub_err_t offset_phdr (Elf32_Phdr *phdr, grub_addr_t *addr, int *do_load);
|
||||
grub_err_t offset_phdr (Elf32_Phdr *phdr, grub_addr_t *addr, int *do_load)
|
||||
|
@ -141,9 +183,7 @@ grub_linux_load32 (grub_elf_t elf)
|
|||
}
|
||||
*do_load = 1;
|
||||
|
||||
/* Linux's program headers incorrectly contain virtual addresses.
|
||||
* Translate those to physical, and offset to the area we claimed. */
|
||||
*addr = (phdr->p_paddr & ~ELF32_LOADMASK) + linux_addr;
|
||||
*addr = (phdr->p_paddr - base_addr) + seg_addr;
|
||||
return 0;
|
||||
}
|
||||
return grub_elf32_load (elf, offset_phdr, 0, 0);
|
||||
|
@ -152,34 +192,30 @@ grub_linux_load32 (grub_elf_t elf)
|
|||
static grub_err_t
|
||||
grub_linux_load64 (grub_elf_t elf)
|
||||
{
|
||||
Elf64_Addr entry;
|
||||
int found_addr = 0;
|
||||
Elf64_Addr base_addr;
|
||||
grub_addr_t seg_addr;
|
||||
grub_uint64_t align;
|
||||
int offset;
|
||||
|
||||
/* Linux's entry point incorrectly contains a virtual address. */
|
||||
entry = elf->ehdr.ehdr64.e_entry & ~ELF64_LOADMASK;
|
||||
if (entry == 0)
|
||||
entry = 0x01400000;
|
||||
|
||||
linux_size = grub_elf64_size (elf, 0);
|
||||
linux_size = grub_elf64_size (elf, &base_addr, &align);
|
||||
if (linux_size == 0)
|
||||
return grub_errno;
|
||||
/* Pad it; the kernel scribbles over memory beyond its load address. */
|
||||
linux_size += 0x100000;
|
||||
|
||||
offset = elf->ehdr.ehdr64.e_entry - base_addr;
|
||||
/* Linux's incorrectly contains a virtual address. */
|
||||
base_addr &= ~ELF64_LOADMASK;
|
||||
|
||||
/* On some systems, firmware occupies the memory we're trying to use.
|
||||
* Happily, Linux can be loaded anywhere (it relocates itself). Iterate
|
||||
* until we find an open area. */
|
||||
for (linux_addr = entry; linux_addr < entry + 200 * 0x100000; linux_addr += 0x100000)
|
||||
{
|
||||
grub_dprintf ("loader", "Attempting to claim at 0x%x, size 0x%x.\n",
|
||||
linux_addr, linux_size);
|
||||
found_addr = grub_claimmap (linux_addr, linux_size);
|
||||
if (found_addr != -1)
|
||||
break;
|
||||
}
|
||||
if (found_addr == -1)
|
||||
seg_addr = grub_linux_claimmap_iterate (base_addr & ~ELF64_LOADMASK, linux_size, align);
|
||||
if (seg_addr == (grub_addr_t) -1)
|
||||
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "couldn't claim memory");
|
||||
|
||||
linux_addr = seg_addr + offset;
|
||||
|
||||
/* Now load the segments into the area we claimed. */
|
||||
auto grub_err_t offset_phdr (Elf64_Phdr *phdr, grub_addr_t *addr, int *do_load);
|
||||
grub_err_t offset_phdr (Elf64_Phdr *phdr, grub_addr_t *addr, int *do_load)
|
||||
|
@ -190,9 +226,8 @@ grub_linux_load64 (grub_elf_t elf)
|
|||
return 0;
|
||||
}
|
||||
*do_load = 1;
|
||||
/* Linux's program headers incorrectly contain virtual addresses.
|
||||
* Translate those to physical, and offset to the area we claimed. */
|
||||
*addr = (phdr->p_paddr & ~ELF64_LOADMASK) + linux_addr;
|
||||
|
||||
*addr = (phdr->p_paddr - base_addr) + seg_addr;
|
||||
return 0;
|
||||
}
|
||||
return grub_elf64_load (elf, offset_phdr, 0, 0);
|
||||
|
@ -287,7 +322,6 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
grub_ssize_t size;
|
||||
grub_addr_t first_addr;
|
||||
grub_addr_t addr;
|
||||
int found_addr = 0;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
|
@ -311,20 +345,9 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
|
|||
|
||||
/* Attempt to claim at a series of addresses until successful in
|
||||
the same way that grub_rescue_cmd_linux does. */
|
||||
for (addr = first_addr; addr < first_addr + 200 * 0x100000; addr += 0x100000)
|
||||
{
|
||||
grub_dprintf ("loader", "Attempting to claim at 0x%x, size 0x%x.\n",
|
||||
addr, size);
|
||||
found_addr = grub_claimmap (addr, size);
|
||||
if (found_addr != -1)
|
||||
break;
|
||||
}
|
||||
|
||||
if (found_addr == -1)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot claim memory");
|
||||
goto fail;
|
||||
}
|
||||
addr = grub_linux_claimmap_iterate (first_addr, size, 0x100000);
|
||||
if (addr == (grub_addr_t) -1)
|
||||
goto fail;
|
||||
|
||||
grub_dprintf ("loader", "Loading initrd at 0x%x, size 0x%x\n", addr, size);
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ grub_linux_load64 (grub_elf_t elf)
|
|||
linux_entry = elf->ehdr.ehdr64.e_entry;
|
||||
linux_addr = 0x40004000;
|
||||
off = 0x4000;
|
||||
linux_size = grub_elf64_size (elf, 0);
|
||||
linux_size = grub_elf64_size (elf, 0, 0);
|
||||
if (linux_size == 0)
|
||||
return grub_errno;
|
||||
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
#include <grub/env.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
#if defined (__i386) && !defined (GRUB_MACHINE_EFI)
|
||||
#include <grub/autoefi.h>
|
||||
#endif
|
||||
|
||||
struct grub_xnu_devtree_key *grub_xnu_devtree_root = 0;
|
||||
static int driverspackagenum = 0;
|
||||
static int driversnum = 0;
|
||||
|
@ -424,6 +428,12 @@ grub_cmd_xnu_kernel (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (ptr != grub_xnu_cmdline)
|
||||
*(ptr - 1) = 0;
|
||||
|
||||
#if defined (__i386) && !defined (GRUB_MACHINE_EFI)
|
||||
err = grub_efiemu_autocore ();
|
||||
if (err)
|
||||
return err;
|
||||
#endif
|
||||
|
||||
grub_loader_set (grub_xnu_boot, grub_xnu_unload, 0);
|
||||
|
||||
grub_xnu_lock ();
|
||||
|
@ -529,6 +539,12 @@ grub_cmd_xnu_kernel64 (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (ptr != grub_xnu_cmdline)
|
||||
*(ptr - 1) = 0;
|
||||
|
||||
#if defined (__i386) && !defined (GRUB_MACHINE_EFI)
|
||||
err = grub_efiemu_autocore ();
|
||||
if (err)
|
||||
return err;
|
||||
#endif
|
||||
|
||||
grub_loader_set (grub_xnu_boot, grub_xnu_unload, 0);
|
||||
|
||||
grub_xnu_lock ();
|
||||
|
@ -1198,6 +1214,10 @@ grub_cmd_xnu_kext (grub_command_t cmd __attribute__ ((unused)),
|
|||
int argc, char *args[])
|
||||
{
|
||||
grub_file_t binfile = 0;
|
||||
|
||||
if (! grub_xnu_heap_size)
|
||||
return grub_error (GRUB_ERR_BAD_OS, "no xnu kernel loaded");
|
||||
|
||||
if (argc == 2)
|
||||
{
|
||||
/* User explicitly specified plist and binary. */
|
||||
|
@ -1229,6 +1249,9 @@ grub_cmd_xnu_kextdir (grub_command_t cmd __attribute__ ((unused)),
|
|||
if (argc != 1 && argc != 2)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "directory name required");
|
||||
|
||||
if (! grub_xnu_heap_size)
|
||||
return grub_error (GRUB_ERR_BAD_OS, "no xnu kernel loaded");
|
||||
|
||||
if (argc == 1)
|
||||
return grub_xnu_scan_dir_for_kexts (args[0],
|
||||
"console,root,local-root,network-root",
|
||||
|
@ -1370,6 +1393,9 @@ grub_cmd_xnu_splash (grub_extcmd_context_t ctxt,
|
|||
if (argc != 1)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
|
||||
|
||||
if (! grub_xnu_heap_size)
|
||||
return grub_error (GRUB_ERR_BAD_OS, "no xnu kernel loaded");
|
||||
|
||||
if (ctxt->state[XNU_SPLASH_CMD_ARGINDEX_MODE].set &&
|
||||
grub_strcmp (ctxt->state[XNU_SPLASH_CMD_ARGINDEX_MODE].arg,
|
||||
"stretch") == 0)
|
||||
|
|
|
@ -113,16 +113,6 @@ grub_utf8_to_utf16 (grub_uint16_t *dest, grub_size_t destsize,
|
|||
count = 3;
|
||||
code = c & GRUB_UINT8_3_TRAILINGBITS;
|
||||
}
|
||||
else if ((c & GRUB_UINT8_6_LEADINGBITS) == GRUB_UINT8_5_LEADINGBITS)
|
||||
{
|
||||
count = 4;
|
||||
code = c & GRUB_UINT8_2_TRAILINGBITS;
|
||||
}
|
||||
else if ((c & GRUB_UINT8_7_LEADINGBITS) == GRUB_UINT8_6_LEADINGBITS)
|
||||
{
|
||||
count = 5;
|
||||
code = c & GRUB_UINT8_1_TRAILINGBIT;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
@ -177,7 +167,7 @@ grub_ucs4_to_utf8 (grub_uint32_t *src, grub_size_t size,
|
|||
/* No surrogates in UCS-4... */
|
||||
*dest++ = '?';
|
||||
}
|
||||
else
|
||||
else if (code < 0x10000)
|
||||
{
|
||||
if (dest + 2 >= destend)
|
||||
break;
|
||||
|
@ -185,6 +175,15 @@ grub_ucs4_to_utf8 (grub_uint32_t *src, grub_size_t size,
|
|||
*dest++ = ((code >> 6) & 0x3F) | 0x80;
|
||||
*dest++ = (code & 0x3F) | 0x80;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dest + 3 >= destend)
|
||||
break;
|
||||
*dest++ = (code >> 18) | 0xF0;
|
||||
*dest++ = ((code >> 12) & 0x3F) | 0x80;
|
||||
*dest++ = ((code >> 6) & 0x3F) | 0x80;
|
||||
*dest++ = (code & 0x3F) | 0x80;
|
||||
}
|
||||
}
|
||||
*dest = 0;
|
||||
}
|
||||
|
@ -212,8 +211,10 @@ grub_ucs4_to_utf8_alloc (grub_uint32_t *src, grub_size_t size)
|
|||
|| (code >= 0xD800 && code <= 0xDBFF))
|
||||
/* No surrogates in UCS-4... */
|
||||
cnt++;
|
||||
else
|
||||
else if (code < 0x10000)
|
||||
cnt += 3;
|
||||
else
|
||||
cnt += 4;
|
||||
}
|
||||
cnt++;
|
||||
|
||||
|
@ -273,16 +274,6 @@ grub_is_valid_utf8 (const grub_uint8_t *src, grub_size_t srcsize)
|
|||
count = 3;
|
||||
code = c & 0x07;
|
||||
}
|
||||
else if ((c & 0xfc) == 0xf8)
|
||||
{
|
||||
count = 4;
|
||||
code = c & 0x03;
|
||||
}
|
||||
else if ((c & 0xfe) == 0xfc)
|
||||
{
|
||||
count = 5;
|
||||
code = c & 0x01;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
@ -375,16 +366,6 @@ grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize,
|
|||
count = 3;
|
||||
code = c & 0x07;
|
||||
}
|
||||
else if ((c & 0xfc) == 0xf8)
|
||||
{
|
||||
count = 4;
|
||||
code = c & 0x03;
|
||||
}
|
||||
else if ((c & 0xfe) == 0xfc)
|
||||
{
|
||||
count = 5;
|
||||
code = c & 0x01;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* invalid */
|
||||
|
|
|
@ -172,7 +172,7 @@ static void
|
|||
print_up (int flag, struct per_term_screen *term_screen)
|
||||
{
|
||||
grub_term_gotoxy (term_screen->term, GRUB_TERM_LEFT_BORDER_X
|
||||
+ grub_term_entry_width (term_screen->term),
|
||||
+ grub_term_border_width (term_screen->term),
|
||||
GRUB_TERM_FIRST_ENTRY_Y);
|
||||
|
||||
if (flag)
|
||||
|
@ -1163,37 +1163,35 @@ clear_completions_all (struct screen *screen)
|
|||
static int
|
||||
run (struct screen *screen)
|
||||
{
|
||||
int currline = 0;
|
||||
char *nextline;
|
||||
char *script;
|
||||
int errs_before;
|
||||
grub_menu_t menu;
|
||||
char *dummy[1] = { NULL };
|
||||
|
||||
auto grub_err_t editor_getline (char **line, int cont);
|
||||
grub_err_t editor_getline (char **line, int cont __attribute__ ((unused)))
|
||||
{
|
||||
struct line *linep = screen->lines + currline;
|
||||
char *p;
|
||||
auto char * editor_getsource (void);
|
||||
char * editor_getsource (void)
|
||||
{
|
||||
int i;
|
||||
int size = 0;
|
||||
char *source;
|
||||
|
||||
if (currline > screen->num_lines)
|
||||
{
|
||||
*line = 0;
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < screen->num_lines; i++)
|
||||
size += screen->lines[i].len + 1;
|
||||
|
||||
/* Trim down space characters. */
|
||||
for (p = linep->buf + linep->len - 1;
|
||||
p >= linep->buf && grub_isspace (*p);
|
||||
p--)
|
||||
;
|
||||
*++p = '\0';
|
||||
source = grub_malloc (size + 1);
|
||||
if (! source)
|
||||
return NULL;
|
||||
|
||||
linep->len = p - linep->buf;
|
||||
for (p = linep->buf; grub_isspace (*p); p++)
|
||||
;
|
||||
*line = grub_strdup (p);
|
||||
currline++;
|
||||
return 0;
|
||||
}
|
||||
size = 0;
|
||||
for (i = 0; i < screen->num_lines; i++)
|
||||
{
|
||||
grub_strcpy (source + size, screen->lines[i].buf);
|
||||
size += screen->lines[i].len;
|
||||
source[size++] = '\n';
|
||||
}
|
||||
source[size] = '\0';
|
||||
return source;
|
||||
}
|
||||
|
||||
grub_cls ();
|
||||
grub_printf (" ");
|
||||
|
@ -1212,12 +1210,11 @@ run (struct screen *screen)
|
|||
}
|
||||
|
||||
/* Execute the script, line for line. */
|
||||
while (currline < screen->num_lines)
|
||||
{
|
||||
editor_getline (&nextline, 0);
|
||||
if (grub_normal_parse_line (nextline, editor_getline))
|
||||
break;
|
||||
}
|
||||
script = editor_getsource ();
|
||||
if (! script)
|
||||
return 0;
|
||||
grub_script_execute_sourcecode (script, 0, dummy);
|
||||
grub_free (script);
|
||||
|
||||
if (errs_before != grub_err_printed_errors)
|
||||
grub_wait_after_message ();
|
||||
|
|
|
@ -91,16 +91,16 @@ print_more (void)
|
|||
grub_term_restore_pos (pos);
|
||||
grub_free (pos);
|
||||
|
||||
/* Scroll one lines or an entire page, depending on the key. */
|
||||
/* Scroll one line or an entire page, depending on the key. */
|
||||
|
||||
if (key == '\r' || key =='\n')
|
||||
grub_normal_reset_more ();
|
||||
else
|
||||
{
|
||||
static struct term_state *state;
|
||||
for (state = term_states; state; state = state->next)
|
||||
state->num_lines -= 2;
|
||||
state->num_lines--;
|
||||
}
|
||||
else
|
||||
grub_normal_reset_more ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -27,6 +27,7 @@ struct grub_amiga_rdsk
|
|||
{
|
||||
/* "RDSK". */
|
||||
grub_uint8_t magic[4];
|
||||
#define GRUB_AMIGA_RDSK_MAGIC "RDSK"
|
||||
grub_uint32_t size;
|
||||
grub_int32_t checksum;
|
||||
grub_uint32_t scsihost;
|
||||
|
@ -43,6 +44,7 @@ struct grub_amiga_partition
|
|||
{
|
||||
/* "PART". */
|
||||
grub_uint8_t magic[4];
|
||||
#define GRUB_AMIGA_PART_MAGIC "PART"
|
||||
grub_int32_t size;
|
||||
grub_int32_t checksum;
|
||||
grub_uint32_t scsihost;
|
||||
|
@ -87,7 +89,8 @@ amiga_partition_map_iterate (grub_disk_t disk,
|
|||
if (grub_disk_read (disk, pos, 0, sizeof (rdsk), &rdsk))
|
||||
return grub_errno;
|
||||
|
||||
if (grub_strcmp ((char *) rdsk.magic, "RDSK") == 0)
|
||||
if (grub_memcmp (rdsk.magic, GRUB_AMIGA_RDSK_MAGIC,
|
||||
sizeof (rdsk.magic)) == 0)
|
||||
{
|
||||
/* Found the first PART block. */
|
||||
next = grub_be_to_cpu32 (rdsk.partitionlst);
|
||||
|
@ -108,6 +111,9 @@ amiga_partition_map_iterate (grub_disk_t disk,
|
|||
if (grub_disk_read (disk, next, 0, sizeof (apart), &apart))
|
||||
return grub_errno;
|
||||
|
||||
if (grub_memcmp (apart.magic, GRUB_AMIGA_PART_MAGIC,
|
||||
sizeof (apart.magic)) == 0)
|
||||
|
||||
/* Calculate the first block and the size of the partition. */
|
||||
part.start = (grub_be_to_cpu32 (apart.lowcyl)
|
||||
* grub_be_to_cpu32 (apart.heads)
|
||||
|
|
|
@ -257,6 +257,8 @@ grub_keyboard_controller_write (grub_uint8_t c)
|
|||
grub_outb (c, KEYBOARD_REG_DATA);
|
||||
}
|
||||
|
||||
#if !defined (GRUB_MACHINE_MIPS_YEELOONG) && !defined (GRUB_MACHINE_QEMU)
|
||||
|
||||
static grub_uint8_t
|
||||
grub_keyboard_controller_read (void)
|
||||
{
|
||||
|
@ -265,6 +267,8 @@ grub_keyboard_controller_read (void)
|
|||
return grub_inb (KEYBOARD_REG_DATA);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int
|
||||
write_mode (int mode)
|
||||
{
|
||||
|
@ -558,8 +562,13 @@ grub_keyboard_controller_init (struct grub_term_input *term __attribute__ ((unus
|
|||
keyboard_controller_wait_until_ready ();
|
||||
grub_inb (KEYBOARD_REG_DATA);
|
||||
}
|
||||
#if defined (GRUB_MACHINE_MIPS_YEELOONG) || defined (GRUB_MACHINE_QEMU)
|
||||
grub_keyboard_controller_orig = 0;
|
||||
grub_keyboard_orig_set = 2;
|
||||
#else
|
||||
grub_keyboard_controller_orig = grub_keyboard_controller_read ();
|
||||
grub_keyboard_orig_set = query_mode ();
|
||||
#endif
|
||||
set_scancodes ();
|
||||
keyboard_controller_led (led_status);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2007, 2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2007, 2008, 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -27,18 +27,18 @@
|
|||
|
||||
static int grub_curr_x, grub_curr_y;
|
||||
|
||||
#define VGA_TEXT_SCREEN 0xb8000
|
||||
#define VGA_TEXT_SCREEN ((grub_uint16_t *) 0xb8000)
|
||||
|
||||
static void
|
||||
screen_write_char (int x, int y, short c)
|
||||
{
|
||||
((short *) VGA_TEXT_SCREEN)[y * COLS + x] = c;
|
||||
VGA_TEXT_SCREEN[y * COLS + x] = c;
|
||||
}
|
||||
|
||||
static short
|
||||
screen_read_char (int x, int y)
|
||||
{
|
||||
return ((short *) VGA_TEXT_SCREEN)[y * COLS + x];
|
||||
return VGA_TEXT_SCREEN[y * COLS + x];
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -120,7 +120,7 @@ grub_vga_text_cls (struct grub_term_output *term)
|
|||
{
|
||||
int i;
|
||||
for (i = 0; i < ROWS * COLS; i++)
|
||||
((short *) VGA_TEXT_SCREEN)[i] = ' ' | (grub_console_cur_color << 8);
|
||||
VGA_TEXT_SCREEN[i] = ' ' | (grub_console_cur_color << 8);
|
||||
grub_vga_text_gotoxy (term, 0, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -97,12 +97,19 @@ grub_utf16_to_utf8 (grub_uint8_t *dest, grub_uint16_t *src,
|
|||
/* Error... */
|
||||
*dest++ = '?';
|
||||
}
|
||||
else
|
||||
else if (code < 0x10000)
|
||||
{
|
||||
*dest++ = (code >> 12) | 0xE0;
|
||||
*dest++ = ((code >> 6) & 0x3F) | 0x80;
|
||||
*dest++ = (code & 0x3F) | 0x80;
|
||||
}
|
||||
else
|
||||
{
|
||||
*dest++ = (code >> 18) | 0xF0;
|
||||
*dest++ = ((code >> 12) & 0x3F) | 0x80;
|
||||
*dest++ = ((code >> 6) & 0x3F) | 0x80;
|
||||
*dest++ = (code & 0x3F) | 0x80;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,12 +46,12 @@ grub_elf_t grub_elf_file (grub_file_t);
|
|||
grub_err_t grub_elf_close (grub_elf_t);
|
||||
|
||||
int grub_elf_is_elf32 (grub_elf_t);
|
||||
grub_size_t grub_elf32_size (grub_elf_t, Elf32_Addr *);
|
||||
grub_size_t grub_elf32_size (grub_elf_t, Elf32_Addr *, grub_uint32_t *);
|
||||
grub_err_t grub_elf32_load (grub_elf_t, grub_elf32_load_hook_t, grub_addr_t *,
|
||||
grub_size_t *);
|
||||
|
||||
int grub_elf_is_elf64 (grub_elf_t);
|
||||
grub_size_t grub_elf64_size (grub_elf_t, Elf64_Addr *);
|
||||
grub_size_t grub_elf64_size (grub_elf_t, Elf64_Addr *, grub_uint64_t *);
|
||||
grub_err_t grub_elf64_load (grub_elf_t, grub_elf64_load_hook_t, grub_addr_t *,
|
||||
grub_size_t *);
|
||||
grub_err_t
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef struct grub_gpt_part_type grub_gpt_part_type_t;
|
|||
}
|
||||
|
||||
#define GRUB_GPT_PARTITION_TYPE_BIOS_BOOT \
|
||||
{ grub_cpu_to_le32 (0x21686148), grub_cpu_to_le16 (0x6449), grub_cpu_to_le16 (0x6e6f), \
|
||||
{ grub_cpu_to_le32_compile_time (0x21686148), grub_cpu_to_le16_compile_time (0x6449), grub_cpu_to_le16_compile_time (0x6e6f), \
|
||||
{ 0x74, 0x4e, 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 } \
|
||||
}
|
||||
|
||||
|
|
|
@ -193,6 +193,26 @@ grub_strncasecmp (const char *s1, const char *s2, grub_size_t n)
|
|||
return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
|
||||
}
|
||||
|
||||
/* Replace all `ch' characters of `input' with `with' and copy the
|
||||
result into `output'; return EOS address of `output'. */
|
||||
static inline char *
|
||||
grub_strchrsub (char *output, const char *input, char ch, const char *with)
|
||||
{
|
||||
grub_size_t grub_strlen (const char *s);
|
||||
while (*input)
|
||||
{
|
||||
if (*input == ch)
|
||||
{
|
||||
grub_strcpy (output, with);
|
||||
output += grub_strlen (with);
|
||||
input++;
|
||||
continue;
|
||||
}
|
||||
*output++ = *input++;
|
||||
}
|
||||
*output = '\0';
|
||||
return output;
|
||||
}
|
||||
|
||||
unsigned long EXPORT_FUNC(grub_strtoul) (const char *str, char **end, int base);
|
||||
unsigned long long EXPORT_FUNC(grub_strtoull) (const char *str, char **end, int base);
|
||||
|
|
|
@ -38,9 +38,9 @@
|
|||
#define GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY 0x1c
|
||||
|
||||
/* The size of the first region which won't be compressed. */
|
||||
#define GRUB_KERNEL_I386_PC_RAW_SIZE 0xc90
|
||||
#define GRUB_KERNEL_I386_PC_RAW_SIZE 0xca4
|
||||
|
||||
#define GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART 0x6f8
|
||||
#define GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_PART 0x70c
|
||||
|
||||
/* The offset of GRUB_PREFIX. */
|
||||
#define GRUB_KERNEL_I386_PC_PREFIX GRUB_KERNEL_I386_PC_RAW_SIZE
|
||||
|
|
|
@ -146,6 +146,9 @@ typedef grub_uint64_t grub_disk_addr_t;
|
|||
(grub_uint16_t) ((_x << 8) | (_x >> 8)); \
|
||||
})
|
||||
|
||||
#define grub_swap_bytes16_compile_time(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8))
|
||||
#define grub_swap_bytes32_compile_time(x) ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000UL) >> 24))
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 3) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3)
|
||||
static inline grub_uint32_t grub_swap_bytes32(grub_uint32_t x)
|
||||
{
|
||||
|
@ -193,6 +196,8 @@ static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t x)
|
|||
# define grub_be_to_cpu16(x) ((grub_uint16_t) (x))
|
||||
# define grub_be_to_cpu32(x) ((grub_uint32_t) (x))
|
||||
# define grub_be_to_cpu64(x) ((grub_uint64_t) (x))
|
||||
# define grub_cpu_to_le32_compile_time(x) grub_swap_bytes32_compile_time(x)
|
||||
# define grub_cpu_to_le16_compile_time(x) grub_swap_bytes16_compile_time(x)
|
||||
#else /* ! WORDS_BIGENDIAN */
|
||||
# define grub_cpu_to_le16(x) ((grub_uint16_t) (x))
|
||||
# define grub_cpu_to_le32(x) ((grub_uint32_t) (x))
|
||||
|
@ -206,6 +211,8 @@ static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t x)
|
|||
# define grub_be_to_cpu16(x) grub_swap_bytes16(x)
|
||||
# define grub_be_to_cpu32(x) grub_swap_bytes32(x)
|
||||
# define grub_be_to_cpu64(x) grub_swap_bytes64(x)
|
||||
# define grub_cpu_to_le16_compile_time(x) ((grub_uint16_t) (x))
|
||||
# define grub_cpu_to_le32_compile_time(x) ((grub_uint32_t) (x))
|
||||
#endif /* ! WORDS_BIGENDIAN */
|
||||
|
||||
#endif /* ! GRUB_TYPES_HEADER */
|
||||
|
|
119
include/grub/zfs/dmu.h
Normal file
119
include/grub/zfs/dmu.h
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_DMU_H
|
||||
#define _SYS_DMU_H
|
||||
|
||||
/*
|
||||
* This file describes the interface that the DMU provides for its
|
||||
* consumers.
|
||||
*
|
||||
* The DMU also interacts with the SPA. That interface is described in
|
||||
* dmu_spa.h.
|
||||
*/
|
||||
typedef enum dmu_object_type {
|
||||
DMU_OT_NONE,
|
||||
/* general: */
|
||||
DMU_OT_OBJECT_DIRECTORY, /* ZAP */
|
||||
DMU_OT_OBJECT_ARRAY, /* UINT64 */
|
||||
DMU_OT_PACKED_NVLIST, /* UINT8 (XDR by nvlist_pack/unpack) */
|
||||
DMU_OT_PACKED_NVLIST_SIZE, /* UINT64 */
|
||||
DMU_OT_BPLIST, /* UINT64 */
|
||||
DMU_OT_BPLIST_HDR, /* UINT64 */
|
||||
/* spa: */
|
||||
DMU_OT_SPACE_MAP_HEADER, /* UINT64 */
|
||||
DMU_OT_SPACE_MAP, /* UINT64 */
|
||||
/* zil: */
|
||||
DMU_OT_INTENT_LOG, /* UINT64 */
|
||||
/* dmu: */
|
||||
DMU_OT_DNODE, /* DNODE */
|
||||
DMU_OT_OBJSET, /* OBJSET */
|
||||
/* dsl: */
|
||||
DMU_OT_DSL_DIR, /* UINT64 */
|
||||
DMU_OT_DSL_DIR_CHILD_MAP, /* ZAP */
|
||||
DMU_OT_DSL_DS_SNAP_MAP, /* ZAP */
|
||||
DMU_OT_DSL_PROPS, /* ZAP */
|
||||
DMU_OT_DSL_DATASET, /* UINT64 */
|
||||
/* zpl: */
|
||||
DMU_OT_ZNODE, /* ZNODE */
|
||||
DMU_OT_OLDACL, /* OLD ACL */
|
||||
DMU_OT_PLAIN_FILE_CONTENTS, /* UINT8 */
|
||||
DMU_OT_DIRECTORY_CONTENTS, /* ZAP */
|
||||
DMU_OT_MASTER_NODE, /* ZAP */
|
||||
DMU_OT_UNLINKED_SET, /* ZAP */
|
||||
/* zvol: */
|
||||
DMU_OT_ZVOL, /* UINT8 */
|
||||
DMU_OT_ZVOL_PROP, /* ZAP */
|
||||
/* other; for testing only! */
|
||||
DMU_OT_PLAIN_OTHER, /* UINT8 */
|
||||
DMU_OT_UINT64_OTHER, /* UINT64 */
|
||||
DMU_OT_ZAP_OTHER, /* ZAP */
|
||||
/* new object types: */
|
||||
DMU_OT_ERROR_LOG, /* ZAP */
|
||||
DMU_OT_SPA_HISTORY, /* UINT8 */
|
||||
DMU_OT_SPA_HISTORY_OFFSETS, /* spa_his_phys_t */
|
||||
DMU_OT_POOL_PROPS, /* ZAP */
|
||||
DMU_OT_DSL_PERMS, /* ZAP */
|
||||
DMU_OT_ACL, /* ACL */
|
||||
DMU_OT_SYSACL, /* SYSACL */
|
||||
DMU_OT_FUID, /* FUID table (Packed NVLIST UINT8) */
|
||||
DMU_OT_FUID_SIZE, /* FUID table size UINT64 */
|
||||
DMU_OT_NEXT_CLONES, /* ZAP */
|
||||
DMU_OT_SCRUB_QUEUE, /* ZAP */
|
||||
DMU_OT_USERGROUP_USED, /* ZAP */
|
||||
DMU_OT_USERGROUP_QUOTA, /* ZAP */
|
||||
DMU_OT_USERREFS, /* ZAP */
|
||||
DMU_OT_DDT_ZAP, /* ZAP */
|
||||
DMU_OT_DDT_STATS, /* ZAP */
|
||||
DMU_OT_SA, /* System attr */
|
||||
DMU_OT_SA_MASTER_NODE, /* ZAP */
|
||||
DMU_OT_SA_ATTR_REGISTRATION, /* ZAP */
|
||||
DMU_OT_SA_ATTR_LAYOUTS, /* ZAP */
|
||||
DMU_OT_NUMTYPES
|
||||
} dmu_object_type_t;
|
||||
|
||||
typedef enum dmu_objset_type {
|
||||
DMU_OST_NONE,
|
||||
DMU_OST_META,
|
||||
DMU_OST_ZFS,
|
||||
DMU_OST_ZVOL,
|
||||
DMU_OST_OTHER, /* For testing only! */
|
||||
DMU_OST_ANY, /* Be careful! */
|
||||
DMU_OST_NUMTYPES
|
||||
} dmu_objset_type_t;
|
||||
|
||||
/*
|
||||
* The names of zap entries in the DIRECTORY_OBJECT of the MOS.
|
||||
*/
|
||||
#define DMU_POOL_DIRECTORY_OBJECT 1
|
||||
#define DMU_POOL_CONFIG "config"
|
||||
#define DMU_POOL_ROOT_DATASET "root_dataset"
|
||||
#define DMU_POOL_SYNC_BPLIST "sync_bplist"
|
||||
#define DMU_POOL_ERRLOG_SCRUB "errlog_scrub"
|
||||
#define DMU_POOL_ERRLOG_LAST "errlog_last"
|
||||
#define DMU_POOL_SPARES "spares"
|
||||
#define DMU_POOL_DEFLATE "deflate"
|
||||
#define DMU_POOL_HISTORY "history"
|
||||
#define DMU_POOL_PROPS "pool_props"
|
||||
#define DMU_POOL_L2CACHE "l2cache"
|
||||
|
||||
#endif /* _SYS_DMU_H */
|
43
include/grub/zfs/dmu_objset.h
Normal file
43
include/grub/zfs/dmu_objset.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2010 Robert Millan <rmh@gnu.org>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_DMU_OBJSET_H
|
||||
#define _SYS_DMU_OBJSET_H
|
||||
|
||||
#include <grub/zfs/zil.h>
|
||||
|
||||
#define OBJSET_PHYS_SIZE 2048
|
||||
#define OBJSET_PHYS_SIZE_V14 1024
|
||||
|
||||
typedef struct objset_phys {
|
||||
dnode_phys_t os_meta_dnode;
|
||||
zil_header_t os_zil_header;
|
||||
grub_uint64_t os_type;
|
||||
grub_uint64_t os_flags;
|
||||
char os_pad[OBJSET_PHYS_SIZE - sizeof (dnode_phys_t)*3 -
|
||||
sizeof (zil_header_t) - sizeof (grub_uint64_t)*2];
|
||||
dnode_phys_t os_userused_dnode;
|
||||
dnode_phys_t os_groupused_dnode;
|
||||
} objset_phys_t;
|
||||
|
||||
#endif /* _SYS_DMU_OBJSET_H */
|
80
include/grub/zfs/dnode.h
Normal file
80
include/grub/zfs/dnode.h
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_DNODE_H
|
||||
#define _SYS_DNODE_H
|
||||
|
||||
#include <grub/zfs/spa.h>
|
||||
|
||||
/*
|
||||
* Fixed constants.
|
||||
*/
|
||||
#define DNODE_SHIFT 9 /* 512 bytes */
|
||||
#define DN_MIN_INDBLKSHIFT 10 /* 1k */
|
||||
#define DN_MAX_INDBLKSHIFT 14 /* 16k */
|
||||
#define DNODE_BLOCK_SHIFT 14 /* 16k */
|
||||
#define DNODE_CORE_SIZE 64 /* 64 bytes for dnode sans blkptrs */
|
||||
#define DN_MAX_OBJECT_SHIFT 48 /* 256 trillion (zfs_fid_t limit) */
|
||||
#define DN_MAX_OFFSET_SHIFT 64 /* 2^64 bytes in a dnode */
|
||||
|
||||
/*
|
||||
* Derived constants.
|
||||
*/
|
||||
#define DNODE_SIZE (1 << DNODE_SHIFT)
|
||||
#define DN_MAX_NBLKPTR ((DNODE_SIZE - DNODE_CORE_SIZE) >> SPA_BLKPTRSHIFT)
|
||||
#define DN_MAX_BONUSLEN (DNODE_SIZE - DNODE_CORE_SIZE - (1 << SPA_BLKPTRSHIFT))
|
||||
#define DN_MAX_OBJECT (1ULL << DN_MAX_OBJECT_SHIFT)
|
||||
|
||||
#define DNODES_PER_BLOCK_SHIFT (DNODE_BLOCK_SHIFT - DNODE_SHIFT)
|
||||
#define DNODES_PER_BLOCK (1ULL << DNODES_PER_BLOCK_SHIFT)
|
||||
#define DNODES_PER_LEVEL_SHIFT (DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT)
|
||||
|
||||
#define DNODE_FLAG_SPILL_BLKPTR (1<<2)
|
||||
|
||||
#define DN_BONUS(dnp) ((void*)((dnp)->dn_bonus + \
|
||||
(((dnp)->dn_nblkptr - 1) * sizeof (blkptr_t))))
|
||||
|
||||
typedef struct dnode_phys {
|
||||
grub_uint8_t dn_type; /* dmu_object_type_t */
|
||||
grub_uint8_t dn_indblkshift; /* ln2(indirect block size) */
|
||||
grub_uint8_t dn_nlevels; /* 1=dn_blkptr->data blocks */
|
||||
grub_uint8_t dn_nblkptr; /* length of dn_blkptr */
|
||||
grub_uint8_t dn_bonustype; /* type of data in bonus buffer */
|
||||
grub_uint8_t dn_checksum; /* ZIO_CHECKSUM type */
|
||||
grub_uint8_t dn_compress; /* ZIO_COMPRESS type */
|
||||
grub_uint8_t dn_flags; /* DNODE_FLAG_* */
|
||||
grub_uint16_t dn_datablkszsec; /* data block size in 512b sectors */
|
||||
grub_uint16_t dn_bonuslen; /* length of dn_bonus */
|
||||
grub_uint8_t dn_pad2[4];
|
||||
|
||||
/* accounting is protected by dn_dirty_mtx */
|
||||
grub_uint64_t dn_maxblkid; /* largest allocated block ID */
|
||||
grub_uint64_t dn_used; /* bytes (or sectors) of disk space */
|
||||
|
||||
grub_uint64_t dn_pad3[4];
|
||||
|
||||
blkptr_t dn_blkptr[1];
|
||||
grub_uint8_t dn_bonus[DN_MAX_BONUSLEN - sizeof (blkptr_t)];
|
||||
blkptr_t dn_spill;
|
||||
} dnode_phys_t;
|
||||
|
||||
#endif /* _SYS_DNODE_H */
|
52
include/grub/zfs/dsl_dataset.h
Normal file
52
include/grub/zfs/dsl_dataset.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_DSL_DATASET_H
|
||||
#define _SYS_DSL_DATASET_H
|
||||
|
||||
typedef struct dsl_dataset_phys {
|
||||
grub_uint64_t ds_dir_obj;
|
||||
grub_uint64_t ds_prev_snap_obj;
|
||||
grub_uint64_t ds_prev_snap_txg;
|
||||
grub_uint64_t ds_next_snap_obj;
|
||||
grub_uint64_t ds_snapnames_zapobj; /* zap obj of snaps; ==0 for snaps */
|
||||
grub_uint64_t ds_num_children; /* clone/snap children; ==0 for head */
|
||||
grub_uint64_t ds_creation_time; /* seconds since 1970 */
|
||||
grub_uint64_t ds_creation_txg;
|
||||
grub_uint64_t ds_deadlist_obj;
|
||||
grub_uint64_t ds_used_bytes;
|
||||
grub_uint64_t ds_compressed_bytes;
|
||||
grub_uint64_t ds_uncompressed_bytes;
|
||||
grub_uint64_t ds_unique_bytes; /* only relevant to snapshots */
|
||||
/*
|
||||
* The ds_fsid_guid is a 56-bit ID that can change to avoid
|
||||
* collisions. The ds_guid is a 64-bit ID that will never
|
||||
* change, so there is a small probability that it will collide.
|
||||
*/
|
||||
grub_uint64_t ds_fsid_guid;
|
||||
grub_uint64_t ds_guid;
|
||||
grub_uint64_t ds_flags;
|
||||
blkptr_t ds_bp;
|
||||
grub_uint64_t ds_pad[8]; /* pad out to 320 bytes for good measure */
|
||||
} dsl_dataset_phys_t;
|
||||
|
||||
#endif /* _SYS_DSL_DATASET_H */
|
48
include/grub/zfs/dsl_dir.h
Normal file
48
include/grub/zfs/dsl_dir.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_DSL_DIR_H
|
||||
#define _SYS_DSL_DIR_H
|
||||
|
||||
typedef struct dsl_dir_phys {
|
||||
grub_uint64_t dd_creation_time; /* not actually used */
|
||||
grub_uint64_t dd_head_dataset_obj;
|
||||
grub_uint64_t dd_parent_obj;
|
||||
grub_uint64_t dd_clone_parent_obj;
|
||||
grub_uint64_t dd_child_dir_zapobj;
|
||||
/*
|
||||
* how much space our children are accounting for; for leaf
|
||||
* datasets, == physical space used by fs + snaps
|
||||
*/
|
||||
grub_uint64_t dd_used_bytes;
|
||||
grub_uint64_t dd_compressed_bytes;
|
||||
grub_uint64_t dd_uncompressed_bytes;
|
||||
/* Administrative quota setting */
|
||||
grub_uint64_t dd_quota;
|
||||
/* Administrative reservation setting */
|
||||
grub_uint64_t dd_reserved;
|
||||
grub_uint64_t dd_props_zapobj;
|
||||
grub_uint64_t dd_deleg_zapobj; /* dataset permissions */
|
||||
grub_uint64_t dd_pad[20]; /* pad out to 256 bytes for good measure */
|
||||
} dsl_dir_phys_t;
|
||||
|
||||
#endif /* _SYS_DSL_DIR_H */
|
34
include/grub/zfs/sa_impl.h
Normal file
34
include/grub/zfs/sa_impl.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
#ifndef _SYS_SA_IMPL_H
|
||||
#define _SYS_SA_IMPL_H
|
||||
|
||||
typedef struct sa_hdr_phys {
|
||||
grub_uint32_t sa_magic;
|
||||
grub_uint16_t sa_layout_info;
|
||||
grub_uint16_t sa_lengths[1];
|
||||
} sa_hdr_phys_t;
|
||||
|
||||
#define SA_HDR_SIZE(hdr) BF32_GET_SB(hdr->sa_layout_info, 10, 16, 3, 0)
|
||||
#define SA_SIZE_OFFSET 0x8
|
||||
|
||||
#endif /* _SYS_SA_IMPL_H */
|
310
include/grub/zfs/spa.h
Normal file
310
include/grub/zfs/spa.h
Normal file
|
@ -0,0 +1,310 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2009 Free Software Foundation, Inc.
|
||||
* Copyright 2010 Sun Microsystems, Inc.
|
||||
*
|
||||
* GRUB is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_ZFS_SPA_HEADER
|
||||
#define GRUB_ZFS_SPA_HEADER 1
|
||||
|
||||
typedef enum grub_zfs_endian
|
||||
{
|
||||
UNKNOWN_ENDIAN = -2,
|
||||
LITTLE_ENDIAN = -1,
|
||||
BIG_ENDIAN = 0
|
||||
} grub_zfs_endian_t;
|
||||
|
||||
#define grub_zfs_to_cpu16(x,a) (((a) == BIG_ENDIAN) ? grub_be_to_cpu16(x) \
|
||||
: grub_le_to_cpu16(x))
|
||||
#define grub_cpu_to_zfs16(x,a) (((a) == BIG_ENDIAN) ? grub_cpu_to_be16(x) \
|
||||
: grub_cpu_to_le16(x))
|
||||
|
||||
#define grub_zfs_to_cpu32(x,a) (((a) == BIG_ENDIAN) ? grub_be_to_cpu32(x) \
|
||||
: grub_le_to_cpu32(x))
|
||||
#define grub_cpu_to_zfs32(x,a) (((a) == BIG_ENDIAN) ? grub_cpu_to_be32(x) \
|
||||
: grub_cpu_to_le32(x))
|
||||
|
||||
#define grub_zfs_to_cpu64(x,a) (((a) == BIG_ENDIAN) ? grub_be_to_cpu64(x) \
|
||||
: grub_le_to_cpu64(x))
|
||||
#define grub_cpu_to_zfs64(x,a) (((a) == BIG_ENDIAN) ? grub_cpu_to_be64(x) \
|
||||
: grub_cpu_to_le64(x))
|
||||
|
||||
/*
|
||||
* General-purpose 32-bit and 64-bit bitfield encodings.
|
||||
*/
|
||||
#define BF32_DECODE(x, low, len) P2PHASE((x) >> (low), 1U << (len))
|
||||
#define BF64_DECODE(x, low, len) P2PHASE((x) >> (low), 1ULL << (len))
|
||||
#define BF32_ENCODE(x, low, len) (P2PHASE((x), 1U << (len)) << (low))
|
||||
#define BF64_ENCODE(x, low, len) (P2PHASE((x), 1ULL << (len)) << (low))
|
||||
|
||||
#define BF32_GET(x, low, len) BF32_DECODE(x, low, len)
|
||||
#define BF64_GET(x, low, len) BF64_DECODE(x, low, len)
|
||||
|
||||
#define BF32_SET(x, low, len, val) \
|
||||
((x) ^= BF32_ENCODE((x >> low) ^ (val), low, len))
|
||||
#define BF64_SET(x, low, len, val) \
|
||||
((x) ^= BF64_ENCODE((x >> low) ^ (val), low, len))
|
||||
|
||||
#define BF32_GET_SB(x, low, len, shift, bias) \
|
||||
((BF32_GET(x, low, len) + (bias)) << (shift))
|
||||
#define BF64_GET_SB(x, low, len, shift, bias) \
|
||||
((BF64_GET(x, low, len) + (bias)) << (shift))
|
||||
|
||||
#define BF32_SET_SB(x, low, len, shift, bias, val) \
|
||||
BF32_SET(x, low, len, ((val) >> (shift)) - (bias))
|
||||
#define BF64_SET_SB(x, low, len, shift, bias, val) \
|
||||
BF64_SET(x, low, len, ((val) >> (shift)) - (bias))
|
||||
|
||||
/*
|
||||
* We currently support nine block sizes, from 512 bytes to 128K.
|
||||
* We could go higher, but the benefits are near-zero and the cost
|
||||
* of COWing a giant block to modify one byte would become excessive.
|
||||
*/
|
||||
#define SPA_MINBLOCKSHIFT 9
|
||||
#define SPA_MAXBLOCKSHIFT 17
|
||||
#define SPA_MINBLOCKSIZE (1ULL << SPA_MINBLOCKSHIFT)
|
||||
#define SPA_MAXBLOCKSIZE (1ULL << SPA_MAXBLOCKSHIFT)
|
||||
|
||||
#define SPA_BLOCKSIZES (SPA_MAXBLOCKSHIFT - SPA_MINBLOCKSHIFT + 1)
|
||||
|
||||
/*
|
||||
* Size of block to hold the configuration data (a packed nvlist)
|
||||
*/
|
||||
#define SPA_CONFIG_BLOCKSIZE (1 << 14)
|
||||
|
||||
/*
|
||||
* The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB.
|
||||
* The ASIZE encoding should be at least 64 times larger (6 more bits)
|
||||
* to support up to 4-way RAID-Z mirror mode with worst-case gang block
|
||||
* overhead, three DVAs per bp, plus one more bit in case we do anything
|
||||
* else that expands the ASIZE.
|
||||
*/
|
||||
#define SPA_LSIZEBITS 16 /* LSIZE up to 32M (2^16 * 512) */
|
||||
#define SPA_PSIZEBITS 16 /* PSIZE up to 32M (2^16 * 512) */
|
||||
#define SPA_ASIZEBITS 24 /* ASIZE up to 64 times larger */
|
||||
|
||||
/*
|
||||
* All SPA data is represented by 128-bit data virtual addresses (DVAs).
|
||||
* The members of the dva_t should be considered opaque outside the SPA.
|
||||
*/
|
||||
typedef struct dva {
|
||||
grub_uint64_t dva_word[2];
|
||||
} dva_t;
|
||||
|
||||
/*
|
||||
* Each block has a 256-bit checksum -- strong enough for cryptographic hashes.
|
||||
*/
|
||||
typedef struct zio_cksum {
|
||||
grub_uint64_t zc_word[4];
|
||||
} zio_cksum_t;
|
||||
|
||||
/*
|
||||
* Each block is described by its DVAs, time of birth, checksum, etc.
|
||||
* The word-by-word, bit-by-bit layout of the blkptr is as follows:
|
||||
*
|
||||
* 64 56 48 40 32 24 16 8 0
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* 0 | vdev1 | GRID | ASIZE |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* 1 |G| offset1 |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* 2 | vdev2 | GRID | ASIZE |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* 3 |G| offset2 |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* 4 | vdev3 | GRID | ASIZE |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* 5 |G| offset3 |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* 6 |BDX|lvl| type | cksum | comp | PSIZE | LSIZE |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* 7 | padding |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* 8 | padding |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* 9 | physical birth txg |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* a | logical birth txg |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* b | fill count |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* c | checksum[0] |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* d | checksum[1] |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* e | checksum[2] |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
* f | checksum[3] |
|
||||
* +-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
*
|
||||
* Legend:
|
||||
*
|
||||
* vdev virtual device ID
|
||||
* offset offset into virtual device
|
||||
* LSIZE logical size
|
||||
* PSIZE physical size (after compression)
|
||||
* ASIZE allocated size (including RAID-Z parity and gang block headers)
|
||||
* GRID RAID-Z layout information (reserved for future use)
|
||||
* cksum checksum function
|
||||
* comp compression function
|
||||
* G gang block indicator
|
||||
* B byteorder (endianness)
|
||||
* D dedup
|
||||
* X unused
|
||||
* lvl level of indirection
|
||||
* type DMU object type
|
||||
* phys birth txg of block allocation; zero if same as logical birth txg
|
||||
* log. birth transaction group in which the block was logically born
|
||||
* fill count number of non-zero blocks under this bp
|
||||
* checksum[4] 256-bit checksum of the data this bp describes
|
||||
*/
|
||||
#define SPA_BLKPTRSHIFT 7 /* blkptr_t is 128 bytes */
|
||||
#define SPA_DVAS_PER_BP 3 /* Number of DVAs in a bp */
|
||||
|
||||
typedef struct blkptr {
|
||||
dva_t blk_dva[SPA_DVAS_PER_BP]; /* Data Virtual Addresses */
|
||||
grub_uint64_t blk_prop; /* size, compression, type, etc */
|
||||
grub_uint64_t blk_pad[2]; /* Extra space for the future */
|
||||
grub_uint64_t blk_phys_birth; /* txg when block was allocated */
|
||||
grub_uint64_t blk_birth; /* transaction group at birth */
|
||||
grub_uint64_t blk_fill; /* fill count */
|
||||
zio_cksum_t blk_cksum; /* 256-bit checksum */
|
||||
} blkptr_t;
|
||||
|
||||
/*
|
||||
* Macros to get and set fields in a bp or DVA.
|
||||
*/
|
||||
#define DVA_GET_ASIZE(dva) \
|
||||
BF64_GET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0)
|
||||
#define DVA_SET_ASIZE(dva, x) \
|
||||
BF64_SET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0, x)
|
||||
|
||||
#define DVA_GET_GRID(dva) BF64_GET((dva)->dva_word[0], 24, 8)
|
||||
#define DVA_SET_GRID(dva, x) BF64_SET((dva)->dva_word[0], 24, 8, x)
|
||||
|
||||
#define DVA_GET_VDEV(dva) BF64_GET((dva)->dva_word[0], 32, 32)
|
||||
#define DVA_SET_VDEV(dva, x) BF64_SET((dva)->dva_word[0], 32, 32, x)
|
||||
|
||||
#define DVA_GET_GANG(dva) BF64_GET((dva)->dva_word[1], 63, 1)
|
||||
#define DVA_SET_GANG(dva, x) BF64_SET((dva)->dva_word[1], 63, 1, x)
|
||||
|
||||
#define BP_GET_LSIZE(bp) \
|
||||
BF64_GET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1)
|
||||
#define BP_SET_LSIZE(bp, x) \
|
||||
BF64_SET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x)
|
||||
|
||||
#define BP_GET_COMPRESS(bp) BF64_GET((bp)->blk_prop, 32, 8)
|
||||
#define BP_SET_COMPRESS(bp, x) BF64_SET((bp)->blk_prop, 32, 8, x)
|
||||
|
||||
#define BP_GET_CHECKSUM(bp) BF64_GET((bp)->blk_prop, 40, 8)
|
||||
#define BP_SET_CHECKSUM(bp, x) BF64_SET((bp)->blk_prop, 40, 8, x)
|
||||
|
||||
#define BP_GET_TYPE(bp) BF64_GET((bp)->blk_prop, 48, 8)
|
||||
#define BP_SET_TYPE(bp, x) BF64_SET((bp)->blk_prop, 48, 8, x)
|
||||
|
||||
#define BP_GET_LEVEL(bp) BF64_GET((bp)->blk_prop, 56, 5)
|
||||
#define BP_SET_LEVEL(bp, x) BF64_SET((bp)->blk_prop, 56, 5, x)
|
||||
|
||||
#define BP_GET_PROP_BIT_61(bp) BF64_GET((bp)->blk_prop, 61, 1)
|
||||
#define BP_SET_PROP_BIT_61(bp, x) BF64_SET((bp)->blk_prop, 61, 1, x)
|
||||
|
||||
#define BP_GET_DEDUP(bp) BF64_GET((bp)->blk_prop, 62, 1)
|
||||
#define BP_SET_DEDUP(bp, x) BF64_SET((bp)->blk_prop, 62, 1, x)
|
||||
|
||||
#define BP_GET_BYTEORDER(bp) (0 - BF64_GET((bp)->blk_prop, 63, 1))
|
||||
#define BP_SET_BYTEORDER(bp, x) BF64_SET((bp)->blk_prop, 63, 1, x)
|
||||
|
||||
#define BP_PHYSICAL_BIRTH(bp) \
|
||||
((bp)->blk_phys_birth ? (bp)->blk_phys_birth : (bp)->blk_birth)
|
||||
|
||||
#define BP_SET_BIRTH(bp, logical, physical) \
|
||||
{ \
|
||||
(bp)->blk_birth = (logical); \
|
||||
(bp)->blk_phys_birth = ((logical) == (physical) ? 0 : (physical)); \
|
||||
}
|
||||
|
||||
#define BP_GET_ASIZE(bp) \
|
||||
(DVA_GET_ASIZE(&(bp)->blk_dva[0]) + DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
|
||||
DVA_GET_ASIZE(&(bp)->blk_dva[2]))
|
||||
|
||||
#define BP_GET_UCSIZE(bp) \
|
||||
((BP_GET_LEVEL(bp) > 0 || dmu_ot[BP_GET_TYPE(bp)].ot_metadata) ? \
|
||||
BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp));
|
||||
|
||||
#define BP_GET_NDVAS(bp) \
|
||||
(!!DVA_GET_ASIZE(&(bp)->blk_dva[0]) + \
|
||||
!!DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
|
||||
!!DVA_GET_ASIZE(&(bp)->blk_dva[2]))
|
||||
|
||||
#define BP_COUNT_GANG(bp) \
|
||||
(DVA_GET_GANG(&(bp)->blk_dva[0]) + \
|
||||
DVA_GET_GANG(&(bp)->blk_dva[1]) + \
|
||||
DVA_GET_GANG(&(bp)->blk_dva[2]))
|
||||
|
||||
#define DVA_EQUAL(dva1, dva2) \
|
||||
((dva1)->dva_word[1] == (dva2)->dva_word[1] && \
|
||||
(dva1)->dva_word[0] == (dva2)->dva_word[0])
|
||||
|
||||
#define BP_EQUAL(bp1, bp2) \
|
||||
(BP_PHYSICAL_BIRTH(bp1) == BP_PHYSICAL_BIRTH(bp2) && \
|
||||
DVA_EQUAL(&(bp1)->blk_dva[0], &(bp2)->blk_dva[0]) && \
|
||||
DVA_EQUAL(&(bp1)->blk_dva[1], &(bp2)->blk_dva[1]) && \
|
||||
DVA_EQUAL(&(bp1)->blk_dva[2], &(bp2)->blk_dva[2]))
|
||||
|
||||
#define ZIO_CHECKSUM_EQUAL(zc1, zc2) \
|
||||
(0 == (((zc1).zc_word[0] - (zc2).zc_word[0]) | \
|
||||
((zc1).zc_word[1] - (zc2).zc_word[1]) | \
|
||||
((zc1).zc_word[2] - (zc2).zc_word[2]) | \
|
||||
((zc1).zc_word[3] - (zc2).zc_word[3])))
|
||||
|
||||
#define DVA_IS_VALID(dva) (DVA_GET_ASIZE(dva) != 0)
|
||||
|
||||
#define ZIO_SET_CHECKSUM(zcp, w0, w1, w2, w3) \
|
||||
{ \
|
||||
(zcp)->zc_word[0] = w0; \
|
||||
(zcp)->zc_word[1] = w1; \
|
||||
(zcp)->zc_word[2] = w2; \
|
||||
(zcp)->zc_word[3] = w3; \
|
||||
}
|
||||
|
||||
#define BP_IDENTITY(bp) (&(bp)->blk_dva[0])
|
||||
#define BP_IS_GANG(bp) DVA_GET_GANG(BP_IDENTITY(bp))
|
||||
#define BP_IS_HOLE(bp) ((bp)->blk_birth == 0)
|
||||
|
||||
/* BP_IS_RAIDZ(bp) assumes no block compression */
|
||||
#define BP_IS_RAIDZ(bp) (DVA_GET_ASIZE(&(bp)->blk_dva[0]) > \
|
||||
BP_GET_PSIZE(bp))
|
||||
|
||||
#define BP_ZERO(bp) \
|
||||
{ \
|
||||
(bp)->blk_dva[0].dva_word[0] = 0; \
|
||||
(bp)->blk_dva[0].dva_word[1] = 0; \
|
||||
(bp)->blk_dva[1].dva_word[0] = 0; \
|
||||
(bp)->blk_dva[1].dva_word[1] = 0; \
|
||||
(bp)->blk_dva[2].dva_word[0] = 0; \
|
||||
(bp)->blk_dva[2].dva_word[1] = 0; \
|
||||
(bp)->blk_prop = 0; \
|
||||
(bp)->blk_pad[0] = 0; \
|
||||
(bp)->blk_pad[1] = 0; \
|
||||
(bp)->blk_phys_birth = 0; \
|
||||
(bp)->blk_birth = 0; \
|
||||
(bp)->blk_fill = 0; \
|
||||
ZIO_SET_CHECKSUM(&(bp)->blk_cksum, 0, 0, 0, 0); \
|
||||
}
|
||||
|
||||
#define BP_SPRINTF_LEN 320
|
||||
|
||||
#endif /* ! GRUB_ZFS_SPA_HEADER */
|
60
include/grub/zfs/uberblock_impl.h
Normal file
60
include/grub/zfs/uberblock_impl.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_UBERBLOCK_IMPL_H
|
||||
#define _SYS_UBERBLOCK_IMPL_H
|
||||
|
||||
/*
|
||||
* The uberblock version is incremented whenever an incompatible on-disk
|
||||
* format change is made to the SPA, DMU, or ZAP.
|
||||
*
|
||||
* Note: the first two fields should never be moved. When a storage pool
|
||||
* is opened, the uberblock must be read off the disk before the version
|
||||
* can be checked. If the ub_version field is moved, we may not detect
|
||||
* version mismatch. If the ub_magic field is moved, applications that
|
||||
* expect the magic number in the first word won't work.
|
||||
*/
|
||||
#define UBERBLOCK_MAGIC 0x00bab10c /* oo-ba-bloc! */
|
||||
#define UBERBLOCK_SHIFT 10 /* up to 1K */
|
||||
|
||||
typedef struct uberblock {
|
||||
grub_uint64_t ub_magic; /* UBERBLOCK_MAGIC */
|
||||
grub_uint64_t ub_version; /* ZFS_VERSION */
|
||||
grub_uint64_t ub_txg; /* txg of last sync */
|
||||
grub_uint64_t ub_guid_sum; /* sum of all vdev guids */
|
||||
grub_uint64_t ub_timestamp; /* UTC time of last sync */
|
||||
blkptr_t ub_rootbp; /* MOS objset_phys_t */
|
||||
} uberblock_t;
|
||||
|
||||
#define UBERBLOCK_SIZE (1ULL << UBERBLOCK_SHIFT)
|
||||
#define VDEV_UBERBLOCK_SHIFT UBERBLOCK_SHIFT
|
||||
|
||||
/* XXX Uberblock_phys_t is no longer in the kernel zfs */
|
||||
typedef struct uberblock_phys {
|
||||
uberblock_t ubp_uberblock;
|
||||
char ubp_pad[UBERBLOCK_SIZE - sizeof (uberblock_t) -
|
||||
sizeof (zio_eck_t)];
|
||||
zio_eck_t ubp_zec;
|
||||
} uberblock_phys_t;
|
||||
|
||||
|
||||
#endif /* _SYS_UBERBLOCK_IMPL_H */
|
69
include/grub/zfs/vdev_impl.h
Normal file
69
include/grub/zfs/vdev_impl.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_VDEV_IMPL_H
|
||||
#define _SYS_VDEV_IMPL_H
|
||||
|
||||
#define VDEV_SKIP_SIZE (8 << 10)
|
||||
#define VDEV_BOOT_HEADER_SIZE (8 << 10)
|
||||
#define VDEV_PHYS_SIZE (112 << 10)
|
||||
#define VDEV_UBERBLOCK_RING (128 << 10)
|
||||
|
||||
/* ZFS boot block */
|
||||
#define VDEV_BOOT_MAGIC 0x2f5b007b10cULL
|
||||
#define VDEV_BOOT_VERSION 1 /* version number */
|
||||
|
||||
typedef struct vdev_boot_header {
|
||||
grub_uint64_t vb_magic; /* VDEV_BOOT_MAGIC */
|
||||
grub_uint64_t vb_version; /* VDEV_BOOT_VERSION */
|
||||
grub_uint64_t vb_offset; /* start offset (bytes) */
|
||||
grub_uint64_t vb_size; /* size (bytes) */
|
||||
char vb_pad[VDEV_BOOT_HEADER_SIZE - 4 * sizeof (grub_uint64_t)];
|
||||
} vdev_boot_header_t;
|
||||
|
||||
typedef struct vdev_phys {
|
||||
char vp_nvlist[VDEV_PHYS_SIZE - sizeof (zio_eck_t)];
|
||||
zio_eck_t vp_zbt;
|
||||
} vdev_phys_t;
|
||||
|
||||
typedef struct vdev_label {
|
||||
char vl_pad[VDEV_SKIP_SIZE]; /* 8K */
|
||||
vdev_boot_header_t vl_boot_header; /* 8K */
|
||||
vdev_phys_t vl_vdev_phys; /* 112K */
|
||||
char vl_uberblock[VDEV_UBERBLOCK_RING]; /* 128K */
|
||||
} vdev_label_t; /* 256K total */
|
||||
|
||||
/*
|
||||
* Size and offset of embedded boot loader region on each label.
|
||||
* The total size of the first two labels plus the boot area is 4MB.
|
||||
*/
|
||||
#define VDEV_BOOT_OFFSET (2 * sizeof (vdev_label_t))
|
||||
#define VDEV_BOOT_SIZE (7ULL << 19) /* 3.5M */
|
||||
|
||||
/*
|
||||
* Size of label regions at the start and end of each leaf device.
|
||||
*/
|
||||
#define VDEV_LABEL_START_SIZE (2 * sizeof (vdev_label_t) + VDEV_BOOT_SIZE)
|
||||
#define VDEV_LABEL_END_SIZE (2 * sizeof (vdev_label_t))
|
||||
#define VDEV_LABELS 4
|
||||
|
||||
#endif /* _SYS_VDEV_IMPL_H */
|
111
include/grub/zfs/zap_impl.h
Normal file
111
include/grub/zfs/zap_impl.h
Normal file
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_ZAP_IMPL_H
|
||||
#define _SYS_ZAP_IMPL_H
|
||||
|
||||
#define ZAP_MAGIC 0x2F52AB2ABULL
|
||||
|
||||
#define ZAP_HASHBITS 28
|
||||
#define MZAP_ENT_LEN 64
|
||||
#define MZAP_NAME_LEN (MZAP_ENT_LEN - 8 - 4 - 2)
|
||||
#define MZAP_MAX_BLKSHIFT SPA_MAXBLOCKSHIFT
|
||||
#define MZAP_MAX_BLKSZ (1 << MZAP_MAX_BLKSHIFT)
|
||||
|
||||
typedef struct mzap_ent_phys {
|
||||
grub_uint64_t mze_value;
|
||||
grub_uint32_t mze_cd;
|
||||
grub_uint16_t mze_pad; /* in case we want to chain them someday */
|
||||
char mze_name[MZAP_NAME_LEN];
|
||||
} mzap_ent_phys_t;
|
||||
|
||||
typedef struct mzap_phys {
|
||||
grub_uint64_t mz_block_type; /* ZBT_MICRO */
|
||||
grub_uint64_t mz_salt;
|
||||
grub_uint64_t mz_pad[6];
|
||||
mzap_ent_phys_t mz_chunk[1];
|
||||
/* actually variable size depending on block size */
|
||||
} mzap_phys_t;
|
||||
|
||||
/*
|
||||
* The (fat) zap is stored in one object. It is an array of
|
||||
* 1<<FZAP_BLOCK_SHIFT byte blocks. The layout looks like one of:
|
||||
*
|
||||
* ptrtbl fits in first block:
|
||||
* [zap_phys_t zap_ptrtbl_shift < 6] [zap_leaf_t] ...
|
||||
*
|
||||
* ptrtbl too big for first block:
|
||||
* [zap_phys_t zap_ptrtbl_shift >= 6] [zap_leaf_t] [ptrtbl] ...
|
||||
*
|
||||
*/
|
||||
|
||||
#define ZBT_LEAF ((1ULL << 63) + 0)
|
||||
#define ZBT_HEADER ((1ULL << 63) + 1)
|
||||
#define ZBT_MICRO ((1ULL << 63) + 3)
|
||||
/* any other values are ptrtbl blocks */
|
||||
|
||||
/*
|
||||
* the embedded pointer table takes up half a block:
|
||||
* block size / entry size (2^3) / 2
|
||||
*/
|
||||
#define ZAP_EMBEDDED_PTRTBL_SHIFT(zap) (FZAP_BLOCK_SHIFT(zap) - 3 - 1)
|
||||
|
||||
/*
|
||||
* The embedded pointer table starts half-way through the block. Since
|
||||
* the pointer table itself is half the block, it starts at (64-bit)
|
||||
* word number (1<<ZAP_EMBEDDED_PTRTBL_SHIFT(zap)).
|
||||
*/
|
||||
#define ZAP_EMBEDDED_PTRTBL_ENT(zap, idx) \
|
||||
((grub_uint64_t *)(zap)->zap_f.zap_phys) \
|
||||
[(idx) + (1<<ZAP_EMBEDDED_PTRTBL_SHIFT(zap))]
|
||||
|
||||
/*
|
||||
* TAKE NOTE:
|
||||
* If zap_phys_t is modified, zap_byteswap() must be modified.
|
||||
*/
|
||||
typedef struct zap_phys {
|
||||
grub_uint64_t zap_block_type; /* ZBT_HEADER */
|
||||
grub_uint64_t zap_magic; /* ZAP_MAGIC */
|
||||
|
||||
struct zap_table_phys {
|
||||
grub_uint64_t zt_blk; /* starting block number */
|
||||
grub_uint64_t zt_numblks; /* number of blocks */
|
||||
grub_uint64_t zt_shift; /* bits to index it */
|
||||
grub_uint64_t zt_nextblk; /* next (larger) copy start block */
|
||||
grub_uint64_t zt_blks_copied; /* number source blocks copied */
|
||||
} zap_ptrtbl;
|
||||
|
||||
grub_uint64_t zap_freeblk; /* the next free block */
|
||||
grub_uint64_t zap_num_leafs; /* number of leafs */
|
||||
grub_uint64_t zap_num_entries; /* number of entries */
|
||||
grub_uint64_t zap_salt; /* salt to stir into hash function */
|
||||
grub_uint64_t zap_normflags; /* flags for u8_textprep_str() */
|
||||
grub_uint64_t zap_flags; /* zap_flag_t */
|
||||
/*
|
||||
* This structure is followed by padding, and then the embedded
|
||||
* pointer table. The embedded pointer table takes up second
|
||||
* half of the block. It is accessed using the
|
||||
* ZAP_EMBEDDED_PTRTBL_ENT() macro.
|
||||
*/
|
||||
} zap_phys_t;
|
||||
|
||||
#endif /* _SYS_ZAP_IMPL_H */
|
103
include/grub/zfs/zap_leaf.h
Normal file
103
include/grub/zfs/zap_leaf.h
Normal file
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_ZAP_LEAF_H
|
||||
#define _SYS_ZAP_LEAF_H
|
||||
|
||||
#define ZAP_LEAF_MAGIC 0x2AB1EAF
|
||||
|
||||
/* chunk size = 24 bytes */
|
||||
#define ZAP_LEAF_CHUNKSIZE 24
|
||||
|
||||
/*
|
||||
* The amount of space within the chunk available for the array is:
|
||||
* chunk size - space for type (1) - space for next pointer (2)
|
||||
*/
|
||||
#define ZAP_LEAF_ARRAY_BYTES (ZAP_LEAF_CHUNKSIZE - 3)
|
||||
|
||||
typedef enum zap_chunk_type {
|
||||
ZAP_CHUNK_FREE = 253,
|
||||
ZAP_CHUNK_ENTRY = 252,
|
||||
ZAP_CHUNK_ARRAY = 251,
|
||||
ZAP_CHUNK_TYPE_MAX = 250
|
||||
} zap_chunk_type_t;
|
||||
|
||||
/*
|
||||
* TAKE NOTE:
|
||||
* If zap_leaf_phys_t is modified, zap_leaf_byteswap() must be modified.
|
||||
*/
|
||||
typedef struct zap_leaf_phys {
|
||||
struct zap_leaf_header {
|
||||
grub_uint64_t lh_block_type; /* ZBT_LEAF */
|
||||
grub_uint64_t lh_pad1;
|
||||
grub_uint64_t lh_prefix; /* hash prefix of this leaf */
|
||||
grub_uint32_t lh_magic; /* ZAP_LEAF_MAGIC */
|
||||
grub_uint16_t lh_nfree; /* number free chunks */
|
||||
grub_uint16_t lh_nentries; /* number of entries */
|
||||
grub_uint16_t lh_prefix_len; /* num bits used to id this */
|
||||
|
||||
/* above is accessable to zap, below is zap_leaf private */
|
||||
|
||||
grub_uint16_t lh_freelist; /* chunk head of free list */
|
||||
grub_uint8_t lh_pad2[12];
|
||||
} l_hdr; /* 2 24-byte chunks */
|
||||
|
||||
/*
|
||||
* The header is followed by a hash table with
|
||||
* ZAP_LEAF_HASH_NUMENTRIES(zap) entries. The hash table is
|
||||
* followed by an array of ZAP_LEAF_NUMCHUNKS(zap)
|
||||
* zap_leaf_chunk structures. These structures are accessed
|
||||
* with the ZAP_LEAF_CHUNK() macro.
|
||||
*/
|
||||
|
||||
grub_uint16_t l_hash[1];
|
||||
} zap_leaf_phys_t;
|
||||
|
||||
typedef union zap_leaf_chunk {
|
||||
struct zap_leaf_entry {
|
||||
grub_uint8_t le_type; /* always ZAP_CHUNK_ENTRY */
|
||||
grub_uint8_t le_int_size; /* size of ints */
|
||||
grub_uint16_t le_next; /* next entry in hash chain */
|
||||
grub_uint16_t le_name_chunk; /* first chunk of the name */
|
||||
grub_uint16_t le_name_length; /* bytes in name, incl null */
|
||||
grub_uint16_t le_value_chunk; /* first chunk of the value */
|
||||
grub_uint16_t le_value_length; /* value length in ints */
|
||||
grub_uint32_t le_cd; /* collision differentiator */
|
||||
grub_uint64_t le_hash; /* hash value of the name */
|
||||
} l_entry;
|
||||
struct zap_leaf_array {
|
||||
grub_uint8_t la_type; /* always ZAP_CHUNK_ARRAY */
|
||||
union
|
||||
{
|
||||
grub_uint8_t la_array[ZAP_LEAF_ARRAY_BYTES];
|
||||
grub_uint64_t la_array64;
|
||||
};
|
||||
grub_uint16_t la_next; /* next blk or CHAIN_END */
|
||||
} l_array;
|
||||
struct zap_leaf_free {
|
||||
grub_uint8_t lf_type; /* always ZAP_CHUNK_FREE */
|
||||
grub_uint8_t lf_pad[ZAP_LEAF_ARRAY_BYTES];
|
||||
grub_uint16_t lf_next; /* next in free list, or CHAIN_END */
|
||||
} l_free;
|
||||
} zap_leaf_chunk_t;
|
||||
|
||||
#endif /* _SYS_ZAP_LEAF_H */
|
123
include/grub/zfs/zfs.h
Normal file
123
include/grub/zfs/zfs.h
Normal file
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2009 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_ZFS_HEADER
|
||||
#define GRUB_ZFS_HEADER 1
|
||||
|
||||
#include <grub/err.h>
|
||||
#include <grub/disk.h>
|
||||
|
||||
/*
|
||||
* On-disk version number.
|
||||
*/
|
||||
#define SPA_VERSION 28ULL
|
||||
|
||||
/*
|
||||
* The following are configuration names used in the nvlist describing a pool's
|
||||
* configuration.
|
||||
*/
|
||||
#define ZPOOL_CONFIG_VERSION "version"
|
||||
#define ZPOOL_CONFIG_POOL_NAME "name"
|
||||
#define ZPOOL_CONFIG_POOL_STATE "state"
|
||||
#define ZPOOL_CONFIG_POOL_TXG "txg"
|
||||
#define ZPOOL_CONFIG_POOL_GUID "pool_guid"
|
||||
#define ZPOOL_CONFIG_CREATE_TXG "create_txg"
|
||||
#define ZPOOL_CONFIG_TOP_GUID "top_guid"
|
||||
#define ZPOOL_CONFIG_VDEV_TREE "vdev_tree"
|
||||
#define ZPOOL_CONFIG_TYPE "type"
|
||||
#define ZPOOL_CONFIG_CHILDREN "children"
|
||||
#define ZPOOL_CONFIG_ID "id"
|
||||
#define ZPOOL_CONFIG_GUID "guid"
|
||||
#define ZPOOL_CONFIG_PATH "path"
|
||||
#define ZPOOL_CONFIG_DEVID "devid"
|
||||
#define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array"
|
||||
#define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift"
|
||||
#define ZPOOL_CONFIG_ASHIFT "ashift"
|
||||
#define ZPOOL_CONFIG_ASIZE "asize"
|
||||
#define ZPOOL_CONFIG_DTL "DTL"
|
||||
#define ZPOOL_CONFIG_STATS "stats"
|
||||
#define ZPOOL_CONFIG_WHOLE_DISK "whole_disk"
|
||||
#define ZPOOL_CONFIG_ERRCOUNT "error_count"
|
||||
#define ZPOOL_CONFIG_NOT_PRESENT "not_present"
|
||||
#define ZPOOL_CONFIG_SPARES "spares"
|
||||
#define ZPOOL_CONFIG_IS_SPARE "is_spare"
|
||||
#define ZPOOL_CONFIG_NPARITY "nparity"
|
||||
#define ZPOOL_CONFIG_PHYS_PATH "phys_path"
|
||||
#define ZPOOL_CONFIG_L2CACHE "l2cache"
|
||||
#define ZPOOL_CONFIG_HOLE_ARRAY "hole_array"
|
||||
#define ZPOOL_CONFIG_VDEV_CHILDREN "vdev_children"
|
||||
#define ZPOOL_CONFIG_IS_HOLE "is_hole"
|
||||
#define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram"
|
||||
#define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats"
|
||||
#define ZPOOL_CONFIG_DDT_STATS "ddt_stats"
|
||||
/*
|
||||
* The persistent vdev state is stored as separate values rather than a single
|
||||
* 'vdev_state' entry. This is because a device can be in multiple states, such
|
||||
* as offline and degraded.
|
||||
*/
|
||||
#define ZPOOL_CONFIG_OFFLINE "offline"
|
||||
#define ZPOOL_CONFIG_FAULTED "faulted"
|
||||
#define ZPOOL_CONFIG_DEGRADED "degraded"
|
||||
#define ZPOOL_CONFIG_REMOVED "removed"
|
||||
|
||||
#define VDEV_TYPE_ROOT "root"
|
||||
#define VDEV_TYPE_MIRROR "mirror"
|
||||
#define VDEV_TYPE_REPLACING "replacing"
|
||||
#define VDEV_TYPE_RAIDZ "raidz"
|
||||
#define VDEV_TYPE_DISK "disk"
|
||||
#define VDEV_TYPE_FILE "file"
|
||||
#define VDEV_TYPE_MISSING "missing"
|
||||
#define VDEV_TYPE_HOLE "hole"
|
||||
#define VDEV_TYPE_SPARE "spare"
|
||||
#define VDEV_TYPE_L2CACHE "l2cache"
|
||||
|
||||
/*
|
||||
* pool state. The following states are written to disk as part of the normal
|
||||
* SPA lifecycle: ACTIVE, EXPORTED, DESTROYED, SPARE, L2CACHE. The remaining
|
||||
* states are software abstractions used at various levels to communicate pool
|
||||
* state.
|
||||
*/
|
||||
typedef enum pool_state {
|
||||
POOL_STATE_ACTIVE = 0, /* In active use */
|
||||
POOL_STATE_EXPORTED, /* Explicitly exported */
|
||||
POOL_STATE_DESTROYED, /* Explicitly destroyed */
|
||||
POOL_STATE_SPARE, /* Reserved for hot spare use */
|
||||
POOL_STATE_L2CACHE, /* Level 2 ARC device */
|
||||
POOL_STATE_UNINITIALIZED, /* Internal spa_t state */
|
||||
POOL_STATE_UNAVAIL, /* Internal libzfs state */
|
||||
POOL_STATE_POTENTIALLY_ACTIVE /* Internal libzfs state */
|
||||
} pool_state_t;
|
||||
|
||||
struct grub_zfs_data;
|
||||
|
||||
grub_err_t grub_zfs_fetch_nvlist (grub_device_t dev, char **nvlist);
|
||||
grub_err_t grub_zfs_getmdnobj (grub_device_t dev, const char *fsfilename,
|
||||
grub_uint64_t *mdnobj);
|
||||
|
||||
char *grub_zfs_nvlist_lookup_string (char *nvlist, char *name);
|
||||
char *grub_zfs_nvlist_lookup_nvlist (char *nvlist, char *name);
|
||||
int grub_zfs_nvlist_lookup_uint64 (char *nvlist, char *name,
|
||||
grub_uint64_t *out);
|
||||
char *grub_zfs_nvlist_lookup_nvlist_array (char *nvlist, char *name,
|
||||
grub_size_t index);
|
||||
int grub_zfs_nvlist_lookup_nvlist_array_get_nelm (char *nvlist, char *name);
|
||||
|
||||
#endif /* ! GRUB_ZFS_HEADER */
|
59
include/grub/zfs/zfs_acl.h
Normal file
59
include/grub/zfs/zfs_acl.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_FS_ZFS_ACL_H
|
||||
#define _SYS_FS_ZFS_ACL_H
|
||||
|
||||
#ifndef _UID_T
|
||||
#define _UID_T
|
||||
typedef unsigned int uid_t; /* UID type */
|
||||
#endif /* _UID_T */
|
||||
|
||||
typedef struct zfs_oldace {
|
||||
grub_uint32_t z_fuid; /* "who" */
|
||||
grub_uint32_t z_access_mask; /* access mask */
|
||||
grub_uint16_t z_flags; /* flags, i.e inheritance */
|
||||
grub_uint16_t z_type; /* type of entry allow/deny */
|
||||
} zfs_oldace_t;
|
||||
|
||||
#define ACE_SLOT_CNT 6
|
||||
|
||||
typedef struct zfs_znode_acl_v0 {
|
||||
grub_uint64_t z_acl_extern_obj; /* ext acl pieces */
|
||||
grub_uint32_t z_acl_count; /* Number of ACEs */
|
||||
grub_uint16_t z_acl_version; /* acl version */
|
||||
grub_uint16_t z_acl_pad; /* pad */
|
||||
zfs_oldace_t z_ace_data[ACE_SLOT_CNT]; /* 6 standard ACEs */
|
||||
} zfs_znode_acl_v0_t;
|
||||
|
||||
#define ZFS_ACE_SPACE (sizeof (zfs_oldace_t) * ACE_SLOT_CNT)
|
||||
|
||||
typedef struct zfs_znode_acl {
|
||||
grub_uint64_t z_acl_extern_obj; /* ext acl pieces */
|
||||
grub_uint32_t z_acl_size; /* Number of bytes in ACL */
|
||||
grub_uint16_t z_acl_version; /* acl version */
|
||||
grub_uint16_t z_acl_count; /* ace count */
|
||||
grub_uint8_t z_ace_data[ZFS_ACE_SPACE]; /* space for embedded ACEs */
|
||||
} zfs_znode_acl_t;
|
||||
|
||||
|
||||
#endif /* _SYS_FS_ZFS_ACL_H */
|
70
include/grub/zfs/zfs_znode.h
Normal file
70
include/grub/zfs/zfs_znode.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_FS_ZFS_ZNODE_H
|
||||
#define _SYS_FS_ZFS_ZNODE_H
|
||||
|
||||
#include <grub/zfs/zfs_acl.h>
|
||||
|
||||
#define MASTER_NODE_OBJ 1
|
||||
#define ZFS_ROOT_OBJ "ROOT"
|
||||
#define ZPL_VERSION_STR "VERSION"
|
||||
#define ZFS_SA_ATTRS "SA_ATTRS"
|
||||
|
||||
#define ZPL_VERSION 5ULL
|
||||
|
||||
#define ZFS_DIRENT_OBJ(de) BF64_GET(de, 0, 48)
|
||||
|
||||
/*
|
||||
* This is the persistent portion of the znode. It is stored
|
||||
* in the "bonus buffer" of the file. Short symbolic links
|
||||
* are also stored in the bonus buffer.
|
||||
*/
|
||||
typedef struct znode_phys {
|
||||
grub_uint64_t zp_atime[2]; /* 0 - last file access time */
|
||||
grub_uint64_t zp_mtime[2]; /* 16 - last file modification time */
|
||||
grub_uint64_t zp_ctime[2]; /* 32 - last file change time */
|
||||
grub_uint64_t zp_crtime[2]; /* 48 - creation time */
|
||||
grub_uint64_t zp_gen; /* 64 - generation (txg of creation) */
|
||||
grub_uint64_t zp_mode; /* 72 - file mode bits */
|
||||
grub_uint64_t zp_size; /* 80 - size of file */
|
||||
grub_uint64_t zp_parent; /* 88 - directory parent (`..') */
|
||||
grub_uint64_t zp_links; /* 96 - number of links to file */
|
||||
grub_uint64_t zp_xattr; /* 104 - DMU object for xattrs */
|
||||
grub_uint64_t zp_rdev; /* 112 - dev_t for VBLK & VCHR files */
|
||||
grub_uint64_t zp_flags; /* 120 - persistent flags */
|
||||
grub_uint64_t zp_uid; /* 128 - file owner */
|
||||
grub_uint64_t zp_gid; /* 136 - owning group */
|
||||
grub_uint64_t zp_pad[4]; /* 144 - future */
|
||||
zfs_znode_acl_t zp_acl; /* 176 - 263 ACL */
|
||||
/*
|
||||
* Data may pad out any remaining bytes in the znode buffer, eg:
|
||||
*
|
||||
* |<---------------------- dnode_phys (512) ------------------------>|
|
||||
* |<-- dnode (192) --->|<----------- "bonus" buffer (320) ---------->|
|
||||
* |<---- znode (264) ---->|<---- data (56) ---->|
|
||||
*
|
||||
* At present, we only use this space to store symbolic links.
|
||||
*/
|
||||
} znode_phys_t;
|
||||
|
||||
#endif /* _SYS_FS_ZFS_ZNODE_H */
|
56
include/grub/zfs/zil.h
Normal file
56
include/grub/zfs/zil.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_ZIL_H
|
||||
#define _SYS_ZIL_H
|
||||
|
||||
/*
|
||||
* Intent log format:
|
||||
*
|
||||
* Each objset has its own intent log. The log header (zil_header_t)
|
||||
* for objset N's intent log is kept in the Nth object of the SPA's
|
||||
* intent_log objset. The log header points to a chain of log blocks,
|
||||
* each of which contains log records (i.e., transactions) followed by
|
||||
* a log block trailer (zil_trailer_t). The format of a log record
|
||||
* depends on the record (or transaction) type, but all records begin
|
||||
* with a common structure that defines the type, length, and txg.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Intent log header - this on disk structure holds fields to manage
|
||||
* the log. All fields are 64 bit to easily handle cross architectures.
|
||||
*/
|
||||
typedef struct zil_header {
|
||||
grub_uint64_t zh_claim_txg; /* txg in which log blocks were claimed */
|
||||
grub_uint64_t zh_replay_seq; /* highest replayed sequence number */
|
||||
blkptr_t zh_log; /* log chain */
|
||||
grub_uint64_t zh_claim_seq; /* highest claimed sequence number */
|
||||
grub_uint64_t zh_flags; /* header flags */
|
||||
grub_uint64_t zh_pad[4];
|
||||
} zil_header_t;
|
||||
|
||||
/*
|
||||
* zh_flags bit settings
|
||||
*/
|
||||
#define ZIL_REPLAY_NEEDED 0x1 /* replay needed - internal only */
|
||||
|
||||
#endif /* _SYS_ZIL_H */
|
84
include/grub/zfs/zio.h
Normal file
84
include/grub/zfs/zio.h
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _ZIO_H
|
||||
#define _ZIO_H
|
||||
|
||||
#include <grub/zfs/spa.h>
|
||||
|
||||
#define ZEC_MAGIC 0x210da7ab10c7a11ULL /* zio data bloc tail */
|
||||
|
||||
typedef struct zio_eck {
|
||||
grub_uint64_t zec_magic; /* for validation, endianness */
|
||||
zio_cksum_t zec_cksum; /* 256-bit checksum */
|
||||
} zio_eck_t;
|
||||
|
||||
/*
|
||||
* Gang block headers are self-checksumming and contain an array
|
||||
* of block pointers.
|
||||
*/
|
||||
#define SPA_GANGBLOCKSIZE SPA_MINBLOCKSIZE
|
||||
#define SPA_GBH_NBLKPTRS ((SPA_GANGBLOCKSIZE - \
|
||||
sizeof (zio_eck_t)) / sizeof (blkptr_t))
|
||||
#define SPA_GBH_FILLER ((SPA_GANGBLOCKSIZE - \
|
||||
sizeof (zio_eck_t) - \
|
||||
(SPA_GBH_NBLKPTRS * sizeof (blkptr_t))) /\
|
||||
sizeof (grub_uint64_t))
|
||||
|
||||
#define ZIO_GET_IOSIZE(zio) \
|
||||
(BP_IS_GANG((zio)->io_bp) ? \
|
||||
SPA_GANGBLOCKSIZE : BP_GET_PSIZE((zio)->io_bp))
|
||||
|
||||
typedef struct zio_gbh {
|
||||
blkptr_t zg_blkptr[SPA_GBH_NBLKPTRS];
|
||||
grub_uint64_t zg_filler[SPA_GBH_FILLER];
|
||||
zio_eck_t zg_tail;
|
||||
} zio_gbh_phys_t;
|
||||
|
||||
enum zio_checksum {
|
||||
ZIO_CHECKSUM_INHERIT = 0,
|
||||
ZIO_CHECKSUM_ON,
|
||||
ZIO_CHECKSUM_OFF,
|
||||
ZIO_CHECKSUM_LABEL,
|
||||
ZIO_CHECKSUM_GANG_HEADER,
|
||||
ZIO_CHECKSUM_ZILOG,
|
||||
ZIO_CHECKSUM_FLETCHER_2,
|
||||
ZIO_CHECKSUM_FLETCHER_4,
|
||||
ZIO_CHECKSUM_SHA256,
|
||||
ZIO_CHECKSUM_ZILOG2,
|
||||
ZIO_CHECKSUM_FUNCTIONS
|
||||
};
|
||||
|
||||
#define ZIO_CHECKSUM_ON_VALUE ZIO_CHECKSUM_FLETCHER_2
|
||||
#define ZIO_CHECKSUM_DEFAULT ZIO_CHECKSUM_ON
|
||||
|
||||
enum zio_compress {
|
||||
ZIO_COMPRESS_INHERIT = 0,
|
||||
ZIO_COMPRESS_ON,
|
||||
ZIO_COMPRESS_OFF,
|
||||
ZIO_COMPRESS_LZJB,
|
||||
ZIO_COMPRESS_EMPTY,
|
||||
ZIO_COMPRESS_GZIP,
|
||||
ZIO_COMPRESS_FUNCTIONS
|
||||
};
|
||||
|
||||
#endif /* _ZIO_H */
|
49
include/grub/zfs/zio_checksum.h
Normal file
49
include/grub/zfs/zio_checksum.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004 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/>.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_ZIO_CHECKSUM_H
|
||||
#define _SYS_ZIO_CHECKSUM_H
|
||||
|
||||
/*
|
||||
* Signature for checksum functions.
|
||||
*/
|
||||
typedef void zio_checksum_t(const void *data, grub_uint64_t size,
|
||||
grub_zfs_endian_t endian, zio_cksum_t *zcp);
|
||||
|
||||
/*
|
||||
* Information about each checksum function.
|
||||
*/
|
||||
typedef struct zio_checksum_info {
|
||||
zio_checksum_t *ci_func; /* checksum function for each byteorder */
|
||||
int ci_correctable; /* number of correctable bits */
|
||||
int ci_eck; /* uses zio embedded checksum? */
|
||||
char *ci_name; /* descriptive name */
|
||||
} zio_checksum_info_t;
|
||||
|
||||
extern void zio_checksum_SHA256 (const void *, grub_uint64_t,
|
||||
grub_zfs_endian_t endian, zio_cksum_t *);
|
||||
extern void fletcher_2 (const void *, grub_uint64_t, grub_zfs_endian_t endian,
|
||||
zio_cksum_t *);
|
||||
extern void fletcher_4 (const void *, grub_uint64_t, grub_zfs_endian_t endian,
|
||||
zio_cksum_t *);
|
||||
|
||||
#endif /* _SYS_ZIO_CHECKSUM_H */
|
|
@ -173,7 +173,8 @@ $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in $(srcdir)/POTFILES-shell
|
|||
--files-from=$(srcdir)/POTFILES-shell.in \
|
||||
--copyright-holder='$(COPYRIGHT_HOLDER)' \
|
||||
--msgid-bugs-address="$$msgid_bugs_address" \
|
||||
--join-existing --language=Shell --keyword=gettext_quoted \
|
||||
--join-existing --language=Shell \
|
||||
--keyword=gettext_quoted --keyword=gettext_printf \
|
||||
;; \
|
||||
*) \
|
||||
$(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
|
||||
|
@ -183,10 +184,13 @@ $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in $(srcdir)/POTFILES-shell
|
|||
--package-name="$${package_gnu}@PACKAGE@" \
|
||||
--package-version='@VERSION@' \
|
||||
--msgid-bugs-address="$$msgid_bugs_address" \
|
||||
--join-existing --language=Shell --keyword=gettext_quoted \
|
||||
--join-existing --language=Shell \
|
||||
--keyword=gettext_quoted --keyword=gettext_printf \
|
||||
;; \
|
||||
esac
|
||||
test ! -f $(DOMAIN).po || { \
|
||||
sed -f grub.d.sed < $(DOMAIN).po > $(DOMAIN).1po && \
|
||||
mv $(DOMAIN).1po $(DOMAIN).po; \
|
||||
if test -f $(srcdir)/$(DOMAIN).pot; then \
|
||||
sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
|
||||
sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
|
||||
|
|
2
po/grub.d.sed
Normal file
2
po/grub.d.sed
Normal file
|
@ -0,0 +1,2 @@
|
|||
/^#: util\/grub\.d\//a\
|
||||
#, c-format
|
|
@ -132,6 +132,8 @@ done
|
|||
|
||||
cat <<EOF >>${cfgfile}
|
||||
source /boot/grub/testcase.cfg
|
||||
# Stop serial output to suppress "ACPI shutdown failed" error.
|
||||
terminal_output console
|
||||
halt
|
||||
EOF
|
||||
|
||||
|
|
|
@ -485,12 +485,15 @@ compare_devices (const void *a, const void *b)
|
|||
{
|
||||
const struct device *left = (const struct device *) a;
|
||||
const struct device *right = (const struct device *) b;
|
||||
int ret;
|
||||
ret = strcmp (left->kernel, right->kernel);
|
||||
if (ret)
|
||||
return ret;
|
||||
else
|
||||
return strcmp (left->stable, right->stable);
|
||||
|
||||
if (left->kernel && right->kernel)
|
||||
{
|
||||
int ret = strcmp (left->kernel, right->kernel);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return strcmp (left->stable, right->stable);
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
|
||||
|
@ -533,6 +536,10 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
|
|||
necessary. */
|
||||
for (entry = readdir (dir); entry; entry = readdir (dir))
|
||||
{
|
||||
/* Skip current and parent directory entries. */
|
||||
if (strcmp (entry->d_name, ".") == 0 ||
|
||||
strcmp (entry->d_name, "..") == 0)
|
||||
continue;
|
||||
/* Skip partition entries. */
|
||||
if (strstr (entry->d_name, "-part"))
|
||||
continue;
|
||||
|
|
|
@ -19,32 +19,32 @@
|
|||
# Initialize some variables.
|
||||
transform="@program_transform_name@"
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
sbindir=@sbindir@
|
||||
bindir=@bindir@
|
||||
libdir=@libdir@
|
||||
sysconfdir=@sysconfdir@
|
||||
prefix="@prefix@"
|
||||
exec_prefix="@exec_prefix@"
|
||||
sbindir="@sbindir@"
|
||||
bindir="@bindir@"
|
||||
libdir="@libdir@"
|
||||
sysconfdir="@sysconfdir@"
|
||||
PACKAGE_NAME=@PACKAGE_NAME@
|
||||
PACKAGE_TARNAME=@PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION=@PACKAGE_VERSION@
|
||||
target_cpu=@target_cpu@
|
||||
platform=@platform@
|
||||
host_os=@host_os@
|
||||
pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`
|
||||
localedir=@datadir@/locale
|
||||
pkglibdir="${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}`"
|
||||
localedir="@datadir@/locale"
|
||||
|
||||
self=`basename $0`
|
||||
self="`basename $0`"
|
||||
|
||||
grub_setup=${sbindir}/`echo grub-setup | sed ${transform}`
|
||||
grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
|
||||
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
|
||||
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
|
||||
grub_editenv=${bindir}/`echo grub-editenv | sed ${transform}`
|
||||
grub_mkrelpath=${bindir}/`echo grub-mkrelpath | sed ${transform}`
|
||||
grub_setup="${sbindir}/`echo grub-setup | sed ${transform}`"
|
||||
grub_mkimage="${bindir}/`echo grub-mkimage | sed ${transform}`"
|
||||
grub_mkdevicemap="${sbindir}/`echo grub-mkdevicemap | sed ${transform}`"
|
||||
grub_probe="${sbindir}/`echo grub-probe | sed ${transform}`"
|
||||
grub_editenv="${bindir}/`echo grub-editenv | sed ${transform}`"
|
||||
grub_mkrelpath="${bindir}/`echo grub-mkrelpath | sed ${transform}`"
|
||||
rootdir=
|
||||
bootdir=
|
||||
grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
|
||||
grubdir="`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`"
|
||||
modules=
|
||||
|
||||
install_device=
|
||||
|
@ -56,15 +56,15 @@ debug_image=
|
|||
|
||||
update_nvram=yes
|
||||
|
||||
ofpathname=`which ofpathname`
|
||||
nvsetenv=`which nvsetenv`
|
||||
efibootmgr=`which efibootmgr 2>/dev/null || true`
|
||||
ofpathname="`which ofpathname`"
|
||||
nvsetenv="`which nvsetenv`"
|
||||
efibootmgr="`which efibootmgr 2>/dev/null || true`"
|
||||
removable=no
|
||||
efi_quiet=
|
||||
|
||||
# Get GRUB_DISTRIBUTOR.
|
||||
if test -f ${sysconfdir}/default/grub ; then
|
||||
. ${sysconfdir}/default/grub
|
||||
if test -f "${sysconfdir}/default/grub" ; then
|
||||
. "${sysconfdir}/default/grub"
|
||||
fi
|
||||
|
||||
bootloader_id="$(echo "$GRUB_DISTRIBUTOR" | tr '[A-Z]' '[a-z]' | cut -d' ' -f1)"
|
||||
|
@ -140,14 +140,14 @@ EOF
|
|||
}
|
||||
|
||||
argument () {
|
||||
opt=$1
|
||||
opt="$1"
|
||||
shift
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo "$0: option requires an argument -- '$opt'" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
echo $1
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
allow_floppy=""
|
||||
|
@ -179,44 +179,44 @@ do
|
|||
|
||||
# Accept for compatibility
|
||||
--root-directory)
|
||||
rootdir=`argument $option "$@"`; shift;;
|
||||
rootdir="`argument $option "$@"`"; shift;;
|
||||
--root-directory=*)
|
||||
rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
|
||||
rootdir="`echo "$option" | sed 's/--root-directory=//'`" ;;
|
||||
|
||||
--boot-directory)
|
||||
bootdir=`argument $option "$@"`; shift;;
|
||||
bootdir="`argument $option "$@"`"; shift;;
|
||||
--boot-directory=*)
|
||||
bootdir=`echo "$option" | sed 's/--boot-directory=//'` ;;
|
||||
bootdir="`echo "$option" | sed 's/--boot-directory=//'`" ;;
|
||||
|
||||
--grub-setup)
|
||||
grub_setup=`argument $option "$@"`; shift;;
|
||||
grub_setup="`argument "$option" "$@"`"; shift;;
|
||||
--grub-setup=*)
|
||||
grub_setup=`echo "$option" | sed 's/--grub-setup=//'` ;;
|
||||
grub_setup="`echo "$option" | sed 's/--grub-setup=//'`" ;;
|
||||
|
||||
--bootloader-id)
|
||||
bootloader_id=`argument $option "$@"`; shift;;
|
||||
bootloader_id="`argument $option "$@"`"; shift;;
|
||||
--bootloader-id=*)
|
||||
bootloader_id=`echo "$option" | sed 's/--bootloader-id=//'` ;;
|
||||
bootloader_id="`echo "$option" | sed 's/--bootloader-id=//'`" ;;
|
||||
|
||||
--grub-mkimage)
|
||||
grub_mkimage=`argument $option "$@"`; shift;;
|
||||
grub_mkimage="`argument $option "$@"`"; shift;;
|
||||
--grub-mkimage=*)
|
||||
grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;;
|
||||
grub_mkimage="`echo "$option" | sed 's/--grub-mkimage=//'`" ;;
|
||||
|
||||
--grub-mkrelpath)
|
||||
grub_mkrelpath=`argument $option "$@"`; shift;;
|
||||
--grub-mkimage=*)
|
||||
grub_mkrelpath=`echo "$option" | sed 's/--grub-mkrelpath=//'` ;;
|
||||
grub_mkrelpath="`argument "$option" "$@"`"; shift;;
|
||||
--grub-mkrelpath=*)
|
||||
grub_mkrelpath="`echo "$option" | sed 's/--grub-mkrelpath=//'`" ;;
|
||||
|
||||
--grub-mkdevicemap)
|
||||
grub_mkdevicemap=`argument $option "$@"`; shift;;
|
||||
grub_mkdevicemap="`argument "$option" "$@"`"; shift;;
|
||||
--grub-mkdevicemap=*)
|
||||
grub_mkdevicemap=`echo "$option" | sed 's/--grub-mkdevicemap=//'` ;;
|
||||
grub_mkdevicemap="`echo "$option" | sed 's/--grub-mkdevicemap=//'`" ;;
|
||||
|
||||
--grub-probe)
|
||||
grub_probe=`argument $option "$@"`; shift;;
|
||||
grub_probe="`argument "$option" "$@"`"; shift;;
|
||||
--grub-probe=*)
|
||||
grub_probe=`echo "$option" | sed 's/--grub-probe=//'` ;;
|
||||
grub_probe="`echo "$option" | sed 's/--grub-probe=//'`" ;;
|
||||
|
||||
--no-floppy)
|
||||
no_floppy="--no-floppy" ;;
|
||||
|
@ -230,11 +230,11 @@ do
|
|||
|
||||
--disk-module)
|
||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
||||
disk_module=`argument $option "$@"`; shift;
|
||||
disk_module="`argument "$option" "$@"`"; shift;
|
||||
fi ;;
|
||||
--disk-module=*)
|
||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
||||
disk_module=`echo "$option" | sed 's/--disk-module=//'`
|
||||
disk_module="`echo "$option" | sed 's/--disk-module=//'`"
|
||||
fi ;;
|
||||
|
||||
--no-nvram)
|
||||
|
@ -244,9 +244,9 @@ do
|
|||
--debug)
|
||||
debug=yes ;;
|
||||
--debug-image)
|
||||
debug_image=`argument $option "$@"`; shift;;
|
||||
debug_image="`argument "$option" "$@"`"; shift;;
|
||||
--debug-image=*)
|
||||
debug_image=`echo "$option" | sed 's/--debug-image=//'` ;;
|
||||
debug_image="`echo "$option" | sed 's/--debug-image=//'`" ;;
|
||||
|
||||
-f | --force)
|
||||
setup_force="--force" ;;
|
||||
|
@ -266,9 +266,6 @@ do
|
|||
esac
|
||||
done
|
||||
|
||||
# for make_system_path_relative_to_its_root()
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
|
||||
if test "x$install_device" = x && ([ "${target_cpu}-${platform}" = "i386-pc" ] \
|
||||
|| [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ]); then
|
||||
echo "install_device not specified." 1>&2
|
||||
|
@ -278,7 +275,7 @@ fi
|
|||
|
||||
# If the debugging feature is enabled, print commands.
|
||||
setup_verbose=
|
||||
if test $debug = yes; then
|
||||
if test x"$debug" = xyes; then
|
||||
set -x
|
||||
setup_verbose="--verbose"
|
||||
efi_quiet=-q
|
||||
|
@ -286,17 +283,17 @@ fi
|
|||
|
||||
if [ -z "$bootdir" ]; then
|
||||
# Default bootdir if bootdir not initialized.
|
||||
bootdir=/@bootdirname@
|
||||
bootdir="/@bootdirname@"
|
||||
|
||||
if [ -n "$rootdir" ] ; then
|
||||
# Initialize bootdir if rootdir was initialized.
|
||||
bootdir=${rootdir}/@bootdirname@
|
||||
bootdir="${rootdir}/@bootdirname@"
|
||||
fi
|
||||
fi
|
||||
|
||||
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
|
||||
device_map=${grubdir}/device.map
|
||||
grub_probe="${grub_probe} --device-map=${device_map}"
|
||||
grubdir="`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`"
|
||||
device_map="${grubdir}/device.map"
|
||||
|
||||
|
||||
# Check if GRUB is installed.
|
||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then
|
||||
|
@ -309,7 +306,7 @@ if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}"
|
|||
fi
|
||||
fi
|
||||
|
||||
set $grub_mkimage dummy
|
||||
set "$grub_mkimage" dummy
|
||||
if test -f "$1"; then
|
||||
:
|
||||
else
|
||||
|
@ -317,7 +314,7 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
set $grub_mkdevicemap dummy
|
||||
set "$grub_mkdevicemap" dummy
|
||||
if test -f "$1"; then
|
||||
:
|
||||
else
|
||||
|
@ -328,24 +325,24 @@ fi
|
|||
if [ x"$platform" = xefi ]; then
|
||||
# Find the EFI System Partition.
|
||||
efidir=
|
||||
if test -d ${bootdir}/efi; then
|
||||
install_device=`$grub_mkdevicemap --device-map=/dev/stdout | $grub_probe --target=device --device-map=/dev/stdin ${bootdir}/efi`
|
||||
if test -d "${bootdir}/efi"; then
|
||||
install_device="`"$grub_mkdevicemap" --device-map=/dev/stdout | "$grub_probe" --target=device --device-map=/dev/stdin "${bootdir}/efi"`"
|
||||
# Is it a mount point?
|
||||
if test "x$install_device" != "x`$grub_mkdevicemap --device-map=/dev/stdout | $grub_probe --target=device --device-map=/dev/stdin ${bootdir}`"; then
|
||||
efidir=${bootdir}/efi
|
||||
if test "x$install_device" != "x`"$grub_mkdevicemap" --device-map=/dev/stdout | "$grub_probe" --target=device --device-map=/dev/stdin "${bootdir}"`"; then
|
||||
efidir="${bootdir}/efi"
|
||||
fi
|
||||
elif test -n "$rootdir" && test "x$rootdir" != "x/"; then
|
||||
# The EFI System Partition may have been given directly using
|
||||
# --root-directory.
|
||||
install_device=`$grub_mkdevicemap --device-map=/dev/stdout | $grub_probe --target=device --device-map=/dev/stdin ${rootdir}`
|
||||
install_device="`"$grub_mkdevicemap" --device-map=/dev/stdout | "$grub_probe" --target=device --device-map=/dev/stdin "${rootdir}"`"
|
||||
# Is it a mount point?
|
||||
if test "x$install_device" != "x`$grub_mkdevicemap --device-map=/dev/stdout | $grub_probe --target=device --device-map=/dev/stdin ${rootdir}/..`"; then
|
||||
efidir=${rootdir}
|
||||
if test "x$install_device" != "x`"$grub_mkdevicemap" --device-map=/dev/stdout | "$grub_probe" --target=device --device-map=/dev/stdin "${rootdir}/.."`"; then
|
||||
efidir="${rootdir}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$efidir"; then
|
||||
efi_fs=`$grub_probe --target=fs --device-map=${device_map} ${efidir}`
|
||||
efi_fs=`"$grub_probe" --target=fs "--device-map=${device_map}" "${efidir}"`
|
||||
if test "x$efi_fs" = xfat; then :; else
|
||||
echo "${efidir} doesn't look like an EFI partition." 1>&2
|
||||
efidir=
|
||||
|
@ -411,7 +408,7 @@ mkdir -p "$grubdir" || exit 1
|
|||
|
||||
# If --recheck is specified, remove the device map, if present.
|
||||
if test $recheck = yes; then
|
||||
rm -f $device_map
|
||||
rm -f "$device_map"
|
||||
fi
|
||||
|
||||
# Create the device map file if it is not present.
|
||||
|
@ -421,11 +418,11 @@ else
|
|||
# Create a safe temporary file.
|
||||
test -n "$mklog" && log_file=`$mklog`
|
||||
|
||||
$grub_mkdevicemap --device-map=$device_map $no_floppy || exit 1
|
||||
"$grub_mkdevicemap" "--device-map=$device_map" $no_floppy || exit 1
|
||||
fi
|
||||
|
||||
# Make sure that there is no duplicated entry.
|
||||
tmp=`sed -n '/^([fh]d[0-9]*)/s/\(^(.*)\).*/\1/p' $device_map \
|
||||
tmp=`sed -n '/^([fh]d[0-9]*)/s/\(^(.*)\).*/\1/p' "$device_map" \
|
||||
| sort | uniq -d | sed -n 1p`
|
||||
if test -n "$tmp"; then
|
||||
echo "The drive $tmp is defined multiple times in the device map $device_map" 1>&2
|
||||
|
@ -433,42 +430,42 @@ if test -n "$tmp"; then
|
|||
fi
|
||||
|
||||
# Copy the GRUB images to the GRUB directory.
|
||||
for file in ${grubdir}/*.mod ${grubdir}/*.lst ${grubdir}/*.img ${grubdir}/efiemu??.o; do
|
||||
if test -f $file && [ "`basename $file`" != menu.lst ]; then
|
||||
rm -f $file || exit 1
|
||||
for file in "${grubdir}"/*.mod "${grubdir}"/*.lst "${grubdir}"/*.img "${grubdir}"/efiemu??.o; do
|
||||
if test -f "$file" && [ "`basename $file`" != menu.lst ]; then
|
||||
rm -f "$file" || exit 1
|
||||
fi
|
||||
done
|
||||
for file in ${pkglibdir}/*.mod ${pkglibdir}/*.lst; do
|
||||
cp -f $file ${grubdir} || exit 1
|
||||
for file in "${pkglibdir}"/*.mod "${pkglibdir}"/*.lst; do
|
||||
cp -f "$file" "${grubdir}" || exit 1
|
||||
done
|
||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then
|
||||
for file in ${pkglibdir}/*.img ${pkglibdir}/efiemu??.o; do
|
||||
if test -f $file; then
|
||||
cp -f $file ${grubdir} || exit 1
|
||||
for file in "${pkglibdir}"/*.img "${pkglibdir}"/efiemu??.o; do
|
||||
if test -f "$file"; then
|
||||
cp -f "$file" "${grubdir}" || exit 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Copy gettext files
|
||||
mkdir -p ${grubdir}/locale/
|
||||
for dir in ${localedir}/*; do
|
||||
mkdir -p "${grubdir}"/locale/
|
||||
for dir in "${localedir}"/*; do
|
||||
if test -f "$dir/LC_MESSAGES/grub.mo"; then
|
||||
cp -f "$dir/LC_MESSAGES/grub.mo" "${grubdir}/locale/${dir##*/}.mo"
|
||||
fi
|
||||
done
|
||||
|
||||
# Write device to a variable so we don't have to traverse /dev every time.
|
||||
grub_device=`$grub_probe --target=device ${grubdir}` || exit 1
|
||||
grub_device="`"$grub_probe" --device-map="${device_map}" --target=device "${grubdir}"`" || exit 1
|
||||
|
||||
if ! test -f ${grubdir}/grubenv; then
|
||||
$grub_editenv ${grubdir}/grubenv create
|
||||
if ! test -f "${grubdir}"/grubenv; then
|
||||
"$grub_editenv" "${grubdir}"/grubenv create
|
||||
fi
|
||||
|
||||
# Create the core image. First, auto-detect the filesystem module.
|
||||
fs_module=`$grub_probe --target=fs --device ${grub_device}`
|
||||
fs_module="`"$grub_probe" --device-map="${device_map}" --target=fs --device "${grub_device}"`"
|
||||
if test "x$fs_module" = x ; then
|
||||
echo "Auto-detection of a filesystem of ${grub_device} failed." 1>&2
|
||||
echo "Please report this together with the output of \"$grub_probe --target=fs -v ${grubdir}\" to <bug-grub@gnu.org>" 1>&2
|
||||
echo "Please report this together with the output of \"$grub_probe --device-map=\"${device_map}\" --target=fs -v ${grubdir}\" to <bug-grub@gnu.org>" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -476,23 +473,24 @@ fi
|
|||
# this command is allowed to fail (--target=fs already grants us that the
|
||||
# filesystem will be accessible).
|
||||
partmap_module=
|
||||
for x in `$grub_probe --target=partmap --device ${grub_device} 2> /dev/null`; do
|
||||
for x in `"$grub_probe" --device-map="${device_map}" --target=partmap --device "${grub_device}" 2> /dev/null`; do
|
||||
case "$x" in
|
||||
netbsd | openbsd)
|
||||
partmap_module="$partmap_module part_bsd";;
|
||||
"") ;;
|
||||
*)
|
||||
partmap_module="$partmap_module part_$x";;
|
||||
esac
|
||||
done
|
||||
|
||||
# Device abstraction module, if any (lvm, raid).
|
||||
devabstraction_module=`$grub_probe --target=abstraction --device ${grub_device}`
|
||||
devabstraction_module="`"$grub_probe" --device-map="${device_map}" --target=abstraction --device "${grub_device}"`"
|
||||
|
||||
# The order in this list is critical. Be careful when modifying it.
|
||||
modules="$modules $disk_module"
|
||||
modules="$modules $fs_module $partmap_module $devabstraction_module"
|
||||
|
||||
relative_grubdir=`make_system_path_relative_to_its_root ${grubdir}` || exit 1
|
||||
relative_grubdir="`"$grub_mkrelpath" "${grubdir}"`" || exit 1
|
||||
if [ "x${relative_grubdir}" = "x" ] ; then
|
||||
relative_grubdir=/
|
||||
fi
|
||||
|
@ -500,10 +498,10 @@ fi
|
|||
prefix_drive=
|
||||
config_opt=
|
||||
|
||||
rm -f ${grubdir}/load.cfg
|
||||
rm -f "${grubdir}/load.cfg"
|
||||
|
||||
if [ "x${debug_image}" != x ]; then
|
||||
echo "set debug='${debug_image}'" >> ${grubdir}/load.cfg
|
||||
echo "set debug='${debug_image}'" >> "${grubdir}/load.cfg"
|
||||
config_opt="-c ${grubdir}/load.cfg "
|
||||
fi
|
||||
|
||||
|
@ -512,28 +510,28 @@ if [ "x${devabstraction_module}" = "x" ] ; then
|
|||
if echo "${install_device}" | grep -qx "(.*)" ; then
|
||||
install_drive="${install_device}"
|
||||
else
|
||||
install_drive="`$grub_probe --target=drive --device ${install_device}`" || exit 1
|
||||
install_drive="`"$grub_probe" --device-map="${device_map}" --target=drive --device "${install_device}"`" || exit 1
|
||||
fi
|
||||
install_drive="`echo ${install_drive} | sed -e s/,[a-z0-9,]*//g`"
|
||||
install_drive="`echo "${install_drive}" | sed -e s/,[a-z0-9,]*//g`"
|
||||
fi
|
||||
grub_drive="`$grub_probe --target=drive --device ${grub_device}`" || exit 1
|
||||
grub_drive="`"$grub_probe" --device-map="${device_map}" --target=drive --device "${grub_device}"`" || exit 1
|
||||
|
||||
# Strip partition number
|
||||
grub_partition="`echo ${grub_drive} | sed -e 's/^[^,]*[,)]//; s/)$//'`"
|
||||
grub_drive="`echo ${grub_drive} | sed -e s/,[a-z0-9,]*//g`"
|
||||
grub_partition="`echo "${grub_drive}" | sed -e 's/^[^,]*[,)]//; s/)$//'`"
|
||||
grub_drive="`echo "${grub_drive}" | sed -e s/,[a-z0-9,]*//g`"
|
||||
if [ "$disk_module" = ata ] ; then
|
||||
# generic method (used on coreboot and ata mod)
|
||||
uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`"
|
||||
uuid="`"$grub_probe" --device-map="${device_map}" --target=fs_uuid --device "${grub_device}"`"
|
||||
if [ "x${uuid}" = "x" ] ; then
|
||||
echo "UUID needed with ata mod, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
echo "search.fs_uuid ${uuid} root " >> ${grubdir}/load.cfg
|
||||
echo 'set prefix=($root)'"${relative_grubdir}" >> ${grubdir}/load.cfg
|
||||
echo "search.fs_uuid ${uuid} root " >> "${grubdir}/load.cfg"
|
||||
echo 'set prefix=($root)'"${relative_grubdir}" >> "${grubdir}/load.cfg"
|
||||
config_opt="-c ${grubdir}/load.cfg "
|
||||
modules="$modules search_fs_uuid"
|
||||
elif [ "x${grub_drive}" != "x${install_drive}" ] ; then
|
||||
uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`"
|
||||
uuid="`"$grub_probe" --device-map="${device_map}" --target=fs_uuid --device "${grub_device}"`"
|
||||
if [ "x${uuid}" = "x" ] ; then
|
||||
echo "You attempted a cross-disk install, but the filesystem containing ${grubdir} does not support UUIDs." 1>&2
|
||||
exit 1
|
||||
|
@ -551,7 +549,7 @@ if [ "x${devabstraction_module}" = "x" ] ; then
|
|||
fi
|
||||
fi
|
||||
else
|
||||
prefix_drive=`$grub_probe --target=drive --device ${grub_device}` || exit 1
|
||||
prefix_drive=`"$grub_probe" --device-map="${device_map}" --target=drive --device "${grub_device}"` || exit 1
|
||||
fi
|
||||
|
||||
case "${target_cpu}-${platform}" in
|
||||
|
@ -568,33 +566,33 @@ case "${target_cpu}-${platform}" in
|
|||
esac
|
||||
|
||||
|
||||
$grub_mkimage ${config_opt} -d ${pkglibdir} -O ${mkimage_target} --output=${grubdir}/core.${imgext} --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1
|
||||
"$grub_mkimage" ${config_opt} -d "${pkglibdir}" -O ${mkimage_target} --output="${grubdir}/core.${imgext}" --prefix="${prefix_drive}${relative_grubdir}" $modules || exit 1
|
||||
|
||||
# Backward-compatibility kludges
|
||||
if [ "${target_cpu}-${platform}" = "mips-yeeloong" ]; then
|
||||
cp ${grubdir}/core.${imgext} ${bootdir}/grub.elf
|
||||
cp "${grubdir}/core.${imgext}" "${bootdir}"/grub.elf
|
||||
elif [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${platform}" = "powerpc-ieee1275" ]; then
|
||||
cp ${grubdir}/core.${imgext} ${grubdir}/grub
|
||||
cp "${grubdir}/core.${imgext}" "${grubdir}/grub"
|
||||
elif [ "${target_cpu}-${platform}" = "i386-efi" ] || [ "${target_cpu}-${platform}" = "x86_64-efi" ]; then
|
||||
$grub_mkimage ${config_opt} -d ${pkglibdir} -O ${mkimage_target} --output=${grubdir}/grub.efi --prefix="" $modules || exit 1
|
||||
"$grub_mkimage" ${config_opt} -d "${pkglibdir}" -O ${mkimage_target} --output="${grubdir}/grub.efi" --prefix="" $modules || exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Perform the platform-dependent install
|
||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then
|
||||
# Now perform the installation.
|
||||
$grub_setup ${allow_floppy} ${setup_verbose} ${setup_force} --directory=${grubdir} \
|
||||
--device-map=${device_map} ${install_device} || exit 1
|
||||
"$grub_setup" ${allow_floppy} ${setup_verbose} ${setup_force} --directory="${grubdir}" \
|
||||
--device-map="${device_map}" "${install_device}" || exit 1
|
||||
elif [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${platform}" = "powerpc-ieee1275" ]; then
|
||||
if [ x"$update_nvram" = xyes ]; then
|
||||
set $ofpathname dummy
|
||||
set "$ofpathname" dummy
|
||||
if test -f "$1"; then
|
||||
:
|
||||
else
|
||||
echo "$1: Not found." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
set $nvsetenv dummy
|
||||
set "$nvsetenv" dummy
|
||||
if test -f "$1"; then
|
||||
:
|
||||
else
|
||||
|
@ -602,16 +600,16 @@ elif [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${pla
|
|||
exit 1
|
||||
fi
|
||||
# Get the Open Firmware device tree path translation.
|
||||
dev=`echo $grub_device | sed -e 's/\/dev\///' -e 's/[0-9]\+//'`
|
||||
partno=`echo $grub_device | sed -e 's/.*[^0-9]\([0-9]\+\)$/\1/'`
|
||||
ofpath=`$ofpathname $dev` || {
|
||||
dev="`echo $grub_device | sed -e 's/\/dev\///' -e 's/[0-9]\+//'`"
|
||||
partno="`echo $grub_device | sed -e 's/.*[^0-9]\([0-9]\+\)$/\1/'`"
|
||||
ofpath="`$ofpathname $dev`" || {
|
||||
echo "Couldn't find Open Firmware device tree path for $dev."
|
||||
echo "You will have to set boot-device manually."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Point boot-device at the new grub install
|
||||
boot_device="$ofpath:$partno,"`grub-mkrelpath ${grubdir}/core.${imgext} | sed 's,/,\\\\,g'`
|
||||
boot_device="$ofpath:$partno,"`"$grub_mkrelpath" "${grubdir}/core.${imgext}" | sed 's,/,\\\\,g'`
|
||||
"$nvsetenv" boot-device "$boot_device" || {
|
||||
echo "$nvsetenv failed."
|
||||
echo "You will have to set boot-device manually. At the Open Firmware prompt, type:"
|
||||
|
@ -620,7 +618,7 @@ elif [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${pla
|
|||
}
|
||||
fi
|
||||
elif [ x"$platform" = xefi ]; then
|
||||
cp ${grubdir}/core.${imgext} ${efidir}/${efi_file}
|
||||
cp "${grubdir}/core.${imgext}" "${efidir}/${efi_file}"
|
||||
|
||||
# Try to make this image bootable using the EFI Boot Manager, if available.
|
||||
if test "$removable" = no && test -n "$efi_distributor" && \
|
||||
|
@ -643,14 +641,14 @@ elif [ x"$platform" = xefi ]; then
|
|||
# Use fresh device map text to avoid any problems with stale data, since
|
||||
# all we need here is a one-to-one mapping.
|
||||
clean_devmap="$($grub_mkdevicemap --device-map=/dev/stdout)"
|
||||
efidir_drive="$(echo "$clean_devmap" | $grub_probe --target=drive --device-map=/dev/stdin "$efidir")"
|
||||
efidir_drive="$(echo "$clean_devmap" | "$grub_probe" --device-map="${device_map}" --target=drive --device-map=/dev/stdin "$efidir")"
|
||||
if test -z "$efidir_drive"; then
|
||||
echo "Can't find GRUB drive for $efidir; unable to create EFI Boot Manager entry." >&2
|
||||
else
|
||||
efidir_disk="$(echo "$clean_devmap" | grep "^$(echo "$efidir_drive" | sed 's/,[^)]*//')" | cut -f2)"
|
||||
efidir_part="$(echo "$efidir_drive" | sed 's/^([^,]*,[^0-9]*//; s/[^0-9].*//')"
|
||||
efibootmgr $efi_quiet -c -d "$efidir_disk" -p "$efidir_part" -w \
|
||||
-L "$GRUB_DISTRIBUTOR" -l "\\EFI\\$efi_distributor\\$efi_file"
|
||||
-L "$bootloader_id" -l "\\EFI\\$efi_distributor\\$efi_file"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -22,6 +22,7 @@ transform="@program_transform_name@"
|
|||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
sbindir=@sbindir@
|
||||
bindir=@bindir@
|
||||
libdir=@libdir@
|
||||
sysconfdir=@sysconfdir@
|
||||
PACKAGE_NAME=@PACKAGE_NAME@
|
||||
|
@ -35,8 +36,9 @@ grub_mkconfig_dir=${sysconfdir}/grub.d
|
|||
|
||||
self=`basename $0`
|
||||
|
||||
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed ${transform}`
|
||||
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
|
||||
grub_mkdevicemap=${sbindir}/`echo grub-mkdevicemap | sed "${transform}"`
|
||||
grub_probe=${sbindir}/`echo grub-probe | sed "${transform}"`
|
||||
grub_script_check="${bindir}/`echo grub-script-check | sed "${transform}"`"
|
||||
|
||||
GRUB_PREFIX=`echo '/@bootdirname@/@grubdirname@' | sed "s,//*,/,g"`
|
||||
|
||||
|
@ -290,7 +292,7 @@ for i in ${grub_mkconfig_dir}/* ; do
|
|||
done
|
||||
|
||||
if test "x${grub_cfg}" != "x" ; then
|
||||
if ! grub-script-check ${grub_cfg}.new; then
|
||||
if ! ${grub_script_check} ${grub_cfg}.new; then
|
||||
echo "Syntax errors are detected in generated GRUB config file." >&2
|
||||
echo "Ensure that there are no errors in /etc/default/grub" >&2
|
||||
echo "and /etc/grub.d/* files or please file a bug report with" >&2
|
||||
|
|
|
@ -187,8 +187,20 @@ version_find_latest ()
|
|||
echo "$a"
|
||||
}
|
||||
|
||||
# One layer of quotation is eaten by "", the second by sed, and the third by
|
||||
# printf; so this turns ' into \'. Note that you must use the output of
|
||||
# this function in a printf format string.
|
||||
gettext_quoted () {
|
||||
$gettext "$@" | sed "s/'/'\\\\''/g"
|
||||
$gettext "$@" | sed "s/'/'\\\\\\\\''/g"
|
||||
}
|
||||
|
||||
# Run the first argument through gettext_quoted, and then pass that and all
|
||||
# remaining arguments to printf. This is a useful abbreviation and tends to
|
||||
# be easier to type.
|
||||
gettext_printf () {
|
||||
local format="$1"
|
||||
shift
|
||||
printf "$(gettext_quoted "$format")" "$@"
|
||||
}
|
||||
|
||||
uses_abstraction () {
|
||||
|
|
|
@ -1146,11 +1146,18 @@ main (int argc, char *argv[])
|
|||
{
|
||||
FT_Face ft_face;
|
||||
int size;
|
||||
FT_Error err;
|
||||
|
||||
if (FT_New_Face (ft_lib, argv[optind], font_index, &ft_face))
|
||||
err = FT_New_Face (ft_lib, argv[optind], font_index, &ft_face);
|
||||
if (err)
|
||||
{
|
||||
grub_util_info ("can't open file %s, index %d", argv[optind],
|
||||
font_index);
|
||||
grub_printf ("can't open file %s, index %d: error %d", argv[optind],
|
||||
font_index, err);
|
||||
if (err > 0 && err < (signed) ARRAY_SIZE (ft_errmsgs))
|
||||
printf (": %s\n", ft_errmsgs[err]);
|
||||
else
|
||||
printf ("\n");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1170,7 +1177,8 @@ main (int argc, char *argv[])
|
|||
font_info.style = ft_face->style_flags;
|
||||
font_info.size = size;
|
||||
|
||||
FT_Set_Pixel_Sizes (ft_face, size, size);
|
||||
if (FT_Set_Pixel_Sizes (ft_face, size, size))
|
||||
grub_util_error ("can't set %dx%d font size", size, size);
|
||||
add_font (&font_info, ft_face, file_format != PF2);
|
||||
FT_Done_Face (ft_face);
|
||||
}
|
||||
|
|
|
@ -142,6 +142,7 @@ probe (const char *path, char *device_name)
|
|||
int is_raid5 = 0;
|
||||
int is_raid6 = 0;
|
||||
int raid_level;
|
||||
grub_disk_t raid_disk;
|
||||
|
||||
raid_level = probe_raid_level (dev->disk);
|
||||
if (raid_level >= 0)
|
||||
|
@ -149,6 +150,7 @@ probe (const char *path, char *device_name)
|
|||
is_raid = 1;
|
||||
is_raid5 |= (raid_level == 5);
|
||||
is_raid6 |= (raid_level == 6);
|
||||
raid_disk = dev->disk;
|
||||
}
|
||||
|
||||
if ((is_lvm) && (dev->disk->dev->memberlist))
|
||||
|
@ -161,6 +163,7 @@ probe (const char *path, char *device_name)
|
|||
is_raid = 1;
|
||||
is_raid5 |= (raid_level == 5);
|
||||
is_raid6 |= (raid_level == 6);
|
||||
raid_disk = list->disk;
|
||||
}
|
||||
|
||||
tmp = list->next;
|
||||
|
@ -175,8 +178,8 @@ probe (const char *path, char *device_name)
|
|||
printf ("raid5rec ");
|
||||
if (is_raid6)
|
||||
printf ("raid6rec ");
|
||||
if (dev->disk->dev->raidname)
|
||||
printf ("%s ", dev->disk->dev->raidname (dev->disk));
|
||||
if (raid_disk->dev->raidname)
|
||||
printf ("%s ", raid_disk->dev->raidname (raid_disk));
|
||||
}
|
||||
|
||||
if (is_lvm)
|
||||
|
|
|
@ -73,6 +73,7 @@ main (int argc, char *argv[])
|
|||
{
|
||||
char *argument;
|
||||
char *input;
|
||||
int lineno = 0;
|
||||
FILE *file = 0;
|
||||
int verbose = 0;
|
||||
int found_input = 0;
|
||||
|
@ -111,6 +112,7 @@ main (int argc, char *argv[])
|
|||
cmdline[i] = '\0';
|
||||
}
|
||||
|
||||
lineno++;
|
||||
*line = grub_strdup (cmdline);
|
||||
|
||||
free (cmdline);
|
||||
|
@ -189,5 +191,11 @@ main (int argc, char *argv[])
|
|||
|
||||
if (file) fclose (file);
|
||||
|
||||
return (found_input && script == 0);
|
||||
if (found_input && script == 0)
|
||||
{
|
||||
fprintf (stderr, "error: line no: %u\n", lineno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -492,7 +492,7 @@ unable_to_embed:
|
|||
"setup by using blocklists. However, blocklists are UNRELIABLE and "
|
||||
"their use is discouraged."));
|
||||
if (! force)
|
||||
grub_util_error (_("if you really want blocklists, use --force"));
|
||||
grub_util_error (_("will not proceed with blocklists"));
|
||||
|
||||
/* The core image must be put on a filesystem unfortunately. */
|
||||
grub_util_info ("will leave the core image on the filesystem");
|
||||
|
|
|
@ -23,7 +23,7 @@ prefix=@prefix@
|
|||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
locale_dir=`echo ${GRUB_PREFIX}/locale | sed ${transform}`
|
||||
grub_lang=`echo $LANG | cut -d _ -f 1`
|
||||
grub_lang=`echo $LANG | cut -d . -f 1`
|
||||
|
||||
. ${libdir}/grub/grub-mkconfig_lib
|
||||
|
||||
|
|
|
@ -81,14 +81,16 @@ do
|
|||
menuentry "${OS} ${KERNEL}" ${CLASS} {
|
||||
EOF
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
|
||||
message="$(gettext_printf "Loading GNU Mach ...")"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading GNU Mach ...")'
|
||||
echo '$message'
|
||||
multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/}
|
||||
EOF
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
|
||||
message="$(gettext_printf "Loading the Hurd ...")"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading the Hurd ...")'
|
||||
echo '$message'
|
||||
module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
|
||||
--multiboot-command-line='\${kernel-command-line}' \\
|
||||
--host-priv-port='\${host-port}' \\
|
||||
|
@ -103,13 +105,15 @@ EOF
|
|||
menuentry "${OS} ${KERNEL} (recovery mode)" ${CLASS} {
|
||||
EOF
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
|
||||
message="$(gettext_printf "Loading GNU Mach ...")"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading GNU Mach ...")'
|
||||
echo '$message'
|
||||
multiboot ${kernel} root=device:${GRUB_DEVICE#/dev/} -s
|
||||
EOF
|
||||
prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
|
||||
message="$(gettext_printf "Loading the Hurd ...")"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading the Hurd ...")'
|
||||
echo '$message'
|
||||
module /hurd/${hurd_fs}.static ${hurd_fs} \\
|
||||
--multiboot-command-line='\${kernel-command-line}' \\
|
||||
--host-priv-port='\${host-port}' \\
|
||||
|
|
|
@ -84,8 +84,9 @@ kfreebsd_entry ()
|
|||
fi
|
||||
|
||||
printf '%s\n' "${prepare_boot_cache}"
|
||||
message="$(gettext_printf "Loading kernel of FreeBSD %s ..." ${version})"
|
||||
cat << EOF
|
||||
echo '$(printf "$(gettext_quoted "Loading kernel of FreeBSD %s ...")" ${version})'
|
||||
echo '$message'
|
||||
kfreebsd ${rel_dirname}/${basename} ${args}
|
||||
EOF
|
||||
|
||||
|
|
|
@ -94,13 +94,15 @@ EOF
|
|||
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
|
||||
fi
|
||||
printf '%s\n' "${prepare_boot_cache}"
|
||||
message="$(gettext_printf "Loading Linux %s ..." ${version})"
|
||||
cat << EOF
|
||||
echo '$(printf "$(gettext_quoted "Loading Linux %s ...")" ${version})'
|
||||
echo '$message'
|
||||
linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
|
||||
EOF
|
||||
if test -n "${initrd}" ; then
|
||||
message="$(gettext_printf "Loading initial ramdisk ...")"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading initial ramdisk ...")'
|
||||
echo '$message'
|
||||
initrd ${rel_dirname}/${initrd}
|
||||
EOF
|
||||
fi
|
||||
|
|
|
@ -60,11 +60,11 @@ linux_entry ()
|
|||
args="$5"
|
||||
xen_args="$6"
|
||||
if ${recovery} ; then
|
||||
title="$(gettext_quoted "%s, with Linux %s and XEN %s (recovery mode)")"
|
||||
title="$(gettext_quoted "%s, with Xen %s and Linux %s (recovery mode)")"
|
||||
else
|
||||
title="$(gettext_quoted "%s, with Linux %s and XEN %s")"
|
||||
title="$(gettext_quoted "%s, with Xen %s and Linux %s")"
|
||||
fi
|
||||
printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${version}" "${xen_version}"
|
||||
printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${xen_version}" "${version}"
|
||||
if ! ${recovery} ; then
|
||||
save_default_entry | sed -e "s/^/\t/"
|
||||
fi
|
||||
|
@ -73,14 +73,18 @@ linux_entry ()
|
|||
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
|
||||
fi
|
||||
printf '%s\n' "${prepare_boot_cache}"
|
||||
xmessage="$(gettext_printf "Loading Xen %s ..." ${xen_version})"
|
||||
lmessage="$(gettext_printf "Loading Linux %s ..." ${version})"
|
||||
cat << EOF
|
||||
echo '$(printf "$(gettext_quoted "Loading Linux %s ...")" ${version})'
|
||||
echo '$xmessage'
|
||||
multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args}
|
||||
echo '$lmessage'
|
||||
module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
|
||||
EOF
|
||||
if test -n "${initrd}" ; then
|
||||
message="$(gettext_printf "Loading initial ramdisk ...")"
|
||||
cat << EOF
|
||||
echo '$(gettext_quoted "Loading initial ramdisk ...")'
|
||||
echo '$message'
|
||||
module ${rel_dirname}/${initrd}
|
||||
EOF
|
||||
fi
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue