Compare commits

...
Author SHA1 Message Date
206676601e README: remove references to grub.enbug.org 2015-10-30 11:13:17 +01:00
Andrei Borzenkov 33b1103e30 NEWS: mention powerpc64le support 2015-10-29 21:29:12 +03:00
Ignat Korchagin 43c8310244 tcp: Fix uninited mac address when accepting connection. 2015-10-29 16:30:28 +01:00
Fu Wei 83cb45e982 arm64: Add support for xen boot protocol. 2015-10-29 15:24:20 +01:00
Vladimir Serbinenko 4d0cb75538 arm64: Move FDT functions to separate module 2015-10-29 14:06:45 +01:00
Andrei Borzenkov 5fcde03bf1 efi: fix warnings with recent GCC
../../grub-core/term/efi/console.c:128:32: error: suggest parentheses around '&&' within '||' [-Werror=parentheses]
   if (key.unicode_char >= 0x20 && key.unicode_char <= 0x7f
2015-10-27 23:30:54 +03:00
Eric Snowberg 0b72543afd ofdisk: Fix devpath freeing logic. 2015-10-26 23:03:06 +01:00
Paulo Flabiano Smorigo bf3df4070f Implement cross-endian ELF load for powerpc 2015-10-26 22:07:26 +01:00
Peter Jones 9e5f70174e Use EFI_SIMPLE_TEXT_INPUT_EX to support key combinations. 2015-10-25 16:36:28 +01:00
Andrei Borzenkov a3645c1240 configure: find options to force endian on MIPS 2015-10-14 00:42:14 +02:00
Andrei Borzenkov be25d92196 configure: force o32 ABI on MIPS
GRUB code expects O32 or N32. N32 is less tested than O32, so we prefer to
compile with O32. Some systems (e.g. GNU Guix) default to using newer
n64 or n32 ABI. Try to find suitable options to force o32.

For GCC this is simply -mabi=32. While clang supports this option as well,
o32 ABI is valid for MIPS target and n32/64 ABI are valid for MIPS64 target
only, so use "-target mips/mipsel -mabi=32".

Reported-By: Mark H Weaver <mhw@netris.org>
Also-By: Mark H Weaver <mhw@netris.org>
2015-10-14 00:39:15 +02:00
Andrei Borzenkov a01ab69848 net: avoid closing NULL socket in DNS lookup
Refactor code so that we do not store NULL pointers in array
of in-flight DNS servers.

Reported-By: Josef Bacik <jbacik@fb.com>
2015-10-12 23:16:23 +03:00
Andrei Borzenkov 76197d9be6 install: --compress argument is not optional
Fixes crash if argument is not specified. Also use `|' to separate choices
in list of compression methods to align it with --core-compress.
2015-10-11 21:17:37 +03:00
Vladimir Serbinenko cfabe05cc6 mips: Make setjmp code N32-compliant. 2015-10-11 13:20:26 +02:00
Vladimir Serbinenko 285540e448 mips: Make the assembly-code N32-compatible.
There are no $t4 or $t5 in N32 but there are $a4 and $a5.
2015-10-11 13:20:26 +02:00
Andrei Borzenkov 6e21195890 progress: avoid NULL dereference for net files
From original patch by dann frazier <dann.frazier@canonical.com>:

  grub_net_fs_open() saves off a copy of the file structure it gets passed and
  uses it to create a bufio structure. It then overwrites the passed in file
  structure with this new bufio structure. Since file->name doesn't get set
  until we return back to grub_file_open(), it means that only the bufio
  structure gets a valid file->name. The "real" file's name is left
  uninitialized. This leads to a crash when the progress module hook is called
  on it.

grub_net_fs_open() already saved copy of file name as ->net->name, so change
progress module to use it.

Also, grub_file_open may leave file->name as NULL if grub_strdup fails. Check
for it.

Also-By: dann frazier <dann.frazier@canonical.com>
2015-10-10 11:44:14 +03:00
Andrei Borzenkov d31321835e file: ignore host disk in blocklist check
It cannot work anyway because host disk cannot be read. This fixes hostfs access
on native Windows build where filenames start with '\' or do not have initial
separator at all (d:\foo).

Issue was observed when running grub-fstest on Windows. On UNIX image name is
canonicalized to always start with `/' so this was not noticed.

This has side effect of allowing relative path names on host, but this already
was the case with `ls' command, so it just extends it to all commands.

Reported-By: Arch Stack <archstacker@gmail.com>
Also-By: Arch Stack <archstacker@gmail.com>
2015-10-10 10:02:20 +03:00
Vladimir Serbinenko c2443e49bc mips/dl: Handle addend in RELA entries. 2015-10-09 23:32:06 +02:00
Vladimir Serbinenko f59b83fce6 gfxmenu/model: Delete empty file. 2015-10-09 23:30:53 +02:00
Alexander Bluhm f188a86064 ufs: Fix parameters to grub_memset.
len = 0 made simply no sense. Fix parameters to be in line with read.
2015-10-09 13:35:40 +02:00
Stanislav Kholmanskikh ee67bcf31e ofnet: Do not set SUFFIX for sun4v network devices
sun4v vnet devices do not implement the support of duplex and speed
instance attributes. An attempt to open such a device with
the attributes will fail:

ok select net:speed=auto,duplex=auto
Unknown key 'speed'
Unknown key 'duplex'
Manual Configuration: Host IP, boot server and filename must be specified
WARNING: /virtual-devices@100/channel-devices@200/network@0: Can't open OBP standard TFTP package

Can't open device
ok

Therefore, let's not set SUFFIX for such devices.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
2015-10-07 20:00:52 +03:00
Eric Snowberg 8cb4c4edbe sparc64 - use correct drive name within grub_util_sparc_setup
Incorrect drive name was being passed into grub_util_sparc_setup,
causing the grub-install to fail.

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
2015-10-07 19:51:57 +03:00
Andrei Borzenkov c93d3e6947 cryptodisk: strip parenthesis from backing device name
Otherwise subsequent disk open fails.

Reported-By: Klemens Nanni <contact@autoboot.org>
2015-09-13 20:12:31 +03:00
Felix Zielcke 8e3d2c80ed disk/ldm, partmap/msdos.c: fix spelling error 2015-08-22 21:22:41 +02:00
Andrei Borzenkov ba218c1c10 net: do not try to load protocol module via itself
Otherwise we get infinite recursion.

Closes: 45729
2015-08-13 20:20:39 +03:00
Josef Bacik 4fe8e6d4a1 efinet: handle get_status() on buggy firmware properly
The EFI spec indicates that get_status() should return the address of the buffer
we passed into transmit to indicate the the buffer was transmitted.  However we
have boxes where the firmware returns some arbitrary address instead, which
makes grub think that we've not sent anything.  So since we have the SNP stuff
opened in exclusive mode just assume any non-NULL txbuf means that our transmit
occurred properly.  This makes grub able to do its networking stuff properly on
our broken firmware.  Thanks,

cc: Peter Jones <pjones@redhat.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
2015-08-09 16:37:26 +03:00
Andrei Borzenkov d7a85e69e0 linguas.sh: fix error when removing non-existing autogenerated files 2015-08-09 16:28:12 +03:00
Vladimir Serbinenko 72fc110d95 ahci: Ensure that bus mastering is set.
Fixes ahci_test failing on several platforms.
2015-07-28 01:51:14 +02:00
Vladimir Serbinenko d3b464a7c0 archelp: Never pass NULL as mtime.
Moves complexity from fs code (NULL check) to common code (passing non-NULL).
2015-07-27 13:19:02 +02:00
Vladimir Serbinenko 5fb1e859f7 HFS: Convert to fshelp.
HFS doesn't handle "." and ".." properly. Convert it to fshelp to reuse the
logic.
2015-07-27 12:50:22 +02:00
Vladimir Serbinenko bfb5b33e96 FAT: Convert to fshelp.
exFAT doesn't handle "." and ".." correctly, convert it to fshelp to
reuse the same logic.
2015-07-27 12:49:26 +02:00
Vladimir Serbinenko d1d3a60b71 BFS: Convert to fshelp.
BFS doesn't handle ".." correctly, so convert it to fshelp to reuse the logic.
2015-07-27 12:48:38 +02:00
Vladimir Serbinenko fa93b0e4f5 fshelp: Add handling of "." and ".." and grub_fshelp_find_file_lookup.
Recent tests have discovered that many of our filesystems have flawed
handling of "." and "..". Rather than attempting to fix it in filesystems
themselves, make the common code fshelp aware of "." and ".." and handle
them in this layer. Add grub_fshelp_find_file_lookup for easy conversion
of BFS, HFS and exFAT which have the same problem and don't use fshelp.
2015-07-27 12:45:35 +02:00
Vladimir Serbinenko 4622f4e1ee Switch procfs to use archelp.
This fixes handling of "." and "..".
2015-07-27 12:44:19 +02:00
Vladimir Serbinenko a2721778e5 grub-install: Use a+ in fopen rather than r+.
r+ does not create a file if none exists.
2015-07-27 12:42:47 +02:00
Vladimir Serbinenko 368ecfc3a0 Add transform_data as a variant of data with substitutions.
This fixrs name mismatch for grub.chrp with
transform_program_name='s,grub,grub2,g'
2015-07-27 12:39:41 +02:00
Ignat Korchagin d5847bf594 efi: fix GetVariable return status check in 81ca24a
GetVariable should return EFI_BUFFER_TOO_SMALL if given buffer of size
zero; commit incorrectly checked for EFI_SUCCESS.
2015-07-24 20:46:02 +03:00
Vladimir Serbinenko 333855c646 zfs_test: Skip dotdot in volume root test.
Given special semantics of ZFS it's far from clear what the expected
result is. Just skip it for now
2015-07-24 01:23:45 +02:00
Vladimir Serbinenko 900fca88ac xfs_test: Test both crc and non-crc filesystems. 2015-07-24 01:23:45 +02:00
Vladimir Serbinenko 049dcfa03c xfs: Fix handling of symlink with crc-enabled filesystem. 2015-07-24 01:23:45 +02:00
Vladimir Serbinenko 02a249005f reiserfs: Fix handling of first entry in the directory.
Fixes garbage being added to "." filename.
2015-07-24 01:23:45 +02:00
Ignat Korchagin 81ca24a59c efi: fix memory leak in variable handling 2015-07-23 21:13:09 +03:00
Vladimir Serbinenko d0d90d7848 exclude.pot: Add missing blacklisted strings. 2015-07-23 19:04:55 +02:00
Vladimir Serbinenko f34a422081 archelp: Fix handling of dot and dotdot at the end of the name.
Fixes cpio_test and tar_test.
2015-07-23 19:01:00 +02:00
Vladimir Serbinenko ca73ae446c arm-emu: Add __aeabi_memcpy* and __aeabi_memclr* symbols.
Fixes compilation with clang.
2015-07-23 02:15:46 +02:00
Vladimir Serbinenko 248bc1d0fc fwstart: Fix loading of address of read_spd_fail. 2015-07-22 21:42:41 +02:00
Vladimir Serbinenko 63411b14be fwstart: Add missing argument to p2align.
Resulting binary is unchanged as it happens we were already aligned
by chance.
2015-07-22 21:41:58 +02:00
Vladimir Serbinenko 80783ea646 fwstart: Replace blt with bltz.
blt A, $zero, B and bltz A, B are equivalent but clang recognizes only
later, so use it.

Resulting binary is unchanged.
2015-07-22 21:40:55 +02:00
Vladimir Serbinenko eecdbebc84 Remove mips_attributes.
mips_attributes was introduced to work around clang problems with
-msoft-float. Those problems are now fixed and moreover .gnu_attributes
itself is unportable and creates problem with clang.

Revert "mips: Fix soft-float handling."

This partially reverts commit 6a4ecd276e.
2015-07-22 21:05:11 +02:00
Vladimir Serbinenko f250c337f1 ARM: provide __aeabi_memclr* and __aeabi_memcpy* symbols
Fixes compilation with recent clang.
2015-07-22 20:40:13 +02:00
Vladimir Serbinenko 389d509df0 diskfilter: Make name a const char to fix compilation error. 2015-07-22 20:39:14 +02:00
Vladimir Serbinenko 9f27f9f691 dmraid_nvidia: Set a name to usable value to avoid null dereference.
Reported by: Andrei Borzenkov
2015-07-22 01:57:40 +02:00
Vladimir Serbinenko 5c46165a7c configure.ac: Handle powerpc64le compiler
Also-by: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
2015-07-22 01:54:59 +02:00
Bernhard Übelacker 61c778f640 loader/linux: Make trailer initrd entry aligned again.
Regression from commit:
  loader/linux: do not pad initrd with zeroes at the end
  a8c473288d

Wimboot fails since the change above because it expects the "trailer"
initrd element on an aligned address.
This issue shows only when newc_name is used and the last initrd
entry has a not aligned size.
2015-07-20 19:07:20 +03:00
Vladimir Serbinenko ff3c2007ef XFS: Fix wrong alignment treatment. 2015-07-16 12:46:02 +02:00
Vladimir Serbinenko 54e7dbbcb9 grub_ext2_read_block: Fix return type on error. 2015-07-16 10:59:33 +02:00
Andrei Borzenkov 0d7c7f751d use TARGET_LDFLAGS in grub_PROG_OBJCOPY_ABSOLUTE
That's what Makefile will use and it is required if unusual flags
must be passed to linker (e.g. to build ppc32 code on ppc64le with clang).
2015-07-05 08:21:38 +03:00
Michael Chang 7a210304eb Fix missing byte order conversion in get_btrfs_fs_prefix function
Since btrfs on-disk format uses little-endian, the searched item types
(ROOT_REF, INODE_REF) need converting the byte order in order to
function properly on big-endian systems.
2015-06-26 09:55:56 +03:00
Andrei Borzenkov c058e85615 chainloader: fix resoource leak
Found by: Coverity scan.
CID: 96651
2015-06-26 09:25:30 +03:00
Andrei Borzenkov 806bb7999d loader/bsd: fix memory leak
Found by: Coverity scan.
CID: 96662, 96665
2015-06-26 09:25:30 +03:00
Andrei Borzenkov 867c9b7bec loader/bsd: free memory leaks
Found by: Coverity scan.
CID: 96671, 96658, 96653
2015-06-20 23:38:19 +03:00
Andrei Borzenkov 5af859bb77 search_wrap: fix memory leak
Found by: Coverity scan.
CID: 96675
2015-06-20 23:38:19 +03:00
Andrei Borzenkov 2f01f08103 password_pbkdf2: fix memory leak
Found by: Coverity scan.
CID: 96676
2015-06-20 23:38:19 +03:00
Andrei Borzenkov 152695d0fa normal: fix memory leak
Found by: Coverity scan.
CID: 96677
2015-06-20 23:38:19 +03:00
Andrei Borzenkov e7e05cae8d efi/serial: fix memory leak
Found by: Coverity scan.
CID: 96678
2015-06-20 23:38:19 +03:00
Andrei Borzenkov 47490ada3d ohci: fix memory leak
Found by: Coverity scan.
CID: 96679
2015-06-20 23:38:19 +03:00
Andrei Borzenkov 4a857e63c1 loader/bsd: free memory leaks
Found by: Coverity scan.
CID: 96682
2015-06-20 23:38:18 +03:00
Andrei Borzenkov eb33e61b31 multiboot: fix memory leak
Found by: Coverity scan.
CID: 96684
2015-06-20 23:38:18 +03:00
Andrei Borzenkov 2a3ebf9428 normal: fix memory leak
Found by: Coverity scan.
CID: 96685
2015-06-20 23:38:18 +03:00
Andrei Borzenkov 20211c0077 loader/bsd: fix memory leak
Found by: Coverity scan.
CID: 96686
2015-06-20 23:38:18 +03:00
Andrei Borzenkov a6f7d1abce reed_solomon: fix memory leak
Found by: Coverity scan.
CID: 96688
2015-06-20 23:38:18 +03:00
Andrei Borzenkov cf0b0306d8 usb: fix use after free
Found by: Coverity scan.
CID: 96704
2015-06-20 23:38:18 +03:00
Andrei Borzenkov e261fcf4c6 xnu: fix use after free
Found by: Coverity scan.
CID: 96706
2015-06-20 23:38:18 +03:00
Andrei Borzenkov cd816bd236 disk/scsi: fix use after free
Found by: Coverity scan.
CID: 96713
2015-06-20 23:38:18 +03:00
Andrei Borzenkov c069460259 efi/chainloader: fix use after free
Found by: Coverity scan.
CID: 96714
2015-06-20 23:38:17 +03:00
Andrei Borzenkov 0fb886cde9 search: fix use after free
Found by: Coverity scan.
CID: 96715
2015-06-20 23:38:17 +03:00
Andrei Borzenkov 72ccf92c39 NEWS: emu libusb support removed 2015-06-20 09:23:43 +03:00
Andrei Borzenkov 4358e0c81e grub-probe: fix memory leak in probe (ofpath)
Found by: Coverity scan.
CID: 73772
2015-06-19 20:47:44 +03:00
Andrei Borzenkov 03f1f24e37 grub-probe: restructure code to make static analysis easier
Current code in probe() could not be verified to not contain memory leaks.
Restructure code and ensure grub_device_close is always called at the end of
loop.

Calms down Coverity scan.
CID: 73739
2015-06-19 20:47:43 +03:00
Andrei Borzenkov fbdd37e7f9 zfs: fix memory leak
Found by: Coverity scan.
CID: 73647
2015-06-19 20:47:43 +03:00
Andrei Borzenkov 4db569ca6a xfs: silence Coverity overflow warning
inode size cannot really overflow integer, but Coverity does not know it.
CID: 96602
2015-06-19 18:38:25 +03:00
Andrei Borzenkov 15ba6a40be zfs: memory leak
Found by Coverity scan.
CID: 96603
2015-06-19 18:38:25 +03:00
Andrei Borzenkov 5d0ee3d7a1 unix/getroot: memory leak
Found by Coverity scan.
CID: 96605
2015-06-19 18:38:25 +03:00
Andrei Borzenkov 10a6d2d915 unix/relpath: memory leak
Found by Coverity scan.
CID: 96606
2015-06-19 18:38:25 +03:00
Andrei Borzenkov 48cd9dc104 syslinux_parse: assorted issues found by Coverity
1. Remove unneeded NULL check
CID: 96607

2. Do not allocate storage for initrd, copy it directly from input
buffer. Avoids memory leak in failure path.
CID: 96604

3. Unchecked error return from print()
CID: 96601, 73595
2015-06-19 18:38:25 +03:00
Andrei Borzenkov 8067fe28ed syslinux_parse: make print_escaped actually stop before `to'
The only current user is mboot.c32 which unfortunately is not covered
by regression tests.
2015-06-19 17:35:17 +03:00
Andrei Borzenkov 7bb7140df2 fat: fix handling of "." and ".." directory entries
Emulate dot and dotdot in root directory. For other directories do not
add separator between name and extension for these two special entries.

Closes: 45335
2015-06-18 20:09:47 +03:00
Andrei Borzenkov 7af839a108 tests: regression tests for "." and ".." directory entries 2015-06-18 20:09:47 +03:00
Andrei Borzenkov f348aee7b3 efinet: enable hardware filters when opening interface
Exclusive open on SNP will close all existing protocol instances which
may disable all receive filters on interface. Reinstall them after we
opened protocol exclusively.

Also follow UEFI specification recommendation and stop interfaces when
closing them:

Unexpected system errors, reboots and hangs can occur if an OS is loaded
and the network devices are not Shutdown() and Stopped().

Also by: Mark Salter <msalter@redhat.com>
Closes: 45204
2015-06-16 19:52:45 +03:00
Andrei Borzenkov b27af387ea NEWS: mention libgcc removal 2015-06-16 19:49:32 +03:00
Paulo Flabiano Smorigo afd0f21b20 Add flag for powerpc ieee1275 to avoid unneeded optimizations 2015-06-15 09:10:19 -03:00
Mark Salter c945ca75c3 Fix exit to EFI firmware
The current code for EFI grub_exit() calls grub_efi_fini() before
returning to firmware. In the case of ARM, this leaves a timer
event running which could lead to a firmware crash. This patch
changes this so that grub_machine_fini() is called with a NORETURN
flag. This allows machine-specific shutdown to happen as well
as the shutdown done by grub_efi_fini().

Signed-off-by: Mark Salter <msalter@redhat.com>
2015-06-12 13:08:36 +03:00
Paul Menzel f4b1b48a83 disk/ahci.c: Use defines GRUB_AHCI_HBA_PORT_CMD_SPIN_UP and GRUB_AHCI_HBA_PORT_CMD_POWER_ON
Instead of hard coding `2` and `4` use the macros defined already at the
top of the file. As a consequence, wrap the now too long line.
2015-06-12 09:43:00 +03:00
Andrei Borzenkov df2aaf94b8 NEWS: XFS v5 support 2015-06-12 09:40:00 +03:00
Jan Kara b6e80c7778 xfs: V5 filesystem format support
Add support for new XFS on disk format. We have to handle optional
filetype fields in directory entries, additional CRC, LSN, UUID entries
in some structures, etc.

Signed-off-by: Jan Kara <jack@suse.cz>
2015-06-12 09:30:02 +03:00
Jan Kara d3ffeb9a9a xfs: Add helpers for inode size
Add helpers to return size of XFS inode on disk and when loaded in
memory.

Signed-off-by: Jan Kara <jack@suse.cz>
2015-06-12 09:27:09 +03:00
Toomas Soome 697eceff6a multiboot_header_tag_module_align fix to confirm multiboot specification 2015-06-04 19:58:59 +03:00
Leif Lindholm 43d4231432 configure.ac: clean up arm64 soft-float handling
Fix compilation with gcc 5.1 (avoid internal compiler error), by
replacing explicit -march +nofp+nosimd options with -mgeneral-regs-only.

This also enables the removal of some further conditional build flag
setting.
2015-06-02 15:41:09 +01:00
dann frazier 3ac342205d arm64/setjmp: Add missing license macro
Including the setjmp module in an arm64-efi image will cause it to
immediately exit with an "incompatible license" error.

The source file includes a GPLv3+ boilerplate, so fix this by declaring a
GPLv3+ license using the GRUB_MOD_LICENSE macro.

Signed-off-by: dann frazier <dann.frazier@canonical.com>
2015-06-01 17:02:04 +01:00
Paul Menzel ca59c24bd0 disk/ahci.c: Add port number to port debug messages
Currently, some messages cannot be mapped to the port they belong to as
the port number is missing from the output. So add `port: n` to the
debug messages.
2015-05-31 09:26:46 +03:00
Andrei Borzenkov dec7718878 Clarify use of superusers variable and menu entry access
superusers controls both CLI and editing. Also explicitly mention that
empty superusers disables them.

"Access to menuentry" is a bit vague - change to "execute menuentry"
to make it obvious, what access is granted.
2015-05-30 19:36:41 +03:00
Paul Menzel fd73b3d008 Correct spelling of *scheduled*
Run the command below

	$ git grep -l schedulded | xargs sed -i 's/schedulded/scheduled/g'

and revert the change in `ChangeLog-2015`.

Including "miscellaneous" spelling fix noted by richardvoigt@gmail.com
2015-05-30 10:05:43 +03:00
Toomas Soome cad5cc0f5d zfs extensible_dataset and large_blocks feature support
large blocks basically use extensible dataset feature, or to be exact,
setting recordsize above 128k will trigger large_block feature to be
enabled and storing such blocks is using feature extensible dataset. so
the extensible dataset is prerequisite.

Changes implement read support extensible dataset… instead of fixed DMU
types they dont specify type, making it possible to use fat zap objects
from bonus area.
2015-05-30 08:50:53 +03:00
Vladimir Serbinenko c856be6bca multiboot1: never place modules in low memory.
While in theory permitted by the spec, modules rarely fit in low memory
anyway and not every kernel is able to handle modules in low memory anyway.
At least VMWare is known not to be able to handle modules at arbitrary
locations.
2015-05-27 08:41:39 +02:00
Paul Menzel 5e74a3e6df disk/ahci: Use defines GRUB_ATA_STATUS_BUSY and GRUB_ATA_STATUS_DRQ
Instead of hard coding `0x88` use the macros defined in `disk/ata.h`.
2015-05-24 21:19:01 +03:00
Paul Menzel f4e62af000 cb_timestamps.c: Add new time stamp descriptions
Add the descriptions of the “core”, that means no vendorcode or payload,
coreboot time stamps added up to coreboot commit a7d92441 (timestamps:
You can never have enough of them!) [1].

Running `coreboot_boottime` in the GRUB command line interface now shows
descriptions for all time stamps again on the ASRock E350M1.

[1] http://review.coreboot.org/9608
2015-05-19 20:28:07 +03:00
Andrei Borzenkov a666c8bd18 bootp: ignore gateway_ip (relay) field.
From RFC1542:

   The 'giaddr' field is rather poorly named.  It exists to facilitate
   the transfer of BOOTREQUEST messages from a client, through BOOTP
   relay agents, to servers on different networks than the client.
   Similarly, it facilitates the delivery of BOOTREPLY messages from the
   servers, through BOOTP relay agents, back to the client.  In no case
   does it represent a general IP router to be used by the client.  A
   BOOTP client MUST set the 'giaddr' field to zero (0.0.0.0) in all
   BOOTREQUEST messages it generates.

   A BOOTP client MUST NOT interpret the 'giaddr' field of a BOOTREPLY
   message to be the IP address of an IP router.  A BOOTP client SHOULD
   completely ignore the contents of the 'giaddr' field in BOOTREPLY
   messages.

Leave code ifdef'd out for the time being in case we see regression.

Suggested by: Rink Springer <rink@rink.nu>
Closes: 43396
2015-05-17 22:38:30 +03:00
Andrei Borzenkov 2498dc7a3a hostdisk: fix crash with NULL device.map
grub-macbless calls grub_util_biosdisk_init with NULL device.map.
2015-05-17 14:16:36 +03:00
Andrei Borzenkov 5370dcfdae zfs: fix integer truncation in zap_lookup
Size after shift could exceed 16 bits; use grub_unit32_t for result.

Reported and tested by: Kostya Berger <bergerkos@yahoo.co.uk>
Closes: 44448
2015-05-14 07:50:33 +03:00
Andrei Borzenkov 5082ea6184 remove extra newlines in grub_util_* strings
grub_util_{info,warn,error} already add trailing newlines, so remove
them from format strings. Also trailing full stops are already added.
2015-05-13 09:47:17 +03:00
Jan Kara a139188eb5 xfs: Convert inode numbers to cpu endianity immediately after reading
Currently XFS driver converted inode numbers to native endianity only
when using them to compute inode position. Although this works, it is
somewhat confusing. So convert inode numbers when reading them from disk
structures as every other field.

Signed-off-by: Jan Kara <jack@suse.cz>
2015-05-12 08:21:10 +03:00
Jan Kara 1570140f03 xfs: Fix termination loop for directory iteration
Directory iteration used wrong position (sizeof wrong structure) for
termination of iteration inside a directory block. Luckily the position
ended up being wrong by just 1 byte and directory entries are larger so
things worked out fine in practice. But fix the problem anyway.

Signed-off-by: Jan Kara <jack@suse.cz>
2015-05-11 14:48:14 +03:00
Andrei Borzenkov 07258815e9 acpi: do not skip BIOS scan if EBDA length is zero
EBDA layout is not standardized so we cannot assume first two bytes
are length. Neither is it required by ACPI standard. HP 8710W is known
to contain zeroes here.

Closes: 45002
2015-05-08 06:15:16 +03:00
Andrei Borzenkov 6a5c78c8c8 Add asm-tests to tarball 2015-05-07 22:15:16 +03:00
Vladimir Serbinenko 2dcf260d89 util/grub-mkrescue: Fix compilation 2015-05-07 19:45:06 +02:00
Andrei Borzenkov 49426e9fd2 efinet: open Simple Network Protocol exclusively
EDK2 network stack is based on Managed Network Protocol which is layered
on top of Simple Management Protocol and does background polling. This
polling races with grub for received (and probably trasmitted) packets
which causes either serious slowdown or complete failure to load files.

Open SNP device exclusively.  This destroys all child MNP instances and
stops background polling.

Exclusive open cannot be done when enumerating cards, as it would destroy
PXE information we need to autoconfigure interface; and it cannot be done
during autoconfiguration as we need to do it for non-PXE boot as well. So
move SNP open to card ->open method and add matching ->close to clean up.

Based on patch from Mark Salter <msalter@redhat.com>

Also-By: Mark Salter <msalter@redhat.com>
Closes: 41731
2015-05-07 20:37:17 +03:00
Andrei Borzenkov c52ae40570 efinet: skip virtual IPv4 and IPv6 devices when enumerating cards
EDK2 PXE driver creates two child devices - IPv4 and IPv6 - with
bound SNP instance. This means we get three cards for every physical
adapter when enumerating. Not only is this confusing, this may result
in grub ignoring packets that come in via the "wrong" card.

Example of device hierarchy is

 Ctrl[91] PciRoot(0x0)/Pci(0x3,0x0)
   Ctrl[95] PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)
     Ctrl[B4] PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)/IPv4(0.0.0.0)
     Ctrl[BC] PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)

Skip PXE created virtual devices when enumerating cards. Make sure to
find real card when applying initial autoconfiguration during PXE boot,
this information is associated with one of child devices.
2015-05-07 20:37:17 +03:00
Andrei Borzenkov 7b386b7031 efidisk: move device path helpers in core for efinet 2015-05-07 20:37:16 +03:00
Andrei Borzenkov 16a7e723ea convert to, not from, CPU byte order in DNS receive function 2015-05-07 20:33:28 +03:00
Andrei Borzenkov a8c473288d loader/linux: do not pad initrd with zeroes at the end
Syslinux memdisk is using initrd image and needs to know uncompressed
size in advance. For gzip uncompressed size is at the end of compressed
stream. Grub padded each input file to 4 bytes at the end, which means
syslinux got wrong size.

Linux initramfs loader apparently does not care about trailing alignment.
So change code to align beginning of each file instead which atomatically
gives us the correct size for single file.

Reported-By: David Shaw <dshaw@jabberwocky.com>
2015-05-07 20:24:24 +03:00
Daniel Kiper 71783dc978 i386/relocator: Remove unused extern grub_relocator64_rip_addr
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
2015-05-07 18:00:47 +02:00
Vladimir Serbinenko 9916ed6f82 grub-install-common: Increase buf size to 8192 as modinfo.sh is bigger. 2015-05-07 17:09:58 +02:00
Vladimir Serbinenko 5fd1cb980a grub-mkrescue: Recognize -output as an alias of --output.
This helps us to be in line with xorriso -as mkisofs.

Suggested by: Thomas Schmitt
2015-05-07 16:34:34 +02:00
Vladimir Serbinenko e5b4ba8c2b linux.c: Ensure that initrd is page-aligned. 2015-05-07 16:23:39 +02:00
Vladimir Serbinenko 9f731abc7f Revert parts accidentally committed 2 commits ago. 2015-05-07 16:21:34 +02:00
Fu Wei cfe2ae8936 fdt.h: Add grub_fdt_set_reg64 macro
Signed-off-by: Fu Wei <fu.wei@linaro.org>
2015-05-07 15:13:25 +02:00
Fu Wei f8451af825 arm64: Export useful functions from linux.c
Signed-off-by: Fu Wei <fu.wei@linaro.org>
2015-05-07 15:11:04 +02:00
Andrei Borzenkov cc699535e5 Revert "efinet: memory leak on module removal"
This reverts commits 47b2bee3ef
and 8d3c4544ff. It is not safe
to free allocated cards, dangling pointers main remain. Such
cleanup requires more changes in net core.
2015-05-04 09:17:59 +03:00
Andrei Borzenkov 47b2bee3ef efinet: cannot free const char * pointer 2015-05-04 08:39:29 +03:00
Andrei Borzenkov 8d3c4544ff efinet: memory leak on module removal 2015-05-04 08:08:57 +03:00
Andrei Borzenkov 6210b8e8f7 zfs: add missing NULL check and fix incorrect buffer overwrite
grub_memset should zero out padding after data end. It is not clear
why it is needed at all - ZFS block is at least 512 bytes and power
of two, so it is always multiple of 16 bytes. This grub_memset
apparently never did anything.
2015-05-03 18:57:32 +03:00
Toomas Soome 4a7ea4003b zfs: com.delphix:embedded_data feature support 2015-05-03 18:45:40 +03:00
Toomas Soome a1007c6af2 zfs: com.delphix:hole_birth feature support
In the past birth was always zero for holes. This feature started
to make use of birth for holes as well, so change code to test for
valid DVA address instead.
2015-05-03 18:11:29 +03:00
Andrei Borzenkov 104dff36ea grub-mkconfig: use $pkgdatadir in scripts
Otherwise scripts will source wrong grub-mkconfig_lib.
2015-04-29 19:18:54 +03:00
Vladimir Serbinenko 70b002de55 Remove -V in grub-mkrescue.c
It clashhes with -V which is alias to -volid.
2015-04-24 17:52:30 +02:00
Toomas Soome 677dcaa92b getroot: include sys/mkdev.h for makedev
Solaris (like) systems need to include sys/mkdev.h for makedev() function.
2015-04-13 19:52:28 +03:00
Toomas Soome 5b5d8666a7 core/partmap: rename 'sun' to avoid clash with predefined symbol
the symbol “sun” is defined macro in solaris derived systems, from
gcc -dM -E:

and therefore can not be used as name.
2015-04-13 19:49:15 +03:00
Paul Menzel e97f5f4968 docs/grub.texi: Fix spelling of cbfstool 2015-04-12 09:10:11 +03:00
Andrei Borzenkov f11db3c7fc core: avoid NULL derefrence in grub_divmod64s
It can be called with NULL for third argument.  grub_divmod32* for
now are called only from within wrappers, so skip check.

Reported-By: Michael Zimmermann <sigmaepsilon92@gmail.com>
2015-04-06 19:30:51 +03:00
Andrei Borzenkov 12bf557039 do not emit cryptomount without crypto UUID 2015-03-28 22:13:35 +03:00
Sarah Newman 7d39938474 grub-core/loader/i386/xen.c: Initialized initrd_ctx so we don't free a random pointer from the stack.
Signed-off-by: Sarah Newman <srn@prgmr.com>
2015-03-28 07:14:17 +03:00
Andrei Borzenkov ebd92af8c3 net: trivial grub_cpu_to_XX_compile_time cleanup 2015-03-27 18:58:57 +03:00
Lunar c9ee9bedef syslinux: Support {vesa,}menu.c32. 2015-03-27 15:15:13 +01:00
Steve McIntyre 1a33de8b56 Recognize EFI platform even in case of mismatch between Linux and EFI.
Some x86 systems might be capable of running a 64-bit Linux kernel but
only use a 32-bit EFI (e.g. Intel Bay Trail systems). It's useful for
grub-install to be able to recognise such systems, to set the default
x86 platform correctly.

To allow grub-install to know the size of the firmware rather than
just the size of the kernel, there is now an extra EFI sysfs file to
describe the underlying firmware. Read that if possible, otherwise
fall back to the kernel type as before.

Signed-off-by: Steve McIntyre <steve@einval.com>
2015-03-27 14:51:51 +01:00
Michael Zimmermann ed07b7e128 Add missing initializers to silence suprious warnings. 2015-03-27 14:44:41 +01:00
Leif Lindholm d47e8ab4b9 dl_helper: Cleanup
Use the new thumb_get_instruction_word/thumb_set_instruction_word
helpers throughout.

Style cleanup (missing spaces).

Move Thumb MOVW/MOVT handlers into Thumb relocation section of file.
2015-03-27 14:37:16 +01:00
Martin Wilck cf2b4a36c4 efinet: Check for immediate completition.
This both speeds GRUB up and workarounds unexpected EFI behaviour.
2015-03-27 14:27:56 +01:00
Vladimir Serbinenko 1f23c87c19 Make Makefile.util.def independent of platform. 2015-03-27 14:04:41 +01:00
Daniel Kahn Gillmor 85a7be2414 util/mkimage: Use stable timestamp when generating binaries. 2015-03-27 13:26:48 +01:00
Vladimir Serbinenko c14f8a9366 modinfo.sh.in: Add missing config variables. 2015-03-27 12:18:25 +01:00
Vladimir Serbinenko 94222b72b5 Makefile.core.def: Remove obsolete LDADD_KERNEL 2015-03-27 12:18:25 +01:00
Vladimir Serbinenko 63034d3261 arp, icmp: Fix handling in case of oversized or invalid packets.
This restrict ARP handling to MAC and IP addresses but in practice we need
only this case anyway and other cases are very rar if exist at all. It makes
code much simpler and less error-prone.
2015-03-27 12:18:25 +01:00
Colin Watson 5974d4ba65 hostfs: Drop unnecessary feature test macros
_BSD_SOURCE was added to allow the use of DT_DIR, but that was removed
in e768b77068.  While adding
_DEFAULT_SOURCE as well works around problems with current glibc,
neither is in fact needed nowadays.
2015-03-23 14:32:30 +00:00
Vladimir Serbinenko e9f68f1f4c compiler-rt-emu: Add missing file. 2015-03-20 13:00:53 +01:00
Vladimir Serbinenko fe6695b7d6 emunet: Fix init error checking.
Otherwise emunet doesn't expose any cards.
2015-03-20 12:59:00 +01:00
Vladimir Serbinenko 237510486a fddboot_test: Add -no-pad to xorriso. 2015-03-20 12:58:08 +01:00
Vladimir Serbinenko cf47a2fba5 grub-mkrescue: pass all unrecognized options unchanged to xorriso. 2015-03-20 12:55:27 +01:00
Vladimir Serbinenko 9c07daaf91 cacheinfo: Add missing license information. 2015-03-20 11:13:58 +01:00
Andrei Borzenkov 19c4156d16 grub-fs-tester: add LVM RAID1 support
LVM miscalculates bitmap size with small extent, so start with 16K as
for other RAID types.

Until version 2.02.103 LVM counts metadata segments twice when checking
available space, reduce segment count by one to account for this bug.
2015-03-19 21:31:26 +03:00
Andrei Borzenkov 527eeeeee6 core: add LVM RAID1 support
Closes 44534.
2015-03-19 21:30:27 +03:00
Andrei Borzenkov 7c9309e50a grub-fs-tester: explicitly set segment type for LVM mirror
LVM mirror defaults to RAID1 today and can be different on different
systems as set in lvm.conf.
2015-03-16 21:16:19 +03:00
Andrei Borzenkov fa07d919d1 grub-fs-tester: better estimation of filesystem time for LVM/RAID
Write activity with LVM/RAID can happen after filesystem is unmounted.
In my testing modification time of loop files was 15 - 20 seconds
after unmount.  So use time as close to unmount as possible as
reference instead.
2015-03-15 21:24:09 +03:00
Vladimir Serbinenko 5fe21c9968 hfsplus: Fix potential access to uninited memory on invalid FS 2015-03-06 22:33:20 +01:00
Jon McCune be41c1cf11 autogen.sh: Allow overriding the python to be used by setting $PYTHON.
Some installations have several python versions installed. Allow user
to choose which one to use by setting $PYTHON.
2015-03-06 00:34:18 +01:00
Andrei Borzenkov 8842991a56 update gnulib/argp-help.c to fix garbage in grub-mknetdir --help output
argp_help attempts to translate empty string, which results in printing
meta information about translation, like in

bor@opensuse:~/build/grub> grub2-mknetdir --help
Использование: grub2-mknetdir [ПАРАМЕТР…]
Project-Id-Version: grub 2.02-pre2
Report-Msgid-Bugs-To: bug-grub@gnu.org
...

Update gnulib/argp-help.c to the current version which fixes this
(commit b9bfe78424b871f5b92e5ee9e7d21ef951a6801d).
2015-03-05 20:19:47 +03:00
Andrey Borzenkov 20f21d8978 update m4/extern-inline.m4 to upstream version to fix compilation on FreeBSD
In file included from util/grub-mkimage.c:54:0:
./grub-core/gnulib/argp.h:627:49: error: '__sbistype' is static but
used in inline function '_option_is_short' which is not static
[-Werror] cc1: all warnings being treated as errors gmake[2]: ***
[util/grub_mkimage-grub-mkimage.o] Error 1

Update m4/extern-inline.m4 to current upstream gnulib version that
contains fix for this (commit b9bfe78424b871f5b92e5ee9e7d21ef951a6801d).

Reported-By: Beeblebrox <zaphod@berentweb.com>
2015-03-05 19:25:56 +03:00
Vladimir Serbinenko dc06aa949b syslinux_parse: Fix the case of unknown localboot.
Reported by: Jordan Uggla
2015-03-04 14:19:29 +01:00
Vladimir Serbinenko 5959b15c1c configure.ac: Fix the name of pciaccess header. 2015-03-04 01:01:45 +01:00
Vladimir Serbinenko 27d1a67f8a Fix canonicalize_file_name clash.
canonicalize_file_name clashed with gnulib function. Additionally
it was declared in 2 places: emu/misc.h and util/misc.h. Added
grub_ prefix and removed second declaration.
2015-03-04 01:00:19 +01:00
Vladimir Serbinenko 9d25b0da9a Remove emu libusb support.
It's disabled by default and has been broken for a long time.
As nobody is interested in fixing and maintaining it, remove it.
2015-03-03 20:59:36 +01:00
Vladimir Serbinenko 9f95d12153 configure.ac: Remove unused COND_clang 2015-03-03 20:50:37 +01:00
Vladimir Serbinenko 064360e667 Remove libgcc dependency.
libgcc for boot environment isn't always present and compatible.
libgcc is often absent if endianness or bit-size at boot is different
from running OS.
libgcc may use optimised opcodes that aren't available on boot time.
So instead of relying on libgcc shipped with the compiler, supply
the functions in GRUB directly.
Tests are present to ensure that those replacement functions behave the
way compiler expects them to.
2015-03-03 20:50:37 +01:00
Vladimir Serbinenko 77697d14e5 types.h: Use __builtin_bswap* with clang.
clang pretends to be GCC 4.2 but we use __builtin_bswap* only with GCC 4.3+.
clang support __builtin_bswap*, so use it.
2015-03-03 20:50:37 +01:00
Vladimir Serbinenko aa6ccc05c1 configure.ac: Set $CPPFLAGS when checking for no_app_regs.
Fixes compilation for sparc64 with clang.
2015-03-03 20:50:37 +01:00
Vladimir Serbinenko 87ec3b7fa9 Don't continue to query block-size if disk doesn't have it.
Stops poluting screen with a lot of "block-size: exception -21".
2015-03-03 20:50:37 +01:00
Andrei Borzenkov 018f79da6f grub-probe: free temporary variable 2015-02-28 20:19:57 +03:00
Vladimir Serbinenko 0d6498a67d exclude.pot: Add new technical strings 2015-02-28 16:23:27 +01:00
Vladimir Serbinenko afd6b6bbae grub-probe: Mark a "[default=]" for translation. 2015-02-28 16:22:46 +01:00
Vladimir Serbinenko ddde9ca71a grub-shell: Add missing --locale-directory.
Fixes the language tests is no make install was done.
2015-02-28 15:14:16 +01:00
Vladimir Serbinenko 050505ab8f ntfs_test: Skip is setfattr is unavailable. 2015-02-28 15:13:41 +01:00
Vladimir Serbinenko 66b0e6649b emu/cache: Change declaration of __clear_cache to match builtin declaration.
Fixes compile of arm64-emu.
2015-02-26 22:20:59 +01:00
Vladimir Serbinenko 38b7a30269 arm/dl: Fix handling of nonstandard relocation sizes 2015-02-26 22:10:29 +01:00
Vladimir Serbinenko 7ba066419a gzio: Optimize by removing division. 2015-02-26 22:10:09 +01:00
Vladimir Serbinenko 67a6a9512a raid6: Optimize by removing division. 2015-02-26 22:07:22 +01:00
Vladimir Serbinenko f76c98b79e dmraid_nvidia: Fix division by 0 and missing byte-swap. 2015-02-26 22:06:19 +01:00
Vladimir Serbinenko 94f701a826 crypto: restrict cipher block size to power of 2.
All current ciphers have blocks which are power of 2 and it's
unlikely to change. Other block length would be tricky to handle anyway.
This restriction allows avoiding extra divisions.
2015-02-26 22:04:40 +01:00
Vladimir Serbinenko 7213c1e028 jpeg: Optimise by replacing division with shifts. 2015-02-26 21:27:32 +01:00
Vladimir Serbinenko 18125877ee png: Optimize by avoiding divisions. 2015-02-26 18:27:43 +01:00
Vladimir Serbinenko 80310ad07d Add missing lib/division.c 2015-02-26 18:22:40 +01:00
Vladimir Serbinenko f51218bc15 fbblit: Optimize by replacing division with additions and shifts. 2015-02-26 18:14:28 +01:00
Vladimir Serbinenko dd4889f727 bitmap_scale: Optimize by moving division out of the loop. 2015-02-26 18:13:36 +01:00
Vladimir Serbinenko c5a4e79335 minilzo: Skip parts tha we don't need. 2015-02-26 18:11:53 +01:00
Vladimir Serbinenko 6a4ecd276e mips: Fix soft-float handling.
Add -msoft-float alongside clang arguments to specify ABI.
Specify ABI in asm files explicitly.
This trigers asm warning due to gcc failing to propagate -msoft-float
but it's tolerable.
2015-02-23 22:33:28 +01:00
Vladimir Serbinenko 7ea452a142 Add missing grub_ prefix in memcpy invocation 2015-02-23 22:29:33 +01:00
Vladimir Serbinenko 2066c35b3f Allow clang compilation for thumb with -mthumb-interwork.
clang already uses -mthumb-interwork behaviour even thout it doesn't
support the option.
2015-02-23 22:29:33 +01:00
Vladimir Serbinenko 345076a78a arm64: Fix compilation failure.
Don't supply +nosimd to asm files.
Otherwise +nosimd coming from flags forbids some of instructions
used in cache_flush.
2015-02-23 22:29:28 +01:00
Vladimir Serbinenko f034fab620 Supply signed division to fix ARM compilation.
Previously we supplied only unsigned divisions on platforms that need software
division.
Yet compiler may itself use a signed division. A typical example would be a
difference between 2 pointers which involves division by object size.
2015-02-23 04:12:04 +01:00
Vladimir Serbinenko e1d4520bfb acpi: Fix unused function warning. 2015-02-22 14:42:43 +01:00
Vladimir Serbinenko ea39b87a8b configure.ac: Add ia64-specific way to disable floats. 2015-02-22 14:42:19 +01:00
Vladimir Serbinenko 50ebc8f5f3 i386/tsc: Fix unused function warning on xen. 2015-02-22 13:12:44 +01:00
Vladimir Serbinenko 155f334f57 Experimental support for clang for sparc64.
Automatically discover command line options to make clang and
gcc behave in same way.

Tested with qemu.
2015-02-22 01:54:55 +01:00
Vladimir Serbinenko ebe316e4df Discover which option provides soft-float on configure stage.
Deals with clang needing other arguments to stop issuing floating
instructions than gcc.
2015-02-22 00:35:11 +01:00
Vladimir Serbinenko da9f30b455 mips: Switch to more portable .org
Binary is unchanged.
2015-02-21 20:43:57 +01:00
Vladimir Serbinenko 49e5fcb9fb sparc64: Switch to more portable .org.
Binaries are unchanged.
2015-02-21 20:32:03 +01:00
Vladimir Serbinenko e77dc3d9a0 kernel-8086: Switch to more portable .org. 2015-02-21 20:24:59 +01:00
Vladimir Serbinenko f16b8c0405 Relax requirements on asm for non-BIOS i386 platforms.
These platforms don't have a hard limit on size of resulting code16
code, so we don't care if assembly is bigger than necessarry.
2015-02-21 20:18:18 +01:00
Vladimir Serbinenko 3c6043245e qemu: Switch to more portable .org
Binary is checked identical.
2015-02-21 20:13:58 +01:00
Vladimir Serbinenko 8afd8f3b64 qemu: Fix GateA20 enabling.
GateA20 code was inactive due to address error.
2015-02-21 20:00:18 +01:00
Vladimir Serbinenko e62ca2a870 qemu: Fix compilation 2015-02-21 19:55:53 +01:00
Vladimir Serbinenko 44ff462e83 Remove realmode.S from coreboot and qemu.
It's not used there.
2015-02-21 19:53:18 +01:00
Vladimir Serbinenko 6505b241fd Remove obsolete ADDR32 and DATA32 checks. 2015-02-21 17:44:41 +01:00
Vladimir Serbinenko 37353f0ae5 i386: Remove needless ADDR32 prefixes when address is known and fixed.
Shaves off 6 bytes in lzma_decompress.img.
2015-02-21 17:38:56 +01:00
Vladimir Serbinenko 1998d63688 i386-pc/boot: Explicitly mark kernel_address[_high] as local.
Otherwise apple asm might try to make accesses relocatable.
2015-02-21 17:20:10 +01:00
Vladimir Serbinenko bc29c6d019 Change dot assignmnet to more portable .org.
Binary is unchanged (verified)
2015-02-21 17:19:01 +01:00
Vladimir Serbinenko f571dc1af8 i386: Move from explicit ADDR32/DATA32 prefixes to instruction suffixes.
Is more portable.
Binary is unchanged (verified).
2015-02-21 17:13:23 +01:00
Vladimir Serbinenko 065ad910f1 Test which flags make our asm compile.
Previously we relied on assumption that clang always needs -no-integrated-as
but it's not always true.
2015-02-21 16:29:28 +01:00
Vladimir Serbinenko 0b02bfa034 INSTALL: clarify that clang support is experimental 2015-02-21 16:22:48 +01:00
Vladimir Serbinenko 87a04adb65 zfs/mzap_lookup: Fix argument types 2015-02-21 16:22:01 +01:00
Vladimir Serbinenko ec65605af4 wildcard: Mark unused argument as such. 2015-02-21 16:19:09 +01:00
Vladimir Serbinenko 967e5aa591 ofdisk: Exclude floppies from scanning.
It causes similar hang as CD on at least the qemu.
2015-02-21 16:16:48 +01:00
Vladimir Serbinenko ef7c843b44 configure: Add -msoft-float to CCASFLAGS
Otherwise mismatch between API flags triggers linker failure
2015-02-21 16:13:11 +01:00
Vladimir Serbinenko e5851b63e0 mips/startup_raw: Use more portable .asciz 2015-02-21 16:09:46 +01:00
Vladimir Serbinenko aee2502cb5 Provide __aeabi_mem{cpy,set}
Fixes ARM compilation
2015-02-21 16:07:59 +01:00
Vladimir Serbinenko 2426ac36d3 div_test: Don't try to divide by zero 2015-02-21 16:05:45 +01:00
Vladimir Serbinenko d93147abb7 INSTALL: Fix names of host flags to match actual behaviour 2015-02-21 16:03:11 +01:00
Vladimir Serbinenko e3c7aca76d Strip .MIPS.abiflags which causes compile failure 2015-02-21 16:01:53 +01:00
Vladimir Serbinenko b46bf3cd1c configure: Move adding of include options to the very end to avoid subshell. 2015-02-20 21:30:34 +01:00
Vladimir Serbinenko 86f05f1491 configure: Add missing comma. 2015-02-20 21:29:35 +01:00
Vladimir Serbinenko 5537a586e0 ext2: Ignore INCOMPAT_MMP.
It's not really incompatible as long as driver never writes to FS.
2015-02-16 21:08:37 +01:00
Vladimir Serbinenko e20aa39ea4 ext2: Support META_BG.
This fixes bug that system would become unbootable after ext*
online resize if no resize_inode was created at ext* format time.
2015-02-16 20:53:26 +01:00
Andrei Borzenkov 35a492e4a2 tests: remove hardcoded paths from syslinux_test
abs_top_srcdir appeared in Autoconf 2.52f. Minimal grub requirement
is 2.60 so we should be good here.
2015-02-16 22:24:05 +03:00
Andrei Borzenkov 251ddf26dc build-sys: add syslinux test files to tarball 2015-02-16 20:31:22 +03:00
Vladimir Serbinenko d3d2e54911 Add test for syslinux converter 2015-02-16 15:58:59 +01:00
Vladimir Serbinenko e29af836d0 Don't remove initrd= parameter.
Based on simplified patch by Lunar.

Reported by: Lunar
2015-02-16 15:56:26 +01:00
Vladimir Serbinenko b23635fcff syslinux_parse: Always output comments even if no entries are found. 2015-02-16 10:54:20 +01:00
Andrei Borzenkov 8f5ebb1245 diskfilter_make_raid: more memory leaks in failure path 2015-02-15 10:14:07 +03:00
Vladimir Serbinenko 2ae9457e6e disk/lvm: Use zalloc to ensure that segments are initialised to sane value.
Reported by: EmanueL Czirai.
2015-02-14 20:31:00 +01:00
Daniel Kiper 8e5bc2f4d3 multiboot2: Fix information request tag size calculation
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
2015-02-14 19:26:04 +03:00
Andrei Borzenkov fc535b32b9 diskfilter: fix double free of lv names for mdraid
Avoid micro-optimization in grub_diskfilter_make_raid and make sure
name and fullname are independent strings. This avoids need to special
case it everywhere else.

Also fix memory leak in failure case in grub_diskfilter_make_raid.

Closes: 41582
2015-02-14 19:08:58 +03:00
Andrei Borzenkov e27fdbd686 diskfilter: fix crash in validate_lv for mdraid arrays
Commit 750f4bacd3 put LV validation before
actual vg assignment. Make grub_diskfilter_make_raid to assign ->vg as
happens in other cases for consistency. Also clean up redundant code and add
explicit NULL lv->vg check in validate_lv.

Also fix segment validation in validate_lv; it became obvious when crash
was fixed.

Closes: 44199
2015-02-14 17:56:01 +03:00
Jiri Slaby 32cd33bd19 util: mkimage, fix gcc5 build failure
gcc5 reports:
../util/mkimage.c: In function 'grub_install_get_image_target':
../util/mkimage.c:954:5: error: loop exit may only be reached after undefined behavior [-Werror=aggressive-loop-optimizations]
     && j < ARRAY_SIZE (image_targets[i].names); j++)
     ^
../util/mkimage.c:953:39: note: possible undefined statement is here
      for (j = 0; image_targets[i].names[j]
                                        ^

Well, let's move the index 'j' test before accesing the array to:
1) make the loop obvious
2) make gcc happy

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
2015-02-12 22:18:01 +03:00
Leif Lindholm c0f529ea67 arm: implement additional relocations generated by gcc 4.9 at -O3
GCC 4.9 also generates R_ARM_THM_MOVW_ABS_NC and R_ARM_THM_MOVT_ABS,
as an alternative to ABS32.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
2015-02-03 22:50:08 +00:00
Andrei Borzenkov 016875dd52 setup: fix blocklist size calculation
Found by: Coverity scan.
2015-01-30 22:57:39 +03:00
Andrei Borzenkov 151c19a42a grub-fstest: fix descriptor leak
Found by: Coverity scan.
2015-01-30 22:45:58 +03:00
Andrei Borzenkov 12abe75aa0 net/pxe: fix error condition
Test return value of grub_netbuff_reserve(), buf itself cannot be
NULL here.

Found by: Coverity scan.
2015-01-30 22:39:11 +03:00
Andrei Borzenkov 7aaed66455 grub-mkimage: fix potential NULL pointer dereference
Move fatal check whether symtab_section is NULL before first reference.

Found by: Coverity scan.
2015-01-30 22:26:05 +03:00
Andrei Borzenkov b40fde29a4 net/ip: check result of grub_netbuff_push
Found by: Coverity scan.
2015-01-30 22:09:51 +03:00
Andrei Borzenkov 1e047e53ae tests: add test command file tests
This requires access to files in both host and grub image, so
implementing as separate test unit instead of script test was
more easy.
2015-01-30 21:42:46 +03:00
Andrei Borzenkov f153fcb5a5 test: consistently use TMPDIR and same name pattern for temp files 2015-01-30 20:31:20 +03:00
Andrei Borzenkov 958167b91c test: fix previous commit - we need to return from subexpression
( ... ) was processed recursively, we need to return from it. Revert
this change.
2015-01-30 20:21:56 +03:00
Andrei Borzenkov d29259b134 test: do not stop after first file test or closing bracket
Closes: 44115
2015-01-30 20:10:43 +03:00
Leif Lindholm 2da4171eab configure.ac: don't use -msoft-float for arm64
aarch64 toolchains do not support the -msoft-float option added by
commit 3661261f. Insted, for arm64 use -march=armv8-a+nofp+nosimd.

Reported-by: Ryan Harkin <ryan.harkin@linaro.org>
2015-01-28 20:44:41 +00:00
Andrei Borzenkov 9883307a52 script/execute.c: fix memory leak.
Make sure to continue loop over array after failure to free
allocated strings.

Found by: Coverity scan.
2015-01-28 20:35:28 +03:00
Andrei Borzenkov 2efab86d5a syslinux_parse: fix memory leak.
Found by: Coverity scan.
2015-01-28 20:09:25 +03:00
Andrei Borzenkov 1a4e47879c Change quotes to match overall style in NEWS 2015-01-27 22:34:50 +03:00
Andrei Borzenkov fbb4aa1c05 loader/xnu: fix memory leak.
Foound by: Coverity scan.
2015-01-27 22:12:06 +03:00
Andrei Borzenkov 11aae26cc3 util/grub-probe: fix memory leaks.
Found by: Coverity scan.
2015-01-27 22:11:52 +03:00
Andrei Borzenkov edc94e4b0b fs/hfsplus: fix memory leak.
Found by: Coverity scan.
2015-01-27 21:19:28 +03:00
Andrei Borzenkov 3900726fa8 fs/zfs/zfscrypt.c: fix indentation. 2015-01-27 21:13:10 +03:00
Andrei Borzenkov fa13e60527 fs/zfs/zfscrypt.c: fix memory leaks.
Found by: Coverity scan.
2015-01-27 21:12:19 +03:00
Andrei Borzenkov 3db4f05a10 commands/parttool: fix memory leak.
Found by: Coverity scan.
2015-01-27 20:55:25 +03:00
Andrei Borzenkov e871994849 fs/zfs/zfs.c: fix memory leak.
Found by: Coverity scan.
2015-01-27 20:52:27 +03:00
Andrei Borzenkov 637fc62699 linux/ofpath: fix descriptor leak
Found by: Coverity scan
2015-01-27 20:29:00 +03:00
Andrei Borzenkov 7ba137f628 linux/hostdisk: use strncpy instead of strlcpy
strlcpy is not available on Linux as part of standard libraries.
It probably is not worth extra configure checks espicially as we
need to handle missing function anyway.
2015-01-27 20:00:23 +03:00
Vladimir Serbinenko 9ee5ae1fae Document intentional fallthroughs.
Found by: Coverity scan.
2015-01-27 17:17:58 +01:00
Vladimir Serbinenko 8f95eae423 linux/ofpath: Fix error handling.
Found by: Coverity Scan.
2015-01-27 16:49:49 +01:00
Vladimir Serbinenko c2fc41990a linux/hostdisk: Limit strcpy size to buffer size.
Found by: Coverity scan.
2015-01-27 16:48:53 +01:00
Vladimir Serbinenko 916733ea6a fs/zfscrypt: Add missing explicit cast.
Found by: Coverity scan.
2015-01-27 16:35:37 +01:00
Vladimir Serbinenko 0daf46fdbd fs/zfs: Fix error handling.
Found by: Coverity Scan.
2015-01-27 16:32:21 +01:00
Vladimir Serbinenko 69a52e95d4 fs/{cbfs,cpio}: Remove useless check if mode is NULL.
Callers already ensure that it's not null.

Found by: Coverity Scan.
2015-01-27 16:32:21 +01:00
Vladimir Serbinenko 4192f2e3d1 commands/acpi: Use ALIGN_UP rather than manual expression.
Improves readability and hopefully automatic scanning.

Found by: Coverity Scan.
2015-01-27 16:32:21 +01:00
Andrei Borzenkov bd196014ec util/setup: fix memory leak.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00
Andrei Borzenkov fe4efe0d50 util/mkimage: fix memory leaks.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00
Andrei Borzenkov 1a87156e01 util/grub-mount: fix descriptor leak.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00
Andrei Borzenkov bd4e20eedf util/grub-mkstandalone: fix memory leak.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00
Andrei Borzenkov be0743b052 util/grub-install: rearrange code to avoid memory leak.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00
Andrei Borzenkov e61f4eba18 linux/getroot: fix memory leak.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00
Andrei Borzenkov 5e27fb06f2 util/install: fix memory leak.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00
Andrei Borzenkov 64440daa21 util/setup: fix memory leak.
Found by: Coverity scan.
2015-01-26 23:04:09 +03:00
Andrei Borzenkov e2a21238da linux/ofpath: fix various memory leaks.
Found by: Coverity scan.
2015-01-26 23:04:00 +03:00
Andrei Borzenkov 6704abade6 linux/getroot: fix descriptor leak.
Found by: Coverity scan.
2015-01-26 23:02:55 +03:00
Vladimir Serbinenko 11eed6abce util/misc.c: Check ftello return value.
Found by: Coverity scan.
2015-01-26 09:56:24 +01:00
Vladimir Serbinenko 5d61a6a612 grub-macbless: Fix resource leak.
Found by: Coverity scan.
2015-01-26 09:55:58 +01:00
Vladimir Serbinenko 3c6384832b grub-install: Fix memory leak.
Found by: Coverity scan.
2015-01-26 09:55:30 +01:00
Vladimir Serbinenko c3f5230597 grub-install-common: Fix sizeof usage.
Found by: Coverity scan.
2015-01-26 09:54:50 +01:00
Vladimir Serbinenko 866f469683 util/getroot: Add missing grub_disk_close.
Found by: Coverity scan.
2015-01-26 09:54:14 +01:00
Vladimir Serbinenko c4fcfd8744 vbe: Fix incorrect register usage.
Found by: Coverity scan.
2015-01-26 09:53:39 +01:00
Vladimir Serbinenko 8102540939 unix/password: Fix file descriptor leak.
Found by: Coverity scan.
2015-01-26 09:53:03 +01:00
Vladimir Serbinenko cba5a85a67 linux/getroot: Fix error handling.
Found by: Coverity scan.
2015-01-26 09:51:48 +01:00
Vladimir Serbinenko 5adc6d76d3 linux/blocklist: Fix memory leak.
Found by: Coverity scan.
2015-01-26 09:50:58 +01:00
Vladimir Serbinenko c14dff3ca7 devmapper/getroot: Fix memory leak.
Found by: Coverity scan.
2015-01-26 09:50:27 +01:00
Vladimir Serbinenko 6603c22f31 normal/misc: Close device on all pathes.
Found by: Coverity scan.
2015-01-26 09:49:32 +01:00
Vladimir Serbinenko 73b1e83839 normal/main: Fix error handling.
Found by: Coverity scan.
2015-01-26 09:48:46 +01:00
Vladimir Serbinenko a05a6e6f92 xnu: Add missing error check.
Found by: Coveriy scan.
2015-01-26 09:45:55 +01:00
Vladimir Serbinenko e12c3bed90 plan9: Add missing grub_device_close.
Found by: Coverity scan.
2015-01-26 09:45:37 +01:00
Vladimir Serbinenko ef02b4ca93 multiboot: Simplify to avoid confusing assignment.
Found by: Coverity scan.
2015-01-26 09:43:52 +01:00
Vladimir Serbinenko 1e0d718371 bsd: Add missing null-pointer check.
Found by: Coverity scan.
2015-01-26 09:42:42 +01:00
Vladimir Serbinenko 49978c5c4f lib/syslinux_parse: Add missing error check.
Found by: Coverity scan.
2015-01-26 09:42:04 +01:00
Vladimir Serbinenko ca7c1fd6f3 lib/syslinux_parse: Fix memory leak.
Found by: Coveriy scan.
2015-01-26 09:41:43 +01:00
Vladimir Serbinenko aa64393144 lib/syslinux_parse: Add missing alloc check.
Found by: Coverity scan.
2015-01-26 09:40:42 +01:00
Vladimir Serbinenko 21f22c7107 i386/pc/mmap: Fix memset size.
Found by: Coverity scan.
2015-01-26 09:38:11 +01:00
Vladimir Serbinenko af0be976bf gfxmenu/theme_loader: Add missing allos error check.
Found by: Coverity scan.
2015-01-26 09:37:39 +01:00
Vladimir Serbinenko bd74a925e5 gfxmenu/icon_manager: Fix null pointer dereference.
Found by: Coverity scan.
2015-01-26 09:37:01 +01:00
Vladimir Serbinenko a4e33a8b18 fs/ufs: Add missing error check.
Found by: Coverity scan.
2015-01-26 09:36:19 +01:00
Vladimir Serbinenko fc7a64bc5a configure.ac: Always add -D_FILE_OFFSET_BITS=64. 2015-01-26 09:35:44 +01:00
Vladimir Serbinenko 66baeffc0f fs/sfs: Fix error check and add sanity check.
Found by: Coverity scan.
2015-01-25 20:32:31 +01:00
Vladimir Serbinenko 8c1d086689 fs/reiserfs: Fix sector count overflow.
Found by: Coverity scan.
2015-01-25 20:32:31 +01:00
Vladimir Serbinenko 157f9a9cca fs/ntfs: Add sizes sanity checks.
Found by: Coverity scan.
2015-01-25 20:32:31 +01:00
Vladimir Serbinenko bc0ecd7104 fs/ntfs: Add missing free.
Found by: Coverity scan.
2015-01-25 20:32:31 +01:00
Vladimir Serbinenko ca793e9c05 fs/minix: Fix sector promotion to 64-bit.
While on it make GRUB_MINIX_ZONE2SECT into function.

Found by: Coverity scan
2015-01-25 20:32:31 +01:00
Vladimir Serbinenko ac602ce700 grub_iso9660_read: Explicitly check read_node return value.
Not really needed as grub_errno is already checked but is nicer.

Found by: Coverity scan.
2015-01-25 20:32:31 +01:00
Andrei Borzenkov fb66b512fa commands/fileXX: Fix remaining memory leak.
Found by: Coverity Scan.
2015-01-25 16:36:30 +03:00
Vladimir Serbinenko d0af2156c3 fs/hfs: Add pointer sanity checks.
Found by: Coverity scan.
2015-01-25 13:18:10 +01:00
Vladimir Serbinenko 4387ca78f0 fs/hfs/hfs_open: Check that mount succeeded.
Found by: Coverity scan.
2015-01-25 01:28:17 +01:00
Vladimir Serbinenko 83543f937a fs/fat: Fix codepath to properly free on error.
Found by: Coverity scan.
2015-01-25 01:27:44 +01:00
Vladimir Serbinenko faad548ce3 fs/cpio_common: Add a sanity check on namesize.
Found by: Coverity scan.
2015-01-25 00:11:59 +01:00
Vladimir Serbinenko b6f21bcb98 fs/cbfs: Add missing free.
Found by: Coverity scan.
2015-01-25 00:00:49 +01:00
Vladimir Serbinenko dd430afbf8 font: Add missing free.
Found by: Coverity Scan.
2015-01-24 21:55:18 +01:00
Vladimir Serbinenko d1130afa5f biosdisk: Add missing cast.
Found by: Coverity scan.
2015-01-24 21:50:30 +01:00
Vladimir Serbinenko 7656b72b17 disk/geli: Add missing free.
Found by: Coverity scan.
2015-01-24 21:47:51 +01:00
Vladimir Serbinenko 6f43e350ed disk/geli: Add missing seek success check.
Found by: Coverity scan.
2015-01-24 21:46:23 +01:00
Vladimir Serbinenko f2baeb194b disk/diskfilter: Add missing lv presence check.
Found by: Coverity scan.
2015-01-24 21:44:27 +01:00
Vladimir Serbinenko 4c7337bfe9 disk/cryptodisk: Add missing error check.
Found by: Coverity scan.
2015-01-24 21:38:22 +01:00
Vladimir Serbinenko 2a8200bba8 disk/ahci: Fix device_map_range argument.
Argument is not used on x86, hence it's gone unnoticed.

Found by: Coverity scan.
2015-01-24 21:37:28 +01:00
Vladimir Serbinenko 7d97335942 disk/AFsplitter: check argument validity before doing any allocs.
This avoids possible memory leaks.

Found by: Coverity scan.
2015-01-24 21:33:30 +01:00
Vladimir Serbinenko 3b1b39c082 commands/wildcard: Add missing free.
Found by: Coverity scan.
2015-01-24 21:29:19 +01:00
Vladimir Serbinenko 37ba761b1c commands/verify: Fix sha1 context zeroing-out.
Current code doesn't zero-out context completely. It's a minor issue
really as sha1 init already takes care of initing the context.
2015-01-24 21:27:10 +01:00
Vladimir Serbinenko 6079e67926 commands/tr: Simplify and fix missing parameter test.
Found by: Coverity scan
2015-01-24 21:25:42 +01:00
Vladimir Serbinenko fbae51dcea commands/syslinux: Add missing free.
Found by: Coverity scan.
2015-01-24 21:23:25 +01:00
Vladimir Serbinenko 4947f11b09 commands/parttool: Add missing device close.
Found by: Coverity scan.
2015-01-24 21:22:02 +01:00
Vladimir Serbinenko bd50aa323d commands/nativedisk: Add missing device_close.
Found by: Coverity scan.
2015-01-24 21:18:36 +01:00
Vladimir Serbinenko 72bbd8046a commands/macbless: Handle device opening errors correctly.
Wrong variable was checked for errors.

Found by: Coverity scan.
2015-01-24 21:15:14 +01:00
Vladimir Serbinenko e3b3e53f72 commands/macbless: Fix potential overflow.
Is a minor concern as no such FS would be created under normal circumstances
and failure was benign.

Found by: Coverity scan.
2015-01-24 21:12:02 +01:00
Vladimir Serbinenko 09e84f188b commands/macbless: Remove incorrect grub_free.
Found by: Coverity Scan
2015-01-24 21:08:50 +01:00
Vladimir Serbinenko f579f097bb commands/legacycfg: Fix resource leaks. 2015-01-24 21:06:23 +01:00
Vladimir Serbinenko 12a9c52e51 zfs: Fix disk-matching logic.
Reported by: Tim Chase <dweeezil>
2015-01-24 20:57:26 +01:00
Vladimir Serbinenko 68cf24376c commands/hdparm: Add missing grub_disk_close.
Found by: Coverity scan.
2015-01-24 20:55:06 +01:00
Vladimir Serbinenko 9d999852a2 gptsync: Add missing device_close.
Found by: Coverity scan
2015-01-24 20:52:02 +01:00
Vladimir Serbinenko 95a8c9182b commands/fileXX: Fix memory leak.
Found by: Coverity Scan.
2015-01-24 20:50:35 +01:00
Vladimir Serbinenko b04c6d32ce commands/file: Change the confusing loop stop condition.
Old condition was used to zero-out header variable on exit of the loop.
This is correct but confusing. Replace with in-loop logic.

Found by: Coverity Scan.
2015-01-24 20:47:41 +01:00
Vladimir Serbinenko e902163e48 commands/acpi: Use ALIGN_UP rather than manual expression.
Improves readability and hopefully automatic scanning.

Found by: Coverity Scan.
2015-01-24 20:41:43 +01:00
Vladimir Serbinenko 9ff9d5a54e uhci: Fix null pointer dereference.
Found by: Coverity scan.
2015-01-24 20:38:12 +01:00
Vladimir Serbinenko 3661261fe1 Always add -msoft-float to avoid compiler generating float arithmetics. 2015-01-24 20:37:08 +01:00
Vladimir Serbinenko b8f537199a Generate empty ChangeLog if no .git is available.
When making dist from a git snapshot without repo available make dist would
fail to find ChangeLog. Generate empty ChangeLog if no ChangeLog is already
present and repo is not available.

Reported by: Andrei Borzenkov <arvidjaar@gmail.com>
2015-01-24 20:14:59 +01:00
Vladimir Serbinenko 14c9a72039 Makefile.am: Fix Changelog cutoff address.
gitlog-to-changelog Doesn't generate entries for cutoff day, only
for days after the cutoff date, adjust by one to compensate.
2015-01-24 20:12:51 +01:00
Vladimir Serbinenko 7d027b4d3e efidisk: Return the determined root disk even if partition is unknown. 2015-01-24 19:53:13 +01:00
Vladimir Serbinenko eeea31b220 util/grub-mkrescue.c: Always include part_msdos and part_gpt on EFI.
When booted from stick, EFI would use GPT partition and our root
device detection algortihm depends on GRUB's ability to see the same
partitions. Hence include msdos and gpt partmap modules on EFI even when
they're not needed to access root filesystem.
2015-01-24 17:45:16 +01:00
Vladimir Serbinenko 11504d523c conf/Makefile.common: Remove unused {LD,C}FLAGS_CPU. 2015-01-24 17:44:19 +01:00
Vladimir Serbinenko 3bd0868364 Autogenerate ChangeLog from git changelog.
Old ChangeLog is moved to ChangeLog-2015. For all changes starting from
this one ChangeLog will be generated from gitlog only on explicit make
invocation and make dist.
2015-01-24 17:29:50 +01:00
Vladimir Serbinenko 8acb9dc697 * tests/file_filter/file: Really add missing file. 2015-01-23 19:46:02 +01:00
Andrei Borzenkov edf2db97e7 Mention platform "none" in NEWS 2015-01-23 21:06:16 +03:00
Andrey Borzenkov 2f73d2733c accept also hdX as alias to native Xen disk name
To be compatible with legacy pv-grub, sort disks by increasing order of handle
value. This allows reusing legacy pv-grub menu.lst which is using hdX names.

Suggested-By: Michael Chang <mchang@suse.com>
Closes: 44026
2015-01-23 19:52:45 +03:00
284 changed files with 8313 additions and 2997 deletions

No files matched your search

+9
View File
@@ -1,3 +1,12 @@
2015-01-23 Vladimir Serbinenko <phcoder@gmail.com>
* tests/file_filter/file: Really add missing file.
2015-01-23 Andrei Borzenkov <arvidjaar@gmail.com>
* grub-core/disk/xen/xendisk.c: Accept hdX as disk names on Xen to
allow legacy menu.lst processing.
2015-01-22 Felix Janda <felix.janda@posteo.de> 2015-01-22 Felix Janda <felix.janda@posteo.de>
Remove direct _llseek code and require long filesystem libc. Remove direct _llseek code and require long filesystem libc.
+11 -4
View File
@@ -13,6 +13,9 @@ configuring the GRUB.
* GCC 4.1.3 or later * GCC 4.1.3 or later
Note: older versions may work but support is limited Note: older versions may work but support is limited
Experimental support for clang 3.3 or later (results in much bigger binaries)
for i386, x86_64, arm (except thumb), arm64, mips(el), powerpc, sparc64
Note: clang 3.2 or later works for i386 and x86_64 targets but results in Note: clang 3.2 or later works for i386 and x86_64 targets but results in
much bigger binaries. much bigger binaries.
earlier versions not tested earlier versions not tested
@@ -26,7 +29,8 @@ configuring the GRUB.
fail. fail.
Note: clang 3.2 or later works for powerpc Note: clang 3.2 or later works for powerpc
earlier versions not tested earlier versions not tested
Note: clang doesn't support -mno-app-regs and so can't be used for sparc64 Note: clang 3.5 or later works for sparc64
earlier versions return "error: unable to interface with target machine"
Note: clang has no support for ia64 and hence you can't compile GRUB Note: clang has no support for ia64 and hence you can't compile GRUB
for ia64 with clang for ia64 with clang
* GNU Make * GNU Make
@@ -100,6 +104,9 @@ The simplest way to compile this package is:
3. Type `./autogen.sh'. 3. Type `./autogen.sh'.
* autogen.sh uses python. By default invocation is "python" but can be
overriden by setting variable $PYTHON.
4. Type `./configure' to configure the package for your system. 4. Type `./configure' to configure the package for your system.
If you're using `csh' on an old version of System V, you might If you're using `csh' on an old version of System V, you might
need to type `sh ./configure' instead to prevent `csh' from trying need to type `sh ./configure' instead to prevent `csh' from trying
@@ -175,9 +182,9 @@ corresponding platform are not needed for the platform in question.
- For host - For host
1. --host= to autoconf name of host. 1. --host= to autoconf name of host.
2. CC= for gcc able to compile for host 2. CC= for gcc able to compile for host
3. CFLAGS= for C options for host. 3. HOST_CFLAGS= for C options for host.
4. CPPFLAGS= for C preprocessor options for host. 4. HOST_CPPFLAGS= for C preprocessor options for host.
5. LDFLAGS= for linker options for host. 5. HOST_LDFLAGS= for linker options for host.
6. FREETYPE= for freetype-config for host (optional). 6. FREETYPE= for freetype-config for host (optional).
7. Libdevmapper if any must be in standard linker folders (-ldevmapper) (optional). 7. Libdevmapper if any must be in standard linker folders (-ldevmapper) (optional).
8. Libfuse if any must be in standard linker folders (-lfuse) (optional). 8. Libfuse if any must be in standard linker folders (-lfuse) (optional).
+20 -1
View File
@@ -392,7 +392,7 @@ endif
.PHONY: bootcheck-linux-i386 bootcheck-linux-x86_64 \ .PHONY: bootcheck-linux-i386 bootcheck-linux-x86_64 \
bootcheck-kfreebsd-i386 bootcheck-kfreebsd-x86_64 \ bootcheck-kfreebsd-i386 bootcheck-kfreebsd-x86_64 \
bootcheck-knetbsd-i386 bootcheck-knetbsd-x86_64 \ bootcheck-knetbsd-i386 bootcheck-knetbsd-x86_64 \
bootcheck-linux-mips bootcheck-linux-mips FORCE
# Randomly generated # Randomly generated
SUCCESSFUL_BOOT_STRING=3e49994fd5d82b7c9298d672d774080d SUCCESSFUL_BOOT_STRING=3e49994fd5d82b7c9298d672d774080d
@@ -439,3 +439,22 @@ windowszip: windowsdir
rm -rf $(windowsdir) rm -rf $(windowsdir)
EXTRA_DIST += linguas.sh EXTRA_DIST += linguas.sh
changelog_start_date = 2015-01-23
gitlog_to_changelog = $(top_srcdir)/build-aux/gitlog-to-changelog
ChangeLog: FORCE
if test -d $(top_srcdir)/.git; then \
$(gitlog_to_changelog) --srcdir=$(top_srcdir) --since=$(changelog_start_date) > '$@.tmp'; \
rm -f '$@'; mv '$@.tmp' '$@'; \
else \
touch $@; \
fi
EXTRA_DIST += ChangeLog ChangeLog-2015
syslinux_test: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_grub.cfg
tests/syslinux/ubuntu10.04_grub.cfg: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_grub.cfg.in
(for x in tests/syslinux/ubuntu10.04_grub.cfg.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
CLEANFILES += tests/syslinux/ubuntu10.04_grub.cfg
+13 -2
View File
@@ -48,6 +48,7 @@ library = {
common = grub-core/partmap/gpt.c; common = grub-core/partmap/gpt.c;
common = grub-core/partmap/msdos.c; common = grub-core/partmap/msdos.c;
common = grub-core/fs/proc.c; common = grub-core/fs/proc.c;
common = grub-core/fs/archelp.c;
}; };
library = { library = {
@@ -91,7 +92,6 @@ library = {
common = grub-core/fs/bfs.c; common = grub-core/fs/bfs.c;
common = grub-core/fs/btrfs.c; common = grub-core/fs/btrfs.c;
common = grub-core/fs/cbfs.c; common = grub-core/fs/cbfs.c;
common = grub-core/fs/archelp.c;
common = grub-core/fs/cpio.c; common = grub-core/fs/cpio.c;
common = grub-core/fs/cpio_be.c; common = grub-core/fs/cpio_be.c;
common = grub-core/fs/odc.c; common = grub-core/fs/odc.c;
@@ -613,7 +613,6 @@ program = {
common = grub-core/disk/host.c; common = grub-core/disk/host.c;
common = util/resolve.c; common = util/resolve.c;
enable = noemu;
common = grub-core/kern/emu/argp_common.c; common = grub-core/kern/emu/argp_common.c;
common = grub-core/osdep/init.c; common = grub-core/osdep/init.c;
@@ -1156,6 +1155,18 @@ script = {
common = tests/file_filter_test.in; common = tests/file_filter_test.in;
}; };
script = {
testcase;
name = grub_cmd_test;
common = tests/grub_cmd_test.in;
};
script = {
testcase;
name = syslinux_test;
common = tests/syslinux_test.in;
};
program = { program = {
testcase; testcase;
name = example_unit_test; name = example_unit_test;
+9
View File
@@ -17,6 +17,7 @@ New in 2.02:
files. files.
* ZFS features support. * ZFS features support.
* ZFS LZ4 support. * ZFS LZ4 support.
* XFS V5 format support.
* New/improved terminal and video support: * New/improved terminal and video support:
* Monochrome text (matching `hercules' in GRUB Legacy). * Monochrome text (matching `hercules' in GRUB Legacy).
@@ -85,6 +86,9 @@ New in 2.02:
* Support for USB debug dongles. * Support for USB debug dongles.
* Support for *-emu on all platforms (previously only i386/x86_64 worked). * Support for *-emu on all platforms (previously only i386/x86_64 worked).
* Support *-emu on Windows. * Support *-emu on Windows.
* New platform `none' which builds only user level utilities. This is now
default if target CPU is not supported.
* Support for booting little-endian Linux kernel on powerpc.
* Security: * Security:
* Add optional facility to enforce that all files read by the core image * Add optional facility to enforce that all files read by the core image
@@ -143,6 +147,11 @@ New in 2.02:
Python 2.6. Python 2.6.
* modinfo.sh contains build information now. * modinfo.sh contains build information now.
* Added many new tests to improve robustness. * Added many new tests to improve robustness.
* Target is built without libgcc now. Necessary builtins are reimplemented
directly. This removes requirement for target-specific runtime on build
system.
* emu libusb support removed (was broken and unmaintained).
* powerpc64le compile support.
* Revision control moved to git. * Revision control moved to git.
-2
View File
@@ -12,8 +12,6 @@ The URL is <http://www.gnu.org/software/grub/grub.html>.
More extensive documentation is available in the Info manual, More extensive documentation is available in the Info manual,
accessible using 'info grub' after building and installing GRUB 2. accessible using 'info grub' after building and installing GRUB 2.
Please look at the GRUB Wiki <http://grub.enbug.org> for testing
procedures.
There are a number of important user-visible differences from the There are a number of important user-visible differences from the
first version of GRUB, now known as GRUB Legacy. For a summary, please first version of GRUB, now known as GRUB Legacy. For a summary, please
+1 -75
View File
@@ -93,7 +93,7 @@ else
fi fi
grub_cv_prog_objcopy_absolute=yes grub_cv_prog_objcopy_absolute=yes
for link_addr in 0x2000 0x8000 0x7C00; do for link_addr in 0x2000 0x8000 0x7C00; do
if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},$link_addr conftest.o -o conftest.exec]); then : if AC_TRY_COMMAND([${CC-cc} ${TARGET_CFLAGS} ${TARGET_LDFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},$link_addr conftest.o -o conftest.exec]); then :
else else
AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr]) AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr])
fi fi
@@ -210,80 +210,6 @@ fi
]) ])
dnl Mass confusion!
dnl Older versions of GAS interpret `.code16' to mean ``generate 32-bit
dnl instructions, but implicitly insert addr32 and data32 bytes so
dnl that the code works in real mode''.
dnl
dnl Newer versions of GAS interpret `.code16' to mean ``generate 16-bit
dnl instructions,'' which seems right. This requires the programmer
dnl to explicitly insert addr32 and data32 instructions when they want
dnl them.
dnl
dnl We only support the newer versions, because the old versions cause
dnl major pain, by requiring manual assembly to get 16-bit instructions into
dnl asm files.
AC_DEFUN([grub_I386_ASM_ADDR32],
[AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([grub_I386_ASM_PREFIX_REQUIREMENT])
AC_MSG_CHECKING([for .code16 addr32 assembler support])
AC_CACHE_VAL(grub_cv_i386_asm_addr32,
[cat > conftest.s.in <<\EOF
.code16
l1: @ADDR32@ movb %al, l1
EOF
if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then
sed -e s/@ADDR32@/addr32/ < conftest.s.in > conftest.s
else
sed -e s/@ADDR32@/addr32\;/ < conftest.s.in > conftest.s
fi
if AC_TRY_COMMAND([${CC-cc} ${TARGET_CCASFLAGS} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then
grub_cv_i386_asm_addr32=yes
else
grub_cv_i386_asm_addr32=no
fi
rm -f conftest*])
AC_MSG_RESULT([$grub_cv_i386_asm_addr32])])
dnl Later versions of GAS requires that addr32 and data32 prefixes
dnl appear in the same lines as the instructions they modify, while
dnl earlier versions requires that they appear in separate lines.
AC_DEFUN([grub_I386_ASM_PREFIX_REQUIREMENT],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(dnl
[whether addr32 must be in the same line as the instruction])
AC_CACHE_VAL(grub_cv_i386_asm_prefix_requirement,
[cat > conftest.s <<\EOF
.code16
l1: addr32 movb %al, l1
EOF
if AC_TRY_COMMAND([${CC-cc} ${TARGET_CCASFLAGS} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then
grub_cv_i386_asm_prefix_requirement=yes
else
grub_cv_i386_asm_prefix_requirement=no
fi
rm -f conftest*])
if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then
grub_tmp_addr32="addr32"
grub_tmp_data32="data32"
else
grub_tmp_addr32="addr32;"
grub_tmp_data32="data32;"
fi
ADDR32=$grub_tmp_addr32
DATA32=$grub_tmp_data32
AC_MSG_RESULT([$grub_cv_i386_asm_prefix_requirement])])
dnl Check what symbol is defined as a bss start symbol. dnl Check what symbol is defined as a bss start symbol.
dnl Written by Michael Hohmoth and Yoshinori K. Okuji. dnl Written by Michael Hohmoth and Yoshinori K. Okuji.
AC_DEFUN([grub_CHECK_BSS_START_SYMBOL], AC_DEFUN([grub_CHECK_BSS_START_SYMBOL],
+20
View File
@@ -0,0 +1,20 @@
/* on arm clang doesn't support .arch directive */
.text
.syntax unified
#if !defined (__thumb2__)
.arch armv7a
.arm
#else
.arch armv7
.thumb
#endif
mcr p15, 0, r11, c7, c14, 2
/* clang restricts access to dsb/isb despite .arch */
dsb
isb
+10
View File
@@ -0,0 +1,10 @@
/* on x86 old clang doesn't support .code16
newer clang supports it but creates 6-byte jumps instead of 3-byte ones
which makes us go over boot sector size. */
.code16
jmp far
.org 4
.space 300
far:
.byte 0
+4
View File
@@ -0,0 +1,4 @@
/* on x86 old clang doesn't support .code16 */
.code16
movb %al, %bl
+11
View File
@@ -0,0 +1,11 @@
/* on mips clang doesn't support privilegied instructions, doubleword store/load
and crashes with hand-written assembly
*/
.set mips3
sync
ld $t2, 0($t1)
a:
addiu $t1, $s0, (b - a)
b: nop
+8
View File
@@ -0,0 +1,8 @@
/* clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly
used by gcrypt */
/* Cache invalidation loop is a fair test. */
li 5, 0
1: icbi 5, 3
addi 5, 5, 32
cmpw 5, 4
blt 1b
+9
View File
@@ -0,0 +1,9 @@
.text
1:
/* A small list of examples of what clang doesn't support. */
clr %o0
lduw [%o4 + 4], %o4
and %o6, ~0xff, %o6
stw %o5, [%o3]
bne,pt %icc, 1b
nop
+7 -4
View File
@@ -2,6 +2,9 @@
set -e set -e
# Set ${PYTHON} to plain 'python' if not set already
: ${PYTHON:=python}
export LC_COLLATE=C export LC_COLLATE=C
unset LC_ALL unset LC_ALL
@@ -9,10 +12,10 @@ find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './b
find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in
echo "Importing unicode..." echo "Importing unicode..."
python util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c ${PYTHON} util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c
echo "Importing libgcrypt..." echo "Importing libgcrypt..."
python util/import_gcry.py grub-core/lib/libgcrypt/ grub-core ${PYTHON} util/import_gcry.py grub-core/lib/libgcrypt/ grub-core
sed -n -f util/import_gcrypth.sed < grub-core/lib/libgcrypt/src/gcrypt.h.in > include/grub/gcrypt/gcrypt.h sed -n -f util/import_gcrypth.sed < grub-core/lib/libgcrypt/src/gcrypt.h.in > include/grub/gcrypt/gcrypt.h
if [ -f include/grub/gcrypt/g10lib.h ]; then if [ -f include/grub/gcrypt/g10lib.h ]; then
rm include/grub/gcrypt/g10lib.h rm include/grub/gcrypt/g10lib.h
@@ -54,8 +57,8 @@ for extra in contrib/*/Makefile.core.def; do
fi fi
done done
python gentpl.py $UTIL_DEFS > Makefile.util.am ${PYTHON} gentpl.py $UTIL_DEFS > Makefile.util.am
python gentpl.py $CORE_DEFS > grub-core/Makefile.core.am ${PYTHON} gentpl.py $CORE_DEFS > grub-core/Makefile.core.am
for extra in contrib/*/Makefile.common; do for extra in contrib/*/Makefile.common; do
if test -e "$extra"; then if test -e "$extra"; then
+432
View File
@@ -0,0 +1,432 @@
eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}'
& eval 'exec perl -wS "$0" $argv:q'
if 0;
# Convert git log output to ChangeLog format.
my $VERSION = '2012-07-29 06:11'; # UTC
# The definition above must lie within the first 8 lines in order
# for the Emacs time-stamp write hook (at end) to update it.
# If you change this file with Emacs, please let the write hook
# do its job. Otherwise, update this string manually.
# Copyright (C) 2008-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Written by Jim Meyering
use strict;
use warnings;
use Getopt::Long;
use POSIX qw(strftime);
(my $ME = $0) =~ s|.*/||;
# use File::Coda; # http://meyering.net/code/Coda/
END {
defined fileno STDOUT or return;
close STDOUT and return;
warn "$ME: failed to close standard output: $!\n";
$? ||= 1;
}
sub usage ($)
{
my ($exit_code) = @_;
my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR);
if ($exit_code != 0)
{
print $STREAM "Try '$ME --help' for more information.\n";
}
else
{
print $STREAM <<EOF;
Usage: $ME [OPTIONS] [ARGS]
Convert git log output to ChangeLog format. If present, any ARGS
are passed to "git log". To avoid ARGS being parsed as options to
$ME, they may be preceded by '--'.
OPTIONS:
--amend=FILE FILE maps from an SHA1 to perl code (i.e., s/old/new/) that
makes a change to SHA1's commit log text or metadata.
--append-dot append a dot to the first line of each commit message if
there is no other punctuation or blank at the end.
--no-cluster never cluster commit messages under the same date/author
header; the default is to cluster adjacent commit messages
if their headers are the same and neither commit message
contains multiple paragraphs.
--srcdir=DIR the root of the source tree, from which the .git/
directory can be derived.
--since=DATE convert only the logs since DATE;
the default is to convert all log entries.
--format=FMT set format string for commit subject and body;
see 'man git-log' for the list of format metacharacters;
the default is '%s%n%b%n'
--strip-tab remove one additional leading TAB from commit message lines.
--strip-cherry-pick remove data inserted by "git cherry-pick";
this includes the "cherry picked from commit ..." line,
and the possible final "Conflicts:" paragraph.
--help display this help and exit
--version output version information and exit
EXAMPLE:
$ME --since=2008-01-01 > ChangeLog
$ME -- -n 5 foo > last-5-commits-to-branch-foo
SPECIAL SYNTAX:
The following types of strings are interpreted specially when they appear
at the beginning of a log message line. They are not copied to the output.
Copyright-paperwork-exempt: Yes
Append the "(tiny change)" notation to the usual "date name email"
ChangeLog header to mark a change that does not require a copyright
assignment.
Co-authored-by: Joe User <user\@example.com>
List the specified name and email address on a second
ChangeLog header, denoting a co-author.
Signed-off-by: Joe User <user\@example.com>
These lines are simply elided.
In a FILE specified via --amend, comment lines (starting with "#") are ignored.
FILE must consist of <SHA,CODE+> pairs where SHA is a 40-byte SHA1 (alone on
a line) referring to a commit in the current project, and CODE refers to one
or more consecutive lines of Perl code. Pairs must be separated by one or
more blank line.
Here is sample input for use with --amend=FILE, from coreutils:
3a169f4c5d9159283548178668d2fae6fced3030
# fix typo in title:
s/all tile types/all file types/
1379ed974f1fa39b12e2ffab18b3f7a607082202
# Due to a bug in vc-dwim, I mis-attributed a patch by Paul to myself.
# Change the author to be Paul. Note the escaped "@":
s,Jim .*>,Paul Eggert <eggert\\\@cs.ucla.edu>,
EOF
}
exit $exit_code;
}
# If the string $S is a well-behaved file name, simply return it.
# If it contains white space, quotes, etc., quote it, and return the new string.
sub shell_quote($)
{
my ($s) = @_;
if ($s =~ m![^\w+/.,-]!)
{
# Convert each single quote to '\''
$s =~ s/\'/\'\\\'\'/g;
# Then single quote the string.
$s = "'$s'";
}
return $s;
}
sub quoted_cmd(@)
{
return join (' ', map {shell_quote $_} @_);
}
# Parse file F.
# Comment lines (starting with "#") are ignored.
# F must consist of <SHA,CODE+> pairs where SHA is a 40-byte SHA1
# (alone on a line) referring to a commit in the current project, and
# CODE refers to one or more consecutive lines of Perl code.
# Pairs must be separated by one or more blank line.
sub parse_amend_file($)
{
my ($f) = @_;
open F, '<', $f
or die "$ME: $f: failed to open for reading: $!\n";
my $fail;
my $h = {};
my $in_code = 0;
my $sha;
while (defined (my $line = <F>))
{
$line =~ /^\#/
and next;
chomp $line;
$line eq ''
and $in_code = 0, next;
if (!$in_code)
{
$line =~ /^([0-9a-fA-F]{40})$/
or (warn "$ME: $f:$.: invalid line; expected an SHA1\n"),
$fail = 1, next;
$sha = lc $1;
$in_code = 1;
exists $h->{$sha}
and (warn "$ME: $f:$.: duplicate SHA1\n"),
$fail = 1, next;
}
else
{
$h->{$sha} ||= '';
$h->{$sha} .= "$line\n";
}
}
close F;
$fail
and exit 1;
return $h;
}
# git_dir_option $SRCDIR
#
# From $SRCDIR, the --git-dir option to pass to git (none if $SRCDIR
# is undef). Return as a list (0 or 1 element).
sub git_dir_option($)
{
my ($srcdir) = @_;
my @res = ();
if (defined $srcdir)
{
my $qdir = shell_quote $srcdir;
my $cmd = "cd $qdir && git rev-parse --show-toplevel";
my $qcmd = shell_quote $cmd;
my $git_dir = qx($cmd);
defined $git_dir
or die "$ME: cannot run $qcmd: $!\n";
$? == 0
or die "$ME: $qcmd had unexpected exit code or signal ($?)\n";
chomp $git_dir;
push @res, "--git-dir=$git_dir/.git";
}
@res;
}
{
my $since_date;
my $format_string = '%s%n%b%n';
my $amend_file;
my $append_dot = 0;
my $cluster = 1;
my $strip_tab = 0;
my $strip_cherry_pick = 0;
my $srcdir;
GetOptions
(
help => sub { usage 0 },
version => sub { print "$ME version $VERSION\n"; exit },
'since=s' => \$since_date,
'format=s' => \$format_string,
'amend=s' => \$amend_file,
'append-dot' => \$append_dot,
'cluster!' => \$cluster,
'strip-tab' => \$strip_tab,
'strip-cherry-pick' => \$strip_cherry_pick,
'srcdir=s' => \$srcdir,
) or usage 1;
defined $since_date
and unshift @ARGV, "--since=$since_date";
# This is a hash that maps an SHA1 to perl code (i.e., s/old/new/)
# that makes a correction in the log or attribution of that commit.
my $amend_code = defined $amend_file ? parse_amend_file $amend_file : {};
my @cmd = ('git',
git_dir_option $srcdir,
qw(log --log-size),
'--pretty=format:%H:%ct %an <%ae>%n%n'.$format_string, @ARGV);
open PIPE, '-|', @cmd
or die ("$ME: failed to run '". quoted_cmd (@cmd) ."': $!\n"
. "(Is your Git too old? Version 1.5.1 or later is required.)\n");
my $prev_multi_paragraph;
my $prev_date_line = '';
my @prev_coauthors = ();
while (1)
{
defined (my $in = <PIPE>)
or last;
$in =~ /^log size (\d+)$/
or die "$ME:$.: Invalid line (expected log size):\n$in";
my $log_nbytes = $1;
my $log;
my $n_read = read PIPE, $log, $log_nbytes;
$n_read == $log_nbytes
or die "$ME:$.: unexpected EOF\n";
# Extract leading hash.
my ($sha, $rest) = split ':', $log, 2;
defined $sha
or die "$ME:$.: malformed log entry\n";
$sha =~ /^[0-9a-fA-F]{40}$/
or die "$ME:$.: invalid SHA1: $sha\n";
# If this commit's log requires any transformation, do it now.
my $code = $amend_code->{$sha};
if (defined $code)
{
eval 'use Safe';
my $s = new Safe;
# Put the unpreprocessed entry into "$_".
$_ = $rest;
# Let $code operate on it, safely.
my $r = $s->reval("$code")
or die "$ME:$.:$sha: failed to eval \"$code\":\n$@\n";
# Note that we've used this entry.
delete $amend_code->{$sha};
# Update $rest upon success.
$rest = $_;
}
# Remove lines inserted by "git cherry-pick".
if ($strip_cherry_pick)
{
$rest =~ s/^\s*Conflicts:\n.*//sm;
$rest =~ s/^\s*\(cherry picked from commit [\da-f]+\)\n//m;
}
my @line = split "\n", $rest;
my $author_line = shift @line;
defined $author_line
or die "$ME:$.: unexpected EOF\n";
$author_line =~ /^(\d+) (.*>)$/
or die "$ME:$.: Invalid line "
. "(expected date/author/email):\n$author_line\n";
# Format 'Copyright-paperwork-exempt: Yes' as a standard ChangeLog
# `(tiny change)' annotation.
my $tiny = (grep (/^Copyright-paperwork-exempt:\s+[Yy]es$/, @line)
? ' (tiny change)' : '');
my $date_line = sprintf "%s %s$tiny\n",
strftime ("%F", localtime ($1)), $2;
my @coauthors = grep /^Co-authored-by:.*$/, @line;
# Omit meta-data lines we've already interpreted.
@line = grep !/^(?:Signed-off-by:[ ].*>$
|Co-authored-by:[ ]
|Copyright-paperwork-exempt:[ ]
)/x, @line;
# Remove leading and trailing blank lines.
if (@line)
{
while ($line[0] =~ /^\s*$/) { shift @line; }
while ($line[$#line] =~ /^\s*$/) { pop @line; }
}
# Record whether there are two or more paragraphs.
my $multi_paragraph = grep /^\s*$/, @line;
# Format 'Co-authored-by: A U Thor <email@example.com>' lines in
# standard multi-author ChangeLog format.
for (@coauthors)
{
s/^Co-authored-by:\s*/\t /;
s/\s*</ </;
/<.*?@.*\..*>/
or warn "$ME: warning: missing email address for "
. substr ($_, 5) . "\n";
}
# If clustering of commit messages has been disabled, if this header
# would be different from the previous date/name/email/coauthors header,
# or if this or the previous entry consists of two or more paragraphs,
# then print the header.
if ( ! $cluster
|| $date_line ne $prev_date_line
|| "@coauthors" ne "@prev_coauthors"
|| $multi_paragraph
|| $prev_multi_paragraph)
{
$prev_date_line eq ''
or print "\n";
print $date_line;
@coauthors
and print join ("\n", @coauthors), "\n";
}
$prev_date_line = $date_line;
@prev_coauthors = @coauthors;
$prev_multi_paragraph = $multi_paragraph;
# If there were any lines
if (@line == 0)
{
warn "$ME: warning: empty commit message:\n $date_line\n";
}
else
{
if ($append_dot)
{
# If the first line of the message has enough room, then
if (length $line[0] < 72)
{
# append a dot if there is no other punctuation or blank
# at the end.
$line[0] =~ /[[:punct:]\s]$/
or $line[0] .= '.';
}
}
# Remove one additional leading TAB from each line.
$strip_tab
and map { s/^\t// } @line;
# Prefix each non-empty line with a TAB.
@line = map { length $_ ? "\t$_" : '' } @line;
print "\n", join ("\n", @line), "\n";
}
defined ($in = <PIPE>)
or last;
$in ne "\n"
and die "$ME:$.: unexpected line:\n$in";
}
close PIPE
or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n";
# FIXME-someday: include $PROCESS_STATUS in the diagnostic
# Complain about any unused entry in the --amend=F specified file.
my $fail = 0;
foreach my $sha (keys %$amend_code)
{
warn "$ME:$amend_file: unused entry: $sha\n";
$fail = 1;
}
exit $fail;
}
# Local Variables:
# mode: perl
# indent-tabs-mode: nil
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "my $VERSION = '"
# time-stamp-format: "%:y-%02m-%02d %02H:%02M"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "'; # UTC"
# End:
+11 -15
View File
@@ -7,12 +7,7 @@ unexport LC_ALL
# Platform specific options # Platform specific options
if COND_sparc64_ieee1275 if COND_sparc64_ieee1275
CFLAGS_PLATFORM += -mno-app-regs LDFLAGS_PLATFORM = -Wl,-melf64_sparc
LDFLAGS_PLATFORM = -Wl,-melf64_sparc -mno-relax
endif
if COND_sparc64_emu
CFLAGS_PLATFORM += -mno-app-regs
LDFLAGS_PLATFORM = -Wl,--no-relax
endif endif
if COND_arm if COND_arm
if !COND_emu if !COND_emu
@@ -22,6 +17,9 @@ endif
if COND_arm64 if COND_arm64
CFLAGS_PLATFORM += -mcmodel=large CFLAGS_PLATFORM += -mcmodel=large
endif endif
if COND_powerpc_ieee1275
CFLAGS_PLATFORM += -mcpu=powerpc
endif
#FIXME: discover and check XEN headers #FIXME: discover and check XEN headers
CPPFLAGS_XEN = -I/usr/include CPPFLAGS_XEN = -I/usr/include
@@ -39,21 +37,19 @@ CPPFLAGS_DEFAULT += -I$(top_srcdir)/grub-core/lib/libgcrypt-grub/src/
CCASFLAGS_DEFAULT = $(CPPFLAGS_DEFAULT) -DASM_FILE=1 CCASFLAGS_DEFAULT = $(CPPFLAGS_DEFAULT) -DASM_FILE=1
BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT) BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT)
LDADD_KERNEL = $(TARGET_LIBGCC) CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC)
CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC)
CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1
CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags
CFLAGS_MODULE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_MODULE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
CFLAGS_IMAGE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -fno-builtin CFLAGS_IMAGE = $(CFLAGS_PLATFORM) -fno-builtin
LDFLAGS_IMAGE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S LDFLAGS_IMAGE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S
CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
+13
View File
@@ -5,6 +5,7 @@ EXTRA_DIST += gentpl.py
EXTRA_DIST += Makefile.util.def EXTRA_DIST += Makefile.util.def
EXTRA_DIST += Makefile.utilgcry.def EXTRA_DIST += Makefile.utilgcry.def
EXTRA_DIST += asm-tests
EXTRA_DIST += unicode EXTRA_DIST += unicode
EXTRA_DIST += util/import_gcry.py EXTRA_DIST += util/import_gcry.py
@@ -121,3 +122,15 @@ EXTRA_DIST += tests/file_filter/file.xz.sig
EXTRA_DIST += tests/file_filter/keys EXTRA_DIST += tests/file_filter/keys
EXTRA_DIST += tests/file_filter/keys.pub EXTRA_DIST += tests/file_filter/keys.pub
EXTRA_DIST += tests/file_filter/test.cfg EXTRA_DIST += tests/file_filter/test.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/prompt.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/txt.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/menu.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/po4a.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg
EXTRA_DIST += tests/syslinux/ubuntu10.04_grub.cfg.in
+9 -4
View File
@@ -7,11 +7,20 @@
#endif #endif
#define GCRYPT_NO_DEPRECATED 1 #define GCRYPT_NO_DEPRECATED 1
#define HAVE_MEMMOVE 1
/* Define to 1 to enable disk cache statistics. */ /* Define to 1 to enable disk cache statistics. */
#define DISK_CACHE_STATS @DISK_CACHE_STATS@ #define DISK_CACHE_STATS @DISK_CACHE_STATS@
#define BOOT_TIME_STATS @BOOT_TIME_STATS@ #define BOOT_TIME_STATS @BOOT_TIME_STATS@
/* We don't need those. */
#define MINILZO_CFG_SKIP_LZO_PTR 1
#define MINILZO_CFG_SKIP_LZO_UTIL 1
#define MINILZO_CFG_SKIP_LZO_STRING 1
#define MINILZO_CFG_SKIP_LZO_INIT 1
#define MINILZO_CFG_SKIP_LZO1X_1_COMPRESS 1
#define MINILZO_CFG_SKIP_LZO1X_DECOMPRESS 1
#if defined (GRUB_BUILD) #if defined (GRUB_BUILD)
#undef ENABLE_NLS #undef ENABLE_NLS
#define BUILD_SIZEOF_LONG @BUILD_SIZEOF_LONG@ #define BUILD_SIZEOF_LONG @BUILD_SIZEOF_LONG@
@@ -31,10 +40,6 @@
#define HAVE_FONT_SOURCE @HAVE_FONT_SOURCE@ #define HAVE_FONT_SOURCE @HAVE_FONT_SOURCE@
/* Define if C symbols get an underscore after compilation. */ /* Define if C symbols get an underscore after compilation. */
#define HAVE_ASM_USCORE @HAVE_ASM_USCORE@ #define HAVE_ASM_USCORE @HAVE_ASM_USCORE@
/* Define it to \"addr32\" or \"addr32;\" to make GAS happy. */
#define ADDR32 @ADDR32@
/* Define it to \"data32\" or \"data32;\" to make GAS happy. */
#define DATA32 @DATA32@
/* Define it to one of __bss_start, edata and _edata. */ /* Define it to one of __bss_start, edata and _edata. */
#define BSS_START_SYMBOL @BSS_START_SYMBOL@ #define BSS_START_SYMBOL @BSS_START_SYMBOL@
/* Define it to either end or _end. */ /* Define it to either end or _end. */
+259 -113
View File
@@ -78,12 +78,9 @@ fi
# Default HOST_CPPFLAGS # Default HOST_CPPFLAGS
HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W" HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1" HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W" TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
case "$target_cpu" in case "$target_cpu" in
i[[3456]]86) target_cpu=i386 ;; i[[3456]]86) target_cpu=i386 ;;
@@ -119,6 +116,7 @@ if test "x$with_platform" = x; then
x86_64-*) platform=pc ;; x86_64-*) platform=pc ;;
powerpc-*) platform=ieee1275 ;; powerpc-*) platform=ieee1275 ;;
powerpc64-*) platform=ieee1275 ;; powerpc64-*) platform=ieee1275 ;;
powerpc64le-*) platform=ieee1275 ;;
sparc64-*) platform=ieee1275 ;; sparc64-*) platform=ieee1275 ;;
mipsel-*) platform=loongson ;; mipsel-*) platform=loongson ;;
mips-*) platform=arc ;; mips-*) platform=arc ;;
@@ -141,6 +139,7 @@ case "$target_cpu"-"$platform" in
x86_64-none) ;; x86_64-none) ;;
x86_64-*) target_cpu=i386 ;; x86_64-*) target_cpu=i386 ;;
powerpc64-ieee1275) target_cpu=powerpc ;; powerpc64-ieee1275) target_cpu=powerpc ;;
powerpc64le-ieee1275) target_cpu=powerpc ;;
esac esac
# Check if the platform is supported, make final adjustments. # Check if the platform is supported, make final adjustments.
@@ -354,6 +353,9 @@ if test x"$target_cpu-$platform" = xsparc64-emu ; then
HOST_CFLAGS="$HOST_CFLAGS -m64" HOST_CFLAGS="$HOST_CFLAGS -m64"
fi fi
CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"
HOST_CPPFLAGS="$HOST_CPPFLAGS -D_FILE_OFFSET_BITS=64"
AC_C_BIGENDIAN AC_C_BIGENDIAN
AC_CHECK_SIZEOF(void *) AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long)
@@ -549,7 +551,7 @@ int main (void);
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags" TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags"
AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang] AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang],
[ [
CFLAGS="$TARGET_CFLAGS" CFLAGS="$TARGET_CFLAGS"
AC_COMPILE_IFELSE( AC_COMPILE_IFELSE(
@@ -560,36 +562,149 @@ AC_COMPILE_IFELSE(
]])], ]])],
[grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])]) [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])])
# on x86 clang doesn't support .code16 if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then
# on arm clang doesn't support .arch directive AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [
# on mips clang doesn't support privilegied instructions, doubleword store/load grub_cv_target_cc_big_endian=no
# and crashes with hand-written assembly for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \
if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 \ "-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \
|| test "x$target_cpu" = xx86_64 || test "x$target_cpu" = xarm \ "-EB" "-mbig-endian"; do
|| test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ); then if test x"$grub_cv_target_cc_big_endian" != xno ; then
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as" break
fi
CFLAGS="$TARGET_CFLAGS $cand -Werror"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__)
#error still little endian
#endif
asm (".globl start; start:");
asm (".globl _start; _start:");
asm (".globl __start; __start:");
void __main (void);
void __main (void) {}
int main (void);
]], [[]])],
[grub_cv_target_cc_big_endian="$cand"], [])
done
])
if test x"$grub_cv_target_cc_big_endian" = xno ; then
AC_MSG_ERROR([could not force big-endian])
fi
skip_linkflags="$(echo "$grub_cv_target_cc_big_endian"|sed 's@-Wl,-EB@@')"
TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian"
elif test x$target_cpu = xmipsel; then
AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [
grub_cv_target_cc_little_endian=no
for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \
"-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \
"-EL"; do
if test x"$grub_cv_target_cc_little_endian" != xno ; then
break
fi
CFLAGS="$TARGET_CFLAGS $cand -Werror"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__)
#error still big endian
#endif
asm (".globl start; start:");
asm (".globl _start; _start:");
asm (".globl __start; __start:");
void __main (void);
void __main (void) {}
int main (void);
]], [[]])],
[grub_cv_target_cc_little_endian="$cand"], [])
done
])
if test x"$grub_cv_target_cc_little_endian" = xno ; then
AC_MSG_ERROR([could not force little-endian])
fi
skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')"
TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags"
TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags"
TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian"
fi fi
if test "x$grub_cv_cc_target_clang" = xyes && test "x$target_cpu" = xpowerpc; then # GRUB code is N32-compliant but it's experimental and we would prefer to
AC_CACHE_CHECK([if clang can handle ame instruction], [grub_cv_cc_target_clang_ame] # avoid having too much variety when it doesn't result in any real improvement.
[ # Moreover N64 isn't supported.
CFLAGS="$TARGET_CFLAGS" if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then
AC_COMPILE_IFELSE( AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [
[AC_LANG_PROGRAM([], [[ grub_cv_target_cc_mips_o32_abi=no
unsigned int a = 0, b = 0; for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do
asm volatile ("{ame|addme} %0,%1" : "=r" (a) : "r" (b)); if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then
if (a) break
return 1; fi
]])], CFLAGS="$TARGET_CFLAGS $arg -Werror"
[grub_cv_cc_target_clang_ame=yes], [grub_cv_cc_target_clang_ame=no])]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[
# clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly #if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32)
# used by gcrypt #error not o32 ABI
if test x$grub_cv_cc_target_clang_ame = xno ; then #endif
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as" asm (".globl start; start:");
TARGET_CFLAGS="$TARGET_CFLAGS -no-integrated-as" asm (".globl _start; _start:");
fi asm (".globl __start; __start:");
void __main (void);
void __main (void) {}
int main (void);
]], [[]])],
[grub_cv_target_cc_mips_o32_abi="$arg"], [])
done
])
if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then
AC_MSG_ERROR([could not force MIPS o32 ABI])
fi
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi"
TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi"
fi fi
AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [
test_program=
case "x$target_cpu-$platform" in
xmips-* | xmipsel-*)
test_program=mips
;;
xi386-pc)
test_program=i386-pc
;;
xi386-* | xx86_64-*)
test_program=i386
;;
xpowerpc-* | xsparc64-* | xarm-*)
test_program=$target_cpu
;;
esac
if test x"$test_program" = x ; then
grub_cv_cc_target_asm_compile=
else
found=no
for arg in "" "-no-integrated-as"; do
cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S"
echo "Running $cmdline" >&AS_MESSAGE_LOG_FD
if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
grub_cv_cc_target_asm_compile="$arg"
found=yes
break
fi
done
if test x"$found" = xno ; then
AC_MSG_ERROR([could not compile assembly])
fi
fi
])
TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile"
if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then
TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" TARGET_CFLAGS="$TARGET_CFLAGS -march=i386"
fi fi
@@ -671,6 +786,102 @@ if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$p
TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow" TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
fi fi
# GRUB doesn't use float or doubles at all. Yet some toolchains may decide
# that floats are a good fit to run instead of what's written in the code.
# Given that floating point unit is disabled (if present to begin with)
# when GRUB is running which may result in various hard crashes.
if test x"$platform" != xemu ; then
AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [
grub_cv_target_cc_soft_float=no
if test "x$target_cpu" = xarm64; then
CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_target_cc_soft_float="-mgeneral-regs-only"], [])
fi
if test "x$target_cpu" = xia64; then
CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], [])
fi
for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \
"-Xclang -msoft-float -Xclang -no-implicit-float" \
"-Xclang -msoft-float" "-msoft-float"; do
if test x"$grub_cv_target_cc_soft_float" != xno ; then
break
fi
CFLAGS="$TARGET_CFLAGS $cand -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_target_cc_soft_float="$cand"], [])
done
])
if test x"$grub_cv_target_cc_soft_float" = xno ; then
AC_MSG_ERROR([could not force soft-float])
fi
case x"$grub_cv_target_cc_soft_float" in
x*"-Xclang"*)
# A trick so that clang doesn't see it on link stаge
TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float"
;;
*)
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float"
;;
esac
TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float"
fi
if test x"$target_cpu" = xsparc64 ; then
AC_CACHE_CHECK([for options to reserve application registers], grub_cv_target_cc_mno_app_regs, [
grub_cv_target_cc_mno_app_regs=no
for cand in "-mllvm -sparc-reserve-app-registers" \
"-mno-app-regs"; do
if test x"$grub_cv_target_cc_mno_app_regs" != xno ; then
break
fi
CFLAGS="$TARGET_CFLAGS $cand -Werror"
CPPFLAGS="$TARGET_CPPFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_target_cc_mno_app_regs="$cand"], [])
done
])
if test x"$grub_cv_target_cc_mno_app_regs" = xno ; then
AC_MSG_ERROR([could not reserve application registers])
fi
if test x"$grub_cv_target_cc_mno_app_regs" = x"-mllvm -sparc-reserve-app-registers" ; then
# A trick so that clang doesn't see it on link stаge
TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_app_regs"
else
TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_app_regs"
fi
AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [
grub_cv_target_cc_mno_relax=no
for cand in "-mno-relax" "-Wl,--no-relax"; do
if test x"$grub_cv_target_cc_mno_relax" != xno ; then
break
fi
LDFLAGS="$TARGET_LDFLAGS $cand -nostdlib -static"
CFLAGS="$TARGET_CFLAGS -Werror"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
asm (".globl start; start:");
void __main (void);
void __main (void) {}
int main (void);
]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], [])
done
])
LDFLAGS="$TARGET_LDFLAGS"
CFLAGS="$TARGET_CFLAGS"
if test x"$grub_cv_target_cc_mno_relax" = xno ; then
AC_MSG_ERROR([could not find no-relax options])
fi
TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax"
fi
# By default, GCC 4.4 generates .eh_frame sections containing unwind # By default, GCC 4.4 generates .eh_frame sections containing unwind
# information in some cases where it previously did not. GRUB doesn't need # information in some cases where it previously did not. GRUB doesn't need
# these and they just use up vital space. Restore the old compiler # these and they just use up vital space. Restore the old compiler
@@ -872,7 +1083,7 @@ AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
LDFLAGS="$TARGET_LDFLAGS" LDFLAGS="$TARGET_LDFLAGS"
if test "$target_cpu" = x86_64 || test "$target_cpu-$platform" = sparc64-emu ; then if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 ; then
# Use large model to support 4G memory # Use large model to support 4G memory
AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [ AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
CFLAGS="$TARGET_CFLAGS -mcmodel=large" CFLAGS="$TARGET_CFLAGS -mcmodel=large"
@@ -882,7 +1093,7 @@ if test "$target_cpu" = x86_64 || test "$target_cpu-$platform" = sparc64-emu ; t
]) ])
if test "x$grub_cv_cc_mcmodel" = xyes; then if test "x$grub_cv_cc_mcmodel" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large" TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
elif test "$target_cpu-$platform" = sparc64-emu; then elif test "$target_cpu" = sparc64; then
TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany" TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany"
fi fi
fi fi
@@ -920,20 +1131,9 @@ if test "x$target_cpu" = xarm; then
]) ])
if test "x$grub_cv_cc_mthumb_interwork" = xyes; then if test "x$grub_cv_cc_mthumb_interwork" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork" TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork"
# Clang defaults to thumb interworking
elif test "x$grub_cv_cc_target_clang" = xno ; then elif test "x$grub_cv_cc_target_clang" = xno ; then
AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork]) AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork])
else
CFLAGS="$TARGET_CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
#if defined (__thumb__) && !defined (__thumb2__)
#error thumb without interworking
#endif
]])],
[no_interwork_ok=yes],
[no_interwork_ok=no])
if test x$no_interwork_ok = xno ; then
AC_MSG_ERROR([attempt to compile to thumb with no thumb interwork])
fi
fi fi
fi fi
@@ -1031,22 +1231,17 @@ fi
# Set them to their new values for the tests below. # Set them to their new values for the tests below.
CC="$TARGET_CC" CC="$TARGET_CC"
if test "x$TARGET_APPLE_LINKER" = x1 ; then if test x"$platform" = xemu ; then
CFLAGS="$TARGET_CFLAGS -Wno-error"
elif test "x$TARGET_APPLE_LINKER" = x1 ; then
CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error" CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error"
else else
CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error" CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
fi fi
CPPFLAGS="$TARGET_CPPFLAGS" CPPFLAGS="$TARGET_CPPFLAGS"
if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then
TARGET_LIBGCC=
else
TARGET_LIBGCC=-lgcc
fi
LIBS="$TARGET_LIBGCC"
grub_ASM_USCORE grub_ASM_USCORE
if test "x$TARGET_APPLE_LINKER" = x0 ; then if test "x$TARGET_APPLE_LINKER" = x0 && test x"$platform" != xemu; then
if test x$grub_cv_asm_uscore = xyes; then if test x$grub_cv_asm_uscore = xyes; then
DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main" DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main"
else else
@@ -1056,7 +1251,9 @@ CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM"
fi fi
# Check for libgcc symbols # Check for libgcc symbols
AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x) if test x"$platform" = xemu; then
AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms)
fi
if test "x$TARGET_APPLE_LINKER" = x1 ; then if test "x$TARGET_APPLE_LINKER" = x1 ; then
CFLAGS="$TARGET_CFLAGS -nostdlib -static" CFLAGS="$TARGET_CFLAGS -nostdlib -static"
@@ -1081,8 +1278,6 @@ if test "x$target_cpu" = xi386; then
grub_CHECK_END_SYMBOL grub_CHECK_END_SYMBOL
fi fi
CFLAGS="$TARGET_CFLAGS" CFLAGS="$TARGET_CFLAGS"
grub_I386_ASM_PREFIX_REQUIREMENT
grub_I386_ASM_ADDR32
fi fi
grub_PROG_NM_WORKS grub_PROG_NM_WORKS
@@ -1160,10 +1355,6 @@ else
fi fi
AC_SUBST([BOOT_TIME_STATS]) AC_SUBST([BOOT_TIME_STATS])
AC_ARG_ENABLE([grub-emu-usb],
[AS_HELP_STRING([--enable-grub-emu-usb],
[build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
AC_ARG_ENABLE([grub-emu-sdl], AC_ARG_ENABLE([grub-emu-sdl],
[AS_HELP_STRING([--enable-grub-emu-sdl], [AS_HELP_STRING([--enable-grub-emu-sdl],
[build and install the `grub-emu' debugging utility with SDL support (default=guessed)])]) [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
@@ -1174,34 +1365,6 @@ AC_ARG_ENABLE([grub-emu-pci],
if test "$platform" = emu; then if test "$platform" = emu; then
if test x"$enable_grub_emu_usb" != xyes ; then
grub_emu_usb_excuse="not enabled"
fi
if test x"$enable_grub_emu_pci" = xyes ; then
grub_emu_usb_excuse="conflicts with PCI support"
fi
[if [ x"$grub_emu_usb_excuse" = x ]; then
# Check for libusb libraries.]
AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
[grub_emu_usb_excuse=["need libusb library"]])
AC_SUBST([LIBUSB])
[fi]
[if [ x"$grub_emu_usb_excuse" = x ]; then
# Check for headers.]
AC_CHECK_HEADERS([usb.h], [],
[grub_emu_usb_excuse=["need libusb headers"]])
[fi]
if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled ($grub_emu_usb_excuse)])
fi
if test x"$grub_emu_usb_excuse" = x ; then
enable_grub_emu_usb=yes
else
enable_grub_emu_usb=no
fi
if test x"$enable_grub_emu_sdl" = xno ; then if test x"$enable_grub_emu_sdl" = xno ; then
grub_emu_sdl_excuse="explicitly disabled" grub_emu_sdl_excuse="explicitly disabled"
fi fi
@@ -1231,10 +1394,6 @@ if test x"$enable_grub_emu_pci" != xyes ; then
grub_emu_pci_excuse="not enabled" grub_emu_pci_excuse="not enabled"
fi fi
if test x"$enable_grub_emu_usb" = xyes ; then
grub_emu_pci_excuse="conflicts with USB support"
fi
[if [ x"$grub_emu_pci_excuse" = x ]; then [if [ x"$grub_emu_pci_excuse" = x ]; then
# Check for libpci libraries.] # Check for libpci libraries.]
AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"], AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
@@ -1243,7 +1402,7 @@ fi
[fi] [fi]
[if [ x"$grub_emu_pci_excuse" = x ]; then [if [ x"$grub_emu_pci_excuse" = x ]; then
# Check for headers.] # Check for headers.]
AC_CHECK_HEADERS([pci/pci.h], [], AC_CHECK_HEADERS([pciaccess.h], [],
[grub_emu_pci_excuse=["need libpciaccess headers"]]) [grub_emu_pci_excuse=["need libpciaccess headers"]])
[fi] [fi]
@@ -1255,14 +1414,12 @@ enable_grub_emu_pci=no
fi fi
AC_SUBST([enable_grub_emu_sdl]) AC_SUBST([enable_grub_emu_sdl])
AC_SUBST([enable_grub_emu_usb])
AC_SUBST([enable_grub_emu_pci]) AC_SUBST([enable_grub_emu_pci])
else else
# Ignore --enable-emu-* if platform is not emu # Ignore --enable-emu-* if platform is not emu
enable_grub_emu_sdl=no enable_grub_emu_sdl=no
enable_grub_emu_usb=no
enable_grub_emu_pci=no enable_grub_emu_pci=no
fi fi
@@ -1471,7 +1628,7 @@ fi
if test x"$grub_mount_excuse" = x ; then if test x"$grub_mount_excuse" = x ; then
# Check for fuse headers. # Check for fuse headers.
SAVED_CPPFLAGS="$CPPFLAGS" SAVED_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26" CPPFLAGS="$CPPFLAGS -DFUSE_USE_VERSION=26"
AC_CHECK_HEADERS([fuse/fuse.h], [], AC_CHECK_HEADERS([fuse/fuse.h], [],
[grub_mount_excuse=["need FUSE headers"]]) [grub_mount_excuse=["need FUSE headers"]])
CPPFLAGS="$SAVED_CPPFLAGS" CPPFLAGS="$SAVED_CPPFLAGS"
@@ -1606,8 +1763,6 @@ AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
[AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)]) [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
AC_SUBST(HAVE_ASM_USCORE) AC_SUBST(HAVE_ASM_USCORE)
AC_SUBST(ADDR32)
AC_SUBST(DATA32)
AC_SUBST(BSS_START_SYMBOL) AC_SUBST(BSS_START_SYMBOL)
AC_SUBST(END_SYMBOL) AC_SUBST(END_SYMBOL)
AC_SUBST(PACKAGE) AC_SUBST(PACKAGE)
@@ -1621,15 +1776,15 @@ if test x"$enable_werror" != xno ; then
HOST_CFLAGS="$HOST_CFLAGS -Werror" HOST_CFLAGS="$HOST_CFLAGS -Werror"
fi fi
if test "x$grub_cv_cc_target_clang" = xno; then
TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc"
else
TARGET_LDFLAGS_STATIC_LIBGCC=
fi
TARGET_CPP="$TARGET_CC -E" TARGET_CPP="$TARGET_CC -E"
TARGET_CCAS=$TARGET_CC TARGET_CCAS=$TARGET_CC
# Includes which include make-time substitutions. They must come last
# as to avoid executing top_builddir in shell.
HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
GRUB_TARGET_CPU="${target_cpu}" GRUB_TARGET_CPU="${target_cpu}"
GRUB_PLATFORM="${platform}" GRUB_PLATFORM="${platform}"
@@ -1637,8 +1792,6 @@ AC_SUBST(GRUB_TARGET_CPU)
AC_SUBST(GRUB_PLATFORM) AC_SUBST(GRUB_PLATFORM)
AC_SUBST(TARGET_OBJCONV) AC_SUBST(TARGET_OBJCONV)
AC_SUBST(TARGET_LIBGCC)
AC_SUBST(TARGET_LDFLAGS_STATIC_LIBGCC)
AC_SUBST(TARGET_CPP) AC_SUBST(TARGET_CPP)
AC_SUBST(TARGET_CCAS) AC_SUBST(TARGET_CCAS)
AC_SUBST(TARGET_OBJ2ELF) AC_SUBST(TARGET_OBJ2ELF)
@@ -1668,7 +1821,6 @@ AC_SUBST(BUILD_LIBM)
AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone]) AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone])
AM_CONDITIONAL([COND_emu], [test x$platform = xemu]) AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
AM_CONDITIONAL([COND_clang], [test x$grub_cv_cc_target_clang = xyes])
AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc]) AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi]) AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi]) AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
@@ -1703,7 +1855,6 @@ AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu])
AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos]) AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos])
AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x]) AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes]) AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes]) AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes]) AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
@@ -1781,11 +1932,6 @@ echo "*******************************************************"
echo GRUB2 will be compiled with following components: echo GRUB2 will be compiled with following components:
echo Platform: "$target_cpu"-"$platform" echo Platform: "$target_cpu"-"$platform"
if [ x"$platform" = xemu ]; then if [ x"$platform" = xemu ]; then
if [ x"$grub_emu_usb_excuse" = x ]; then
echo USB support for grub-emu: Yes
else
echo USB support for grub-emu: No "($grub_emu_usb_excuse)"
fi
if [ x"$grub_emu_sdl_excuse" = x ]; then if [ x"$grub_emu_sdl_excuse" = x ]; then
echo SDL support for grub-emu: Yes echo SDL support for grub-emu: Yes
else else
+10 -6
View File
@@ -5162,8 +5162,10 @@ by @var{shortname} which can be used to remove it (@pxref{net_del_route}).
Perform configuration of @var{card} using DHCP protocol. If no card name Perform configuration of @var{card} using DHCP protocol. If no card name
is specified, try to configure all existing cards. If configuration was is specified, try to configure all existing cards. If configuration was
successful, interface with name @var{card}@samp{:dhcp} and configured successful, interface with name @var{card}@samp{:dhcp} and configured
address is added to @var{card}. If server provided gateway information in address is added to @var{card}.
DHCP ACK packet, it is added as route entry with the name @var{card}@samp{:dhcp:gw}. Additionally the following DHCP options are recognized and processed: @comment If server provided gateway information in
@comment DHCP ACK packet, it is added as route entry with the name @var{card}@samp{:dhcp:gw}.
Additionally the following DHCP options are recognized and processed:
@table @samp @table @samp
@item 1 (Subnet Mask) @item 1 (Subnet Mask)
@@ -5426,10 +5428,12 @@ In order to enable authentication support, the @samp{superusers} environment
variable must be set to a list of usernames, separated by any of spaces, variable must be set to a list of usernames, separated by any of spaces,
commas, semicolons, pipes, or ampersands. Superusers are permitted to use commas, semicolons, pipes, or ampersands. Superusers are permitted to use
the GRUB command line, edit menu entries, and execute any menu entry. If the GRUB command line, edit menu entries, and execute any menu entry. If
@samp{superusers} is set, then use of the command line is automatically @samp{superusers} is set, then use of the command line and editing of menu
restricted to superusers. entries are automatically restricted to superusers. Setting @samp{superusers}
to empty string effectively disables both access to CLI and editing of menu
entries.
Other users may be given access to specific menu entries by giving a list of Other users may be allowed to execute specific menu entries by giving a list of
usernames (as above) using the @option{--users} option to the usernames (as above) using the @option{--users} option to the
@samp{menuentry} command (@pxref{menuentry}). If the @option{--unrestricted} @samp{menuentry} command (@pxref{menuentry}). If the @option{--unrestricted}
option is used for a menu entry, then that entry is unrestricted. option is used for a menu entry, then that entry is unrestricted.
@@ -5848,7 +5852,7 @@ Following variables must be defined:
@multitable @columnfractions .30 .65 @multitable @columnfractions .30 .65
@item GRUB_PAYLOADS_DIR @tab directory containing the required kernels @item GRUB_PAYLOADS_DIR @tab directory containing the required kernels
@item GRUB_CBFSTOOL @tab cbfstoll from Coreboot package (for coreboot platform only) @item GRUB_CBFSTOOL @tab cbfstool from Coreboot package (for coreboot platform only)
@item GRUB_COREBOOT_ROM @tab empty Coreboot ROM @item GRUB_COREBOOT_ROM @tab empty Coreboot ROM
@item GRUB_QEMU_OPTS @tab additional options to be supplied to QEMU @item GRUB_QEMU_OPTS @tab additional options to be supplied to QEMU
@end multitable @end multitable
+24 -3
View File
@@ -76,7 +76,13 @@ for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i)
# Flattened Device Trees (FDT) # Flattened Device Trees (FDT)
GROUPS["fdt"] = [ "arm64_efi", "arm_uboot", "arm_efi" ] GROUPS["fdt"] = [ "arm64_efi", "arm_uboot", "arm_efi" ]
# Miscelaneous groups schedulded to disappear in future # Needs software helpers for division
# Must match GRUB_DIVISION_IN_SOFTWARE in misc.h
GROUPS["softdiv"] = GROUPS["arm"] + ["ia64_efi"]
GROUPS["no_softdiv"] = GRUB_PLATFORMS[:]
for i in GROUPS["softdiv"]: GROUPS["no_softdiv"].remove(i)
# Miscellaneous groups scheduled to disappear in future
GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"] GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"]
GROUPS["nopc"] = GRUB_PLATFORMS[:]; GROUPS["nopc"].remove("i386_pc") GROUPS["nopc"] = GRUB_PLATFORMS[:]; GROUPS["nopc"].remove("i386_pc")
@@ -600,7 +606,7 @@ def foreach_enabled_platform(defn, closure):
# enable = emu; # enable = emu;
# enable = i386; # enable = i386;
# enable = mips_loongson; # enable = mips_loongson;
# emu_condition = COND_GRUB_EMU_USB; # emu_condition = COND_GRUB_EMU_SDL;
# }; # };
# #
def under_platform_specific_conditionals(defn, platform, closure): def under_platform_specific_conditionals(defn, platform, closure):
@@ -753,7 +759,7 @@ def image(defn, platform):
if test x$(TARGET_APPLE_LINKER) = x1; then \ if test x$(TARGET_APPLE_LINKER) = x1; then \
$(MACHO2IMG) $< $@; \ $(MACHO2IMG) $< $@; \
else \ else \
$(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \ $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \
fi fi
""") """)
@@ -828,6 +834,20 @@ def data(defn, platform):
var_add("dist_" + installdir(defn) + "_DATA", platform_sources(defn, platform)) var_add("dist_" + installdir(defn) + "_DATA", platform_sources(defn, platform))
gvar_add("dist_noinst_DATA", extra_dist(defn)) gvar_add("dist_noinst_DATA", extra_dist(defn))
def transform_data(defn, platform):
name = defn['name']
var_add(installdir(defn) + "_DATA", name)
rule(name, "$(top_builddir)/config.status " + platform_sources(defn, platform) + platform_dependencies(defn, platform), """
(for x in """ + platform_sources(defn, platform) + """; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:-
chmod a+x """ + name + """
""")
gvar_add("CLEANFILES", name)
gvar_add("EXTRA_DIST", extra_dist(defn))
gvar_add("dist_noinst_DATA", platform_sources(defn, platform))
def script(defn, platform): def script(defn, platform):
name = defn['name'] name = defn['name']
@@ -875,6 +895,7 @@ rules("library", library)
rules("program", program) rules("program", program)
rules("script", script) rules("script", script)
rules("data", data) rules("data", data)
rules("transform_data", transform_data)
write_output(section='decl') write_output(section='decl')
write_output() write_output()
+5 -6
View File
@@ -76,6 +76,11 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i18n.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/kernel.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/kernel.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/list.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/list.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/misc.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/misc.h
if COND_emu
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt-emu.h
else
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt.h
endif
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/parser.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/parser.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/partition.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/partition.h
@@ -83,9 +88,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h
if !COND_clang
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h
endif
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h
if COND_i386_pc if COND_i386_pc
@@ -248,9 +250,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
if COND_GRUB_EMU_SDL if COND_GRUB_EMU_SDL
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h
endif endif
if COND_GRUB_EMU_USB
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libusb.h
endif
if COND_GRUB_EMU_PCI if COND_GRUB_EMU_PCI
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libpciaccess.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libpciaccess.h
endif endif
+62 -33
View File
@@ -1,43 +1,43 @@
AutoGen definitions Makefile.tpl; AutoGen definitions Makefile.tpl;
script = { transform_data = {
installdir = noinst; installdir = noinst;
name = gensyminfo.sh; name = gensyminfo.sh;
common = gensyminfo.sh.in; common = gensyminfo.sh.in;
}; };
script = { transform_data = {
installdir = noinst; installdir = noinst;
name = genmod.sh; name = genmod.sh;
common = genmod.sh.in; common = genmod.sh.in;
}; };
script = { transform_data = {
installdir = noinst; installdir = noinst;
name = modinfo.sh; name = modinfo.sh;
common = modinfo.sh.in; common = modinfo.sh.in;
}; };
script = { transform_data = {
installdir = platform; installdir = platform;
name = gmodule.pl; name = gmodule.pl;
common = gmodule.pl.in; common = gmodule.pl.in;
}; };
script = { transform_data = {
installdir = platform; installdir = platform;
name = gdb_grub; name = gdb_grub;
common = gdb_grub.in; common = gdb_grub.in;
}; };
script = { transform_data = {
installdir = platform; installdir = platform;
name = grub.chrp; name = grub.chrp;
common = boot/powerpc/grub.chrp.in; common = boot/powerpc/grub.chrp.in;
enable = powerpc_ieee1275; enable = powerpc_ieee1275;
}; };
script = { transform_data = {
installdir = platform; installdir = platform;
name = bootinfo.txt; name = bootinfo.txt;
common = boot/powerpc/bootinfo.txt.in; common = boot/powerpc/bootinfo.txt.in;
@@ -83,8 +83,6 @@ kernel = {
x86_64_xen_ldflags = '$(TARGET_IMG_LDFLAGS)'; x86_64_xen_ldflags = '$(TARGET_IMG_LDFLAGS)';
x86_64_xen_ldflags = '$(TARGET_IMG_BASE_LDOPT),0'; x86_64_xen_ldflags = '$(TARGET_IMG_BASE_LDOPT),0';
ldadd = '$(LDADD_KERNEL)';
mips_loongson_ldflags = '-Wl,-Ttext,0x80200000'; mips_loongson_ldflags = '-Wl,-Ttext,0x80200000';
powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000'; powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400'; sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
@@ -132,6 +130,7 @@ kernel = {
common = kern/rescue_reader.c; common = kern/rescue_reader.c;
common = kern/term.c; common = kern/term.c;
noemu = kern/compiler-rt.c;
noemu = kern/mm.c; noemu = kern/mm.c;
noemu = kern/time.c; noemu = kern/time.c;
noemu = kern/generic/millisleep.c; noemu = kern/generic/millisleep.c;
@@ -159,6 +158,8 @@ kernel = {
terminfoinkernel = commands/extcmd.c; terminfoinkernel = commands/extcmd.c;
terminfoinkernel = lib/arg.c; terminfoinkernel = lib/arg.c;
softdiv = lib/division.c;
i386 = kern/i386/dl.c; i386 = kern/i386/dl.c;
i386_xen = kern/i386/dl.c; i386_xen = kern/i386/dl.c;
@@ -252,6 +253,7 @@ kernel = {
powerpc_ieee1275 = kern/powerpc/cache.S; powerpc_ieee1275 = kern/powerpc/cache.S;
powerpc_ieee1275 = kern/powerpc/dl.c; powerpc_ieee1275 = kern/powerpc/dl.c;
powerpc_ieee1275 = kern/powerpc/compiler-rt.S;
sparc64_ieee1275 = kern/sparc64/cache.S; sparc64_ieee1275 = kern/sparc64/cache.S;
sparc64_ieee1275 = kern/sparc64/dl.c; sparc64_ieee1275 = kern/sparc64/dl.c;
@@ -263,7 +265,7 @@ kernel = {
arm = kern/arm/cache_armv7.S; arm = kern/arm/cache_armv7.S;
extra_dist = kern/arm/cache.S; extra_dist = kern/arm/cache.S;
arm = kern/arm/cache.c; arm = kern/arm/cache.c;
arm = kern/arm/misc.S; arm = kern/arm/compiler-rt.S;
arm64 = kern/arm64/cache.c; arm64 = kern/arm64/cache.c;
arm64 = kern/arm64/cache_flush.S; arm64 = kern/arm64/cache_flush.S;
@@ -441,13 +443,13 @@ image = {
common = lib/xzembed/xz_dec_bcj.c; common = lib/xzembed/xz_dec_bcj.c;
common = lib/xzembed/xz_dec_lzma2.c; common = lib/xzembed/xz_dec_lzma2.c;
common = lib/xzembed/xz_dec_stream.c; common = lib/xzembed/xz_dec_stream.c;
common = kern/compiler-rt.c;
cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1'; cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1';
objcopyflags = '-O binary'; objcopyflags = '-O binary';
mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)'; mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
ldadd = '$(TARGET_LIBGCC)'; cflags = '-Wno-unreachable-code';
cflags = '-Wno-unreachable-code $(TARGET_LDFLAGS_STATIC_LIBGCC)';
enable = mips; enable = mips;
}; };
@@ -459,9 +461,7 @@ image = {
cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1'; cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1';
objcopyflags = '-O binary'; objcopyflags = '-O binary';
mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)'; mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)';
ldadd = '$(TARGET_LIBGCC)';
cflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC)';
enable = mips; enable = mips;
}; };
@@ -479,7 +479,7 @@ image = {
name = fwstart; name = fwstart;
mips_loongson = boot/mips/loongson/fwstart.S; mips_loongson = boot/mips/loongson/fwstart.S;
objcopyflags = '-O binary'; objcopyflags = '-O binary';
ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
enable = mips_loongson; enable = mips_loongson;
}; };
@@ -487,7 +487,7 @@ image = {
name = fwstart_fuloong2f; name = fwstart_fuloong2f;
mips_loongson = boot/mips/loongson/fuloong2f.S; mips_loongson = boot/mips/loongson/fuloong2f.S;
objcopyflags = '-O binary'; objcopyflags = '-O binary';
ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic';
enable = mips_loongson; enable = mips_loongson;
}; };
@@ -509,13 +509,6 @@ module = {
enable = x86; enable = x86;
}; };
module = {
name = libusb;
emu = bus/usb/emu/usb.c;
enable = emu;
condition = COND_GRUB_EMU_USB;
};
module = { module = {
name = lsspd; name = lsspd;
mips_loongson = commands/mips/loongson/lsspd.c; mips_loongson = commands/mips/loongson/lsspd.c;
@@ -530,13 +523,6 @@ module = {
enable = usb; enable = usb;
}; };
module = {
name = emuusb;
common = bus/usb/usb.c;
enable = emu;
condition = COND_GRUB_EMU_USB;
};
module = { module = {
name = usbserial_common; name = usbserial_common;
common = bus/usb/serial/common.c; common = bus/usb/serial/common.c;
@@ -1462,7 +1448,6 @@ module = {
module = { module = {
name = gfxmenu; name = gfxmenu;
common = gfxmenu/gfxmenu.c; common = gfxmenu/gfxmenu.c;
common = gfxmenu/model.c;
common = gfxmenu/view.c; common = gfxmenu/view.c;
common = gfxmenu/font.c; common = gfxmenu/font.c;
common = gfxmenu/icon_manager.c; common = gfxmenu/icon_manager.c;
@@ -1661,6 +1646,13 @@ module = {
enable = x86; enable = x86;
}; };
module = {
name = xen_boot;
common = lib/cmdline.c;
arm64 = loader/arm64/xen_boot.c;
enable = arm64;
};
module = { module = {
name = linux; name = linux;
x86 = loader/i386/linux.c; x86 = loader/i386/linux.c;
@@ -1679,6 +1671,12 @@ module = {
enable = noemu; enable = noemu;
}; };
module = {
name = fdt;
arm64 = loader/arm64/fdt.c;
enable = arm64;
};
module = { module = {
name = xnu; name = xnu;
x86 = loader/xnu_resume.c; x86 = loader/xnu_resume.c;
@@ -1969,11 +1967,42 @@ module = {
enable = xen; enable = xen;
}; };
module = {
name = div;
common = lib/division.c;
enable = no_softdiv;
};
module = { module = {
name = div_test; name = div_test;
common = tests/div_test.c; common = tests/div_test.c;
}; };
module = {
name = mul_test;
common = tests/mul_test.c;
};
module = {
name = shift_test;
common = tests/shift_test.c;
};
module = {
name = cmp_test;
common = tests/cmp_test.c;
};
module = {
name = ctz_test;
common = tests/ctz_test.c;
};
module = {
name = bswap_test;
common = tests/bswap_test.c;
};
module = { module = {
name = videotest_checksum; name = videotest_checksum;
common = tests/videotest_checksum.c; common = tests/videotest_checksum.c;
+1 -10
View File
@@ -21,7 +21,7 @@
#include <grub/decompressor.h> #include <grub/decompressor.h>
void * void *
memset (void *s, int c, grub_size_t len) grub_memset (void *s, int c, grub_size_t len)
{ {
grub_uint8_t *ptr; grub_uint8_t *ptr;
for (ptr = s; len; ptr++, len--) for (ptr = s; len; ptr++, len--)
@@ -68,15 +68,6 @@ grub_memcmp (const void *s1, const void *s2, grub_size_t n)
return 0; return 0;
} }
int memcmp (const void *s1, const void *s2, grub_size_t n)
__attribute__ ((alias ("grub_memcmp")));
void *memmove (void *dest, const void *src, grub_size_t n)
__attribute__ ((alias ("grub_memmove")));
void *memcpy (void *dest, const void *src, grub_size_t n)
__attribute__ ((alias ("grub_memmove")));
void *grub_decompressor_scratch; void *grub_decompressor_scratch;
void void
+21 -21
View File
@@ -165,8 +165,8 @@ start:
* this area. * this area.
*/ */
. = _start + GRUB_BOOT_MACHINE_BPB_START .org GRUB_BOOT_MACHINE_BPB_START
. = _start + 4 .org 4
#endif #endif
#ifdef HYBRID_BOOT #ifdef HYBRID_BOOT
floppy floppy
@@ -174,23 +174,23 @@ start:
scratch scratch
#endif #endif
. = _start + GRUB_BOOT_MACHINE_BPB_END .org GRUB_BOOT_MACHINE_BPB_END
/* /*
* End of BIOS parameter block. * End of BIOS parameter block.
*/ */
kernel_address: LOCAL(kernel_address):
.word GRUB_BOOT_MACHINE_KERNEL_ADDR .word GRUB_BOOT_MACHINE_KERNEL_ADDR
#ifndef HYBRID_BOOT #ifndef HYBRID_BOOT
. = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR .org GRUB_BOOT_MACHINE_KERNEL_SECTOR
kernel_sector: LOCAL(kernel_sector):
.long 1 .long 1
kernel_sector_high: LOCAL(kernel_sector_high):
.long 0 .long 0
#endif #endif
. = _start + GRUB_BOOT_MACHINE_BOOT_DRIVE .org GRUB_BOOT_MACHINE_BOOT_DRIVE
boot_drive: boot_drive:
.byte 0xff /* the disk to load kernel from */ .byte 0xff /* the disk to load kernel from */
/* 0xff means use the boot drive */ /* 0xff means use the boot drive */
@@ -208,7 +208,7 @@ LOCAL(after_BPB):
* possible boot drive. If GRUB is installed into a floppy, * possible boot drive. If GRUB is installed into a floppy,
* this does nothing (only jump). * this does nothing (only jump).
*/ */
. = _start + GRUB_BOOT_MACHINE_DRIVE_CHECK .org GRUB_BOOT_MACHINE_DRIVE_CHECK
boot_drive_check: boot_drive_check:
jmp 3f /* grub-setup may overwrite this jump */ jmp 3f /* grub-setup may overwrite this jump */
testb $0x80, %dl testb $0x80, %dl
@@ -275,7 +275,7 @@ real_start:
andw $1, %cx andw $1, %cx
jz LOCAL(chs_mode) jz LOCAL(chs_mode)
lba_mode: LOCAL(lba_mode):
xorw %ax, %ax xorw %ax, %ax
movw %ax, 4(%si) movw %ax, 4(%si)
@@ -290,9 +290,9 @@ lba_mode:
movw $0x0010, (%si) movw $0x0010, (%si)
/* the absolute address */ /* the absolute address */
movl kernel_sector, %ebx movl LOCAL(kernel_sector), %ebx
movl %ebx, 8(%si) movl %ebx, 8(%si)
movl kernel_sector_high, %ebx movl LOCAL(kernel_sector_high), %ebx
movl %ebx, 12(%si) movl %ebx, 12(%si)
/* the segment of buffer address */ /* the segment of buffer address */
@@ -361,13 +361,13 @@ LOCAL(final_init):
setup_sectors: setup_sectors:
/* load logical sector start (top half) */ /* load logical sector start (top half) */
movl kernel_sector_high, %eax movl LOCAL(kernel_sector_high), %eax
orl %eax, %eax orl %eax, %eax
jnz LOCAL(geometry_error) jnz LOCAL(geometry_error)
/* load logical sector start (bottom half) */ /* load logical sector start (bottom half) */
movl kernel_sector, %eax movl LOCAL(kernel_sector), %eax
/* zero %edx */ /* zero %edx */
xorl %edx, %edx xorl %edx, %edx
@@ -452,7 +452,7 @@ LOCAL(copy_buffer):
popa popa
/* boot kernel */ /* boot kernel */
jmp *(kernel_address) jmp *(LOCAL(kernel_address))
/* END OF MAIN LOOP */ /* END OF MAIN LOOP */
@@ -511,13 +511,13 @@ LOCAL(message):
*/ */
#ifdef HYBRID_BOOT #ifdef HYBRID_BOOT
. = _start + 0x1b0 .org 0x1b0
kernel_sector: LOCAL(kernel_sector):
.long 1 .long 1
kernel_sector_high: LOCAL(kernel_sector_high):
.long 0 .long 0
#endif #endif
. = _start + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC .org GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC
nt_magic: nt_magic:
.long 0 .long 0
.word 0 .word 0
@@ -528,7 +528,7 @@ nt_magic:
* sneaky, huh? * sneaky, huh?
*/ */
. = _start + GRUB_BOOT_MACHINE_PART_START .org GRUB_BOOT_MACHINE_PART_START
#ifndef HYBRID_BOOT #ifndef HYBRID_BOOT
floppy floppy
@@ -536,7 +536,7 @@ nt_magic:
scratch scratch
#endif #endif
. = _start + GRUB_BOOT_MACHINE_PART_END .org GRUB_BOOT_MACHINE_PART_END
/* the last 2 bytes in the sector 0 contain the signature */ /* the last 2 bytes in the sector 0 contain the signature */
.word GRUB_BOOT_MACHINE_SIGNATURE .word GRUB_BOOT_MACHINE_SIGNATURE
+2 -2
View File
@@ -43,7 +43,7 @@ _start:
LOCAL(next): LOCAL(next):
jmp 1f jmp 1f
. = start + 8 .org 8
bi_pvd: bi_pvd:
.long 0 /* LBA of primary volume descriptor. */ .long 0 /* LBA of primary volume descriptor. */
@@ -168,6 +168,6 @@ err_noboot_msg:
err_cdfail_msg: err_cdfail_msg:
.ascii "cdrom read fails\0" .ascii "cdrom read fails\0"
. = start + 0x7FF .org 0x7FF
.byte 0 .byte 0
+1 -1
View File
@@ -362,7 +362,7 @@ LOCAL(message):
.word 0 .word 0
.word 0 .word 0
. = _start + 0x200 - GRUB_BOOT_MACHINE_LIST_SIZE .org 0x200 - GRUB_BOOT_MACHINE_LIST_SIZE
LOCAL(firstlist): /* this label has to be before the first list entry!!! */ LOCAL(firstlist): /* this label has to be before the first list entry!!! */
/* fill the first data listing with the default */ /* fill the first data listing with the default */
blocklist_default_start: blocklist_default_start:
+2 -2
View File
@@ -41,7 +41,7 @@ data_start:
xorl %ebp, %ebp xorl %ebp, %ebp
jmp LOCAL(linux_next) jmp LOCAL(linux_next)
. = data_start + 0x1F1 .org 0x1F1
setup_sects: setup_sects:
.byte CODE_SECTORS .byte CODE_SECTORS
@@ -292,4 +292,4 @@ LOCAL(fail):
err_int15_msg: err_int15_msg:
.ascii "move memory fails\0" .ascii "move memory fails\0"
. = _start + CODE_SECTORS * 512 .org (CODE_SECTORS * 512 + 512)
+1 -1
View File
@@ -38,5 +38,5 @@ start:
/* This region is a junk. Do you say that this is wasteful? /* This region is a junk. Do you say that this is wasteful?
But I like that the memory layout of the body is consistent But I like that the memory layout of the body is consistent
among different kernels rather than scamping just for 1.5KB. */ among different kernels rather than scamping just for 1.5KB. */
. = _start + 0x8200 - 0x7C00 - 0x200 - 1 .org 0x8200 - 0x7C00 - 0x200 - 1
.byte 0 .byte 0
+8 -8
View File
@@ -50,23 +50,23 @@ LOCAL (base):
* This is a special data area. * This is a special data area.
*/ */
. = _start + GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE .org GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
LOCAL(compressed_size): LOCAL(compressed_size):
.long 0 .long 0
. = _start + GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE .org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
LOCAL(uncompressed_size): LOCAL(uncompressed_size):
.long 0 .long 0
. = _start + GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY .org GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY
reed_solomon_redundancy: reed_solomon_redundancy:
.long 0 .long 0
. = _start + GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH .org GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH
.short (LOCAL(reed_solomon_part) - _start) .short (LOCAL(reed_solomon_part) - _start)
/* /*
* This is the area for all of the special variables. * This is the area for all of the special variables.
*/ */
. = _start + GRUB_DECOMPRESSOR_I386_PC_BOOT_DEVICE .org GRUB_DECOMPRESSOR_I386_PC_BOOT_DEVICE
LOCAL(boot_dev): LOCAL(boot_dev):
.byte 0xFF, 0xFF, 0xFF .byte 0xFF, 0xFF, 0xFF
LOCAL(boot_drive): LOCAL(boot_drive):
@@ -89,13 +89,13 @@ LOCAL (codestart):
sti /* we're safe again */ sti /* we're safe again */
/* save the boot drive */ /* save the boot drive */
ADDR32 movb %dl, LOCAL(boot_drive) movb %dl, LOCAL(boot_drive)
/* reset disk system (%ah = 0) */ /* reset disk system (%ah = 0) */
int $0x13 int $0x13
/* transition to protected mode */ /* transition to protected mode */
DATA32 call real_to_prot calll real_to_prot
/* The ".code32" directive takes GAS out of 16-bit mode. */ /* The ".code32" directive takes GAS out of 16-bit mode. */
.code32 .code32
@@ -149,7 +149,7 @@ gate_a20_try_bios:
movw $0x2401, %ax movw $0x2401, %ax
int $0x15 int $0x15
DATA32 call real_to_prot calll real_to_prot
.code32 .code32
popl %ebp popl %ebp
+5 -5
View File
@@ -31,7 +31,7 @@ _start:
jmp 1f jmp 1f
. = _start + GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR .org GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR
VARIABLE(grub_core_entry_addr) VARIABLE(grub_core_entry_addr)
.long 0 .long 0
1: 1:
@@ -48,8 +48,9 @@ VARIABLE(grub_core_entry_addr)
/* Transition to protected mode. We use pushl to force generation /* Transition to protected mode. We use pushl to force generation
of a flat return address. */ of a flat return address. */
pushl $1f pushl $1f
DATA32 jmp real_to_prot jmp real_to_prot
.code32 .code32
1:
/* Ensure A20 is enabled. We're in qemu, so control port A works /* Ensure A20 is enabled. We're in qemu, so control port A works
and there is no need to wait since there is no real logic, it's and there is no need to wait since there is no real logic, it's
all emulated. */ all emulated. */
@@ -57,7 +58,6 @@ VARIABLE(grub_core_entry_addr)
andb $(~0x03), %al andb $(~0x03), %al
orb $0x02, %al orb $0x02, %al
outb $0x92 outb $0x92
1:
movl EXT_C(grub_core_entry_addr), %edx movl EXT_C(grub_core_entry_addr), %edx
jmp *%edx jmp *%edx
@@ -66,9 +66,9 @@ VARIABLE(grub_core_entry_addr)
/* Intel, in its infinite wisdom, decided to put the i8086 entry point /* Intel, in its infinite wisdom, decided to put the i8086 entry point
*right here* and this is why we need this kludge. */ *right here* and this is why we need this kludge. */
. = GRUB_BOOT_MACHINE_SIZE - 16 .org GRUB_BOOT_MACHINE_SIZE - 16
.code16 .code16
jmp _start jmp _start
. = GRUB_BOOT_MACHINE_SIZE .org GRUB_BOOT_MACHINE_SIZE
+6 -6
View File
@@ -162,7 +162,7 @@ retry_cs5536:
b continue b continue
. = start + GRUB_CPU_LOONGSON_FLASH_TLB_REFILL - GRUB_CPU_LOONGSON_FLASH_START .org GRUB_CPU_LOONGSON_FLASH_TLB_REFILL - GRUB_CPU_LOONGSON_FLASH_START
tlb_refill: tlb_refill:
mfc0 $s1, GRUB_CPU_LOONGSON_COP0_EPC mfc0 $s1, GRUB_CPU_LOONGSON_COP0_EPC
mfc0 $s2, GRUB_CPU_LOONGSON_COP0_BADVADDR mfc0 $s2, GRUB_CPU_LOONGSON_COP0_BADVADDR
@@ -196,13 +196,13 @@ tlb_refill:
b fatal b fatal
addiu $a0, $a0, %lo(unhandled_tlb_refill) addiu $a0, $a0, %lo(unhandled_tlb_refill)
. = start + GRUB_CPU_LOONGSON_FLASH_CACHE_ERROR - GRUB_CPU_LOONGSON_FLASH_START .org GRUB_CPU_LOONGSON_FLASH_CACHE_ERROR - GRUB_CPU_LOONGSON_FLASH_START
cache_error: cache_error:
lui $a0, %hi(unhandled_cache_error) lui $a0, %hi(unhandled_cache_error)
b fatal b fatal
addiu $a0, $a0, %lo(unhandled_cache_error) addiu $a0, $a0, %lo(unhandled_cache_error)
. = start + GRUB_CPU_LOONGSON_FLASH_OTHER_EXCEPTION - GRUB_CPU_LOONGSON_FLASH_START .org GRUB_CPU_LOONGSON_FLASH_OTHER_EXCEPTION - GRUB_CPU_LOONGSON_FLASH_START
other_exception: other_exception:
mfc0 $s0, GRUB_CPU_LOONGSON_COP0_CAUSE mfc0 $s0, GRUB_CPU_LOONGSON_COP0_CAUSE
mfc0 $s1, GRUB_CPU_LOONGSON_COP0_EPC mfc0 $s1, GRUB_CPU_LOONGSON_COP0_EPC
@@ -344,7 +344,7 @@ printhex:
nop nop
srl $t1, $a0, 28 srl $t1, $a0, 28
addiu $t1, $t1, -10 addiu $t1, $t1, -10
blt $t1, $zero, 2f bltz $t1, 2f
sll $a0, $a0, 4 sll $a0, $a0, 4
addiu $t1, $t1, 'A'-10-'0' addiu $t1, $t1, 'A'-10-'0'
2: addiu $t1, $t1, '0'+10 2: addiu $t1, $t1, '0'+10
@@ -398,7 +398,7 @@ read_spd:
move $t2, $a0 move $t2, $a0
move $t3, $ra move $t3, $ra
lui $a0, %hi(read_spd_fail) lui $a0, %hi(read_spd_fail)
addiu $a0, $a0, %hi(read_spd_fail) addiu $a0, $a0, %lo(read_spd_fail)
/* Send START. */ /* Send START. */
lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F)
@@ -547,7 +547,7 @@ gpio_dump:
#endif #endif
gpio_dump_end: gpio_dump_end:
.p2align .p2align 3
write_dumpreg: write_dumpreg:
ld $t2, 0($t6) ld $t2, 0($t6)
+34 -33
View File
@@ -22,6 +22,7 @@
#include <grub/machine/memory.h> #include <grub/machine/memory.h>
#include <grub/machine/kernel.h> #include <grub/machine/kernel.h>
#include <grub/offsets.h> #include <grub/offsets.h>
#include <grub/mips/asm.h>
#define BASE_ADDR 8 #define BASE_ADDR 8
@@ -39,13 +40,13 @@ start:
bal codestart bal codestart
nop nop
base: base:
. = _start + GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE .org GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE
compressed_size: compressed_size:
.long 0 .long 0
. = _start + GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE .org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE
uncompressed_size: uncompressed_size:
.long 0 .long 0
. = _start + GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR .org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR
uncompressed_addr: uncompressed_addr:
.long 0 .long 0
codestart: codestart:
@@ -118,50 +119,50 @@ parsestr:
move $v0, $zero move $v0, $zero
move $t3, $t1 move $t3, $t1
3: 3:
lb $t4, 0($t2) lb GRUB_ASM_T4, 0($t2)
lb $t5, 0($t3) lb GRUB_ASM_T5, 0($t3)
addiu $t2, $t2, 1 addiu $t2, $t2, 1
addiu $t3, $t3, 1 addiu $t3, $t3, 1
beq $t5, $zero, 1f beq GRUB_ASM_T5, $zero, 1f
nop nop
beq $t5, $t4, 3b beq GRUB_ASM_T5, GRUB_ASM_T4, 3b
nop nop
bne $t4, $zero, 1f bne GRUB_ASM_T4, $zero, 1f
nop nop
addiu $t3, $t3, 0xffff addiu $t3, $t3, 0xffff
digcont: digcont:
lb $t5, 0($t3) lb GRUB_ASM_T5, 0($t3)
/* Substract '0' from digit. */ /* Substract '0' from digit. */
addiu $t5, $t5, 0xffd0 addiu GRUB_ASM_T5, GRUB_ASM_T5, 0xffd0
bltz $t5, 1f bltz GRUB_ASM_T5, 1f
nop nop
addiu $t4, $t5, 0xfff7 addiu GRUB_ASM_T4, GRUB_ASM_T5, 0xfff7
bgtz $t4, 1f bgtz GRUB_ASM_T4, 1f
nop nop
/* Multiply $v0 by 10 with bitshifts. */ /* Multiply $v0 by 10 with bitshifts. */
sll $v0, $v0, 1 sll $v0, $v0, 1
sll $t4, $v0, 2 sll GRUB_ASM_T4, $v0, 2
addu $v0, $v0, $t4 addu $v0, $v0, GRUB_ASM_T4
addu $v0, $v0, $t5 addu $v0, $v0, GRUB_ASM_T5
addiu $t3, $t3, 1 addiu $t3, $t3, 1
b digcont b digcont
nop nop
1: 1:
jr $ra jr $ra
nop nop
busclockstr: .asciiz "busclock=" busclockstr: .asciz "busclock="
cpuclockstr: .asciiz "cpuclock=" cpuclockstr: .asciz "cpuclock="
memsizestr: .asciiz "memsize=" memsizestr: .asciz "memsize="
highmemsizestr: .asciiz "highmemsize=" highmemsizestr: .asciz "highmemsize="
machtype_yeeloong_str1: .asciiz "machtype=8.9" machtype_yeeloong_str1: .asciz "machtype=8.9"
machtype_yeeloong_str2: .asciiz "machtype=lemote-yeeloong-" machtype_yeeloong_str2: .asciz "machtype=lemote-yeeloong-"
machtype_fuloong2f_str: .asciiz "machtype=lemote-fuloong-2f" machtype_fuloong2f_str: .asciz "machtype=lemote-fuloong-2f"
machtype_fuloong2e_str: .asciiz "machtype=lemote-fuloong-2e" machtype_fuloong2e_str: .asciz "machtype=lemote-fuloong-2e"
pmon_yeeloong_str: .asciiz "PMON_VER=LM8" pmon_yeeloong_str: .asciz "PMON_VER=LM8"
pmon_fuloong2f_str: .asciiz "PMON_VER=LM6" pmon_fuloong2f_str: .asciz "PMON_VER=LM6"
pmon_yeeloong_verstr: .asciiz "Version=LM8" pmon_yeeloong_verstr: .asciz "Version=LM8"
pmon_fuloong2f_verstr: .asciiz "Version=LM6" pmon_fuloong2f_verstr: .asciz "Version=LM6"
.p2align 2 .p2align 2
argdone: argdone:
@@ -182,10 +183,10 @@ argdone:
b argdone b argdone
addiu $a1, $a1, 4 addiu $a1, $a1, 4
do_check: do_check:
lb $t4, 0($t7) lb GRUB_ASM_T4, 0($t7)
beq $t4, $zero, 1f beq GRUB_ASM_T4, $zero, 1f
lb $t3, 0($t6) lb $t3, 0($t6)
bne $t3, $t4, 2f bne $t3, GRUB_ASM_T4, 2f
addiu $t6, $t6, 1 addiu $t6, $t6, 1
b do_check b do_check
addiu $t7, $t7, 1 addiu $t7, $t7, 1
@@ -222,8 +223,8 @@ cmdlinedone:
1: 1:
beq $t1, $t3, 2f beq $t1, $t3, 2f
lb $t4, 0($t2) lb GRUB_ASM_T4, 0($t2)
sb $t4, 0($t1) sb GRUB_ASM_T4, 0($t1)
addiu $t1, $t1, 1 addiu $t1, $t1, 1
b 1b b 1b
addiu $t2, $t2, 1 addiu $t2, $t2, 1
+4 -4
View File
@@ -41,9 +41,9 @@ pic_base:
* After loading in that block we will execute it by jumping to the * After loading in that block we will execute it by jumping to the
* load address plus the size of the prepended A.OUT header (32 bytes). * load address plus the size of the prepended A.OUT header (32 bytes).
*/ */
. = _start + GRUB_BOOT_MACHINE_BOOT_DEVPATH .org GRUB_BOOT_MACHINE_BOOT_DEVPATH
boot_path: boot_path:
. = _start + GRUB_BOOT_MACHINE_KERNEL_BYTE .org GRUB_BOOT_MACHINE_KERNEL_BYTE
boot_path_end: boot_path_end:
kernel_byte: .xword (2 << 9) kernel_byte: .xword (2 << 9)
kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
@@ -52,7 +52,7 @@ kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
#define boot_path_end (_start + 1024) #define boot_path_end (_start + 1024)
#include <grub/offsets.h> #include <grub/offsets.h>
. = _start + 8 .org 8
kernel_byte: .xword (2 << 9) kernel_byte: .xword (2 << 9)
kernel_size: .word 512 kernel_size: .word 512
kernel_address: .word GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS kernel_address: .word GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS
@@ -224,7 +224,7 @@ bootpath_known:
#else #else
nop nop
#endif #endif
. = _start + GRUB_BOOT_MACHINE_CODE_END .org GRUB_BOOT_MACHINE_CODE_END
/* the last 4 bytes in the sector 0 contain the signature */ /* the last 4 bytes in the sector 0 contain the signature */
.word GRUB_BOOT_MACHINE_SIGNATURE .word GRUB_BOOT_MACHINE_SIGNATURE
+1 -1
View File
@@ -136,7 +136,7 @@ lastlist:
.word 0 .word 0
.word 0 .word 0
. = _start + (0x200 - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE) .org (0x200 - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE)
blocklist_default_start: blocklist_default_start:
.word 0 .word 0
.word 2 .word 2
+4 -3
View File
@@ -55,7 +55,8 @@ grub_pci_device_map_range (grub_pci_device_t dev, grub_addr_t base,
int err; int err;
err = pci_device_map_range (dev, base, size, PCI_DEV_MAP_FLAG_WRITABLE, &addr); err = pci_device_map_range (dev, base, size, PCI_DEV_MAP_FLAG_WRITABLE, &addr);
if (err) if (err)
grub_util_error ("mapping 0x%x failed (error %d)\n", base, err); grub_util_error ("mapping 0x%llx failed (error %d)",
(unsigned long long) base, err);
return addr; return addr;
} }
@@ -66,12 +67,12 @@ grub_pci_device_unmap_range (grub_pci_device_t dev, void *mem,
pci_device_unmap_range (dev, mem, size); pci_device_unmap_range (dev, mem, size);
} }
GRUB_MOD_INIT (pci) GRUB_MOD_INIT (emupci)
{ {
pci_system_init (); pci_system_init ();
} }
GRUB_MOD_FINI (pci) GRUB_MOD_FINI (emupci)
{ {
pci_system_cleanup (); pci_system_cleanup ();
} }
-203
View File
@@ -1,203 +0,0 @@
/* usb.c -- libusb USB support for GRUB. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <usb.h>
#include <grub/usb.h>
#include <grub/dl.h>
GRUB_MOD_LICENSE ("GPLv3+");
static struct grub_usb_controller_dev usb_controller =
{
.name = "libusb"
};
static struct grub_usb_device *grub_usb_devs[128];
struct usb_bus *busses;
static grub_err_t
grub_libusb_devices (void)
{
struct usb_bus *bus;
int last = 0;
busses = usb_get_busses();
for (bus = busses; bus; bus = bus->next)
{
struct usb_device *usbdev;
struct grub_usb_device *dev;
for (usbdev = bus->devices; usbdev; usbdev = usbdev->next)
{
struct usb_device_descriptor *desc = &usbdev->descriptor;
grub_err_t err;
if (! desc->bcdUSB)
continue;
dev = grub_malloc (sizeof (*dev));
if (! dev)
return grub_errno;
dev->data = usbdev;
/* Fill in all descriptors. */
err = grub_usb_device_initialize (dev);
if (err)
{
grub_errno = GRUB_ERR_NONE;
continue;
}
/* Register the device. */
grub_usb_devs[last++] = dev;
}
}
return GRUB_USB_ERR_NONE;
}
void
grub_usb_poll_devices (void)
{
/* TODO: recheck grub_usb_devs */
}
int
grub_usb_iterate (grub_usb_iterate_hook_t hook, void *hook_data)
{
int i;
for (i = 0; i < 128; i++)
{
if (grub_usb_devs[i])
{
if (hook (grub_usb_devs[i], hook_data))
return 1;
}
}
return 0;
}
grub_usb_err_t
grub_usb_root_hub (grub_usb_controller_t controller __attribute__((unused)))
{
return GRUB_USB_ERR_NONE;
}
grub_usb_err_t
grub_usb_control_msg (grub_usb_device_t dev, grub_uint8_t reqtype,
grub_uint8_t request, grub_uint16_t value,
grub_uint16_t idx, grub_size_t size, char *data)
{
usb_dev_handle *devh;
struct usb_device *d = dev->data;
devh = usb_open (d);
if (usb_control_msg (devh, reqtype, request,
value, idx, data, size, 20) < 0)
{
usb_close (devh);
return GRUB_USB_ERR_STALL;
}
usb_close (devh);
return GRUB_USB_ERR_NONE;
}
grub_usb_err_t
grub_usb_bulk_read (grub_usb_device_t dev,
int endpoint, grub_size_t size, char *data)
{
usb_dev_handle *devh;
struct usb_device *d = dev->data;
devh = usb_open (d);
if (usb_claim_interface (devh, 0) < 1)
{
usb_close (devh);
return GRUB_USB_ERR_STALL;
}
if (usb_bulk_read (devh, endpoint, data, size, 20) < 1)
{
usb_close (devh);
return GRUB_USB_ERR_STALL;
}
usb_release_interface (devh, 0);
usb_close (devh);
return GRUB_USB_ERR_NONE;
}
grub_usb_err_t
grub_usb_bulk_write (grub_usb_device_t dev,
int endpoint, grub_size_t size, char *data)
{
usb_dev_handle *devh;
struct usb_device *d = dev->data;
devh = usb_open (d);
if (usb_claim_interface (devh, 0) < 0)
goto fail;
if (usb_bulk_write (devh, endpoint, data, size, 20) < 0)
goto fail;
if (usb_release_interface (devh, 0) < 0)
goto fail;
usb_close (devh);
return GRUB_USB_ERR_NONE;
fail:
usb_close (devh);
return GRUB_USB_ERR_STALL;
}
GRUB_MOD_INIT (libusb)
{
usb_init();
usb_find_busses();
usb_find_devices();
if (grub_libusb_devices ())
return;
grub_usb_controller_dev_register (&usb_controller);
return;
}
GRUB_MOD_FINI (libusb)
{
return;
}
+4 -1
View File
@@ -750,7 +750,10 @@ grub_ohci_setup_transfer (grub_usb_controller_t dev,
{ {
cdata->td_head_virt = grub_ohci_alloc_td (o); cdata->td_head_virt = grub_ohci_alloc_td (o);
if (!cdata->td_head_virt) if (!cdata->td_head_virt)
return GRUB_USB_ERR_INTERNAL; /* We don't need de-allocate ED */ {
grub_free (cdata);
return GRUB_USB_ERR_INTERNAL; /* We don't need de-allocate ED */
}
/* We can set td_head only when ED is not active, i.e. /* We can set td_head only when ED is not active, i.e.
* when it is newly allocated. */ * when it is newly allocated. */
cdata->ed_virt->td_head cdata->ed_virt->td_head
+1 -3
View File
@@ -625,9 +625,7 @@ grub_uhci_check_transfer (grub_usb_controller_t dev,
return GRUB_USB_ERR_NONE; return GRUB_USB_ERR_NONE;
} }
grub_dprintf ("uhci", "t status=0x%02x\n", errtd->ctrl_status); if (errtd && !(errtd->ctrl_status & (1 << 23)))
if (!(errtd->ctrl_status & (1 << 23)))
{ {
grub_usb_err_t err = GRUB_USB_ERR_NONE; grub_usb_err_t err = GRUB_USB_ERR_NONE;
+1 -1
View File
@@ -311,8 +311,8 @@ grub_usb_bulk_finish_readwrite (grub_usb_transfer_t transfer)
transfer->size + 1); transfer->size + 1);
grub_free (transfer->transactions); grub_free (transfer->transactions);
grub_free (transfer);
grub_dma_free (transfer->data_chunk); grub_dma_free (transfer->data_chunk);
grub_free (transfer);
} }
static grub_usb_err_t static grub_usb_err_t
+10 -5
View File
@@ -131,6 +131,8 @@ grub_acpi_get_rsdpv1 (void)
return grub_machine_acpi_get_rsdpv1 (); return grub_machine_acpi_get_rsdpv1 ();
} }
#if defined (__i386__) || defined (__x86_64__)
static inline int static inline int
iszero (grub_uint8_t *reg, int size) iszero (grub_uint8_t *reg, int size)
{ {
@@ -141,7 +143,6 @@ iszero (grub_uint8_t *reg, int size)
return 1; return 1;
} }
#if defined (__i386__) || defined (__x86_64__)
/* Context for grub_acpi_create_ebda. */ /* Context for grub_acpi_create_ebda. */
struct grub_acpi_create_ebda_ctx { struct grub_acpi_create_ebda_ctx {
int ebda_len; int ebda_len;
@@ -179,8 +180,10 @@ grub_acpi_create_ebda (void)
struct grub_acpi_rsdp_v20 *v2; struct grub_acpi_rsdp_v20 *v2;
ebda = (grub_uint8_t *) (grub_addr_t) ((*((grub_uint16_t *)0x40e)) << 4); ebda = (grub_uint8_t *) (grub_addr_t) ((*((grub_uint16_t *)0x40e)) << 4);
grub_dprintf ("acpi", "EBDA @%p\n", ebda);
if (ebda) if (ebda)
ebda_kb_len = *(grub_uint16_t *) ebda; ebda_kb_len = *(grub_uint16_t *) ebda;
grub_dprintf ("acpi", "EBDA length 0x%x\n", ebda_kb_len);
if (ebda_kb_len > 16) if (ebda_kb_len > 16)
ebda_kb_len = 0; ebda_kb_len = 0;
ctx.ebda_len = (ebda_kb_len + 1) << 10; ctx.ebda_len = (ebda_kb_len + 1) << 10;
@@ -227,7 +230,7 @@ grub_acpi_create_ebda (void)
grub_dprintf ("acpi", "Copying rsdpv2 to %p\n", target); grub_dprintf ("acpi", "Copying rsdpv2 to %p\n", target);
v2inebda = target; v2inebda = target;
target += v2->length; target += v2->length;
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1); target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
v2 = 0; v2 = 0;
break; break;
} }
@@ -246,7 +249,7 @@ grub_acpi_create_ebda (void)
grub_dprintf ("acpi", "Copying rsdpv1 to %p\n", target); grub_dprintf ("acpi", "Copying rsdpv1 to %p\n", target);
v1inebda = target; v1inebda = target;
target += sizeof (struct grub_acpi_rsdp_v10); target += sizeof (struct grub_acpi_rsdp_v10);
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1); target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
v1 = 0; v1 = 0;
break; break;
} }
@@ -265,7 +268,7 @@ grub_acpi_create_ebda (void)
grub_memcpy (target, v2, v2->length); grub_memcpy (target, v2, v2->length);
v2inebda = target; v2inebda = target;
target += v2->length; target += v2->length;
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1); target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
v2 = 0; v2 = 0;
break; break;
} }
@@ -282,7 +285,7 @@ grub_acpi_create_ebda (void)
grub_memcpy (target, v1, sizeof (struct grub_acpi_rsdp_v10)); grub_memcpy (target, v1, sizeof (struct grub_acpi_rsdp_v10));
v1inebda = target; v1inebda = target;
target += sizeof (struct grub_acpi_rsdp_v10); target += sizeof (struct grub_acpi_rsdp_v10);
target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1); target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16);
v1 = 0; v1 = 0;
break; break;
} }
@@ -494,6 +497,8 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
if (! rsdp) if (! rsdp)
rsdp = grub_machine_acpi_get_rsdpv1 (); rsdp = grub_machine_acpi_get_rsdpv1 ();
grub_dprintf ("acpi", "RSDP @%p\n", rsdp);
if (rsdp) if (rsdp)
{ {
grub_uint32_t *entry_ptr; grub_uint32_t *entry_ptr;
+2
View File
@@ -23,6 +23,8 @@
#include <grub/i18n.h> #include <grub/i18n.h>
#include <grub/disk.h> #include <grub/disk.h>
GRUB_MOD_LICENSE ("GPLv3+");
static grub_err_t static grub_err_t
grub_rescue_cmd_info (struct grub_command *cmd __attribute__ ((unused)), grub_rescue_cmd_info (struct grub_command *cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)), int argc __attribute__ ((unused)),
+6 -5
View File
@@ -476,8 +476,8 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
be at least 12 bytes and aligned on a 4-byte boundary. */ be at least 12 bytes and aligned on a 4-byte boundary. */
for (header = buffer; for (header = buffer;
((char *) header <= ((char *) header <=
(char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12)) (char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12));
|| (header = 0); header += step) header += step)
{ {
if (header[0] == magic if (header[0] == magic
&& !(grub_le_to_cpu32 (header[0]) && !(grub_le_to_cpu32 (header[0])
@@ -485,11 +485,12 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
+ grub_le_to_cpu32 (header[2]) + grub_le_to_cpu32 (header[2])
+ (type == IS_MULTIBOOT2 + (type == IS_MULTIBOOT2
? grub_le_to_cpu32 (header[3]) : 0))) ? grub_le_to_cpu32 (header[3]) : 0)))
break; {
ret = 1;
break;
}
} }
if (header != 0)
ret = 1;
grub_free (buffer); grub_free (buffer);
break; break;
} }
+7 -4
View File
@@ -40,10 +40,10 @@ grub_file_check_netbsdXX (grub_elf_t elf)
return 0; return 0;
if (grub_file_seek (elf->file, elf->ehdr.ehdrXX.e_shoff) == (grub_off_t) -1) if (grub_file_seek (elf->file, elf->ehdr.ehdrXX.e_shoff) == (grub_off_t) -1)
return 0; goto fail;
if (grub_file_read (elf->file, s0, shsize) != (grub_ssize_t) shsize) if (grub_file_read (elf->file, s0, shsize) != (grub_ssize_t) shsize)
return 0; goto fail;
s = (Elf_Shdr *) ((char *) s0 + elf->ehdr.ehdrXX.e_shstrndx * shentsize); s = (Elf_Shdr *) ((char *) s0 + elf->ehdr.ehdrXX.e_shstrndx * shentsize);
stroff = s->sh_offset; stroff = s->sh_offset;
@@ -54,18 +54,21 @@ grub_file_check_netbsdXX (grub_elf_t elf)
char name[sizeof(".note.netbsd.ident")]; char name[sizeof(".note.netbsd.ident")];
grub_memset (name, 0, sizeof (name)); grub_memset (name, 0, sizeof (name));
if (grub_file_seek (elf->file, stroff + s->sh_name) == (grub_off_t) -1) if (grub_file_seek (elf->file, stroff + s->sh_name) == (grub_off_t) -1)
return grub_errno; goto fail;
if (grub_file_read (elf->file, name, sizeof (name)) != (grub_ssize_t) sizeof (name)) if (grub_file_read (elf->file, name, sizeof (name)) != (grub_ssize_t) sizeof (name))
{ {
if (grub_errno) if (grub_errno)
return grub_errno; goto fail;
continue; continue;
} }
if (grub_memcmp (name, ".note.netbsd.ident", if (grub_memcmp (name, ".note.netbsd.ident",
sizeof(".note.netbsd.ident")) != 0) sizeof(".note.netbsd.ident")) != 0)
continue; continue;
grub_free (s0);
return 1; return 1;
} }
fail:
grub_free (s0);
return 0; return 0;
} }
+2
View File
@@ -235,6 +235,8 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)),
return grub_errno; return grub_errno;
} }
grub_device_close (dev);
grub_printf_ (N_("New MBR is written to `%s'\n"), args[0]); grub_printf_ (N_("New MBR is written to `%s'\n"), args[0]);
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
+1
View File
@@ -329,6 +329,7 @@ grub_cmd_hdparm (grub_extcmd_context_t ctxt, int argc, char **args)
break; break;
} }
default: default:
grub_disk_close (disk);
return grub_error (GRUB_ERR_IO, "not an ATA device"); return grub_error (GRUB_ERR_IO, "not an ATA device");
} }
@@ -39,9 +39,17 @@ static const char *descs[] = {
[2] = "before RAM init", [2] = "before RAM init",
[3] = "after RAM init", [3] = "after RAM init",
[4] = "end of romstage", [4] = "end of romstage",
[5] = "start of verified boot",
[6] = "end of verified boot",
[8] = "start of RAM copy", [8] = "start of RAM copy",
[9] = "end of RAM copy", [9] = "end of RAM copy",
[10] = "start of ramstage", [10] = "start of ramstage",
[11] = "start of bootblock",
[12] = "end of bootblock",
[13] = "starting to load romstage",
[14] = "finished loading romstage",
[15] = "starting LZMA decompress (ignore for x86)",
[16] = "finished LZMA decompress (ignore for x86)",
[30] = "device enumerate", [30] = "device enumerate",
[40] = "device configure", [40] = "device configure",
[50] = "device enable", [50] = "device enable",
+6 -4
View File
@@ -29,14 +29,15 @@ grub_machine_acpi_get_rsdpv1 (void)
grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n"); grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4); ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4);
ebda_len = * (grub_uint16_t *) ebda; ebda_len = * (grub_uint16_t *) ebda;
if (! ebda_len) if (! ebda_len) /* FIXME do we really need this check? */
return 0; goto scan_bios;
for (ptr = ebda; ptr < ebda + 0x400; ptr += 16) for (ptr = ebda; ptr < ebda + 0x400; ptr += 16)
if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0 if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0 && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
&& ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0) && ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0)
return (struct grub_acpi_rsdp_v10 *) ptr; return (struct grub_acpi_rsdp_v10 *) ptr;
scan_bios:
grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n"); grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000; for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000;
ptr += 16) ptr += 16)
@@ -56,8 +57,8 @@ grub_machine_acpi_get_rsdpv2 (void)
grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n"); grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4); ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4);
ebda_len = * (grub_uint16_t *) ebda; ebda_len = * (grub_uint16_t *) ebda;
if (! ebda_len) if (! ebda_len) /* FIXME do we really need this check? */
return 0; goto scan_bios;
for (ptr = ebda; ptr < ebda + 0x400; ptr += 16) for (ptr = ebda; ptr < ebda + 0x400; ptr += 16)
if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0 if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0
&& grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0 && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0
@@ -67,6 +68,7 @@ grub_machine_acpi_get_rsdpv2 (void)
== 0) == 0)
return (struct grub_acpi_rsdp_v20 *) ptr; return (struct grub_acpi_rsdp_v20 *) ptr;
scan_bios:
grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n"); grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n");
for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000; for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000;
ptr += 16) ptr += 16)
+13 -2
View File
@@ -57,14 +57,20 @@ legacy_file (const char *filename)
file = grub_file_open (filename); file = grub_file_open (filename);
if (! file) if (! file)
return grub_errno; {
grub_free (suffix);
return grub_errno;
}
menu = grub_env_get_menu (); menu = grub_env_get_menu ();
if (! menu) if (! menu)
{ {
menu = grub_zalloc (sizeof (*menu)); menu = grub_zalloc (sizeof (*menu));
if (! menu) if (! menu)
return grub_errno; {
grub_free (suffix);
return grub_errno;
}
grub_env_set_menu (menu); grub_env_set_menu (menu);
} }
@@ -77,6 +83,7 @@ legacy_file (const char *filename)
if (!buf && grub_errno) if (!buf && grub_errno)
{ {
grub_file_close (file); grub_file_close (file);
grub_free (suffix);
return grub_errno; return grub_errno;
} }
@@ -173,6 +180,8 @@ legacy_file (const char *filename)
if (!args) if (!args)
{ {
grub_file_close (file); grub_file_close (file);
grub_free (suffix);
grub_free (entrysrc);
return grub_errno; return grub_errno;
} }
args[0] = entryname; args[0] = entryname;
@@ -376,6 +385,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
if (part && grub_strcmp (part->partmap->name, "msdos") == 0) if (part && grub_strcmp (part->partmap->name, "msdos") == 0)
bsd_slice = part->number; bsd_slice = part->number;
} }
if (dev)
grub_device_close (dev);
} }
/* k*BSD didn't really work well with grub-legacy. */ /* k*BSD didn't really work well with grub-legacy. */
+3 -4
View File
@@ -106,7 +106,7 @@ grub_mac_bless_inode (grub_device_t dev, grub_uint32_t inode, int is_dir,
ablk_size = grub_be_to_cpu32 (volheader.hfs.blksz); ablk_size = grub_be_to_cpu32 (volheader.hfs.blksz);
ablk_start = grub_be_to_cpu16 (volheader.hfs.first_block); ablk_start = grub_be_to_cpu16 (volheader.hfs.first_block);
embedded_offset = (ablk_start embedded_offset = (ablk_start
+ extent_start + ((grub_uint64_t) extent_start)
* (ablk_size >> GRUB_DISK_SECTOR_BITS)); * (ablk_size >> GRUB_DISK_SECTOR_BITS));
err = err =
@@ -183,7 +183,7 @@ grub_cmd_macbless (grub_command_t cmd, int argc, char **args)
{ {
char *device_name; char *device_name;
char *path = 0; char *path = 0;
grub_device_t dev; grub_device_t dev = 0;
grub_err_t err; grub_err_t err;
if (argc != 1) if (argc != 1)
@@ -197,13 +197,12 @@ grub_cmd_macbless (grub_command_t cmd, int argc, char **args)
else else
path = path + 1; path = path + 1;
if (!path || *path == 0 || !device_name) if (!path || *path == 0 || !dev)
{ {
if (dev) if (dev)
grub_device_close (dev); grub_device_close (dev);
grub_free (device_name); grub_free (device_name);
grub_free (path);
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument"); return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument");
} }
+2
View File
@@ -57,6 +57,7 @@ get_uuid (const char *name, char **uuid, int getnative)
if (!dev->disk) if (!dev->disk)
{ {
grub_dprintf ("nativedisk", "Skipping non-disk\n"); grub_dprintf ("nativedisk", "Skipping non-disk\n");
grub_device_close (dev);
return 0; return 0;
} }
@@ -90,6 +91,7 @@ get_uuid (const char *name, char **uuid, int getnative)
case GRUB_DISK_DEVICE_MEMDISK_ID: case GRUB_DISK_DEVICE_MEMDISK_ID:
grub_dprintf ("nativedisk", "Skipping native disk %s\n", grub_dprintf ("nativedisk", "Skipping native disk %s\n",
dev->disk->name); dev->disk->name);
grub_device_close (dev);
return 0; return 0;
/* FIXME: those probably need special handling. */ /* FIXME: those probably need special handling. */
+14 -3
View File
@@ -243,11 +243,19 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
} }
if (argc == 1) if (argc == 1)
return show_help (dev); {
err = show_help (dev);
grub_device_close (dev);
return err;
}
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
if (grub_strcmp (args[i], "help") == 0) if (grub_strcmp (args[i], "help") == 0)
return show_help (dev); {
err = show_help (dev);
grub_device_close (dev);
return err;
}
parsed = (int *) grub_zalloc (argc * sizeof (int)); parsed = (int *) grub_zalloc (argc * sizeof (int));
@@ -274,8 +282,11 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
break; break;
} }
if (! cur) if (! cur)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"), {
grub_device_close (dev);
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"),
args[i]); args[i]);
}
ptool = cur; ptool = cur;
pargs = (struct grub_parttool_args *) pargs = (struct grub_parttool_args *)
grub_zalloc (ptool->nargs * sizeof (struct grub_parttool_args)); grub_zalloc (ptool->nargs * sizeof (struct grub_parttool_args));
+4 -1
View File
@@ -104,7 +104,10 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)),
pass->c = grub_strtoul (ptr, &ptr, 0); pass->c = grub_strtoul (ptr, &ptr, 0);
if (grub_errno) if (grub_errno)
return grub_errno; {
grub_free (pass);
return grub_errno;
}
if (*ptr != '.') if (*ptr != '.')
{ {
grub_free (pass); grub_free (pass);
+1 -1
View File
@@ -210,10 +210,10 @@ try (struct search_ctx *ctx)
/* Cache entry was outdated. Remove it. */ /* Cache entry was outdated. Remove it. */
if (!ctx->count) if (!ctx->count)
{ {
*prev = cache_ent->next;
grub_free (cache_ent->key); grub_free (cache_ent->key);
grub_free (cache_ent->value); grub_free (cache_ent->value);
grub_free (cache_ent); grub_free (cache_ent);
*prev = cache_ent->next;
} }
} }
+7 -2
View File
@@ -175,7 +175,10 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
var = "root"; var = "root";
} }
else else
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected")); {
grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
goto out;
}
if (state[SEARCH_LABEL].set) if (state[SEARCH_LABEL].set)
grub_search_label (id, var, state[SEARCH_NO_FLOPPY].set, grub_search_label (id, var, state[SEARCH_NO_FLOPPY].set,
@@ -187,8 +190,10 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
grub_search_fs_file (id, var, state[SEARCH_NO_FLOPPY].set, grub_search_fs_file (id, var, state[SEARCH_NO_FLOPPY].set,
hints, nhints); hints, nhints);
else else
return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type"); grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type");
out:
grub_free (hints);
return grub_errno; return grub_errno;
} }
+4 -1
View File
@@ -119,7 +119,10 @@ syslinux_file (grub_extcmd_context_t ctxt, const char *filename)
{ {
menu = grub_zalloc (sizeof (*menu)); menu = grub_zalloc (sizeof (*menu));
if (! menu) if (! menu)
return grub_errno; {
grub_free (result);
return grub_errno;
}
grub_env_set_menu (menu); grub_env_set_menu (menu);
} }
+4 -4
View File
@@ -332,7 +332,7 @@ test_parse (char **args, int *argn, int argc)
get_fileinfo (args[*argn + 1], &ctx); get_fileinfo (args[*argn + 1], &ctx);
update_val (ctx.file_exists && ctx.file_info.dir, &ctx); update_val (ctx.file_exists && ctx.file_info.dir, &ctx);
(*argn) += 2; (*argn) += 2;
return ctx.or || ctx.and; continue;
} }
if (grub_strcmp (args[*argn], "-e") == 0) if (grub_strcmp (args[*argn], "-e") == 0)
@@ -340,7 +340,7 @@ test_parse (char **args, int *argn, int argc)
get_fileinfo (args[*argn + 1], &ctx); get_fileinfo (args[*argn + 1], &ctx);
update_val (ctx.file_exists, &ctx); update_val (ctx.file_exists, &ctx);
(*argn) += 2; (*argn) += 2;
return ctx.or || ctx.and; continue;
} }
if (grub_strcmp (args[*argn], "-f") == 0) if (grub_strcmp (args[*argn], "-f") == 0)
@@ -349,7 +349,7 @@ test_parse (char **args, int *argn, int argc)
/* FIXME: check for other types. */ /* FIXME: check for other types. */
update_val (ctx.file_exists && ! ctx.file_info.dir, &ctx); update_val (ctx.file_exists && ! ctx.file_info.dir, &ctx);
(*argn) += 2; (*argn) += 2;
return ctx.or || ctx.and; continue;
} }
if (grub_strcmp (args[*argn], "-s") == 0) if (grub_strcmp (args[*argn], "-s") == 0)
@@ -362,7 +362,7 @@ test_parse (char **args, int *argn, int argc)
grub_file_close (file); grub_file_close (file);
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
(*argn) += 2; (*argn) += 2;
return ctx.or || ctx.and; continue;
} }
/* String tests. */ /* String tests. */
+1 -1
View File
@@ -80,7 +80,7 @@ grub_cmd_tr (grub_extcmd_context_t ctxt, int argc, char **args)
} else if (argc > 3) } else if (argc > 3)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many parameters"); return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many parameters");
if (argc <= 0 && (!s1 || !s2 || !input)) if (!s1 || !s2 || !input)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing parameters"); return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing parameters");
if (grub_strlen (s1) != grub_strlen (s2)) if (grub_strlen (s1) != grub_strlen (s2))
+2 -2
View File
@@ -308,7 +308,7 @@ grub_load_public_key (grub_file_t f)
if (!sk) if (!sk)
goto fail; goto fail;
grub_memset (fingerprint_context, 0, sizeof (fingerprint_context)); grub_memset (fingerprint_context, 0, GRUB_MD_SHA1->contextsize);
GRUB_MD_SHA1->init (fingerprint_context); GRUB_MD_SHA1->init (fingerprint_context);
GRUB_MD_SHA1->write (fingerprint_context, "\x99", 1); GRUB_MD_SHA1->write (fingerprint_context, "\x99", 1);
len_be = grub_cpu_to_be16 (len); len_be = grub_cpu_to_be16 (len);
@@ -454,7 +454,7 @@ grub_verify_signature_real (char *buf, grub_size_t size,
grub_err_t err; grub_err_t err;
grub_size_t i; grub_size_t i;
gcry_mpi_t mpis[10]; gcry_mpi_t mpis[10];
grub_uint8_t type; grub_uint8_t type = 0;
err = read_packet_header (sig, &type, &len); err = read_packet_header (sig, &type, &len);
if (err) if (err)
+6 -2
View File
@@ -245,7 +245,10 @@ match_devices_iter (const char *name, void *data)
t = grub_realloc (ctx->devs, sizeof (char*) * (ctx->ndev + 2)); t = grub_realloc (ctx->devs, sizeof (char*) * (ctx->ndev + 2));
if (! t) if (! t)
return 1; {
grub_free (buffer);
return 1;
}
ctx->devs = t; ctx->devs = t;
ctx->devs[ctx->ndev++] = buffer; ctx->devs[ctx->ndev++] = buffer;
@@ -290,7 +293,8 @@ struct match_files_ctx
/* Helper for match_files. */ /* Helper for match_files. */
static int static int
match_files_iter (const char *name, const struct grub_dirhook_info *info, match_files_iter (const char *name,
const struct grub_dirhook_info *info __attribute__((unused)),
void *data) void *data)
{ {
struct match_files_ctx *ctx = data; struct match_files_ctx *ctx = data;
+3 -3
View File
@@ -72,13 +72,13 @@ AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src, grub_uint8_t * dst,
grub_size_t i; grub_size_t i;
grub_uint8_t *bufblock; grub_uint8_t *bufblock;
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN || hash->mdlen == 0)
return GPG_ERR_INV_ARG;
bufblock = grub_zalloc (blocksize); bufblock = grub_zalloc (blocksize);
if (bufblock == NULL) if (bufblock == NULL)
return GPG_ERR_OUT_OF_MEMORY; return GPG_ERR_OUT_OF_MEMORY;
if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN || hash->mdlen == 0)
return GPG_ERR_INV_ARG;
grub_memset (bufblock, 0, blocksize); grub_memset (bufblock, 0, blocksize);
for (i = 0; i < blocknumbers - 1; i++) for (i = 0; i < blocknumbers - 1; i++)
{ {
+19 -17
View File
@@ -195,10 +195,10 @@ grub_ahci_pciinit (grub_pci_device_t dev,
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND); addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
grub_pci_write_word (addr, grub_pci_read_word (addr) grub_pci_write_word (addr, grub_pci_read_word (addr)
| GRUB_PCI_COMMAND_MEM_ENABLED); | GRUB_PCI_COMMAND_MEM_ENABLED | GRUB_PCI_COMMAND_BUS_MASTER);
hba = grub_pci_device_map_range (dev, bar & GRUB_PCI_ADDR_MEM_MASK, hba = grub_pci_device_map_range (dev, bar & GRUB_PCI_ADDR_MEM_MASK,
sizeof (hba)); sizeof (*hba));
grub_dprintf ("ahci", "dev: %x:%x.%x\n", dev.bus, dev.device, dev.function); grub_dprintf ("ahci", "dev: %x:%x.%x\n", dev.bus, dev.device, dev.function);
grub_dprintf ("ahci", "tfd[0]: %x\n", grub_dprintf ("ahci", "tfd[0]: %x\n",
@@ -355,7 +355,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
if (adevs[i]) if (adevs[i])
{ {
adevs[i]->hba->ports[adevs[i]->port].sata_error = adevs[i]->hba->ports[adevs[i]->port].sata_error; adevs[i]->hba->ports[adevs[i]->port].sata_error = adevs[i]->hba->ports[adevs[i]->port].sata_error;
grub_dprintf ("ahci", "err: %x\n", grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->command_list_chunk = grub_memalign_dma32 (1024, sizeof (struct grub_ahci_cmd_head) * 32); adevs[i]->command_list_chunk = grub_memalign_dma32 (1024, sizeof (struct grub_ahci_cmd_head) * 32);
@@ -440,7 +440,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
adevs[i]->hba->ports[adevs[i]->port].intstatus = ~0; adevs[i]->hba->ports[adevs[i]->port].intstatus = ~0;
// adevs[i]->hba->ports[adevs[i]->port].fbs = 0; // adevs[i]->hba->ports[adevs[i]->port].fbs = 0;
grub_dprintf ("ahci", "err: %x\n", grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->rfis = grub_memalign_dma32 (4096, adevs[i]->rfis = grub_memalign_dma32 (4096,
@@ -480,7 +480,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
for (i = 0; i < nports; i++) for (i = 0; i < nports; i++)
if (adevs[i]) if (adevs[i])
{ {
grub_dprintf ("ahci", "err: %x\n", grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].sata_error);
fr_running |= (1 << i); fr_running |= (1 << i);
@@ -488,7 +488,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_POWER_ON; adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_POWER_ON;
adevs[i]->hba->ports[adevs[i]->port].command |= 1 << 28; adevs[i]->hba->ports[adevs[i]->port].command |= 1 << 28;
grub_dprintf ("ahci", "err: %x\n", grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].sata_error);
} }
@@ -515,26 +515,26 @@ grub_ahci_pciinit (grub_pci_device_t dev,
for (i = 0; i < nports; i++) for (i = 0; i < nports; i++)
if (adevs[i]) if (adevs[i])
{ {
grub_dprintf ("ahci", "err: %x\n", grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_POWER_ON; adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_POWER_ON;
adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_SPIN_UP; adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_SPIN_UP;
grub_dprintf ("ahci", "err: %x\n", grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->hba->ports[adevs[i]->port].sata_error = ~0; adevs[i]->hba->ports[adevs[i]->port].sata_error = ~0;
grub_dprintf ("ahci", "err: %x\n", grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].sata_error);
grub_dprintf ("ahci", "offset: %x, tfd:%x, CMD: %x\n", grub_dprintf ("ahci", "port %d, offset: %x, tfd:%x, CMD: %x\n", adevs[i]->port,
(int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data - (int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data -
(char *) adevs[i]->hba), (char *) adevs[i]->hba),
adevs[i]->hba->ports[adevs[i]->port].task_file_data, adevs[i]->hba->ports[adevs[i]->port].task_file_data,
adevs[i]->hba->ports[adevs[i]->port].command); adevs[i]->hba->ports[adevs[i]->port].command);
grub_dprintf ("ahci", "err: %x\n", grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].sata_error);
} }
@@ -542,17 +542,19 @@ grub_ahci_pciinit (grub_pci_device_t dev,
for (i = 0; i < nports; i++) for (i = 0; i < nports; i++)
if (adevs[i]) if (adevs[i])
{ {
grub_dprintf ("ahci", "offset: %x, tfd:%x, CMD: %x\n", grub_dprintf ("ahci", "port %d, offset: %x, tfd:%x, CMD: %x\n", adevs[i]->port,
(int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data - (int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data -
(char *) adevs[i]->hba), (char *) adevs[i]->hba),
adevs[i]->hba->ports[adevs[i]->port].task_file_data, adevs[i]->hba->ports[adevs[i]->port].task_file_data,
adevs[i]->hba->ports[adevs[i]->port].command); adevs[i]->hba->ports[adevs[i]->port].command);
grub_dprintf ("ahci", "err: %x\n", grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port,
adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].sata_error);
adevs[i]->hba->ports[adevs[i]->port].command adevs[i]->hba->ports[adevs[i]->port].command
= (adevs[i]->hba->ports[adevs[i]->port].command & 0x0fffffff) | (1 << 28) | 2 | 4; = (adevs[i]->hba->ports[adevs[i]->port].command & 0x0fffffff) | (1 << 28)
| GRUB_AHCI_HBA_PORT_CMD_SPIN_UP
| GRUB_AHCI_HBA_PORT_CMD_POWER_ON;
/* struct grub_disk_ata_pass_through_parms parms2; /* struct grub_disk_ata_pass_through_parms parms2;
grub_memset (&parms2, 0, sizeof (parms2)); grub_memset (&parms2, 0, sizeof (parms2));
@@ -565,14 +567,14 @@ grub_ahci_pciinit (grub_pci_device_t dev,
while (grub_get_time_ms () < endtime) while (grub_get_time_ms () < endtime)
{ {
for (i = 0; i < nports; i++) for (i = 0; i < nports; i++)
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & 0x88)) if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & (GRUB_ATA_STATUS_BUSY | GRUB_ATA_STATUS_DRQ)))
break; break;
if (i == nports) if (i == nports)
break; break;
} }
for (i = 0; i < nports; i++) for (i = 0; i < nports; i++)
if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & 0x88)) if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & (GRUB_ATA_STATUS_BUSY | GRUB_ATA_STATUS_DRQ)))
{ {
grub_dprintf ("ahci", "port %d is busy\n", i); grub_dprintf ("ahci", "port %d is busy\n", i);
failed_adevs[i] = adevs[i]; failed_adevs[i] = adevs[i];
@@ -1002,7 +1004,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev,
if (parms->write) if (parms->write)
grub_memcpy ((char *) grub_dma_get_virt (bufc), parms->buffer, parms->size); grub_memcpy ((char *) grub_dma_get_virt (bufc), parms->buffer, parms->size);
grub_dprintf ("ahci", "AHCI command schedulded\n"); grub_dprintf ("ahci", "AHCI command scheduled\n");
grub_dprintf ("ahci", "AHCI tfd = %x\n", grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data); dev->hba->ports[dev->port].task_file_data);
grub_dprintf ("ahci", "AHCI inten = %x\n", grub_dprintf ("ahci", "AHCI inten = %x\n",
+45 -27
View File
@@ -110,20 +110,23 @@ grub_crypto_pcbc_decrypt (grub_crypto_cipher_handle_t cipher,
{ {
grub_uint8_t *inptr, *outptr, *end; grub_uint8_t *inptr, *outptr, *end;
grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE]; grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE) grub_size_t blocksize;
return GPG_ERR_INV_ARG;
if (!cipher->cipher->decrypt) if (!cipher->cipher->decrypt)
return GPG_ERR_NOT_SUPPORTED; return GPG_ERR_NOT_SUPPORTED;
if (size % cipher->cipher->blocksize != 0) blocksize = cipher->cipher->blocksize;
if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0)
|| ((size & (blocksize - 1)) != 0))
return GPG_ERR_INV_ARG;
if (blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
return GPG_ERR_INV_ARG; return GPG_ERR_INV_ARG;
end = (grub_uint8_t *) in + size; end = (grub_uint8_t *) in + size;
for (inptr = in, outptr = out; inptr < end; for (inptr = in, outptr = out; inptr < end;
inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) inptr += blocksize, outptr += blocksize)
{ {
grub_memcpy (ivt, inptr, cipher->cipher->blocksize); grub_memcpy (ivt, inptr, blocksize);
cipher->cipher->decrypt (cipher->ctx, outptr, inptr); cipher->cipher->decrypt (cipher->ctx, outptr, inptr);
grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize); grub_crypto_xor (outptr, outptr, iv, blocksize);
grub_crypto_xor (iv, ivt, outptr, cipher->cipher->blocksize); grub_crypto_xor (iv, ivt, outptr, blocksize);
} }
return GPG_ERR_NO_ERROR; return GPG_ERR_NO_ERROR;
} }
@@ -135,20 +138,23 @@ grub_crypto_pcbc_encrypt (grub_crypto_cipher_handle_t cipher,
{ {
grub_uint8_t *inptr, *outptr, *end; grub_uint8_t *inptr, *outptr, *end;
grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE]; grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE];
if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE) grub_size_t blocksize;
return GPG_ERR_INV_ARG; if (!cipher->cipher->encrypt)
if (!cipher->cipher->decrypt)
return GPG_ERR_NOT_SUPPORTED; return GPG_ERR_NOT_SUPPORTED;
if (size % cipher->cipher->blocksize != 0) blocksize = cipher->cipher->blocksize;
if (blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE)
return GPG_ERR_INV_ARG;
if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0)
|| ((size & (blocksize - 1)) != 0))
return GPG_ERR_INV_ARG; return GPG_ERR_INV_ARG;
end = (grub_uint8_t *) in + size; end = (grub_uint8_t *) in + size;
for (inptr = in, outptr = out; inptr < end; for (inptr = in, outptr = out; inptr < end;
inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) inptr += blocksize, outptr += blocksize)
{ {
grub_memcpy (ivt, inptr, cipher->cipher->blocksize); grub_memcpy (ivt, inptr, blocksize);
grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize); grub_crypto_xor (outptr, outptr, iv, blocksize);
cipher->cipher->encrypt (cipher->ctx, outptr, inptr); cipher->cipher->encrypt (cipher->ctx, outptr, inptr);
grub_crypto_xor (iv, ivt, outptr, cipher->cipher->blocksize); grub_crypto_xor (iv, ivt, outptr, blocksize);
} }
return GPG_ERR_NO_ERROR; return GPG_ERR_NO_ERROR;
} }
@@ -372,11 +378,13 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
break; break;
case GRUB_CRYPTODISK_MODE_ECB: case GRUB_CRYPTODISK_MODE_ECB:
if (do_encrypt) if (do_encrypt)
grub_crypto_ecb_encrypt (dev->cipher, data + i, data + i, err = grub_crypto_ecb_encrypt (dev->cipher, data + i, data + i,
(1U << dev->log_sector_size)); (1U << dev->log_sector_size));
else else
grub_crypto_ecb_decrypt (dev->cipher, data + i, data + i, err = grub_crypto_ecb_decrypt (dev->cipher, data + i, data + i,
(1U << dev->log_sector_size)); (1U << dev->log_sector_size));
if (err)
return err;
break; break;
default: default:
return GPG_ERR_NOT_IMPLEMENTED; return GPG_ERR_NOT_IMPLEMENTED;
@@ -956,33 +964,43 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args)
grub_disk_t disk; grub_disk_t disk;
grub_cryptodisk_t dev; grub_cryptodisk_t dev;
char *diskname; char *diskname;
char *disklast; char *disklast = NULL;
grub_size_t len;
search_uuid = NULL; search_uuid = NULL;
check_boot = state[2].set; check_boot = state[2].set;
diskname = args[0]; diskname = args[0];
if (diskname[0] == '(' && *(disklast = &diskname[grub_strlen (diskname) - 1]) == ')') len = grub_strlen (diskname);
if (len && diskname[0] == '(' && diskname[len - 1] == ')')
{ {
disklast = &diskname[len - 1];
*disklast = '\0'; *disklast = '\0';
disk = grub_disk_open (diskname + 1); diskname++;
*disklast = ')';
} }
else
disk = grub_disk_open (diskname); disk = grub_disk_open (diskname);
if (!disk) if (!disk)
return grub_errno; {
if (disklast)
*disklast = ')';
return grub_errno;
}
dev = grub_cryptodisk_get_by_source_disk (disk); dev = grub_cryptodisk_get_by_source_disk (disk);
if (dev) if (dev)
{ {
grub_dprintf ("cryptodisk", "already mounted as crypto%lu\n", dev->id); grub_dprintf ("cryptodisk", "already mounted as crypto%lu\n", dev->id);
grub_disk_close (disk); grub_disk_close (disk);
if (disklast)
*disklast = ')';
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
} }
err = grub_cryptodisk_scan_device_real (args[0], disk); err = grub_cryptodisk_scan_device_real (diskname, disk);
grub_disk_close (disk); grub_disk_close (disk);
if (disklast)
*disklast = ')';
return err; return err;
} }
+47 -27
View File
@@ -71,10 +71,12 @@ is_lv_readable (struct grub_diskfilter_lv *lv, int easily)
case GRUB_DISKFILTER_RAID6: case GRUB_DISKFILTER_RAID6:
if (!easily) if (!easily)
need--; need--;
/* Fallthrough. */
case GRUB_DISKFILTER_RAID4: case GRUB_DISKFILTER_RAID4:
case GRUB_DISKFILTER_RAID5: case GRUB_DISKFILTER_RAID5:
if (!easily) if (!easily)
need--; need--;
/* Fallthrough. */
case GRUB_DISKFILTER_STRIPED: case GRUB_DISKFILTER_STRIPED:
break; break;
@@ -494,13 +496,13 @@ validate_lv (struct grub_diskfilter_lv *lv)
if (!lv) if (!lv)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown volume"); return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown volume");
if (lv->vg->extent_size == 0) if (!lv->vg || lv->vg->extent_size == 0)
return grub_error (GRUB_ERR_READ_ERROR, "invalid volume"); return grub_error (GRUB_ERR_READ_ERROR, "invalid volume");
for (i = 0; i < lv->segment_count; i++) for (i = 0; i < lv->segment_count; i++)
{ {
grub_err_t err; grub_err_t err;
err = validate_segment (&lv->segments[1]); err = validate_segment (&lv->segments[i]);
if (err) if (err)
return err; return err;
} }
@@ -584,6 +586,7 @@ read_segment (struct grub_diskfilter_segment *seg, grub_disk_addr_t sector,
if (seg->node_count == 1) if (seg->node_count == 1)
return grub_diskfilter_read_node (&seg->nodes[0], return grub_diskfilter_read_node (&seg->nodes[0],
sector, size, buf); sector, size, buf);
/* Fallthrough. */
case GRUB_DISKFILTER_MIRROR: case GRUB_DISKFILTER_MIRROR:
case GRUB_DISKFILTER_RAID10: case GRUB_DISKFILTER_RAID10:
{ {
@@ -938,8 +941,10 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg)
for (lv = vg->lvs; lv; lv = lv->next) for (lv = vg->lvs; lv; lv = lv->next)
{ {
/* RAID 1 and single-disk RAID 0 don't use a chunksize but code assumes one so set grub_err_t err;
one. */
/* RAID 1 and single-disk RAID 0 don't use a chunksize but code
assumes one so set one. */
for (i = 0; i < lv->segment_count; i++) for (i = 0; i < lv->segment_count; i++)
{ {
if (lv->segments[i].type == 1) if (lv->segments[i].type == 1)
@@ -949,17 +954,6 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg)
&& lv->segments[i].stripe_size == 0) && lv->segments[i].stripe_size == 0)
lv->segments[i].stripe_size = 64; lv->segments[i].stripe_size = 64;
} }
}
for (lv = vg->lvs; lv; lv = lv->next)
{
grub_err_t err;
/* RAID 1 doesn't use a chunksize but code assumes one so set
one. */
for (i = 0; i < lv->segment_count; i++)
if (lv->segments[i].type == 1)
lv->segments[i].stripe_size = 64;
err = validate_lv(lv); err = validate_lv(lv);
if (err) if (err)
@@ -1004,7 +998,6 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg)
lv->fullname = tmp; lv->fullname = tmp;
} }
} }
lv->vg = vg;
} }
/* Add our new array to the list. */ /* Add our new array to the list. */
vg->next = array_list; vg->next = array_list;
@@ -1014,7 +1007,7 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg)
struct grub_diskfilter_vg * struct grub_diskfilter_vg *
grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
char *name, grub_uint64_t disk_size, const char *name, grub_uint64_t disk_size,
grub_uint64_t stripe_size, grub_uint64_t stripe_size,
int layout, int level) int layout, int level)
{ {
@@ -1038,7 +1031,10 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
if (n == 1) if (n == 1)
n = (layout >> 8) & 0xFF; n = (layout >> 8) & 0xFF;
if (n == 0) if (n == 0)
return NULL; {
grub_free (uuid);
return NULL;
}
totsize = grub_divmod64 (nmemb * disk_size, n, 0); totsize = grub_divmod64 (nmemb * disk_size, n, 0);
} }
@@ -1052,6 +1048,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
break; break;
default: default:
grub_free (uuid);
return NULL; return NULL;
} }
@@ -1065,7 +1062,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
array->lvs->segments->extent_count = totsize; array->lvs->segments->extent_count = totsize;
} }
if (array->lvs->segments if (array->lvs && array->lvs->segments
&& array->lvs->segments->raid_member_size > disk_size) && array->lvs->segments->raid_member_size > disk_size)
array->lvs->segments->raid_member_size = disk_size; array->lvs->segments->raid_member_size = disk_size;
@@ -1074,7 +1071,10 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
} }
array = grub_zalloc (sizeof (*array)); array = grub_zalloc (sizeof (*array));
if (!array) if (!array)
return NULL; {
grub_free (uuid);
return NULL;
}
array->uuid = uuid; array->uuid = uuid;
array->uuid_len = uuidlen; array->uuid_len = uuidlen;
if (name) if (name)
@@ -1096,8 +1096,16 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
goto fail; goto fail;
array->lvs->segment_count = 1; array->lvs->segment_count = 1;
array->lvs->visible = 1; array->lvs->visible = 1;
array->lvs->name = array->name; if (array->name)
array->lvs->fullname = array->name; {
array->lvs->name = grub_strdup (array->name);
if (!array->lvs->name)
goto fail;
array->lvs->fullname = grub_strdup (array->name);
if (!array->lvs->fullname)
goto fail;
}
array->lvs->vg = array;
array->lvs->idname = grub_malloc (sizeof ("mduuid/") + 2 * uuidlen); array->lvs->idname = grub_malloc (sizeof ("mduuid/") + 2 * uuidlen);
if (!array->lvs->idname) if (!array->lvs->idname)
@@ -1147,13 +1155,26 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
return array; return array;
fail: fail:
grub_free (array->lvs); if (array->lvs)
{
grub_free (array->lvs->name);
grub_free (array->lvs->fullname);
grub_free (array->lvs->idname);
if (array->lvs->segments)
{
grub_free (array->lvs->segments->nodes);
grub_free (array->lvs->segments);
}
grub_free (array->lvs);
}
while (array->pvs) while (array->pvs)
{ {
pv = array->pvs->next; pv = array->pvs->next;
grub_free (array->pvs); grub_free (array->pvs);
array->pvs = pv; array->pvs = pv;
} }
grub_free (array->name);
grub_free (array->uuid);
grub_free (array); grub_free (array);
return NULL; return NULL;
} }
@@ -1256,10 +1277,9 @@ free_array (void)
{ {
unsigned i; unsigned i;
vg->lvs = lv->next; vg->lvs = lv->next;
if (lv->name != lv->fullname) grub_free (lv->fullname);
grub_free (lv->fullname); grub_free (lv->name);
if (lv->name != vg->name) grub_free (lv->idname);
grub_free (lv->name);
for (i = 0; i < lv->segment_count; i++) for (i = 0; i < lv->segment_count; i++)
grub_free (lv->segments[i].nodes); grub_free (lv->segments[i].nodes);
grub_free (lv->segments); grub_free (lv->segments);
+10 -5
View File
@@ -99,6 +99,8 @@ grub_dmraid_nv_detect (grub_disk_t disk,
struct grub_nv_super sb; struct grub_nv_super sb;
int level; int level;
grub_uint64_t disk_size; grub_uint64_t disk_size;
grub_uint32_t capacity;
grub_uint8_t total_volumes;
char *uuid; char *uuid;
if (disk->partition) if (disk->partition)
@@ -124,14 +126,17 @@ grub_dmraid_nv_detect (grub_disk_t disk,
return NULL; return NULL;
} }
capacity = grub_le_to_cpu32 (sb.capacity);
total_volumes = sb.array.total_volumes;
switch (sb.array.raid_level) switch (sb.array.raid_level)
{ {
case NV_LEVEL_0: case NV_LEVEL_0:
level = 0; level = 0;
disk_size = sb.capacity / sb.array.total_volumes; if (total_volumes == 0)
if (sb.array.total_volumes == 0)
/* Not RAID. */ /* Not RAID. */
return NULL; return NULL;
disk_size = capacity / total_volumes;
break; break;
case NV_LEVEL_1: case NV_LEVEL_1:
@@ -141,10 +146,10 @@ grub_dmraid_nv_detect (grub_disk_t disk,
case NV_LEVEL_5: case NV_LEVEL_5:
level = 5; level = 5;
disk_size = sb.capacity / (sb.array.total_volumes - 1); if (total_volumes == 0 || total_volumes == 1)
if (sb.array.total_volumes == 0 || sb.array.total_volumes == 1)
/* Not RAID. */ /* Not RAID. */
return NULL; return NULL;
disk_size = capacity / (total_volumes - 1);
break; break;
default: default:
@@ -167,7 +172,7 @@ grub_dmraid_nv_detect (grub_disk_t disk,
return grub_diskfilter_make_raid (sizeof (sb.array.signature), return grub_diskfilter_make_raid (sizeof (sb.array.signature),
uuid, sb.array.total_volumes, uuid, sb.array.total_volumes,
NULL, disk_size, "nv", disk_size,
sb.array.stripe_block_size, sb.array.stripe_block_size,
GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC, GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC,
level); level);
+16 -58
View File
@@ -43,47 +43,6 @@ static struct grub_efidisk_data *fd_devices;
static struct grub_efidisk_data *hd_devices; static struct grub_efidisk_data *hd_devices;
static struct grub_efidisk_data *cd_devices; static struct grub_efidisk_data *cd_devices;
/* Duplicate a device path. */
static grub_efi_device_path_t *
duplicate_device_path (const grub_efi_device_path_t *dp)
{
grub_efi_device_path_t *p;
grub_size_t total_size = 0;
for (p = (grub_efi_device_path_t *) dp;
;
p = GRUB_EFI_NEXT_DEVICE_PATH (p))
{
total_size += GRUB_EFI_DEVICE_PATH_LENGTH (p);
if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (p))
break;
}
p = grub_malloc (total_size);
if (! p)
return 0;
grub_memcpy (p, dp, total_size);
return p;
}
/* Return the device path node right before the end node. */
static grub_efi_device_path_t *
find_last_device_path (const grub_efi_device_path_t *dp)
{
grub_efi_device_path_t *next, *p;
if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp))
return 0;
for (p = (grub_efi_device_path_t *) dp, next = GRUB_EFI_NEXT_DEVICE_PATH (p);
! GRUB_EFI_END_ENTIRE_DEVICE_PATH (next);
p = next, next = GRUB_EFI_NEXT_DEVICE_PATH (next))
;
return p;
}
static struct grub_efidisk_data * static struct grub_efidisk_data *
make_devices (void) make_devices (void)
{ {
@@ -110,7 +69,7 @@ make_devices (void)
if (! dp) if (! dp)
continue; continue;
ldp = find_last_device_path (dp); ldp = grub_efi_find_last_device_path (dp);
if (! ldp) if (! ldp)
/* This is empty. Why? */ /* This is empty. Why? */
continue; continue;
@@ -150,11 +109,11 @@ find_parent_device (struct grub_efidisk_data *devices,
grub_efi_device_path_t *dp, *ldp; grub_efi_device_path_t *dp, *ldp;
struct grub_efidisk_data *parent; struct grub_efidisk_data *parent;
dp = duplicate_device_path (d->device_path); dp = grub_efi_duplicate_device_path (d->device_path);
if (! dp) if (! dp)
return 0; return 0;
ldp = find_last_device_path (dp); ldp = grub_efi_find_last_device_path (dp);
ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
ldp->length = sizeof (*ldp); ldp->length = sizeof (*ldp);
@@ -180,11 +139,11 @@ is_child (struct grub_efidisk_data *child,
grub_efi_device_path_t *dp, *ldp; grub_efi_device_path_t *dp, *ldp;
int ret; int ret;
dp = duplicate_device_path (child->device_path); dp = grub_efi_duplicate_device_path (child->device_path);
if (! dp) if (! dp)
return 0; return 0;
ldp = find_last_device_path (dp); ldp = grub_efi_find_last_device_path (dp);
ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
ldp->length = sizeof (*ldp); ldp->length = sizeof (*ldp);
@@ -207,8 +166,8 @@ add_device (struct grub_efidisk_data **devices, struct grub_efidisk_data *d)
{ {
int ret; int ret;
ret = grub_efi_compare_device_paths (find_last_device_path ((*p)->device_path), ret = grub_efi_compare_device_paths (grub_efi_find_last_device_path ((*p)->device_path),
find_last_device_path (d->device_path)); grub_efi_find_last_device_path (d->device_path));
if (ret == 0) if (ret == 0)
ret = grub_efi_compare_device_paths ((*p)->device_path, ret = grub_efi_compare_device_paths ((*p)->device_path,
d->device_path); d->device_path);
@@ -795,7 +754,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
if (! dp) if (! dp)
return 0; return 0;
ldp = find_last_device_path (dp); ldp = grub_efi_find_last_device_path (dp);
if (! ldp) if (! ldp)
return 0; return 0;
@@ -803,7 +762,6 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE && (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE
|| GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)) || GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE))
{ {
int is_cdrom = 0;
struct grub_efidisk_get_device_name_ctx ctx; struct grub_efidisk_get_device_name_ctx ctx;
char *dev_name; char *dev_name;
grub_efi_device_path_t *dup_dp; grub_efi_device_path_t *dup_dp;
@@ -811,22 +769,19 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
/* It is necessary to duplicate the device path so that GRUB /* It is necessary to duplicate the device path so that GRUB
can overwrite it. */ can overwrite it. */
dup_dp = duplicate_device_path (dp); dup_dp = grub_efi_duplicate_device_path (dp);
if (! dup_dp) if (! dup_dp)
return 0; return 0;
while (1) while (1)
{ {
grub_efi_device_path_t *dup_ldp; grub_efi_device_path_t *dup_ldp;
dup_ldp = find_last_device_path (dup_dp); dup_ldp = grub_efi_find_last_device_path (dup_dp);
if (!(GRUB_EFI_DEVICE_PATH_TYPE (dup_ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE if (!(GRUB_EFI_DEVICE_PATH_TYPE (dup_ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE
&& (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE
|| GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE))) || GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)))
break; break;
if (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE)
is_cdrom = 1;
dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE;
dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE;
dup_ldp->length = sizeof (*dup_ldp); dup_ldp->length = sizeof (*dup_ldp);
@@ -861,10 +816,13 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle)
if (! ctx.partition_name) if (! ctx.partition_name)
{ {
/* No partition found. In most cases partition is embed in
the root path anyway, so this is not critical.
This happens only if partition is on partmap that GRUB
doesn't need to access root.
*/
grub_disk_close (parent); grub_disk_close (parent);
if (is_cdrom) return grub_strdup (device_name);
return grub_strdup (device_name);
return 0;
} }
dev_name = grub_xasprintf ("%s,%s", parent->name, dev_name = grub_xasprintf ("%s,%s", parent->name,
+6 -2
View File
@@ -212,7 +212,8 @@ grub_util_get_geli_uuid (const char *dev)
s = grub_util_get_fd_size (fd, dev, &log_secsize); s = grub_util_get_fd_size (fd, dev, &log_secsize);
s >>= log_secsize; s >>= log_secsize;
grub_util_fd_seek (fd, (s << log_secsize) - 512); if (grub_util_fd_seek (fd, (s << log_secsize) - 512) < 0)
grub_util_error ("%s", _("couldn't read ELI metadata"));
uuid = xmalloc (GRUB_MD_SHA256->mdlen * 2 + 1); uuid = xmalloc (GRUB_MD_SHA256->mdlen * 2 + 1);
if (grub_util_fd_read (fd, (void *) &hdr, 512) < 0) if (grub_util_fd_read (fd, (void *) &hdr, 512) < 0)
@@ -231,7 +232,10 @@ grub_util_get_geli_uuid (const char *dev)
err = make_uuid ((void *) &hdr, uuid); err = make_uuid ((void *) &hdr, uuid);
if (err) if (err)
return NULL; {
grub_free (uuid);
return NULL;
}
return uuid; return uuid;
} }
+4 -2
View File
@@ -382,7 +382,8 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
/* Some buggy BIOSes doesn't return the total sectors /* Some buggy BIOSes doesn't return the total sectors
correctly but returns zero. So if it is zero, compute correctly but returns zero. So if it is zero, compute
it by C/H/S returned by the LBA BIOS call. */ it by C/H/S returned by the LBA BIOS call. */
total_sectors = drp->cylinders * drp->heads * drp->sectors; total_sectors = ((grub_uint64_t) drp->cylinders)
* drp->heads * drp->sectors;
if (drp->bytes_per_sector if (drp->bytes_per_sector
&& !(drp->bytes_per_sector & (drp->bytes_per_sector - 1)) && !(drp->bytes_per_sector & (drp->bytes_per_sector - 1))
&& drp->bytes_per_sector >= 512 && drp->bytes_per_sector >= 512
@@ -425,7 +426,8 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
data->heads = 255; data->heads = 255;
if (! total_sectors) if (! total_sectors)
total_sectors = data->cylinders * data->heads * data->sectors; total_sectors = ((grub_uint64_t) data->cylinders)
* data->heads * data->sectors;
} }
disk->total_sectors = total_sectors; disk->total_sectors = total_sectors;
+60 -29
View File
@@ -34,7 +34,8 @@ struct ofdisk_hash_ent
char *open_path; char *open_path;
char *grub_devpath; char *grub_devpath;
int is_boot; int is_boot;
int is_cdrom; int is_removable;
int block_size_fails;
/* Pointer to shortest available name on nodes representing canonical names, /* Pointer to shortest available name on nodes representing canonical names,
otherwise NULL. */ otherwise NULL. */
const char *shortest; const char *shortest;
@@ -42,6 +43,10 @@ struct ofdisk_hash_ent
struct ofdisk_hash_ent *next; struct ofdisk_hash_ent *next;
}; };
static grub_err_t
grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size,
struct ofdisk_hash_ent *op);
#define OFDISK_HASH_SZ 8 #define OFDISK_HASH_SZ 8
static struct ofdisk_hash_ent *ofdisk_hash[OFDISK_HASH_SZ]; static struct ofdisk_hash_ent *ofdisk_hash[OFDISK_HASH_SZ];
@@ -123,7 +128,7 @@ ofdisk_hash_add_real (char *devpath)
} }
static int static int
check_string_cdrom (const char *str) check_string_removable (const char *str)
{ {
const char *ptr = grub_strrchr (str, '/'); const char *ptr = grub_strrchr (str, '/');
@@ -131,7 +136,7 @@ check_string_cdrom (const char *str)
ptr++; ptr++;
else else
ptr = str; ptr = str;
return (grub_strncmp (ptr, "cdrom", 5) == 0); return (grub_strncmp (ptr, "cdrom", 5) == 0 || grub_strncmp (ptr, "fd", 2) == 0);
} }
static struct ofdisk_hash_ent * static struct ofdisk_hash_ent *
@@ -147,8 +152,8 @@ ofdisk_hash_add (char *devpath, char *curcan)
{ {
p->shortest = p->devpath; p->shortest = p->devpath;
p->grub_shortest = p->grub_devpath; p->grub_shortest = p->grub_devpath;
if (check_string_cdrom (devpath)) if (check_string_removable (devpath))
p->is_cdrom = 1; p->is_removable = 1;
return p; return p;
} }
@@ -158,8 +163,8 @@ ofdisk_hash_add (char *devpath, char *curcan)
else else
grub_free (curcan); grub_free (curcan);
if (check_string_cdrom (devpath) || check_string_cdrom (curcan)) if (check_string_removable (devpath) || check_string_removable (curcan))
pcan->is_cdrom = 1; pcan->is_removable = 1;
if (!pcan) if (!pcan)
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
@@ -330,7 +335,7 @@ grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
} }
} }
if (!ent->is_boot && ent->is_cdrom) if (!ent->is_boot && ent->is_removable)
continue; continue;
if (hook (ent->grub_shortest, hook_data)) if (hook (ent->grub_shortest, hook_data))
@@ -375,6 +380,8 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
/* XXX: This should be large enough for any possible case. */ /* XXX: This should be large enough for any possible case. */
char prop[64]; char prop[64];
grub_ssize_t actual; grub_ssize_t actual;
grub_uint32_t block_size = 0;
grub_err_t err;
if (grub_strncmp (name, "ieee1275/", sizeof ("ieee1275/") - 1) != 0) if (grub_strncmp (name, "ieee1275/", sizeof ("ieee1275/") - 1) != 0)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
@@ -405,14 +412,6 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a block device"); return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a block device");
} }
grub_uint32_t block_size = 0;
if (grub_ofdisk_get_block_size (devpath, &block_size) == 0)
{
for (disk->log_sector_size = 0;
(1U << disk->log_sector_size) < block_size;
disk->log_sector_size++);
}
/* XXX: There is no property to read the number of blocks. There /* XXX: There is no property to read the number of blocks. There
should be a property `#blocks', but it is not there. Perhaps it should be a property `#blocks', but it is not there. Perhaps it
is possible to use seek for this. */ is possible to use seek for this. */
@@ -423,14 +422,31 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
op = ofdisk_hash_find (devpath); op = ofdisk_hash_find (devpath);
if (!op) if (!op)
op = ofdisk_hash_add (devpath, NULL); op = ofdisk_hash_add (devpath, NULL);
else
grub_free (devpath);
if (!op) if (!op)
return grub_errno; {
grub_free (devpath);
return grub_errno;
}
disk->id = (unsigned long) op; disk->id = (unsigned long) op;
disk->data = op->open_path; disk->data = op->open_path;
err = grub_ofdisk_get_block_size (devpath, &block_size, op);
if (err)
{
grub_free (devpath);
return err;
}
if (block_size != 0)
{
for (disk->log_sector_size = 0;
(1U << disk->log_sector_size) < block_size;
disk->log_sector_size++);
}
else
disk->log_sector_size = 9;
} }
grub_free (devpath);
return 0; return 0;
} }
@@ -589,8 +605,9 @@ grub_ofdisk_init (void)
grub_disk_dev_register (&grub_ofdisk_dev); grub_disk_dev_register (&grub_ofdisk_dev);
} }
grub_err_t static grub_err_t
grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size) grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size,
struct ofdisk_hash_ent *op)
{ {
struct size_args_ieee1275 struct size_args_ieee1275
{ {
@@ -612,20 +629,34 @@ grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size)
if (! last_ihandle) if (! last_ihandle)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device"); return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
*block_size = 0;
if (op->block_size_fails >= 2)
return GRUB_ERR_NONE;
INIT_IEEE1275_COMMON (&args_ieee1275.common, "call-method", 2, 2); INIT_IEEE1275_COMMON (&args_ieee1275.common, "call-method", 2, 2);
args_ieee1275.method = (grub_ieee1275_cell_t) "block-size"; args_ieee1275.method = (grub_ieee1275_cell_t) "block-size";
args_ieee1275.ihandle = last_ihandle; args_ieee1275.ihandle = last_ihandle;
args_ieee1275.result = 1; args_ieee1275.result = 1;
*block_size = GRUB_DISK_SECTOR_SIZE; if (IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1)
{
if ((IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1) || (args_ieee1275.result)) grub_dprintf ("disk", "can't get block size: failed call-method\n");
grub_dprintf ("disk", "can't get block size\n"); op->block_size_fails++;
else }
if (args_ieee1275.size1 else if (args_ieee1275.result)
&& !(args_ieee1275.size1 & (args_ieee1275.size1 - 1)) {
&& args_ieee1275.size1 >= 512 && args_ieee1275.size1 <= 16384) grub_dprintf ("disk", "can't get block size: %lld\n",
(long long) args_ieee1275.result);
op->block_size_fails++;
}
else if (args_ieee1275.size1
&& !(args_ieee1275.size1 & (args_ieee1275.size1 - 1))
&& args_ieee1275.size1 >= 512 && args_ieee1275.size1 <= 16384)
{
op->block_size_fails = 0;
*block_size = args_ieee1275.size1; *block_size = args_ieee1275.size1;
}
return 0; return 0;
} }
+1 -1
View File
@@ -963,7 +963,7 @@ grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors,
if (embed_type != GRUB_EMBED_PCBIOS) if (embed_type != GRUB_EMBED_PCBIOS)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"LDM curently supports only PC-BIOS embedding"); "LDM currently supports only PC-BIOS embedding");
if (disk->partition) if (disk->partition)
return grub_error (GRUB_ERR_BUG, "disk isn't LDM"); return grub_error (GRUB_ERR_BUG, "disk isn't LDM");
pv = grub_diskfilter_get_pv_from_disk (disk, &vg); pv = grub_diskfilter_get_pv_from_disk (disk, &vg);
+34 -28
View File
@@ -160,7 +160,7 @@ grub_lvm_detect (grub_disk_t disk,
"we don't support multiple LVM data areas"); "we don't support multiple LVM data areas");
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("we don't support multiple LVM data areas\n"); grub_util_info ("we don't support multiple LVM data areas");
#endif #endif
goto fail; goto fail;
} }
@@ -189,7 +189,7 @@ grub_lvm_detect (grub_disk_t disk,
grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"unknown LVM metadata header"); "unknown LVM metadata header");
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("unknown LVM metadata header\n"); grub_util_info ("unknown LVM metadata header");
#endif #endif
goto fail2; goto fail2;
} }
@@ -213,7 +213,7 @@ grub_lvm_detect (grub_disk_t disk,
if (q == metadatabuf + mda_size) if (q == metadatabuf + mda_size)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("error parsing metadata\n"); grub_util_info ("error parsing metadata");
#endif #endif
goto fail2; goto fail2;
} }
@@ -230,7 +230,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL) if (p == NULL)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("couldn't find ID\n"); grub_util_info ("couldn't find ID");
#endif #endif
goto fail3; goto fail3;
} }
@@ -258,7 +258,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL) if (p == NULL)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("unknown extent size\n"); grub_util_info ("unknown extent size");
#endif #endif
goto fail4; goto fail4;
} }
@@ -306,7 +306,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL) if (p == NULL)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("unknown pe_start\n"); grub_util_info ("unknown pe_start");
#endif #endif
goto pvs_fail; goto pvs_fail;
} }
@@ -315,7 +315,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL) if (p == NULL)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("error parsing pe_start\n"); grub_util_info ("error parsing pe_start");
#endif #endif
goto pvs_fail; goto pvs_fail;
} }
@@ -402,7 +402,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL) if (p == NULL)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("couldn't find ID\n"); grub_util_info ("couldn't find ID");
#endif #endif
goto lvs_fail; goto lvs_fail;
} }
@@ -422,11 +422,11 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL) if (p == NULL)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("unknown segment_count\n"); grub_util_info ("unknown segment_count");
#endif #endif
goto lvs_fail; goto lvs_fail;
} }
lv->segments = grub_malloc (sizeof (*seg) * lv->segment_count); lv->segments = grub_zalloc (sizeof (*seg) * lv->segment_count);
seg = lv->segments; seg = lv->segments;
for (i = 0; i < lv->segment_count; i++) for (i = 0; i < lv->segment_count; i++)
@@ -436,7 +436,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL) if (p == NULL)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("unknown segment\n"); grub_util_info ("unknown segment");
#endif #endif
goto lvs_segment_fail; goto lvs_segment_fail;
} }
@@ -445,7 +445,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL) if (p == NULL)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("unknown start_extent\n"); grub_util_info ("unknown start_extent");
#endif #endif
goto lvs_segment_fail; goto lvs_segment_fail;
} }
@@ -453,7 +453,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL) if (p == NULL)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("unknown extent_count\n"); grub_util_info ("unknown extent_count");
#endif #endif
goto lvs_segment_fail; goto lvs_segment_fail;
} }
@@ -475,7 +475,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL) if (p == NULL)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("unknown stripe_count\n"); grub_util_info ("unknown stripe_count");
#endif #endif
goto lvs_segment_fail; goto lvs_segment_fail;
} }
@@ -491,7 +491,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL) if (p == NULL)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("unknown stripes\n"); grub_util_info ("unknown stripes");
#endif #endif
goto lvs_segment_fail2; goto lvs_segment_fail2;
} }
@@ -533,7 +533,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL) if (p == NULL)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("unknown mirror_count\n"); grub_util_info ("unknown mirror_count");
#endif #endif
goto lvs_segment_fail; goto lvs_segment_fail;
} }
@@ -545,7 +545,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL) if (p == NULL)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("unknown mirrors\n"); grub_util_info ("unknown mirrors");
#endif #endif
goto lvs_segment_fail2; goto lvs_segment_fail2;
} }
@@ -577,13 +577,17 @@ grub_lvm_detect (grub_disk_t disk,
if (is_pvmove) if (is_pvmove)
seg->node_count = 1; seg->node_count = 1;
} }
else if (grub_memcmp (p, "raid", sizeof ("raid") - 1) else if (grub_memcmp (p, "raid", sizeof ("raid") - 1) == 0
== 0 && (p[sizeof ("raid") - 1] >= '4' && ((p[sizeof ("raid") - 1] >= '4'
&& p[sizeof ("raid") - 1] <= '6') && p[sizeof ("raid") - 1] <= '6')
|| p[sizeof ("raid") - 1] == '1')
&& p[sizeof ("raidX") - 1] == '"') && p[sizeof ("raidX") - 1] == '"')
{ {
switch (p[sizeof ("raid") - 1]) switch (p[sizeof ("raid") - 1])
{ {
case '1':
seg->type = GRUB_DISKFILTER_MIRROR;
break;
case '4': case '4':
seg->type = GRUB_DISKFILTER_RAID4; seg->type = GRUB_DISKFILTER_RAID4;
seg->layout = GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC; seg->layout = GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC;
@@ -603,21 +607,23 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL) if (p == NULL)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("unknown device_count\n"); grub_util_info ("unknown device_count");
#endif #endif
goto lvs_segment_fail; goto lvs_segment_fail;
} }
seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = "); if (seg->type != GRUB_DISKFILTER_MIRROR)
if (p == NULL)
{ {
seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = ");
if (p == NULL)
{
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("unknown stripe_size\n"); grub_util_info ("unknown stripe_size");
#endif #endif
goto lvs_segment_fail; goto lvs_segment_fail;
}
} }
seg->nodes = grub_zalloc (sizeof (seg->nodes[0]) seg->nodes = grub_zalloc (sizeof (seg->nodes[0])
* seg->node_count); * seg->node_count);
@@ -625,7 +631,7 @@ grub_lvm_detect (grub_disk_t disk,
if (p == NULL) if (p == NULL)
{ {
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
grub_util_info ("unknown mirrors\n"); grub_util_info ("unknown raids");
#endif #endif
goto lvs_segment_fail2; goto lvs_segment_fail2;
} }
@@ -672,7 +678,7 @@ grub_lvm_detect (grub_disk_t disk,
p2 = grub_strchr (p, '"'); p2 = grub_strchr (p, '"');
if (p2) if (p2)
*p2 = 0; *p2 = 0;
grub_util_info ("unknown LVM type %s\n", p); grub_util_info ("unknown LVM type %s", p);
if (p2) if (p2)
*p2 ='"'; *p2 ='"';
#endif #endif
+13 -3
View File
@@ -63,6 +63,16 @@ grub_raid6_init_table (void)
} }
} }
static unsigned
mod_255 (unsigned x)
{
while (x > 0xff)
x = (x >> 8) + (x & 0xff);
if (x == 0xff)
return 0;
return x;
}
static grub_err_t static grub_err_t
grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p, grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p,
char *buf, grub_disk_addr_t sector, grub_size_t size) char *buf, grub_disk_addr_t sector, grub_size_t size)
@@ -162,11 +172,11 @@ grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p,
grub_crypto_xor (qbuf, qbuf, buf, size); grub_crypto_xor (qbuf, qbuf, buf, size);
c = ((255 ^ bad1) c = mod_255((255 ^ bad1)
+ (255 ^ powx_inv[(powx[bad2 + (bad1 ^ 255)] ^ 1)])) % 255; + (255 ^ powx_inv[(powx[bad2 + (bad1 ^ 255)] ^ 1)]));
grub_raid_block_mulx (c, qbuf, size); grub_raid_block_mulx (c, qbuf, size);
c = ((unsigned) bad2 + c) % 255; c = mod_255((unsigned) bad2 + c);
grub_raid_block_mulx (c, pbuf, size); grub_raid_block_mulx (c, pbuf, size);
grub_crypto_xor (pbuf, pbuf, qbuf, size); grub_crypto_xor (pbuf, pbuf, qbuf, size);
+3 -2
View File
@@ -615,9 +615,10 @@ grub_scsi_open (const char *name, grub_disk_t disk)
if (scsi->blocksize & (scsi->blocksize - 1) || !scsi->blocksize) if (scsi->blocksize & (scsi->blocksize - 1) || !scsi->blocksize)
{ {
grub_error (GRUB_ERR_IO, "invalid sector size %d",
scsi->blocksize);
grub_free (scsi); grub_free (scsi);
return grub_error (GRUB_ERR_IO, "invalid sector size %d", return grub_errno;
scsi->blocksize);
} }
for (disk->log_sector_size = 0; for (disk->log_sector_size = 0;
(1U << disk->log_sector_size) < scsi->blocksize; (1U << disk->log_sector_size) < scsi->blocksize;
+36 -9
View File
@@ -40,6 +40,7 @@ struct virtdisk
grub_xen_evtchn_t evtchn; grub_xen_evtchn_t evtchn;
void *dma_page; void *dma_page;
grub_xen_grant_t dma_grant; grub_xen_grant_t dma_grant;
struct virtdisk *compat_next;
}; };
#define xen_wmb() mb() #define xen_wmb() mb()
@@ -47,6 +48,7 @@ struct virtdisk
static struct virtdisk *virtdisks; static struct virtdisk *virtdisks;
static grub_size_t vdiskcnt; static grub_size_t vdiskcnt;
struct virtdisk *compat_head;
static int static int
grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data, grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
@@ -66,20 +68,32 @@ grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
static grub_err_t static grub_err_t
grub_virtdisk_open (const char *name, grub_disk_t disk) grub_virtdisk_open (const char *name, grub_disk_t disk)
{ {
grub_size_t i; int i;
grub_uint32_t secsize; grub_uint32_t secsize;
char fdir[200]; char fdir[200];
char *buf; char *buf;
int num = -1;
struct virtdisk *vd;
for (i = 0; i < vdiskcnt; i++) /* For compatibility with pv-grub legacy menu.lst accept hdX as disk name */
if (grub_strcmp (name, virtdisks[i].fullname) == 0) if (name[0] == 'h' && name[1] == 'd' && name[2])
{
num = grub_strtoul (name + 2, 0, 10);
if (grub_errno)
{
grub_errno = 0;
num = -1;
}
}
for (i = 0, vd = compat_head; vd; vd = vd->compat_next, i++)
if (i == num || grub_strcmp (name, vd->fullname) == 0)
break; break;
if (i == vdiskcnt) if (!vd)
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a virtdisk"); return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a virtdisk");
disk->data = &virtdisks[i]; disk->data = vd;
disk->id = i; disk->id = vd - virtdisks;
grub_snprintf (fdir, sizeof (fdir), "%s/sectors", virtdisks[i].backend_dir); grub_snprintf (fdir, sizeof (fdir), "%s/sectors", vd->backend_dir);
buf = grub_xenstore_get_file (fdir, NULL); buf = grub_xenstore_get_file (fdir, NULL);
if (!buf) if (!buf)
return grub_errno; return grub_errno;
@@ -87,8 +101,7 @@ grub_virtdisk_open (const char *name, grub_disk_t disk)
if (grub_errno) if (grub_errno)
return grub_errno; return grub_errno;
grub_snprintf (fdir, sizeof (fdir), "%s/sector-size", grub_snprintf (fdir, sizeof (fdir), "%s/sector-size", vd->backend_dir);
virtdisks[i].backend_dir);
buf = grub_xenstore_get_file (fdir, NULL); buf = grub_xenstore_get_file (fdir, NULL);
if (!buf) if (!buf)
return grub_errno; return grub_errno;
@@ -264,6 +277,7 @@ fill (const char *dir, void *data)
grub_err_t err; grub_err_t err;
void *buf; void *buf;
struct evtchn_alloc_unbound alloc_unbound; struct evtchn_alloc_unbound alloc_unbound;
struct virtdisk **prev = &compat_head, *vd = compat_head;
/* Shouldn't happen unles some hotplug happened. */ /* Shouldn't happen unles some hotplug happened. */
if (vdiskcnt >= *ctr) if (vdiskcnt >= *ctr)
@@ -374,6 +388,19 @@ fill (const char *dir, void *data)
virtdisks[vdiskcnt].frontend_dir = grub_strdup (fdir); virtdisks[vdiskcnt].frontend_dir = grub_strdup (fdir);
/* For compatibility with pv-grub maintain linked list sorted by handle
value in increasing order. This allows mapping of (hdX) disk names
from legacy menu.lst */
while (vd)
{
if (vd->handle > virtdisks[vdiskcnt].handle)
break;
prev = &vd->compat_next;
vd = vd->compat_next;
}
virtdisks[vdiskcnt].compat_next = vd;
*prev = &virtdisks[vdiskcnt];
vdiskcnt++; vdiskcnt++;
return 0; return 0;
+3 -1
View File
@@ -777,6 +777,7 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
if (grub_file_read (font->file, glyph->bitmap, len) != len) if (grub_file_read (font->file, glyph->bitmap, len) != len)
{ {
remove_font (font); remove_font (font);
grub_free (glyph);
return 0; return 0;
} }
} }
@@ -1285,7 +1286,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
- grub_font_get_xheight (combining_glyphs[i]->font) - 1; - grub_font_get_xheight (combining_glyphs[i]->font) - 1;
if (space <= 0) if (space <= 0)
space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8; space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8;
/* Fallthrough. */
case GRUB_UNICODE_STACK_ATTACHED_ABOVE: case GRUB_UNICODE_STACK_ATTACHED_ABOVE:
do_blit (combining_glyphs[i], targetx, do_blit (combining_glyphs[i], targetx,
-(ctx.bounds.height + ctx.bounds.y + space -(ctx.bounds.height + ctx.bounds.y + space
@@ -1326,6 +1327,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id,
+ combining_glyphs[i]->height); + combining_glyphs[i]->height);
if (space <= 0) if (space <= 0)
space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8; space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8;
/* Fallthrough. */
case GRUB_UNICODE_STACK_ATTACHED_BELOW: case GRUB_UNICODE_STACK_ATTACHED_BELOW:
do_blit (combining_glyphs[i], targetx, -(ctx.bounds.y - space), do_blit (combining_glyphs[i], targetx, -(ctx.bounds.y - space),
+4 -3
View File
@@ -34,12 +34,12 @@ canonicalize (char *name)
iptr++; iptr++;
if (iptr[0] == '.' && (iptr[1] == '/' || iptr[1] == 0)) if (iptr[0] == '.' && (iptr[1] == '/' || iptr[1] == 0))
{ {
iptr += 2; iptr++;
continue; continue;
} }
if (iptr[0] == '.' && iptr[1] == '.' && (iptr[2] == '/' || iptr[2] == 0)) if (iptr[0] == '.' && iptr[1] == '.' && (iptr[2] == '/' || iptr[2] == 0))
{ {
iptr += 3; iptr += 2;
if (optr == name) if (optr == name)
continue; continue;
for (optr -= 2; optr >= name && *optr != '/'; optr--); for (optr -= 2; optr >= name && *optr != '/'; optr--);
@@ -249,9 +249,10 @@ grub_archelp_open (struct grub_archelp_data *data,
while (1) while (1)
{ {
grub_uint32_t mode; grub_uint32_t mode;
grub_int32_t mtime;
int restart; int restart;
if (arcops->find_file (data, &fn, NULL, &mode)) if (arcops->find_file (data, &fn, &mtime, &mode))
goto fail; goto fail;
if (mode == GRUB_ARCHELP_ATTR_END) if (mode == GRUB_ARCHELP_ATTR_END)
+104 -117
View File
@@ -29,6 +29,7 @@
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/types.h> #include <grub/types.h>
#include <grub/i18n.h> #include <grub/i18n.h>
#include <grub/fshelp.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@@ -561,10 +562,10 @@ iterate_in_b_tree (grub_disk_t disk,
} }
static int static int
bfs_strcmp (const char *a, const char *b, grub_size_t alen, grub_size_t blen) bfs_strcmp (const char *a, const char *b, grub_size_t alen)
{ {
char ac, bc; char ac, bc;
while (blen && alen) while (*b && alen)
{ {
if (*a != *b) if (*a != *b)
break; break;
@@ -572,11 +573,10 @@ bfs_strcmp (const char *a, const char *b, grub_size_t alen, grub_size_t blen)
a++; a++;
b++; b++;
alen--; alen--;
blen--;
} }
ac = alen ? *a : 0; ac = alen ? *a : 0;
bc = blen ? *b : 0; bc = *b;
#ifdef MODE_AFS #ifdef MODE_AFS
return (int) (grub_int8_t) ac - (int) (grub_int8_t) bc; return (int) (grub_int8_t) ac - (int) (grub_int8_t) bc;
@@ -589,7 +589,6 @@ static grub_err_t
find_in_b_tree (grub_disk_t disk, find_in_b_tree (grub_disk_t disk,
const struct grub_bfs_superblock *sb, const struct grub_bfs_superblock *sb,
const struct grub_bfs_inode *ino, const char *name, const struct grub_bfs_inode *ino, const char *name,
grub_size_t name_len,
grub_uint64_t * res) grub_uint64_t * res)
{ {
struct grub_bfs_btree_header head; struct grub_bfs_btree_header head;
@@ -637,7 +636,7 @@ find_in_b_tree (grub_disk_t disk,
end = grub_bfs_to_cpu16 (keylen_idx[(i | (1 << j))]); end = grub_bfs_to_cpu16 (keylen_idx[(i | (1 << j))]);
if (grub_bfs_to_cpu_treehead (node->total_key_len) <= end) if (grub_bfs_to_cpu_treehead (node->total_key_len) <= end)
end = grub_bfs_to_cpu_treehead (node->total_key_len); end = grub_bfs_to_cpu_treehead (node->total_key_len);
cmp = bfs_strcmp (key_data + start, name, end - start, name_len); cmp = bfs_strcmp (key_data + start, name, end - start);
if (cmp == 0 && level == 0) if (cmp == 0 && level == 0)
{ {
*res = grub_bfs_to_cpu64 (key_values[i | (1 << j)].val); *res = grub_bfs_to_cpu64 (key_values[i | (1 << j)].val);
@@ -658,7 +657,7 @@ find_in_b_tree (grub_disk_t disk,
end = grub_bfs_to_cpu16 (keylen_idx[0]); end = grub_bfs_to_cpu16 (keylen_idx[0]);
if (grub_bfs_to_cpu_treehead (node->total_key_len) <= end) if (grub_bfs_to_cpu_treehead (node->total_key_len) <= end)
end = grub_bfs_to_cpu_treehead (node->total_key_len); end = grub_bfs_to_cpu_treehead (node->total_key_len);
cmp = bfs_strcmp (key_data, name, end, name_len); cmp = bfs_strcmp (key_data, name, end);
if (cmp == 0 && level == 0) if (cmp == 0 && level == 0)
{ {
*res = grub_bfs_to_cpu64 (key_values[0].val); *res = grub_bfs_to_cpu64 (key_values[0].val);
@@ -707,127 +706,119 @@ find_in_b_tree (grub_disk_t disk,
} }
} }
struct grub_fshelp_node
{
grub_disk_t disk;
const struct grub_bfs_superblock *sb;
struct grub_bfs_inode ino;
};
static grub_err_t static grub_err_t
hop_level (grub_disk_t disk, lookup_file (grub_fshelp_node_t dir,
const struct grub_bfs_superblock *sb, const char *name,
struct grub_bfs_inode *ino, const char *name, grub_fshelp_node_t *foundnode,
const char *name_end) enum grub_fshelp_filetype *foundtype)
{ {
grub_err_t err; grub_err_t err;
struct grub_bfs_inode *new_ino;
grub_uint64_t res = 0; grub_uint64_t res = 0;
if (((grub_bfs_to_cpu32 (ino->mode) & ATTR_TYPE) != ATTR_DIR)) err = find_in_b_tree (dir->disk, dir->sb, &dir->ino, name, &res);
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
err = find_in_b_tree (disk, sb, ino, name, name_end - name, &res);
if (err) if (err)
return err; return err;
return grub_disk_read (disk, res *foundnode = grub_malloc (sizeof (struct grub_fshelp_node));
<< (grub_bfs_to_cpu32 (sb->log2_bsize) if (!*foundnode)
- GRUB_DISK_SECTOR_BITS), 0, return grub_errno;
sizeof (*ino), (char *) ino);
(*foundnode)->disk = dir->disk;
(*foundnode)->sb = dir->sb;
new_ino = &(*foundnode)->ino;
if (grub_disk_read (dir->disk, res
<< (grub_bfs_to_cpu32 (dir->sb->log2_bsize)
- GRUB_DISK_SECTOR_BITS), 0,
sizeof (*new_ino), (char *) new_ino))
{
grub_free (*foundnode);
return grub_errno;
}
switch (grub_bfs_to_cpu32 (new_ino->mode) & ATTR_TYPE)
{
default:
case ATTR_REG:
*foundtype = GRUB_FSHELP_REG;
break;
case ATTR_DIR:
*foundtype = GRUB_FSHELP_DIR;
break;
case ATTR_LNK:
*foundtype = GRUB_FSHELP_SYMLINK;
break;
}
return GRUB_ERR_NONE;
}
static char *
read_symlink (grub_fshelp_node_t node)
{
char *alloc = NULL;
grub_err_t err;
#ifndef MODE_AFS
if (!(grub_bfs_to_cpu32 (node->ino.flags) & LONG_SYMLINK))
{
alloc = grub_malloc (sizeof (node->ino.inplace_link) + 1);
if (!alloc)
{
return NULL;
}
grub_memcpy (alloc, node->ino.inplace_link,
sizeof (node->ino.inplace_link));
alloc[sizeof (node->ino.inplace_link)] = 0;
}
else
#endif
{
grub_size_t symsize = grub_bfs_to_cpu64 (node->ino.size);
alloc = grub_malloc (symsize + 1);
if (!alloc)
return NULL;
err = read_bfs_file (node->disk, node->sb, &node->ino, 0, alloc, symsize, 0, 0);
if (err)
{
grub_free (alloc);
return NULL;
}
alloc[symsize] = 0;
}
return alloc;
} }
static grub_err_t static grub_err_t
find_file (const char *path, grub_disk_t disk, find_file (const char *path, grub_disk_t disk,
const struct grub_bfs_superblock *sb, struct grub_bfs_inode *ino) const struct grub_bfs_superblock *sb, struct grub_bfs_inode *ino,
enum grub_fshelp_filetype exptype)
{ {
const char *ptr, *next = path;
char *alloc = NULL;
char *wptr;
grub_err_t err; grub_err_t err;
struct grub_bfs_inode old_ino; struct grub_fshelp_node root = {
unsigned symlinks_max = 32; .disk = disk,
.sb = sb,
};
struct grub_fshelp_node *found;
err = read_extent (disk, sb, &sb->root_dir, 0, 0, ino, err = read_extent (disk, sb, &sb->root_dir, 0, 0, &root.ino,
sizeof (*ino)); sizeof (root.ino));
if (err) if (err)
return err; return err;
err = grub_fshelp_find_file_lookup (path, &root, &found, lookup_file, read_symlink, exptype);
if (!err)
grub_memcpy (ino, &found->ino, sizeof (*ino));
while (1) if (&root != found)
{ grub_free (found);
ptr = next; return err;
while (*ptr == '/')
ptr++;
if (*ptr == 0)
{
grub_free (alloc);
return GRUB_ERR_NONE;
}
for (next = ptr; *next && *next != '/'; next++);
grub_memcpy (&old_ino, ino, sizeof (old_ino));
err = hop_level (disk, sb, ino, ptr, next);
if (err)
return err;
if (((grub_bfs_to_cpu32 (ino->mode) & ATTR_TYPE) == ATTR_LNK))
{
char *old_alloc = alloc;
if (--symlinks_max == 0)
{
grub_free (alloc);
return grub_error (GRUB_ERR_SYMLINK_LOOP,
N_("too deep nesting of symlinks"));
}
#ifndef MODE_AFS
if (grub_bfs_to_cpu32 (ino->flags) & LONG_SYMLINK)
#endif
{
grub_size_t symsize = grub_bfs_to_cpu64 (ino->size);
alloc = grub_malloc (grub_strlen (next)
+ symsize + 1);
if (!alloc)
{
grub_free (alloc);
return grub_errno;
}
grub_free (old_alloc);
err = read_bfs_file (disk, sb, ino, 0, alloc, symsize, 0, 0);
if (err)
{
grub_free (alloc);
return err;
}
alloc[symsize] = 0;
}
#ifndef MODE_AFS
else
{
alloc = grub_malloc (grub_strlen (next)
+ sizeof (ino->inplace_link) + 1);
if (!alloc)
{
grub_free (alloc);
return grub_errno;
}
grub_free (old_alloc);
grub_memcpy (alloc, ino->inplace_link,
sizeof (ino->inplace_link));
alloc[sizeof (ino->inplace_link)] = 0;
}
#endif
if (alloc[0] == '/')
{
err = read_extent (disk, sb, &sb->root_dir, 0, 0, ino,
sizeof (*ino));
if (err)
{
grub_free (alloc);
return err;
}
}
else
grub_memcpy (ino, &old_ino, sizeof (old_ino));
wptr = alloc + grub_strlen (alloc);
if (next)
wptr = grub_stpcpy (wptr, next);
*wptr = 0;
next = alloc;
continue;
}
}
} }
static grub_err_t static grub_err_t
@@ -909,11 +900,9 @@ grub_bfs_dir (grub_device_t device, const char *path,
{ {
struct grub_bfs_inode ino; struct grub_bfs_inode ino;
err = find_file (path, device->disk, &ctx.sb, &ino); err = find_file (path, device->disk, &ctx.sb, &ino, GRUB_FSHELP_DIR);
if (err) if (err)
return err; return err;
if (((grub_bfs_to_cpu32 (ino.mode) & ATTR_TYPE) != ATTR_DIR))
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
iterate_in_b_tree (device->disk, &ctx.sb, &ino, grub_bfs_dir_iter, iterate_in_b_tree (device->disk, &ctx.sb, &ino, grub_bfs_dir_iter,
&ctx); &ctx);
} }
@@ -934,11 +923,9 @@ grub_bfs_open (struct grub_file *file, const char *name)
{ {
struct grub_bfs_inode ino; struct grub_bfs_inode ino;
struct grub_bfs_data *data; struct grub_bfs_data *data;
err = find_file (name, file->device->disk, &sb, &ino); err = find_file (name, file->device->disk, &sb, &ino, GRUB_FSHELP_REG);
if (err) if (err)
return err; return err;
if (((grub_bfs_to_cpu32 (ino.mode) & ATTR_TYPE) != ATTR_REG))
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
data = grub_zalloc (sizeof (struct grub_bfs_data)); data = grub_zalloc (sizeof (struct grub_bfs_data));
if (!data) if (!data)
@@ -1034,7 +1021,7 @@ read_bfs_attr (grub_disk_t disk,
if (err) if (err)
return -1; return -1;
err = find_in_b_tree (disk, sb, ino, name, grub_strlen (name), &res); err = find_in_b_tree (disk, sb, ino, name, &res);
if (err) if (err)
return -1; return -1;
grub_disk_read (disk, res grub_disk_read (disk, res
+3 -3
View File
@@ -74,8 +74,7 @@ grub_cbfs_find_file (struct grub_archelp_data *data, char **name,
(void) mtime; (void) mtime;
offset = grub_be_to_cpu32 (hd.offset); offset = grub_be_to_cpu32 (hd.offset);
if (mode) *mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME;
*mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME;
namesize = offset; namesize = offset;
if (namesize >= sizeof (hd)) if (namesize >= sizeof (hd))
@@ -144,7 +143,7 @@ static struct grub_archelp_data *
grub_cbfs_mount (grub_disk_t disk) grub_cbfs_mount (grub_disk_t disk)
{ {
struct cbfs_file hd; struct cbfs_file hd;
struct grub_archelp_data *data; struct grub_archelp_data *data = NULL;
grub_uint32_t ptr; grub_uint32_t ptr;
grub_off_t header_off; grub_off_t header_off;
struct cbfs_header head; struct cbfs_header head;
@@ -196,6 +195,7 @@ grub_cbfs_mount (grub_disk_t disk)
return data; return data;
fail: fail:
grub_free (data);
grub_error (GRUB_ERR_BAD_FS, "not a cbfs filesystem"); grub_error (GRUB_ERR_BAD_FS, "not a cbfs filesystem");
return 0; return 0;
} }
+9 -2
View File
@@ -61,8 +61,15 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name,
modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode)); modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode));
namesize = read_number (hd.namesize, ARRAY_SIZE (hd.namesize)); namesize = read_number (hd.namesize, ARRAY_SIZE (hd.namesize));
if (mode) /* Don't allow negative numbers. */
*mode = modeval; if (namesize >= 0x80000000)
{
/* Probably a corruption, don't attempt to recover. */
*mode = GRUB_ARCHELP_ATTR_END;
return GRUB_ERR_NONE;
}
*mode = modeval;
*name = grub_malloc (namesize + 1); *name = grub_malloc (namesize + 1);
if (*name == NULL) if (*name == NULL)
+69 -9
View File
@@ -100,6 +100,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010 #define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* Extents used */ #define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* Extents used */
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
/* The set of back-incompatible features this driver DOES support. Add (OR) /* The set of back-incompatible features this driver DOES support. Add (OR)
@@ -107,6 +108,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define EXT2_DRIVER_SUPPORTED_INCOMPAT ( EXT2_FEATURE_INCOMPAT_FILETYPE \ #define EXT2_DRIVER_SUPPORTED_INCOMPAT ( EXT2_FEATURE_INCOMPAT_FILETYPE \
| EXT4_FEATURE_INCOMPAT_EXTENTS \ | EXT4_FEATURE_INCOMPAT_EXTENTS \
| EXT4_FEATURE_INCOMPAT_FLEX_BG \ | EXT4_FEATURE_INCOMPAT_FLEX_BG \
| EXT2_FEATURE_INCOMPAT_META_BG \
| EXT4_FEATURE_INCOMPAT_64BIT) | EXT4_FEATURE_INCOMPAT_64BIT)
/* List of rationales for the ignored "incompatible" features: /* List of rationales for the ignored "incompatible" features:
* needs_recovery: Not really back-incompatible - was added as such to forbid * needs_recovery: Not really back-incompatible - was added as such to forbid
@@ -114,8 +116,13 @@ GRUB_MOD_LICENSE ("GPLv3+");
* journal because they will ignore the journal, but the next * journal because they will ignore the journal, but the next
* ext3 driver to mount the volume will find the journal and * ext3 driver to mount the volume will find the journal and
* replay it, potentially corrupting the metadata written by * replay it, potentially corrupting the metadata written by
* the ext2 drivers. Safe to ignore for this RO driver. */ * the ext2 drivers. Safe to ignore for this RO driver.
#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER ) * mmp: Not really back-incompatible - was added as such to
* avoid multiple read-write mounts. Safe to ignore for this
* RO driver.
*/
#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER \
| EXT4_FEATURE_INCOMPAT_MMP)
#define EXT3_JOURNAL_MAGIC_NUMBER 0xc03b3998U #define EXT3_JOURNAL_MAGIC_NUMBER 0xc03b3998U
@@ -331,16 +338,68 @@ static grub_dl_t my_mod;
/* Check is a = b^x for some x. */
static inline int
is_power_of (grub_uint64_t a, grub_uint32_t b)
{
grub_uint64_t c;
/* Prevent overflow assuming b < 8. */
if (a >= (1LL << 60))
return 0;
for (c = 1; c <= a; c *= b);
return (c == a);
}
static inline int
group_has_super_block (struct grub_ext2_data *data, grub_uint64_t group)
{
if (!(data->sblock.feature_ro_compat
& grub_cpu_to_le32_compile_time(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)))
return 1;
/* Algorithm looked up in Linux source. */
if (group <= 1)
return 1;
/* Even number is never a power of odd number. */
if (!(group & 1))
return 0;
return (is_power_of(group, 7) || is_power_of(group, 5) ||
is_power_of(group, 3));
}
/* Read into BLKGRP the blockgroup descriptor of blockgroup GROUP of /* Read into BLKGRP the blockgroup descriptor of blockgroup GROUP of
the mounted filesystem DATA. */ the mounted filesystem DATA. */
inline static grub_err_t inline static grub_err_t
grub_ext2_blockgroup (struct grub_ext2_data *data, int group, grub_ext2_blockgroup (struct grub_ext2_data *data, grub_uint64_t group,
struct grub_ext2_block_group *blkgrp) struct grub_ext2_block_group *blkgrp)
{ {
grub_uint64_t full_offset = (group << data->log_group_desc_size);
grub_uint64_t block, offset;
block = (full_offset >> LOG2_BLOCK_SIZE (data));
offset = (full_offset & ((1 << LOG2_BLOCK_SIZE (data)) - 1));
if ((data->sblock.feature_incompat
& grub_cpu_to_le32_compile_time (EXT2_FEATURE_INCOMPAT_META_BG))
&& block >= grub_le_to_cpu32(data->sblock.first_meta_bg))
{
grub_uint64_t first_block_group;
/* Find the first block group for which a descriptor
is stored in given block. */
first_block_group = (block << (LOG2_BLOCK_SIZE (data)
- data->log_group_desc_size));
block = (first_block_group
* grub_le_to_cpu32(data->sblock.blocks_per_group));
if (group_has_super_block (data, first_block_group))
block++;
}
else
/* Superblock. */
block++;
return grub_disk_read (data->disk, return grub_disk_read (data->disk,
((grub_le_to_cpu32 (data->sblock.first_data_block) + 1) ((grub_le_to_cpu32 (data->sblock.first_data_block)
<< LOG2_EXT2_BLOCK_SIZE (data)), + block)
group << data->log_group_desc_size, << LOG2_EXT2_BLOCK_SIZE (data)), offset,
sizeof (struct grub_ext2_block_group), blkgrp); sizeof (struct grub_ext2_block_group), blkgrp);
} }
@@ -479,8 +538,9 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
shift = 2; shift = 2;
goto indirect; goto indirect;
} }
return grub_error (GRUB_ERR_BAD_FS, grub_error (GRUB_ERR_BAD_FS,
"ext2fs doesn't support quadruple indirect blocks"); "ext2fs doesn't support quadruple indirect blocks");
return -1;
indirect: indirect:
do { do {
@@ -495,7 +555,7 @@ indirect:
& ((1 << log_perblock) - 1)) & ((1 << log_perblock) - 1))
* sizeof (indir), * sizeof (indir),
sizeof (indir), &indir)) sizeof (indir), &indir))
return grub_errno; return -1;
} while (shift--); } while (shift--);
return grub_le_to_cpu32 (indir); return grub_le_to_cpu32 (indir);
+174 -170
View File
@@ -31,6 +31,7 @@
#else #else
#include <grub/exfat.h> #include <grub/exfat.h>
#endif #endif
#include <grub/fshelp.h>
#include <grub/i18n.h> #include <grub/i18n.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@@ -173,8 +174,6 @@ struct grub_fat_data
#ifndef MODE_EXFAT #ifndef MODE_EXFAT
grub_uint32_t root_sector; grub_uint32_t root_sector;
grub_uint32_t num_root_sectors; grub_uint32_t num_root_sectors;
#else
int is_contiguous;
#endif #endif
int cluster_bits; int cluster_bits;
@@ -182,13 +181,22 @@ struct grub_fat_data
grub_uint32_t cluster_sector; grub_uint32_t cluster_sector;
grub_uint32_t num_clusters; grub_uint32_t num_clusters;
grub_uint32_t uuid;
};
struct grub_fshelp_node {
grub_disk_t disk;
struct grub_fat_data *data;
grub_uint8_t attr; grub_uint8_t attr;
grub_ssize_t file_size; grub_ssize_t file_size;
grub_uint32_t file_cluster; grub_uint32_t file_cluster;
grub_uint32_t cur_cluster_num; grub_uint32_t cur_cluster_num;
grub_uint32_t cur_cluster; grub_uint32_t cur_cluster;
grub_uint32_t uuid; #ifdef MODE_EXFAT
int is_contiguous;
#endif
}; };
static grub_dl_t my_mod; static grub_dl_t my_mod;
@@ -427,13 +435,6 @@ grub_fat_mount (grub_disk_t disk)
(void) magic; (void) magic;
#endif #endif
/* Start from the root directory. */
data->file_cluster = data->root_cluster;
data->cur_cluster_num = ~0U;
data->attr = GRUB_FAT_ATTR_DIRECTORY;
#ifdef MODE_EXFAT
data->is_contiguous = 0;
#endif
return data; return data;
fail: fail:
@@ -444,7 +445,7 @@ grub_fat_mount (grub_disk_t disk)
} }
static grub_ssize_t static grub_ssize_t
grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data, grub_fat_read_data (grub_disk_t disk, grub_fshelp_node_t node,
grub_disk_read_hook_t read_hook, void *read_hook_data, grub_disk_read_hook_t read_hook, void *read_hook_data,
grub_off_t offset, grub_size_t len, char *buf) grub_off_t offset, grub_size_t len, char *buf)
{ {
@@ -457,13 +458,13 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
#ifndef MODE_EXFAT #ifndef MODE_EXFAT
/* This is a special case. FAT12 and FAT16 doesn't have the root directory /* This is a special case. FAT12 and FAT16 doesn't have the root directory
in clusters. */ in clusters. */
if (data->file_cluster == ~0U) if (node->file_cluster == ~0U)
{ {
size = (data->num_root_sectors << GRUB_DISK_SECTOR_BITS) - offset; size = (node->data->num_root_sectors << GRUB_DISK_SECTOR_BITS) - offset;
if (size > len) if (size > len)
size = len; size = len;
if (grub_disk_read (disk, data->root_sector, offset, size, buf)) if (grub_disk_read (disk, node->data->root_sector, offset, size, buf))
return -1; return -1;
return size; return size;
@@ -471,12 +472,12 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
#endif #endif
#ifdef MODE_EXFAT #ifdef MODE_EXFAT
if (data->is_contiguous) if (node->is_contiguous)
{ {
/* Read the data here. */ /* Read the data here. */
sector = (data->cluster_sector sector = (node->data->cluster_sector
+ ((data->file_cluster - 2) + ((node->file_cluster - 2)
<< data->cluster_bits)); << node->data->cluster_bits));
disk->read_hook = read_hook; disk->read_hook = read_hook;
disk->read_hook_data = read_hook_data; disk->read_hook_data = read_hook_data;
@@ -491,53 +492,53 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
#endif #endif
/* Calculate the logical cluster number and offset. */ /* Calculate the logical cluster number and offset. */
logical_cluster_bits = (data->cluster_bits logical_cluster_bits = (node->data->cluster_bits
+ GRUB_DISK_SECTOR_BITS); + GRUB_DISK_SECTOR_BITS);
logical_cluster = offset >> logical_cluster_bits; logical_cluster = offset >> logical_cluster_bits;
offset &= (1ULL << logical_cluster_bits) - 1; offset &= (1ULL << logical_cluster_bits) - 1;
if (logical_cluster < data->cur_cluster_num) if (logical_cluster < node->cur_cluster_num)
{ {
data->cur_cluster_num = 0; node->cur_cluster_num = 0;
data->cur_cluster = data->file_cluster; node->cur_cluster = node->file_cluster;
} }
while (len) while (len)
{ {
while (logical_cluster > data->cur_cluster_num) while (logical_cluster > node->cur_cluster_num)
{ {
/* Find next cluster. */ /* Find next cluster. */
grub_uint32_t next_cluster; grub_uint32_t next_cluster;
grub_uint32_t fat_offset; grub_uint32_t fat_offset;
switch (data->fat_size) switch (node->data->fat_size)
{ {
case 32: case 32:
fat_offset = data->cur_cluster << 2; fat_offset = node->cur_cluster << 2;
break; break;
case 16: case 16:
fat_offset = data->cur_cluster << 1; fat_offset = node->cur_cluster << 1;
break; break;
default: default:
/* case 12: */ /* case 12: */
fat_offset = data->cur_cluster + (data->cur_cluster >> 1); fat_offset = node->cur_cluster + (node->cur_cluster >> 1);
break; break;
} }
/* Read the FAT. */ /* Read the FAT. */
if (grub_disk_read (disk, data->fat_sector, fat_offset, if (grub_disk_read (disk, node->data->fat_sector, fat_offset,
(data->fat_size + 7) >> 3, (node->data->fat_size + 7) >> 3,
(char *) &next_cluster)) (char *) &next_cluster))
return -1; return -1;
next_cluster = grub_le_to_cpu32 (next_cluster); next_cluster = grub_le_to_cpu32 (next_cluster);
switch (data->fat_size) switch (node->data->fat_size)
{ {
case 16: case 16:
next_cluster &= 0xFFFF; next_cluster &= 0xFFFF;
break; break;
case 12: case 12:
if (data->cur_cluster & 1) if (node->cur_cluster & 1)
next_cluster >>= 4; next_cluster >>= 4;
next_cluster &= 0x0FFF; next_cluster &= 0x0FFF;
@@ -545,27 +546,27 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data,
} }
grub_dprintf ("fat", "fat_size=%d, next_cluster=%u\n", grub_dprintf ("fat", "fat_size=%d, next_cluster=%u\n",
data->fat_size, next_cluster); node->data->fat_size, next_cluster);
/* Check the end. */ /* Check the end. */
if (next_cluster >= data->cluster_eof_mark) if (next_cluster >= node->data->cluster_eof_mark)
return ret; return ret;
if (next_cluster < 2 || next_cluster >= data->num_clusters) if (next_cluster < 2 || next_cluster >= node->data->num_clusters)
{ {
grub_error (GRUB_ERR_BAD_FS, "invalid cluster %u", grub_error (GRUB_ERR_BAD_FS, "invalid cluster %u",
next_cluster); next_cluster);
return -1; return -1;
} }
data->cur_cluster = next_cluster; node->cur_cluster = next_cluster;
data->cur_cluster_num++; node->cur_cluster_num++;
} }
/* Read the data here. */ /* Read the data here. */
sector = (data->cluster_sector sector = (node->data->cluster_sector
+ ((data->cur_cluster - 2) + ((node->cur_cluster - 2)
<< data->cluster_bits)); << node->data->cluster_bits));
size = (1 << logical_cluster_bits) - offset; size = (1 << logical_cluster_bits) - offset;
if (size > len) if (size > len)
size = len; size = len;
@@ -631,7 +632,7 @@ grub_fat_iterate_fini (struct grub_fat_iterate_context *ctxt)
#ifdef MODE_EXFAT #ifdef MODE_EXFAT
static grub_err_t static grub_err_t
grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, grub_fat_iterate_dir_next (grub_fshelp_node_t node,
struct grub_fat_iterate_context *ctxt) struct grub_fat_iterate_context *ctxt)
{ {
grub_memset (&ctxt->dir, 0, sizeof (ctxt->dir)); grub_memset (&ctxt->dir, 0, sizeof (ctxt->dir));
@@ -641,7 +642,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
ctxt->offset += sizeof (dir); ctxt->offset += sizeof (dir);
if (grub_fat_read_data (disk, data, 0, 0, ctxt->offset, sizeof (dir), if (grub_fat_read_data (node->disk, node, 0, 0, ctxt->offset, sizeof (dir),
(char *) &dir) (char *) &dir)
!= sizeof (dir)) != sizeof (dir))
break; break;
@@ -663,7 +664,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
{ {
struct grub_fat_dir_entry sec; struct grub_fat_dir_entry sec;
ctxt->offset += sizeof (sec); ctxt->offset += sizeof (sec);
if (grub_fat_read_data (disk, data, 0, 0, if (grub_fat_read_data (node->disk, node, 0, 0,
ctxt->offset, sizeof (sec), (char *) &sec) ctxt->offset, sizeof (sec), (char *) &sec)
!= sizeof (sec)) != sizeof (sec))
break; break;
@@ -727,7 +728,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
#else #else
static grub_err_t static grub_err_t
grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, grub_fat_iterate_dir_next (grub_fshelp_node_t node,
struct grub_fat_iterate_context *ctxt) struct grub_fat_iterate_context *ctxt)
{ {
char *filep = 0; char *filep = 0;
@@ -742,7 +743,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
ctxt->offset += sizeof (ctxt->dir); ctxt->offset += sizeof (ctxt->dir);
/* Read a directory entry. */ /* Read a directory entry. */
if (grub_fat_read_data (disk, data, 0, 0, if (grub_fat_read_data (node->disk, node, 0, 0,
ctxt->offset, sizeof (ctxt->dir), ctxt->offset, sizeof (ctxt->dir),
(char *) &ctxt->dir) (char *) &ctxt->dir)
!= sizeof (ctxt->dir) || ctxt->dir.name[0] == 0) != sizeof (ctxt->dir) || ctxt->dir.name[0] == 0)
@@ -829,7 +830,9 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
i--; i--;
} }
*filep++ = '.'; /* XXX should we check that dir position is 0 or 1? */
if (i > 2 || filep[0] != '.' || (i == 2 && filep[1] != '.'))
*filep++ = '.';
for (i = 8; i < 11 && ctxt->dir.name[i]; i++) for (i = 8; i < 11 && ctxt->dir.name[i]; i++)
*filep++ = grub_tolower (ctxt->dir.name[i]); *filep++ = grub_tolower (ctxt->dir.name[i]);
@@ -851,62 +854,20 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data,
#endif #endif
/* Find the underlying directory or file in PATH and return the static grub_err_t lookup_file (grub_fshelp_node_t node,
next path. If there is no next path or an error occurs, return NULL. const char *name,
If HOOK is specified, call it with each file name. */ grub_fshelp_node_t *foundnode,
static char * enum grub_fshelp_filetype *foundtype)
grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
const char *path, const char *origpath,
grub_fs_dir_hook_t hook, void *hook_data)
{ {
char *dirname, *dirp;
int call_hook;
int found = 0;
struct grub_fat_iterate_context ctxt;
grub_err_t err; grub_err_t err;
struct grub_fat_iterate_context ctxt;
if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY))
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
return 0;
}
/* Extract a directory name. */
while (*path == '/')
path++;
dirp = grub_strchr (path, '/');
if (dirp)
{
unsigned len = dirp - path;
dirname = grub_malloc (len + 1);
if (! dirname)
goto fail;
grub_memcpy (dirname, path, len);
dirname[len] = '\0';
}
else
/* This is actually a file. */
dirname = grub_strdup (path);
call_hook = (! dirp && hook);
err = grub_fat_iterate_init (&ctxt); err = grub_fat_iterate_init (&ctxt);
if (err) if (err)
{ return err;
grub_free (dirname);
return 0;
}
while (!(err = grub_fat_iterate_dir_next (disk, data, &ctxt))) while (!(err = grub_fat_iterate_dir_next (node, &ctxt)))
{ {
struct grub_dirhook_info info;
grub_memset (&info, 0, sizeof (info));
info.dir = !! (ctxt.dir.attr & GRUB_FAT_ATTR_DIRECTORY);
info.case_insensitive = 1;
#ifdef MODE_EXFAT #ifdef MODE_EXFAT
if (!ctxt.dir.have_stream) if (!ctxt.dir.have_stream)
@@ -915,33 +876,33 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
if (ctxt.dir.attr & GRUB_FAT_ATTR_VOLUME_ID) if (ctxt.dir.attr & GRUB_FAT_ATTR_VOLUME_ID)
continue; continue;
#endif #endif
if (*dirname == '\0' && call_hook)
{
if (hook (ctxt.filename, &info, hook_data))
break;
else
continue;
}
if (grub_strcasecmp (dirname, ctxt.filename) == 0) if (grub_strcasecmp (name, ctxt.filename) == 0)
{ {
found = 1; *foundnode = grub_malloc (sizeof (struct grub_fshelp_node));
data->attr = ctxt.dir.attr; if (!*foundnode)
return grub_errno;
(*foundnode)->attr = ctxt.dir.attr;
#ifdef MODE_EXFAT #ifdef MODE_EXFAT
data->file_size = ctxt.dir.file_size; (*foundnode)->file_size = ctxt.dir.file_size;
data->file_cluster = ctxt.dir.first_cluster; (*foundnode)->file_cluster = ctxt.dir.first_cluster;
data->is_contiguous = ctxt.dir.is_contiguous; (*foundnode)->is_contiguous = ctxt.dir.is_contiguous;
#else #else
data->file_size = grub_le_to_cpu32 (ctxt.dir.file_size); (*foundnode)->file_size = grub_le_to_cpu32 (ctxt.dir.file_size);
data->file_cluster = ((grub_le_to_cpu16 (ctxt.dir.first_cluster_high) << 16) (*foundnode)->file_cluster = ((grub_le_to_cpu16 (ctxt.dir.first_cluster_high) << 16)
| grub_le_to_cpu16 (ctxt.dir.first_cluster_low)); | grub_le_to_cpu16 (ctxt.dir.first_cluster_low));
/* If directory points to root, starting cluster is 0 */
if (!(*foundnode)->file_cluster)
(*foundnode)->file_cluster = node->data->root_cluster;
#endif #endif
data->cur_cluster_num = ~0U; (*foundnode)->cur_cluster_num = ~0U;
(*foundnode)->data = node->data;
(*foundnode)->disk = node->disk;
if (call_hook) *foundtype = ((*foundnode)->attr & GRUB_FAT_ATTR_DIRECTORY) ? GRUB_FSHELP_DIR : GRUB_FSHELP_REG;
hook (ctxt.filename, &info, hook_data);
break; grub_fat_iterate_fini (&ctxt);
return GRUB_ERR_NONE;
} }
} }
@@ -949,13 +910,8 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data,
if (err == GRUB_ERR_EOF) if (err == GRUB_ERR_EOF)
err = 0; err = 0;
if (grub_errno == GRUB_ERR_NONE && ! found && !call_hook) return err;
grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
fail:
grub_free (dirname);
return found ? dirp : 0;
} }
static grub_err_t static grub_err_t
@@ -964,9 +920,9 @@ grub_fat_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
{ {
struct grub_fat_data *data = 0; struct grub_fat_data *data = 0;
grub_disk_t disk = device->disk; grub_disk_t disk = device->disk;
grub_size_t len; grub_fshelp_node_t found = NULL;
char *dirname = 0; grub_err_t err;
char *p; struct grub_fat_iterate_context ctxt;
grub_dl_ref (my_mod); grub_dl_ref (my_mod);
@@ -974,27 +930,53 @@ grub_fat_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
if (! data) if (! data)
goto fail; goto fail;
/* Make sure that DIRNAME terminates with '/'. */ struct grub_fshelp_node root = {
len = grub_strlen (path); .data = data,
dirname = grub_malloc (len + 1 + 1); .disk = disk,
if (! dirname) .attr = GRUB_FAT_ATTR_DIRECTORY,
goto fail; .file_size = 0,
grub_memcpy (dirname, path, len); .file_cluster = data->root_cluster,
p = dirname + len; .cur_cluster_num = ~0U,
if (path[len - 1] != '/') .cur_cluster = 0,
*p++ = '/'; #ifdef MODE_EXFAT
*p = '\0'; .is_contiguous = 0,
p = dirname; #endif
};
do err = grub_fshelp_find_file_lookup (path, &root, &found, lookup_file, NULL, GRUB_FSHELP_DIR);
if (err)
goto fail;
err = grub_fat_iterate_init (&ctxt);
if (err)
goto fail;
while (!(err = grub_fat_iterate_dir_next (found, &ctxt)))
{ {
p = grub_fat_find_dir (disk, data, p, path, hook, hook_data); struct grub_dirhook_info info;
grub_memset (&info, 0, sizeof (info));
info.dir = !! (ctxt.dir.attr & GRUB_FAT_ATTR_DIRECTORY);
info.case_insensitive = 1;
#ifdef MODE_EXFAT
if (!ctxt.dir.have_stream)
continue;
#else
if (ctxt.dir.attr & GRUB_FAT_ATTR_VOLUME_ID)
continue;
#endif
if (hook (ctxt.filename, &info, hook_data))
break;
} }
while (p && grub_errno == GRUB_ERR_NONE); grub_fat_iterate_fini (&ctxt);
if (err == GRUB_ERR_EOF)
err = 0;
fail: fail:
if (found != &root)
grub_free (found);
grub_free (dirname);
grub_free (data); grub_free (data);
grub_dl_unref (my_mod); grub_dl_unref (my_mod);
@@ -1006,35 +988,43 @@ static grub_err_t
grub_fat_open (grub_file_t file, const char *name) grub_fat_open (grub_file_t file, const char *name)
{ {
struct grub_fat_data *data = 0; struct grub_fat_data *data = 0;
char *p = (char *) name; grub_fshelp_node_t found = NULL;
grub_err_t err;
grub_disk_t disk = file->device->disk;
grub_dl_ref (my_mod); grub_dl_ref (my_mod);
data = grub_fat_mount (file->device->disk); data = grub_fat_mount (disk);
if (! data) if (! data)
goto fail; goto fail;
do struct grub_fshelp_node root = {
{ .data = data,
p = grub_fat_find_dir (file->device->disk, data, p, name, 0, 0); .disk = disk,
if (grub_errno != GRUB_ERR_NONE) .attr = GRUB_FAT_ATTR_DIRECTORY,
goto fail; .file_size = 0,
} .file_cluster = data->root_cluster,
while (p); .cur_cluster_num = ~0U,
.cur_cluster = 0,
#ifdef MODE_EXFAT
.is_contiguous = 0,
#endif
};
if (data->attr & GRUB_FAT_ATTR_DIRECTORY) err = grub_fshelp_find_file_lookup (name, &root, &found, lookup_file, NULL, GRUB_FSHELP_REG);
{ if (err)
grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file")); goto fail;
goto fail;
}
file->data = data; file->data = found;
file->size = data->file_size; file->size = found->file_size;
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
fail: fail:
if (found != &root)
grub_free (found);
grub_free (data); grub_free (data);
grub_dl_unref (my_mod); grub_dl_unref (my_mod);
@@ -1053,7 +1043,10 @@ grub_fat_read (grub_file_t file, char *buf, grub_size_t len)
static grub_err_t static grub_err_t
grub_fat_close (grub_file_t file) grub_fat_close (grub_file_t file)
{ {
grub_free (file->data); grub_fshelp_node_t node = file->data;
grub_free (node->data);
grub_free (node);
grub_dl_unref (my_mod); grub_dl_unref (my_mod);
@@ -1066,20 +1059,29 @@ grub_fat_label (grub_device_t device, char **label)
{ {
struct grub_fat_dir_entry dir; struct grub_fat_dir_entry dir;
grub_ssize_t offset = -sizeof(dir); grub_ssize_t offset = -sizeof(dir);
struct grub_fat_data *data;
grub_disk_t disk = device->disk; grub_disk_t disk = device->disk;
struct grub_fshelp_node root = {
.disk = disk,
.attr = GRUB_FAT_ATTR_DIRECTORY,
.file_size = 0,
.cur_cluster_num = ~0U,
.cur_cluster = 0,
.is_contiguous = 0,
};
data = grub_fat_mount (disk); root.data = grub_fat_mount (disk);
if (! data) if (! root.data)
return grub_errno; return grub_errno;
root.file_cluster = root.data->root_cluster;
*label = NULL; *label = NULL;
while (1) while (1)
{ {
offset += sizeof (dir); offset += sizeof (dir);
if (grub_fat_read_data (disk, data, 0, 0, if (grub_fat_read_data (disk, &root, 0, 0,
offset, sizeof (dir), (char *) &dir) offset, sizeof (dir), (char *) &dir)
!= sizeof (dir)) != sizeof (dir))
break; break;
@@ -1099,7 +1101,7 @@ grub_fat_label (grub_device_t device, char **label)
* GRUB_MAX_UTF8_PER_UTF16 + 1); * GRUB_MAX_UTF8_PER_UTF16 + 1);
if (!*label) if (!*label)
{ {
grub_free (data); grub_free (root.data);
return grub_errno; return grub_errno;
} }
chc = dir.type_specific.volume_label.character_count; chc = dir.type_specific.volume_label.character_count;
@@ -1111,7 +1113,7 @@ grub_fat_label (grub_device_t device, char **label)
} }
} }
grub_free (data); grub_free (root.data);
return grub_errno; return grub_errno;
} }
@@ -1120,30 +1122,32 @@ grub_fat_label (grub_device_t device, char **label)
static grub_err_t static grub_err_t
grub_fat_label (grub_device_t device, char **label) grub_fat_label (grub_device_t device, char **label)
{ {
struct grub_fat_data *data;
grub_disk_t disk = device->disk; grub_disk_t disk = device->disk;
grub_err_t err; grub_err_t err;
struct grub_fat_iterate_context ctxt; struct grub_fat_iterate_context ctxt;
struct grub_fshelp_node root = {
.disk = disk,
.attr = GRUB_FAT_ATTR_DIRECTORY,
.file_size = 0,
.cur_cluster_num = ~0U,
.cur_cluster = 0,
};
*label = 0; *label = 0;
grub_dl_ref (my_mod); grub_dl_ref (my_mod);
data = grub_fat_mount (disk); root.data = grub_fat_mount (disk);
if (! data) if (! root.data)
goto fail; goto fail;
if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY)) root.file_cluster = root.data->root_cluster;
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
return 0;
}
err = grub_fat_iterate_init (&ctxt); err = grub_fat_iterate_init (&ctxt);
if (err) if (err)
goto fail; goto fail;
while (!(err = grub_fat_iterate_dir_next (disk, data, &ctxt))) while (!(err = grub_fat_iterate_dir_next (&root, &ctxt)))
if ((ctxt.dir.attr & ~GRUB_FAT_ATTR_ARCHIVE) == GRUB_FAT_ATTR_VOLUME_ID) if ((ctxt.dir.attr & ~GRUB_FAT_ATTR_ARCHIVE) == GRUB_FAT_ATTR_VOLUME_ID)
{ {
*label = grub_strdup (ctxt.filename); *label = grub_strdup (ctxt.filename);
@@ -1156,7 +1160,7 @@ grub_fat_label (grub_device_t device, char **label)
grub_dl_unref (my_mod); grub_dl_unref (my_mod);
grub_free (data); grub_free (root.data);
return grub_errno; return grub_errno;
} }
+217 -107
View File
@@ -30,169 +30,287 @@ GRUB_MOD_LICENSE ("GPLv3+");
typedef int (*iterate_dir_func) (grub_fshelp_node_t dir, typedef int (*iterate_dir_func) (grub_fshelp_node_t dir,
grub_fshelp_iterate_dir_hook_t hook, grub_fshelp_iterate_dir_hook_t hook,
void *data); void *data);
typedef grub_err_t (*lookup_file_func) (grub_fshelp_node_t dir,
const char *name,
grub_fshelp_node_t *foundnode,
enum grub_fshelp_filetype *foundtype);
typedef char *(*read_symlink_func) (grub_fshelp_node_t node); typedef char *(*read_symlink_func) (grub_fshelp_node_t node);
struct stack_element {
struct stack_element *parent;
grub_fshelp_node_t node;
enum grub_fshelp_filetype type;
};
/* Context for grub_fshelp_find_file. */ /* Context for grub_fshelp_find_file. */
struct grub_fshelp_find_file_ctx struct grub_fshelp_find_file_ctx
{ {
/* Inputs. */
const char *path; const char *path;
grub_fshelp_node_t rootnode, currroot, currnode, oldnode; grub_fshelp_node_t rootnode;
enum grub_fshelp_filetype foundtype;
/* Global options. */
int symlinknest; int symlinknest;
const char *name;
const char *next; /* Current file being traversed and its parents. */
enum grub_fshelp_filetype type; struct stack_element *currnode;
}; };
/* Helper for find_file_iter. */ /* Helper for find_file_iter. */
static void static void
free_node (grub_fshelp_node_t node, struct grub_fshelp_find_file_ctx *ctx) free_node (grub_fshelp_node_t node, struct grub_fshelp_find_file_ctx *ctx)
{ {
if (node != ctx->rootnode && node != ctx->currroot) if (node != ctx->rootnode)
grub_free (node); grub_free (node);
} }
static void
pop_element (struct grub_fshelp_find_file_ctx *ctx)
{
struct stack_element *el;
el = ctx->currnode;
ctx->currnode = el->parent;
free_node (el->node, ctx);
grub_free (el);
}
static void
free_stack (struct grub_fshelp_find_file_ctx *ctx)
{
while (ctx->currnode)
pop_element (ctx);
}
static void
go_up_a_level (struct grub_fshelp_find_file_ctx *ctx)
{
if (!ctx->currnode->parent)
return;
pop_element (ctx);
}
static grub_err_t
push_node (struct grub_fshelp_find_file_ctx *ctx, grub_fshelp_node_t node, enum grub_fshelp_filetype filetype)
{
struct stack_element *nst;
nst = grub_malloc (sizeof (*nst));
if (!nst)
return grub_errno;
nst->node = node;
nst->type = filetype & ~GRUB_FSHELP_CASE_INSENSITIVE;
nst->parent = ctx->currnode;
ctx->currnode = nst;
return GRUB_ERR_NONE;
}
static grub_err_t
go_to_root (struct grub_fshelp_find_file_ctx *ctx)
{
free_stack (ctx);
return push_node (ctx, ctx->rootnode, GRUB_FSHELP_DIR);
}
struct grub_fshelp_find_file_iter_ctx
{
const char *name;
grub_fshelp_node_t *foundnode;
enum grub_fshelp_filetype *foundtype;
};
/* Helper for grub_fshelp_find_file. */ /* Helper for grub_fshelp_find_file. */
static int static int
find_file_iter (const char *filename, enum grub_fshelp_filetype filetype, find_file_iter (const char *filename, enum grub_fshelp_filetype filetype,
grub_fshelp_node_t node, void *data) grub_fshelp_node_t node, void *data)
{ {
struct grub_fshelp_find_file_ctx *ctx = data; struct grub_fshelp_find_file_iter_ctx *ctx = data;
if (filetype == GRUB_FSHELP_UNKNOWN || if (filetype == GRUB_FSHELP_UNKNOWN ||
((filetype & GRUB_FSHELP_CASE_INSENSITIVE) ((filetype & GRUB_FSHELP_CASE_INSENSITIVE)
? grub_strncasecmp (ctx->name, filename, ctx->next - ctx->name) ? grub_strcasecmp (ctx->name, filename)
: grub_strncmp (ctx->name, filename, ctx->next - ctx->name)) : grub_strcmp (ctx->name, filename)))
|| filename[ctx->next - ctx->name])
{ {
grub_free (node); grub_free (node);
return 0; return 0;
} }
/* The node is found, stop iterating over the nodes. */ /* The node is found, stop iterating over the nodes. */
ctx->type = filetype & ~GRUB_FSHELP_CASE_INSENSITIVE; *ctx->foundnode = node;
ctx->oldnode = ctx->currnode; *ctx->foundtype = filetype;
ctx->currnode = node;
return 1; return 1;
} }
static grub_err_t static grub_err_t
find_file (const char *currpath, grub_fshelp_node_t currroot, directory_find_file (grub_fshelp_node_t node, const char *name, grub_fshelp_node_t *foundnode,
grub_fshelp_node_t *currfound, enum grub_fshelp_filetype *foundtype, iterate_dir_func iterate_dir)
iterate_dir_func iterate_dir, read_symlink_func read_symlink, {
int found;
struct grub_fshelp_find_file_iter_ctx ctx = {
.foundnode = foundnode,
.foundtype = foundtype,
.name = name
};
found = iterate_dir (node, find_file_iter, &ctx);
if (! found)
{
if (grub_errno)
return grub_errno;
}
return GRUB_ERR_NONE;
}
static grub_err_t
find_file (char *currpath,
iterate_dir_func iterate_dir, lookup_file_func lookup_file,
read_symlink_func read_symlink,
struct grub_fshelp_find_file_ctx *ctx) struct grub_fshelp_find_file_ctx *ctx)
{ {
ctx->currroot = currroot; char *name, *next;
ctx->name = currpath; grub_err_t err;
ctx->type = GRUB_FSHELP_DIR; for (name = currpath; ; name = next)
ctx->currnode = currroot;
ctx->oldnode = currroot;
for (;;)
{ {
int found; char c;
grub_fshelp_node_t foundnode = NULL;
enum grub_fshelp_filetype foundtype = 0;
/* Remove all leading slashes. */ /* Remove all leading slashes. */
while (*ctx->name == '/') while (*name == '/')
ctx->name++; name++;
/* Found the node! */ /* Found the node! */
if (! *ctx->name) if (! *name)
{ return 0;
*currfound = ctx->currnode;
ctx->foundtype = ctx->type;
return 0;
}
/* Extract the actual part from the pathname. */ /* Extract the actual part from the pathname. */
for (ctx->next = ctx->name; *ctx->next && *ctx->next != '/'; ctx->next++); for (next = name; *next && *next != '/'; next++);
/* At this point it is expected that the current node is a /* At this point it is expected that the current node is a
directory, check if this is true. */ directory, check if this is true. */
if (ctx->type != GRUB_FSHELP_DIR) if (ctx->currnode->type != GRUB_FSHELP_DIR)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
/* Don't rely on fs providing actual . in the listing. */
if (next - name == 1 && name[0] == '.')
continue;
/* Don't rely on fs providing actual .. in the listing. */
if (next - name == 2 && name[0] == '.' && name[1] == '.')
{ {
free_node (ctx->currnode, ctx); go_up_a_level (ctx);
ctx->currnode = 0; continue;
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
} }
/* Iterate over the directory. */ /* Iterate over the directory. */
found = iterate_dir (ctx->currnode, find_file_iter, ctx); c = *next;
if (! found) *next = '\0';
{ if (lookup_file)
free_node (ctx->currnode, ctx); err = lookup_file (ctx->currnode->node, name, &foundnode, &foundtype);
ctx->currnode = 0; else
if (grub_errno) err = directory_find_file (ctx->currnode->node, name, &foundnode, &foundtype, iterate_dir);
return grub_errno; *next = c;
break; if (err)
} return err;
if (!foundnode)
break;
push_node (ctx, foundnode, foundtype);
/* Read in the symlink and follow it. */ /* Read in the symlink and follow it. */
if (ctx->type == GRUB_FSHELP_SYMLINK) if (ctx->currnode->type == GRUB_FSHELP_SYMLINK)
{ {
char *symlink; char *symlink;
const char *next;
/* Test if the symlink does not loop. */ /* Test if the symlink does not loop. */
if (++ctx->symlinknest == 8) if (++ctx->symlinknest == 8)
{ return grub_error (GRUB_ERR_SYMLINK_LOOP,
free_node (ctx->currnode, ctx); N_("too deep nesting of symlinks"));
free_node (ctx->oldnode, ctx);
ctx->currnode = 0;
ctx->oldnode = 0;
return grub_error (GRUB_ERR_SYMLINK_LOOP,
N_("too deep nesting of symlinks"));
}
symlink = read_symlink (ctx->currnode); symlink = read_symlink (ctx->currnode->node);
free_node (ctx->currnode, ctx);
ctx->currnode = 0;
if (!symlink) if (!symlink)
{ return grub_errno;
free_node (ctx->oldnode, ctx);
ctx->oldnode = 0;
return grub_errno;
}
/* The symlink is an absolute path, go back to the root inode. */ /* The symlink is an absolute path, go back to the root inode. */
if (symlink[0] == '/') if (symlink[0] == '/')
{ {
free_node (ctx->oldnode, ctx); err = go_to_root (ctx);
ctx->oldnode = ctx->rootnode; if (err)
return err;
}
else
{
/* Get from symlink to containing directory. */
go_up_a_level (ctx);
} }
/* Lookup the node the symlink points to. */ /* Lookup the node the symlink points to. */
next = ctx->next; find_file (symlink, iterate_dir, lookup_file, read_symlink, ctx);
find_file (symlink, ctx->oldnode, &ctx->currnode,
iterate_dir, read_symlink, ctx);
ctx->next = next;
ctx->type = ctx->foundtype;
grub_free (symlink); grub_free (symlink);
if (grub_errno) if (grub_errno)
{ return grub_errno;
free_node (ctx->oldnode, ctx);
ctx->oldnode = 0;
return grub_errno;
}
} }
if (ctx->oldnode != ctx->currnode)
{
free_node (ctx->oldnode, ctx);
ctx->oldnode = 0;
}
ctx->name = ctx->next;
} }
return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"),
ctx->path); ctx->path);
} }
static grub_err_t
grub_fshelp_find_file_real (const char *path, grub_fshelp_node_t rootnode,
grub_fshelp_node_t *foundnode,
iterate_dir_func iterate_dir,
lookup_file_func lookup_file,
read_symlink_func read_symlink,
enum grub_fshelp_filetype expecttype)
{
struct grub_fshelp_find_file_ctx ctx = {
.path = path,
.rootnode = rootnode,
.symlinknest = 0,
.currnode = 0
};
grub_err_t err;
enum grub_fshelp_filetype foundtype;
char *duppath;
if (!path || path[0] != '/')
{
return grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path);
}
err = go_to_root (&ctx);
if (err)
return err;
duppath = grub_strdup (path);
if (!duppath)
return grub_errno;
err = find_file (duppath, iterate_dir, lookup_file, read_symlink, &ctx);
grub_free (duppath);
if (err)
{
free_stack (&ctx);
return err;
}
*foundnode = ctx.currnode->node;
foundtype = ctx.currnode->type;
/* Avoid the node being freed. */
ctx.currnode->node = 0;
free_stack (&ctx);
/* Check if the node that was found was of the expected type. */
if (expecttype == GRUB_FSHELP_REG && foundtype != expecttype)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
else if (expecttype == GRUB_FSHELP_DIR && foundtype != expecttype)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
return 0;
}
/* Lookup the node PATH. The node ROOTNODE describes the root of the /* Lookup the node PATH. The node ROOTNODE describes the root of the
directory tree. The node found is returned in FOUNDNODE, which is directory tree. The node found is returned in FOUNDNODE, which is
either a ROOTNODE or a new malloc'ed node. ITERATE_DIR is used to either a ROOTNODE or a new malloc'ed node. ITERATE_DIR is used to
@@ -207,31 +325,23 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
read_symlink_func read_symlink, read_symlink_func read_symlink,
enum grub_fshelp_filetype expecttype) enum grub_fshelp_filetype expecttype)
{ {
struct grub_fshelp_find_file_ctx ctx = { return grub_fshelp_find_file_real (path, rootnode, foundnode,
.path = path, iterate_dir, NULL,
.rootnode = rootnode, read_symlink, expecttype);
.foundtype = GRUB_FSHELP_DIR,
.symlinknest = 0
};
grub_err_t err;
if (!path || path[0] != '/') }
{
grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path);
return grub_errno;
}
err = find_file (path, rootnode, foundnode, iterate_dir, read_symlink, &ctx); grub_err_t
if (err) grub_fshelp_find_file_lookup (const char *path, grub_fshelp_node_t rootnode,
return err; grub_fshelp_node_t *foundnode,
lookup_file_func lookup_file,
read_symlink_func read_symlink,
enum grub_fshelp_filetype expecttype)
{
return grub_fshelp_find_file_real (path, rootnode, foundnode,
NULL, lookup_file,
read_symlink, expecttype);
/* Check if the node that was found was of the expected type. */
if (expecttype == GRUB_FSHELP_REG && ctx.foundtype != expecttype)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file"));
else if (expecttype == GRUB_FSHELP_DIR && ctx.foundtype != expecttype)
return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
return 0;
} }
/* Read LEN bytes from the file NODE on disk DISK into the buffer BUF, /* Read LEN bytes from the file NODE on disk DISK into the buffer BUF,
+95 -102
View File
@@ -29,6 +29,7 @@
#include <grub/types.h> #include <grub/types.h>
#include <grub/hfs.h> #include <grub/hfs.h>
#include <grub/i18n.h> #include <grub/i18n.h>
#include <grub/fshelp.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@@ -692,6 +693,7 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
int i; int i;
struct grub_hfs_extent *dat; struct grub_hfs_extent *dat;
int blk; int blk;
grub_uint16_t reccnt;
dat = (struct grub_hfs_extent *) (type == 0 dat = (struct grub_hfs_extent *) (type == 0
? (&data->sblock.catalog_recs) ? (&data->sblock.catalog_recs)
@@ -710,8 +712,12 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
return grub_errno; return grub_errno;
} }
reccnt = grub_be_to_cpu16 (node->node.reccnt);
if (reccnt > (nodesize >> 1))
reccnt = (nodesize >> 1);
/* Iterate over all records in this node. */ /* Iterate over all records in this node. */
for (i = 0; i < grub_be_to_cpu16 (node->node.reccnt); i++) for (i = 0; i < reccnt; i++)
{ {
int pos = (nodesize >> 1) - 1 - i; int pos = (nodesize >> 1) - 1 - i;
struct pointer struct pointer
@@ -719,16 +725,19 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx,
grub_uint8_t keylen; grub_uint8_t keylen;
grub_uint8_t key; grub_uint8_t key;
} GRUB_PACKED *pnt; } GRUB_PACKED *pnt;
pnt = (struct pointer *) (grub_be_to_cpu16 (node->offsets[pos]) grub_uint16_t off = grub_be_to_cpu16 (node->offsets[pos]);
+ node->rawnode); if (off > nodesize - sizeof(*pnt))
continue;
pnt = (struct pointer *) (off + node->rawnode);
if (nodesize < (grub_size_t) off + pnt->keylen + 1)
continue;
struct grub_hfs_record rec = struct grub_hfs_record rec =
{ {
&pnt->key, &pnt->key,
pnt->keylen, pnt->keylen,
&pnt->key + pnt->keylen +(pnt->keylen + 1) % 2, &pnt->key + pnt->keylen +(pnt->keylen + 1) % 2,
nodesize - grub_be_to_cpu16 (node->offsets[pos]) nodesize - off - pnt->keylen - 1
- pnt->keylen - 1
}; };
if (node_hook (&node->node, &rec, hook_arg)) if (node_hook (&node->node, &rec, hook_arg))
@@ -1117,90 +1126,81 @@ utf8_to_macroman (grub_uint8_t *to, const char *from)
return optr - to; return optr - to;
} }
union grub_hfs_anyrec {
struct grub_hfs_filerec frec;
struct grub_hfs_dirrec dir;
};
struct grub_fshelp_node
{
struct grub_hfs_data *data;
union grub_hfs_anyrec fdrec;
grub_uint32_t inode;
};
static grub_err_t
lookup_file (grub_fshelp_node_t dir,
const char *name,
grub_fshelp_node_t *foundnode,
enum grub_fshelp_filetype *foundtype)
{
struct grub_hfs_catalog_key key;
grub_ssize_t slen;
union grub_hfs_anyrec fdrec;
key.parent_dir = grub_cpu_to_be32 (dir->inode);
slen = utf8_to_macroman (key.str, name);
if (slen < 0)
/* Not found */
return GRUB_ERR_NONE;
key.strlen = slen;
/* Lookup this node. */
if (! grub_hfs_find_node (dir->data, (char *) &key, dir->data->cat_root,
0, (char *) &fdrec.frec, sizeof (fdrec.frec)))
/* Not found */
return GRUB_ERR_NONE;
*foundnode = grub_malloc (sizeof (struct grub_fshelp_node));
if (!*foundnode)
return grub_errno;
(*foundnode)->inode = grub_be_to_cpu32 (fdrec.dir.dirid);
(*foundnode)->fdrec = fdrec;
(*foundnode)->data = dir->data;
*foundtype = (fdrec.frec.type == GRUB_HFS_FILETYPE_DIR) ? GRUB_FSHELP_DIR : GRUB_FSHELP_REG;
return GRUB_ERR_NONE;
}
/* Find a file or directory with the pathname PATH in the filesystem /* Find a file or directory with the pathname PATH in the filesystem
DATA. Return the file record in RETDATA when it is non-zero. DATA. Return the file record in RETDATA when it is non-zero.
Return the directory number in RETINODE when it is non-zero. */ Return the directory number in RETINODE when it is non-zero. */
static grub_err_t static grub_err_t
grub_hfs_find_dir (struct grub_hfs_data *data, const char *path, grub_hfs_find_dir (struct grub_hfs_data *data, const char *path,
struct grub_hfs_filerec *retdata, int *retinode) grub_fshelp_node_t *found,
enum grub_fshelp_filetype exptype)
{ {
int inode = data->rootdir; struct grub_fshelp_node root = {
char *next; .data = data,
char *origpath; .inode = data->rootdir,
union { .fdrec = {
struct grub_hfs_filerec frec; .frec = {
struct grub_hfs_dirrec dir; .type = GRUB_HFS_FILETYPE_DIR
} fdrec; }
fdrec.frec.type = GRUB_HFS_FILETYPE_DIR;
if (path[0] != '/')
{
grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path);
return 0;
} }
};
grub_err_t err;
origpath = grub_strdup (path); err = grub_fshelp_find_file_lookup (path, &root, found, lookup_file, NULL, exptype);
if (!origpath)
return grub_errno;
path = origpath; if (&root == *found)
while (*path == '/')
path++;
while (path && grub_strlen (path))
{ {
grub_ssize_t slen; *found = grub_malloc (sizeof (root));
if (fdrec.frec.type != GRUB_HFS_FILETYPE_DIR) if (!*found)
{ return grub_errno;
grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); grub_memcpy (*found, &root, sizeof (root));
goto fail;
}
/* Isolate a part of the path. */
next = grub_strchr (path, '/');
if (next)
{
while (*next == '/')
*(next++) = '\0';
}
struct grub_hfs_catalog_key key;
key.parent_dir = grub_cpu_to_be32 (inode);
slen = utf8_to_macroman (key.str, path);
if (slen < 0)
{
grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path);
goto fail;
}
key.strlen = slen;
/* Lookup this node. */
if (! grub_hfs_find_node (data, (char *) &key, data->cat_root,
0, (char *) &fdrec.frec, sizeof (fdrec.frec)))
{
grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath);
goto fail;
}
if (grub_errno)
goto fail;
inode = grub_be_to_cpu32 (fdrec.dir.dirid);
path = next;
} }
return err;
if (retdata)
grub_memcpy (retdata, &fdrec.frec, sizeof (fdrec.frec));
if (retinode)
*retinode = inode;
fail:
grub_free (origpath);
return grub_errno;
} }
struct grub_hfs_dir_hook_ctx struct grub_hfs_dir_hook_ctx
@@ -1258,15 +1258,13 @@ static grub_err_t
grub_hfs_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook, grub_hfs_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
void *hook_data) void *hook_data)
{ {
int inode;
struct grub_hfs_data *data; struct grub_hfs_data *data;
struct grub_hfs_filerec frec;
struct grub_hfs_dir_hook_ctx ctx = struct grub_hfs_dir_hook_ctx ctx =
{ {
.hook = hook, .hook = hook,
.hook_data = hook_data .hook_data = hook_data
}; };
grub_fshelp_node_t found = NULL;
grub_dl_ref (my_mod); grub_dl_ref (my_mod);
@@ -1275,18 +1273,13 @@ grub_hfs_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook,
goto fail; goto fail;
/* First the directory ID for the directory. */ /* First the directory ID for the directory. */
if (grub_hfs_find_dir (data, path, &frec, &inode)) if (grub_hfs_find_dir (data, path, &found, GRUB_FSHELP_DIR))
goto fail; goto fail;
if (frec.type != GRUB_HFS_FILETYPE_DIR) grub_hfs_iterate_dir (data, data->cat_root, found->inode, grub_hfs_dir_hook, &ctx);
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory"));
goto fail;
}
grub_hfs_iterate_dir (data, data->cat_root, inode, grub_hfs_dir_hook, &ctx);
fail: fail:
grub_free (found);
grub_free (data); grub_free (data);
grub_dl_unref (my_mod); grub_dl_unref (my_mod);
@@ -1300,35 +1293,35 @@ static grub_err_t
grub_hfs_open (struct grub_file *file, const char *name) grub_hfs_open (struct grub_file *file, const char *name)
{ {
struct grub_hfs_data *data; struct grub_hfs_data *data;
struct grub_hfs_filerec frec; grub_fshelp_node_t found = NULL;
grub_dl_ref (my_mod); grub_dl_ref (my_mod);
data = grub_hfs_mount (file->device->disk); data = grub_hfs_mount (file->device->disk);
if (grub_hfs_find_dir (data, name, &frec, 0)) if (!data)
{
grub_dl_unref (my_mod);
return grub_errno;
}
if (grub_hfs_find_dir (data, name, &found, GRUB_FSHELP_REG))
{ {
grub_free (data); grub_free (data);
grub_dl_unref (my_mod); grub_dl_unref (my_mod);
return grub_errno; return grub_errno;
} }
if (frec.type != GRUB_HFS_FILETYPE_FILE) grub_memcpy (data->extents, found->fdrec.frec.extents, sizeof (grub_hfs_datarecord_t));
{ file->size = grub_be_to_cpu32 (found->fdrec.frec.size);
grub_free (data); data->size = grub_be_to_cpu32 (found->fdrec.frec.size);
grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file")); data->fileid = grub_be_to_cpu32 (found->fdrec.frec.fileid);
grub_dl_unref (my_mod);
return grub_errno;
}
grub_memcpy (data->extents, frec.extents, sizeof (grub_hfs_datarecord_t));
file->size = grub_be_to_cpu32 (frec.size);
data->size = grub_be_to_cpu32 (frec.size);
data->fileid = grub_be_to_cpu32 (frec.fileid);
file->offset = 0; file->offset = 0;
file->data = data; file->data = data;
grub_free (found);
return 0; return 0;
} }
+18 -6
View File
@@ -336,6 +336,9 @@ grub_hfsplus_mount (grub_disk_t disk)
data->case_sensitive = ((magic == GRUB_HFSPLUSX_MAGIC) && data->case_sensitive = ((magic == GRUB_HFSPLUSX_MAGIC) &&
(header.key_compare == GRUB_HFSPLUSX_BINARYCOMPARE)); (header.key_compare == GRUB_HFSPLUSX_BINARYCOMPARE));
if (data->catalog_tree.nodesize < 2)
goto fail;
if (grub_hfsplus_read_file (&data->extoverflow_tree.file, 0, 0, if (grub_hfsplus_read_file (&data->extoverflow_tree.file, 0, 0,
sizeof (struct grub_hfsplus_btnode), sizeof (struct grub_hfsplus_btnode),
sizeof (header), (char *) &header) <= 0) sizeof (header), (char *) &header) <= 0)
@@ -350,6 +353,9 @@ grub_hfsplus_mount (grub_disk_t disk)
data->extoverflow_tree.root = grub_be_to_cpu32 (header.root); data->extoverflow_tree.root = grub_be_to_cpu32 (header.root);
data->extoverflow_tree.nodesize = grub_be_to_cpu16 (header.nodesize); data->extoverflow_tree.nodesize = grub_be_to_cpu16 (header.nodesize);
if (data->extoverflow_tree.nodesize < 2)
goto fail;
if (grub_hfsplus_read_file (&data->attr_tree.file, 0, 0, if (grub_hfsplus_read_file (&data->attr_tree.file, 0, 0,
sizeof (struct grub_hfsplus_btnode), sizeof (struct grub_hfsplus_btnode),
sizeof (header), (char *) &header) <= 0) sizeof (header), (char *) &header) <= 0)
@@ -723,7 +729,10 @@ list_nodes (void *record, void *hook_arg)
/* If the name is obviously invalid, skip this node. */ /* If the name is obviously invalid, skip this node. */
if (catkey->name[i] == 0) if (catkey->name[i] == 0)
return 0; {
grub_free (filename);
return 0;
}
} }
*grub_utf16_to_utf8 ((grub_uint8_t *) filename, catkey->name, *grub_utf16_to_utf8 ((grub_uint8_t *) filename, catkey->name,
@@ -745,7 +754,10 @@ list_nodes (void *record, void *hook_arg)
callback function. */ callback function. */
node = grub_malloc (sizeof (*node)); node = grub_malloc (sizeof (*node));
if (!node) if (!node)
return 1; {
grub_free (filename);
return 1;
}
node->data = ctx->dir->data; node->data = ctx->dir->data;
node->compressed = 0; node->compressed = 0;
node->cbuf = 0; node->cbuf = 0;
@@ -780,8 +792,8 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir,
}; };
struct grub_hfsplus_key_internal intern; struct grub_hfsplus_key_internal intern;
struct grub_hfsplus_btnode *node; struct grub_hfsplus_btnode *node = NULL;
grub_disk_addr_t ptr; grub_disk_addr_t ptr = 0;
{ {
struct grub_fshelp_node *fsnode; struct grub_fshelp_node *fsnode;
@@ -964,8 +976,8 @@ grub_hfsplus_label (grub_device_t device, char **label)
struct grub_hfsplus_catkey *catkey; struct grub_hfsplus_catkey *catkey;
int i, label_len; int i, label_len;
struct grub_hfsplus_key_internal intern; struct grub_hfsplus_key_internal intern;
struct grub_hfsplus_btnode *node; struct grub_hfsplus_btnode *node = NULL;
grub_disk_addr_t ptr; grub_disk_addr_t ptr = 0;
*label = 0; *label = 0;
+3 -2
View File
@@ -959,14 +959,15 @@ grub_iso9660_read (grub_file_t file, char *buf, grub_size_t len)
{ {
struct grub_iso9660_data *data = struct grub_iso9660_data *data =
(struct grub_iso9660_data *) file->data; (struct grub_iso9660_data *) file->data;
grub_err_t err;
/* XXX: The file is stored in as a single extent. */ /* XXX: The file is stored in as a single extent. */
data->disk->read_hook = file->read_hook; data->disk->read_hook = file->read_hook;
data->disk->read_hook_data = file->read_hook_data; data->disk->read_hook_data = file->read_hook_data;
read_node (data->node, file->offset, len, buf); err = read_node (data->node, file->offset, len, buf);
data->disk->read_hook = NULL; data->disk->read_hook = NULL;
if (grub_errno) if (err || grub_errno)
return -1; return -1;
return len; return len;
+22 -15
View File
@@ -82,17 +82,6 @@ typedef grub_uint16_t grub_minix_ino_t;
#define GRUB_MINIX_INODE_DINDIR_ZONE(data) (grub_minix_to_cpu_n \ #define GRUB_MINIX_INODE_DINDIR_ZONE(data) (grub_minix_to_cpu_n \
(data->inode.double_indir_zone)) (data->inode.double_indir_zone))
#ifndef MODE_MINIX3
#define GRUB_MINIX_LOG2_ZONESZ (GRUB_MINIX_LOG2_BSIZE \
+ grub_minix_to_cpu16 (data->sblock.log2_zone_size))
#endif
#ifdef MODE_MINIX3
#define GRUB_MINIX_ZONE2SECT(zone) ((zone) * data->block_size)
#else
#define GRUB_MINIX_ZONE2SECT(zone) ((zone) << GRUB_MINIX_LOG2_ZONESZ)
#endif
#ifdef MODE_MINIX3 #ifdef MODE_MINIX3
struct grub_minix_sblock struct grub_minix_sblock
@@ -182,6 +171,23 @@ static grub_dl_t my_mod;
static grub_err_t grub_minix_find_file (struct grub_minix_data *data, static grub_err_t grub_minix_find_file (struct grub_minix_data *data,
const char *path); const char *path);
#ifdef MODE_MINIX3
static inline grub_disk_addr_t
grub_minix_zone2sect (struct grub_minix_data *data, grub_minix_uintn_t zone)
{
return ((grub_disk_addr_t) zone) * data->block_size;
}
#else
static inline grub_disk_addr_t
grub_minix_zone2sect (struct grub_minix_data *data, grub_minix_uintn_t zone)
{
int log2_zonesz = (GRUB_MINIX_LOG2_BSIZE
+ grub_minix_to_cpu16 (data->sblock.log2_zone_size));
return (((grub_disk_addr_t) zone) << log2_zonesz);
}
#endif
/* Read the block pointer in ZONE, on the offset NUM. */ /* Read the block pointer in ZONE, on the offset NUM. */
static grub_minix_uintn_t static grub_minix_uintn_t
grub_get_indir (struct grub_minix_data *data, grub_get_indir (struct grub_minix_data *data,
@@ -190,7 +196,7 @@ grub_get_indir (struct grub_minix_data *data,
{ {
grub_minix_uintn_t indirn; grub_minix_uintn_t indirn;
grub_disk_read (data->disk, grub_disk_read (data->disk,
GRUB_MINIX_ZONE2SECT(zone), grub_minix_zone2sect(data, zone),
sizeof (grub_minix_uintn_t) * num, sizeof (grub_minix_uintn_t) * num,
sizeof (grub_minix_uintn_t), (char *) &indirn); sizeof (grub_minix_uintn_t), (char *) &indirn);
return grub_minix_to_cpu_n (indirn); return grub_minix_to_cpu_n (indirn);
@@ -281,7 +287,7 @@ grub_minix_read_file (struct grub_minix_data *data,
for (i = posblock; i < blockcnt; i++) for (i = posblock; i < blockcnt; i++)
{ {
grub_disk_addr_t blknr; grub_minix_uintn_t blknr;
grub_uint64_t blockend = data->block_size << GRUB_DISK_SECTOR_BITS; grub_uint64_t blockend = data->block_size << GRUB_DISK_SECTOR_BITS;
grub_off_t skipfirst = 0; grub_off_t skipfirst = 0;
@@ -310,7 +316,7 @@ grub_minix_read_file (struct grub_minix_data *data,
data->disk->read_hook = read_hook; data->disk->read_hook = read_hook;
data->disk->read_hook_data = read_hook_data; data->disk->read_hook_data = read_hook_data;
grub_disk_read (data->disk, grub_disk_read (data->disk,
GRUB_MINIX_ZONE2SECT(blknr), grub_minix_zone2sect(data, blknr),
skipfirst, blockend, buf); skipfirst, blockend, buf);
data->disk->read_hook = 0; data->disk->read_hook = 0;
if (grub_errno) if (grub_errno)
@@ -336,7 +342,8 @@ grub_minix_read_inode (struct grub_minix_data *data, grub_minix_ino_t ino)
/* The first inode in minix is inode 1. */ /* The first inode in minix is inode 1. */
ino--; ino--;
block = GRUB_MINIX_ZONE2SECT (2 + grub_minix_to_cpu16 (sblock->inode_bmap_size) block = grub_minix_zone2sect (data,
2 + grub_minix_to_cpu16 (sblock->inode_bmap_size)
+ grub_minix_to_cpu16 (sblock->zone_bmap_size)); + grub_minix_to_cpu16 (sblock->zone_bmap_size));
block += ino / (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix_inode)); block += ino / (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix_inode));
int offs = (ino % (GRUB_DISK_SECTOR_SIZE int offs = (ino % (GRUB_DISK_SECTOR_SIZE
+8 -1
View File
@@ -618,7 +618,10 @@ list_file (struct grub_ntfs_file *diro, grub_uint8_t *pos,
ustr = get_utf8 (np, ns); ustr = get_utf8 (np, ns);
if (ustr == NULL) if (ustr == NULL)
return 0; {
grub_free (fdiro);
return 0;
}
if (namespace) if (namespace)
type |= GRUB_FSHELP_CASE_INSENSITIVE; type |= GRUB_FSHELP_CASE_INSENSITIVE;
@@ -917,12 +920,16 @@ grub_ntfs_mount (grub_disk_t disk)
if (bpb.clusters_per_mft > 0) if (bpb.clusters_per_mft > 0)
data->mft_size = ((grub_disk_addr_t) bpb.clusters_per_mft) << data->log_spc; data->mft_size = ((grub_disk_addr_t) bpb.clusters_per_mft) << data->log_spc;
else if (-bpb.clusters_per_mft < GRUB_NTFS_BLK_SHR || -bpb.clusters_per_mft >= 31)
goto fail;
else else
data->mft_size = 1ULL << (-bpb.clusters_per_mft - GRUB_NTFS_BLK_SHR); data->mft_size = 1ULL << (-bpb.clusters_per_mft - GRUB_NTFS_BLK_SHR);
if (bpb.clusters_per_index > 0) if (bpb.clusters_per_index > 0)
data->idx_size = (((grub_disk_addr_t) bpb.clusters_per_index) data->idx_size = (((grub_disk_addr_t) bpb.clusters_per_index)
<< data->log_spc); << data->log_spc);
else if (-bpb.clusters_per_index < GRUB_NTFS_BLK_SHR || -bpb.clusters_per_index >= 31)
goto fail;
else else
data->idx_size = 1ULL << (-bpb.clusters_per_index - GRUB_NTFS_BLK_SHR); data->idx_size = 1ULL << (-bpb.clusters_per_index - GRUB_NTFS_BLK_SHR);
+57 -27
View File
@@ -22,6 +22,7 @@
#include <grub/file.h> #include <grub/file.h>
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/archelp.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@@ -74,6 +75,44 @@ grub_procdev_write (grub_disk_t disk __attribute ((unused)),
return GRUB_ERR_OUT_OF_RANGE; return GRUB_ERR_OUT_OF_RANGE;
} }
struct grub_archelp_data
{
struct grub_procfs_entry *entry, *next_entry;
};
static void
grub_procfs_rewind (struct grub_archelp_data *data)
{
data->entry = NULL;
data->next_entry = grub_procfs_entries;
}
static grub_err_t
grub_procfs_find_file (struct grub_archelp_data *data, char **name,
grub_int32_t *mtime,
grub_uint32_t *mode)
{
data->entry = data->next_entry;
if (!data->entry)
{
*mode = GRUB_ARCHELP_ATTR_END;
return GRUB_ERR_NONE;
}
data->next_entry = data->entry->next;
*mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME;
*name = grub_strdup (data->entry->name);
*mtime = 0;
if (!*name)
return grub_errno;
return GRUB_ERR_NONE;
}
static struct grub_archelp_ops arcops =
{
.find_file = grub_procfs_find_file,
.rewind = grub_procfs_rewind
};
static grub_ssize_t static grub_ssize_t
grub_procfs_read (grub_file_t file, char *buf, grub_size_t len) grub_procfs_read (grub_file_t file, char *buf, grub_size_t len)
{ {
@@ -99,44 +138,35 @@ static grub_err_t
grub_procfs_dir (grub_device_t device, const char *path, grub_procfs_dir (grub_device_t device, const char *path,
grub_fs_dir_hook_t hook, void *hook_data) grub_fs_dir_hook_t hook, void *hook_data)
{ {
const char *ptr; struct grub_archelp_data data;
struct grub_dirhook_info info;
struct grub_procfs_entry *entry;
grub_memset (&info, 0, sizeof (info));
/* Check if the disk is our dummy disk. */ /* Check if the disk is our dummy disk. */
if (grub_strcmp (device->disk->name, "proc")) if (grub_strcmp (device->disk->name, "proc"))
return grub_error (GRUB_ERR_BAD_FS, "not a procfs"); return grub_error (GRUB_ERR_BAD_FS, "not a procfs");
for (ptr = path; *ptr == '/'; ptr++);
if (*ptr) grub_procfs_rewind (&data);
return 0;
FOR_LIST_ELEMENTS((entry), (grub_procfs_entries)) return grub_archelp_dir (&data, &arcops,
if (hook (entry->name, &info, hook_data)) path, hook, hook_data);
return 0;
return 0;
} }
static grub_err_t static grub_err_t
grub_procfs_open (struct grub_file *file, const char *path) grub_procfs_open (struct grub_file *file, const char *path)
{ {
const char *pathptr; grub_err_t err;
struct grub_procfs_entry *entry; struct grub_archelp_data data;
grub_size_t sz;
for (pathptr = path; *pathptr == '/'; pathptr++); grub_procfs_rewind (&data);
FOR_LIST_ELEMENTS((entry), (grub_procfs_entries)) err = grub_archelp_open (&data, &arcops, path);
if (grub_strcmp (pathptr, entry->name) == 0) if (err)
{ return err;
grub_size_t sz; file->data = data.entry->get_contents (&sz);
file->data = entry->get_contents (&sz); if (!file->data)
if (!file->data) return grub_errno;
return grub_errno; file->size = sz;
file->size = sz; return GRUB_ERR_NONE;
return GRUB_ERR_NONE;
}
return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path);
} }
static struct grub_disk_dev grub_procfs_dev = { static struct grub_disk_dev grub_procfs_dev = {
+26 -5
View File
@@ -783,12 +783,30 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
struct grub_reiserfs_key entry_key; struct grub_reiserfs_key entry_key;
enum grub_fshelp_filetype entry_type; enum grub_fshelp_filetype entry_type;
char *entry_name; char *entry_name;
char *entry_name_end = 0;
char c;
if (!(entry_state & GRUB_REISERFS_VISIBLE_MASK)) if (!(entry_state & GRUB_REISERFS_VISIBLE_MASK))
continue; continue;
entry_name = (((char *) directory_headers) entry_name = (((char *) directory_headers)
+ grub_le_to_cpu16 (directory_header->location)); + grub_le_to_cpu16 (directory_header->location));
if (entry_number == 0)
{
entry_name_end = (char *) block_header
+ grub_le_to_cpu16 (item_headers[block_position].item_location)
+ grub_le_to_cpu16 (item_headers[block_position].item_size);
}
else
{
entry_name_end = (((char *) directory_headers)
+ grub_le_to_cpu16 (directory_headers[entry_number - 1].location));
}
if (entry_name_end < entry_name || entry_name_end > (char *) block_header + block_size)
{
entry_name_end = (char *) block_header + block_size;
}
entry_key.directory_id = directory_header->directory_id; entry_key.directory_id = directory_header->directory_id;
entry_key.object_id = directory_header->object_id; entry_key.object_id = directory_header->object_id;
entry_key.u.v2.offset_type = 0; entry_key.u.v2.offset_type = 0;
@@ -935,7 +953,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
else else
{ {
/* Pseudo file ".." never has stat block. */ /* Pseudo file ".." never has stat block. */
if (grub_strcmp (entry_name, "..")) if (entry_name_end == entry_name + 2 && grub_memcmp (entry_name, "..", 2) != 0)
grub_dprintf ("reiserfs", grub_dprintf ("reiserfs",
"Warning : %s has no stat block !\n", "Warning : %s has no stat block !\n",
entry_name); entry_name);
@@ -943,18 +961,21 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
goto next; goto next;
} }
} }
c = *entry_name_end;
*entry_name_end = 0;
if (hook (entry_name, entry_type, entry_item, hook_data)) if (hook (entry_name, entry_type, entry_item, hook_data))
{ {
*entry_name_end = c;
grub_dprintf ("reiserfs", "Found : %s, type=%d\n", grub_dprintf ("reiserfs", "Found : %s, type=%d\n",
entry_name, entry_type); entry_name, entry_type);
ret = 1; ret = 1;
goto found; goto found;
} }
*entry_name_end = c;
next: next:
*entry_name = 0; /* Make sure next entry name (which is just ;
before this one in disk order) stops before
the current one. */
} }
if (next_offset == 0) if (next_offset == 0)
@@ -1090,7 +1111,7 @@ grub_reiserfs_read_real (struct grub_fshelp_node *node,
switch (found.type) switch (found.type)
{ {
case GRUB_REISERFS_DIRECT: case GRUB_REISERFS_DIRECT:
block = found.block_number * (block_size >> GRUB_DISK_SECTOR_BITS); block = ((grub_disk_addr_t) found.block_number) * (block_size >> GRUB_DISK_SECTOR_BITS);
grub_dprintf ("reiserfs_blocktype", "D: %u\n", (unsigned) block); grub_dprintf ("reiserfs_blocktype", "D: %u\n", (unsigned) block);
if (initial_position < current_position + item_size) if (initial_position < current_position + item_size)
{ {
+11 -6
View File
@@ -173,10 +173,11 @@ grub_sfs_read_extent (struct grub_sfs_data *data, unsigned int block,
struct grub_sfs_btree *tree; struct grub_sfs_btree *tree;
int i; int i;
grub_uint32_t next; grub_uint32_t next;
grub_size_t blocksize = GRUB_DISK_SECTOR_SIZE << data->log_blocksize;
treeblock = grub_malloc (GRUB_DISK_SECTOR_SIZE << data->log_blocksize); treeblock = grub_malloc (blocksize);
if (!block) if (!treeblock)
return 0; return grub_errno;
next = grub_be_to_cpu32 (data->rblock.btree); next = grub_be_to_cpu32 (data->rblock.btree);
tree = (struct grub_sfs_btree *) treeblock; tree = (struct grub_sfs_btree *) treeblock;
@@ -184,17 +185,21 @@ grub_sfs_read_extent (struct grub_sfs_data *data, unsigned int block,
/* Handle this level in the btree. */ /* Handle this level in the btree. */
do do
{ {
grub_uint16_t nnodes;
grub_disk_read (data->disk, grub_disk_read (data->disk,
((grub_disk_addr_t) next) << data->log_blocksize, ((grub_disk_addr_t) next) << data->log_blocksize,
0, GRUB_DISK_SECTOR_SIZE << data->log_blocksize, 0, blocksize, treeblock);
treeblock);
if (grub_errno) if (grub_errno)
{ {
grub_free (treeblock); grub_free (treeblock);
return grub_errno; return grub_errno;
} }
for (i = grub_be_to_cpu16 (tree->nodes) - 1; i >= 0; i--) nnodes = grub_be_to_cpu16 (tree->nodes);
if (nnodes * (grub_uint32_t) (tree)->nodesize > blocksize)
break;
for (i = (int) nnodes - 1; i >= 0; i--)
{ {
#define EXTNODE(tree, index) \ #define EXTNODE(tree, index) \
+1
View File
@@ -986,6 +986,7 @@ grub_udf_read_symlink (grub_fshelp_node_t node)
case 1: case 1:
if (ptr[1]) if (ptr[1])
goto fail; goto fail;
/* Fallthrough. */
case 2: case 2:
/* in 4 bytes. out: 1 byte. */ /* in 4 bytes. out: 1 byte. */
optr = out; optr = out;
+8 -2
View File
@@ -394,7 +394,7 @@ grub_ufs_read_file (struct grub_ufs_data *data,
return -1; return -1;
} }
else else
grub_memset (buf, UFS_BLKSZ (sblock) - skipfirst, 0); grub_memset (buf, 0, blockend);
buf += UFS_BLKSZ (sblock) - skipfirst; buf += UFS_BLKSZ (sblock) - skipfirst;
} }
@@ -465,7 +465,13 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino)
&& INODE_SIZE (data) <= sizeof (data->inode.symlink)) && INODE_SIZE (data) <= sizeof (data->inode.symlink))
grub_strcpy (symlink, (char *) data->inode.symlink); grub_strcpy (symlink, (char *) data->inode.symlink);
else else
grub_ufs_read_file (data, 0, 0, 0, sz, symlink); {
if (grub_ufs_read_file (data, 0, 0, 0, sz, symlink) < 0)
{
grub_free(symlink);
return grub_errno;
}
}
symlink[sz] = '\0'; symlink[sz] = '\0';
/* The symlink is an absolute path, go back to the root inode. */ /* The symlink is an absolute path, go back to the root inode. */
+336 -123
View File
@@ -34,6 +34,50 @@ GRUB_MOD_LICENSE ("GPLv3+");
#define XFS_INODE_FORMAT_EXT 2 #define XFS_INODE_FORMAT_EXT 2
#define XFS_INODE_FORMAT_BTREE 3 #define XFS_INODE_FORMAT_BTREE 3
/* Superblock version field flags */
#define XFS_SB_VERSION_NUMBITS 0x000f
#define XFS_SB_VERSION_ATTRBIT 0x0010
#define XFS_SB_VERSION_NLINKBIT 0x0020
#define XFS_SB_VERSION_QUOTABIT 0x0040
#define XFS_SB_VERSION_ALIGNBIT 0x0080
#define XFS_SB_VERSION_DALIGNBIT 0x0100
#define XFS_SB_VERSION_LOGV2BIT 0x0400
#define XFS_SB_VERSION_SECTORBIT 0x0800
#define XFS_SB_VERSION_EXTFLGBIT 0x1000
#define XFS_SB_VERSION_DIRV2BIT 0x2000
#define XFS_SB_VERSION_MOREBITSBIT 0x8000
#define XFS_SB_VERSION_BITS_SUPPORTED \
(XFS_SB_VERSION_NUMBITS | \
XFS_SB_VERSION_ATTRBIT | \
XFS_SB_VERSION_NLINKBIT | \
XFS_SB_VERSION_QUOTABIT | \
XFS_SB_VERSION_ALIGNBIT | \
XFS_SB_VERSION_DALIGNBIT | \
XFS_SB_VERSION_LOGV2BIT | \
XFS_SB_VERSION_SECTORBIT | \
XFS_SB_VERSION_EXTFLGBIT | \
XFS_SB_VERSION_DIRV2BIT | \
XFS_SB_VERSION_MOREBITSBIT)
/* Recognized xfs format versions */
#define XFS_SB_VERSION_4 4 /* Good old XFS filesystem */
#define XFS_SB_VERSION_5 5 /* CRC enabled filesystem */
/* features2 field flags */
#define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */
#define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */
#define XFS_SB_VERSION2_PROJID32BIT 0x00000080 /* 32-bit project ids */
#define XFS_SB_VERSION2_FTYPE 0x00000200 /* inode type in dir */
#define XFS_SB_VERSION2_BITS_SUPPORTED \
(XFS_SB_VERSION2_LAZYSBCOUNTBIT | \
XFS_SB_VERSION2_ATTR2BIT | \
XFS_SB_VERSION2_PROJID32BIT | \
XFS_SB_VERSION2_FTYPE)
/* incompat feature flags */
#define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */
#define XFS_SB_FEAT_INCOMPAT_SUPPORTED \
(XFS_SB_FEAT_INCOMPAT_FTYPE)
struct grub_xfs_sblock struct grub_xfs_sblock
{ {
@@ -45,7 +89,9 @@ struct grub_xfs_sblock
grub_uint64_t rootino; grub_uint64_t rootino;
grub_uint8_t unused3[20]; grub_uint8_t unused3[20];
grub_uint32_t agsize; grub_uint32_t agsize;
grub_uint8_t unused4[20]; grub_uint8_t unused4[12];
grub_uint16_t version;
grub_uint8_t unused5[6];
grub_uint8_t label[12]; grub_uint8_t label[12];
grub_uint8_t log2_bsize; grub_uint8_t log2_bsize;
grub_uint8_t log2_sect; grub_uint8_t log2_sect;
@@ -54,12 +100,19 @@ struct grub_xfs_sblock
grub_uint8_t log2_agblk; grub_uint8_t log2_agblk;
grub_uint8_t unused6[67]; grub_uint8_t unused6[67];
grub_uint8_t log2_dirblk; grub_uint8_t log2_dirblk;
grub_uint8_t unused7[7];
grub_uint32_t features2;
grub_uint8_t unused8[4];
grub_uint32_t sb_features_compat;
grub_uint32_t sb_features_ro_compat;
grub_uint32_t sb_features_incompat;
grub_uint32_t sb_features_log_incompat;
} GRUB_PACKED; } GRUB_PACKED;
struct grub_xfs_dir_header struct grub_xfs_dir_header
{ {
grub_uint8_t count; grub_uint8_t count;
grub_uint8_t smallino; grub_uint8_t largeino;
union union
{ {
grub_uint32_t i4; grub_uint32_t i4;
@@ -67,21 +120,29 @@ struct grub_xfs_dir_header
} GRUB_PACKED parent; } GRUB_PACKED parent;
} GRUB_PACKED; } GRUB_PACKED;
/* Structure for directory entry inlined in the inode */
struct grub_xfs_dir_entry struct grub_xfs_dir_entry
{ {
grub_uint8_t len; grub_uint8_t len;
grub_uint16_t offset; grub_uint16_t offset;
char name[1]; char name[1];
/* Inode number follows, 32 bits. */ /* Inode number follows, 32 / 64 bits. */
} GRUB_PACKED; } GRUB_PACKED;
/* Structure for directory entry in a block */
struct grub_xfs_dir2_entry struct grub_xfs_dir2_entry
{ {
grub_uint64_t inode; grub_uint64_t inode;
grub_uint8_t len; grub_uint8_t len;
} GRUB_PACKED; } GRUB_PACKED;
typedef grub_uint32_t grub_xfs_extent[4]; struct grub_xfs_extent
{
/* This should be a bitfield but bietfields are unportable, so just have
a raw array and functions extracting useful info from it.
*/
grub_uint32_t raw[4];
} GRUB_PACKED;
struct grub_xfs_btree_node struct grub_xfs_btree_node
{ {
@@ -90,21 +151,22 @@ struct grub_xfs_btree_node
grub_uint16_t numrecs; grub_uint16_t numrecs;
grub_uint64_t left; grub_uint64_t left;
grub_uint64_t right; grub_uint64_t right;
grub_uint64_t keys[1]; /* In V5 here follow crc, uuid, etc. */
} GRUB_PACKED; /* Then follow keys and block pointers */
} GRUB_PACKED;
struct grub_xfs_btree_root struct grub_xfs_btree_root
{ {
grub_uint16_t level; grub_uint16_t level;
grub_uint16_t numrecs; grub_uint16_t numrecs;
grub_uint64_t keys[1]; grub_uint64_t keys[1];
} GRUB_PACKED; } GRUB_PACKED;
struct grub_xfs_time struct grub_xfs_time
{ {
grub_uint32_t sec; grub_uint32_t sec;
grub_uint32_t nanosec; grub_uint32_t nanosec;
} GRUB_PACKED; } GRUB_PACKED;
struct grub_xfs_inode struct grub_xfs_inode
{ {
@@ -123,19 +185,11 @@ struct grub_xfs_inode
grub_uint16_t unused3; grub_uint16_t unused3;
grub_uint8_t fork_offset; grub_uint8_t fork_offset;
grub_uint8_t unused4[17]; grub_uint8_t unused4[17];
union
{
char raw[156];
struct dir
{
struct grub_xfs_dir_header dirhead;
struct grub_xfs_dir_entry direntry[1];
} dir;
grub_xfs_extent extents[XFS_INODE_EXTENTS];
struct grub_xfs_btree_root btree;
} GRUB_PACKED data;
} GRUB_PACKED; } GRUB_PACKED;
#define XFS_V2_INODE_SIZE sizeof(struct grub_xfs_inode)
#define XFS_V3_INODE_SIZE (XFS_V2_INODE_SIZE + 76)
struct grub_xfs_dirblock_tail struct grub_xfs_dirblock_tail
{ {
grub_uint32_t leaf_count; grub_uint32_t leaf_count;
@@ -157,6 +211,8 @@ struct grub_xfs_data
int pos; int pos;
int bsize; int bsize;
grub_uint32_t agsize; grub_uint32_t agsize;
unsigned int hasftype:1;
unsigned int hascrc:1;
struct grub_fshelp_node diropen; struct grub_fshelp_node diropen;
}; };
@@ -164,6 +220,71 @@ static grub_dl_t my_mod;
static int grub_xfs_sb_hascrc(struct grub_xfs_data *data)
{
return (data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) ==
grub_cpu_to_be16_compile_time(XFS_SB_VERSION_5);
}
static int grub_xfs_sb_hasftype(struct grub_xfs_data *data)
{
if ((data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) ==
grub_cpu_to_be16_compile_time(XFS_SB_VERSION_5) &&
data->sblock.sb_features_incompat & grub_cpu_to_be32_compile_time(XFS_SB_FEAT_INCOMPAT_FTYPE))
return 1;
if (data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_MOREBITSBIT) &&
data->sblock.features2 & grub_cpu_to_be32_compile_time(XFS_SB_VERSION2_FTYPE))
return 1;
return 0;
}
static int grub_xfs_sb_valid(struct grub_xfs_data *data)
{
grub_dprintf("xfs", "Validating superblock\n");
if (grub_strncmp ((char *) (data->sblock.magic), "XFSB", 4)
|| data->sblock.log2_bsize < GRUB_DISK_SECTOR_BITS
|| ((int) data->sblock.log2_bsize
+ (int) data->sblock.log2_dirblk) >= 27)
{
grub_error (GRUB_ERR_BAD_FS, "not a XFS filesystem");
return 0;
}
if ((data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) ==
grub_cpu_to_be16_compile_time(XFS_SB_VERSION_5))
{
grub_dprintf("xfs", "XFS v5 superblock detected\n");
if (data->sblock.sb_features_incompat &
grub_cpu_to_be32_compile_time(~XFS_SB_FEAT_INCOMPAT_SUPPORTED))
{
grub_error (GRUB_ERR_BAD_FS, "XFS filesystem has unsupported "
"incompatible features");
return 0;
}
return 1;
}
else if ((data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) ==
grub_cpu_to_be16_compile_time(XFS_SB_VERSION_4))
{
grub_dprintf("xfs", "XFS v4 superblock detected\n");
if (!(data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_DIRV2BIT)))
{
grub_error (GRUB_ERR_BAD_FS, "XFS filesystem without V2 directories "
"is unsupported");
return 0;
}
if (data->sblock.version & grub_cpu_to_be16_compile_time(~XFS_SB_VERSION_BITS_SUPPORTED) ||
(data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_MOREBITSBIT) &&
data->sblock.features2 & grub_cpu_to_be16_compile_time(~XFS_SB_VERSION2_BITS_SUPPORTED)))
{
grub_error (GRUB_ERR_BAD_FS, "XFS filesystem has unsupported version "
"bits");
return 0;
}
return 1;
}
return 0;
}
/* Filetype information as used in inodes. */ /* Filetype information as used in inodes. */
#define FILETYPE_INO_MASK 0170000 #define FILETYPE_INO_MASK 0170000
#define FILETYPE_INO_REG 0100000 #define FILETYPE_INO_REG 0100000
@@ -180,14 +301,14 @@ static inline grub_uint64_t
GRUB_XFS_INO_INOINAG (struct grub_xfs_data *data, GRUB_XFS_INO_INOINAG (struct grub_xfs_data *data,
grub_uint64_t ino) grub_uint64_t ino)
{ {
return (grub_be_to_cpu64 (ino) & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1)); return (ino & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1));
} }
static inline grub_uint64_t static inline grub_uint64_t
GRUB_XFS_INO_AG (struct grub_xfs_data *data, GRUB_XFS_INO_AG (struct grub_xfs_data *data,
grub_uint64_t ino) grub_uint64_t ino)
{ {
return (grub_be_to_cpu64 (ino) >> GRUB_XFS_INO_AGBITS (data)); return (ino >> GRUB_XFS_INO_AGBITS (data));
} }
static inline grub_disk_addr_t static inline grub_disk_addr_t
@@ -198,37 +319,25 @@ GRUB_XFS_FSB_TO_BLOCK (struct grub_xfs_data *data, grub_disk_addr_t fsb)
} }
static inline grub_uint64_t static inline grub_uint64_t
GRUB_XFS_EXTENT_OFFSET (grub_xfs_extent *exts, int ex) GRUB_XFS_EXTENT_OFFSET (struct grub_xfs_extent *exts, int ex)
{ {
return ((grub_be_to_cpu32 (exts[ex][0]) & ~(1 << 31)) << 23 return ((grub_be_to_cpu32 (exts[ex].raw[0]) & ~(1 << 31)) << 23
| grub_be_to_cpu32 (exts[ex][1]) >> 9); | grub_be_to_cpu32 (exts[ex].raw[1]) >> 9);
} }
static inline grub_uint64_t static inline grub_uint64_t
GRUB_XFS_EXTENT_BLOCK (grub_xfs_extent *exts, int ex) GRUB_XFS_EXTENT_BLOCK (struct grub_xfs_extent *exts, int ex)
{ {
return ((grub_uint64_t) (grub_be_to_cpu32 (exts[ex][1]) return ((grub_uint64_t) (grub_be_to_cpu32 (exts[ex].raw[1])
& (0x1ff)) << 43 & (0x1ff)) << 43
| (grub_uint64_t) grub_be_to_cpu32 (exts[ex][2]) << 11 | (grub_uint64_t) grub_be_to_cpu32 (exts[ex].raw[2]) << 11
| grub_be_to_cpu32 (exts[ex][3]) >> 21); | grub_be_to_cpu32 (exts[ex].raw[3]) >> 21);
} }
static inline grub_uint64_t static inline grub_uint64_t
GRUB_XFS_EXTENT_SIZE (grub_xfs_extent *exts, int ex) GRUB_XFS_EXTENT_SIZE (struct grub_xfs_extent *exts, int ex)
{ {
return (grub_be_to_cpu32 (exts[ex][3]) & ((1 << 21) - 1)); return (grub_be_to_cpu32 (exts[ex].raw[3]) & ((1 << 21) - 1));
}
static inline int
GRUB_XFS_ROUND_TO_DIRENT (int pos)
{
return ((((pos) + 8 - 1) / 8) * 8);
}
static inline int
GRUB_XFS_NEXT_DIRENT (int pos, int len)
{
return (pos) + GRUB_XFS_ROUND_TO_DIRENT (8 + 1 + len + 2);
} }
@@ -255,6 +364,109 @@ grub_xfs_inode_offset (struct grub_xfs_data *data,
data->sblock.log2_inode); data->sblock.log2_inode);
} }
static inline grub_size_t
grub_xfs_inode_size(struct grub_xfs_data *data)
{
return (grub_size_t)1 << data->sblock.log2_inode;
}
/*
* Returns size occupied by XFS inode stored in memory - we store struct
* grub_fshelp_node there but on disk inode size may be actually larger than
* struct grub_xfs_inode so we need to account for that so that we can read
* from disk directly into in-memory structure.
*/
static inline grub_size_t
grub_xfs_fshelp_size(struct grub_xfs_data *data)
{
return sizeof (struct grub_fshelp_node) - sizeof (struct grub_xfs_inode)
+ grub_xfs_inode_size(data);
}
/* This should return void * but XFS code is error-prone with alignment, so
return char to retain cast-align.
*/
static char *
grub_xfs_inode_data(struct grub_xfs_inode *inode)
{
if (inode->version <= 2)
return ((char *)inode) + XFS_V2_INODE_SIZE;
return ((char *)inode) + XFS_V3_INODE_SIZE;
}
static struct grub_xfs_dir_entry *
grub_xfs_inline_de(struct grub_xfs_dir_header *head)
{
/*
With small inode numbers the header is 4 bytes smaller because of
smaller parent pointer
*/
return (struct grub_xfs_dir_entry *)
(((char *) head) + sizeof(struct grub_xfs_dir_header) -
(head->largeino ? 0 : sizeof(grub_uint32_t)));
}
static grub_uint8_t *
grub_xfs_inline_de_inopos(struct grub_xfs_data *data,
struct grub_xfs_dir_entry *de)
{
return ((grub_uint8_t *)(de + 1)) + de->len - 1 + (data->hasftype ? 1 : 0);
}
static struct grub_xfs_dir_entry *
grub_xfs_inline_next_de(struct grub_xfs_data *data,
struct grub_xfs_dir_header *head,
struct grub_xfs_dir_entry *de)
{
char *p = (char *)de + sizeof(struct grub_xfs_dir_entry) - 1 + de->len;
p += head->largeino ? sizeof(grub_uint64_t) : sizeof(grub_uint32_t);
if (data->hasftype)
p++;
return (struct grub_xfs_dir_entry *)p;
}
static struct grub_xfs_dirblock_tail *
grub_xfs_dir_tail(struct grub_xfs_data *data, void *dirblock)
{
int dirblksize = 1 << (data->sblock.log2_bsize + data->sblock.log2_dirblk);
return (struct grub_xfs_dirblock_tail *)
((char *)dirblock + dirblksize - sizeof (struct grub_xfs_dirblock_tail));
}
static struct grub_xfs_dir2_entry *
grub_xfs_first_de(struct grub_xfs_data *data, void *dirblock)
{
if (data->hascrc)
return (struct grub_xfs_dir2_entry *)((char *)dirblock + 64);
return (struct grub_xfs_dir2_entry *)((char *)dirblock + 16);
}
static struct grub_xfs_dir2_entry *
grub_xfs_next_de(struct grub_xfs_data *data, struct grub_xfs_dir2_entry *de)
{
int size = sizeof (struct grub_xfs_dir2_entry) + de->len + 2 /* Tag */;
if (data->hasftype)
size++; /* File type */
return (struct grub_xfs_dir2_entry *)(((char *)de) + ALIGN_UP(size, 8));
}
/* This should return void * but XFS code is error-prone with alignment, so
return char to retain cast-align.
*/
static char *
grub_xfs_btree_keys(struct grub_xfs_data *data,
struct grub_xfs_btree_node *leaf)
{
char *keys = (char *)(leaf + 1);
if (data->hascrc)
keys += 48; /* skip crc, uuid, ... */
return keys;
}
static grub_err_t static grub_err_t
grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino,
@@ -263,9 +475,11 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino,
grub_uint64_t block = grub_xfs_inode_block (data, ino); grub_uint64_t block = grub_xfs_inode_block (data, ino);
int offset = grub_xfs_inode_offset (data, ino); int offset = grub_xfs_inode_offset (data, ino);
grub_dprintf("xfs", "Reading inode (%"PRIuGRUB_UINT64_T") - %"PRIuGRUB_UINT64_T", %d\n",
ino, block, offset);
/* Read the inode. */ /* Read the inode. */
if (grub_disk_read (data->disk, block, offset, if (grub_disk_read (data->disk, block, offset, grub_xfs_inode_size(data),
1 << data->sblock.log2_inode, inode)) inode))
return grub_errno; return grub_errno;
if (grub_strncmp ((char *) inode->magic, "IN", 2)) if (grub_strncmp ((char *) inode->magic, "IN", 2))
@@ -274,40 +488,47 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino,
return 0; return 0;
} }
static grub_uint64_t
get_fsb (const void *keys, int idx)
{
const char *p = (const char *) keys + sizeof(grub_uint64_t) * idx;
return grub_be_to_cpu64 (grub_get_unaligned64 (p));
}
static grub_disk_addr_t static grub_disk_addr_t
grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
{ {
struct grub_xfs_btree_node *leaf = 0; struct grub_xfs_btree_node *leaf = 0;
int ex, nrec; int ex, nrec;
grub_xfs_extent *exts; struct grub_xfs_extent *exts;
grub_uint64_t ret = 0; grub_uint64_t ret = 0;
if (node->inode.format == XFS_INODE_FORMAT_BTREE) if (node->inode.format == XFS_INODE_FORMAT_BTREE)
{ {
const grub_uint64_t *keys; struct grub_xfs_btree_root *root;
const char *keys;
int recoffset; int recoffset;
leaf = grub_malloc (node->data->bsize); leaf = grub_malloc (node->data->bsize);
if (leaf == 0) if (leaf == 0)
return 0; return 0;
nrec = grub_be_to_cpu16 (node->inode.data.btree.numrecs); root = (struct grub_xfs_btree_root *) grub_xfs_inode_data(&node->inode);
keys = &node->inode.data.btree.keys[0]; nrec = grub_be_to_cpu16 (root->numrecs);
keys = (char *) &root->keys[0];
if (node->inode.fork_offset) if (node->inode.fork_offset)
recoffset = (node->inode.fork_offset - 1) / 2; recoffset = (node->inode.fork_offset - 1) / 2;
else else
recoffset = ((1 << node->data->sblock.log2_inode) recoffset = (grub_xfs_inode_size(node->data)
- ((char *) &node->inode.data.btree.keys - ((char *) keys - (char *) &node->inode))
- (char *) &node->inode)) / (2 * sizeof (grub_uint64_t));
/ (2 * sizeof (grub_uint64_t));
do do
{ {
int i; int i;
for (i = 0; i < nrec; i++) for (i = 0; i < nrec; i++)
{ {
if (fileblock < grub_be_to_cpu64 (keys[i])) if (fileblock < get_fsb(keys, i))
break; break;
} }
@@ -317,12 +538,16 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
grub_free (leaf); grub_free (leaf);
return 0; return 0;
} }
if (grub_disk_read (node->data->disk, if (grub_disk_read (node->data->disk,
GRUB_XFS_FSB_TO_BLOCK (node->data, grub_be_to_cpu64 (keys[i - 1 + recoffset])) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS), GRUB_XFS_FSB_TO_BLOCK (node->data, get_fsb (keys, i - 1 + recoffset)) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS),
0, node->data->bsize, leaf)) 0, node->data->bsize, leaf))
return 0; return 0;
if (grub_strncmp ((char *) leaf->magic, "BMAP", 4)) if ((!node->data->hascrc &&
grub_strncmp ((char *) leaf->magic, "BMAP", 4)) ||
(node->data->hascrc &&
grub_strncmp ((char *) leaf->magic, "BMA3", 4)))
{ {
grub_free (leaf); grub_free (leaf);
grub_error (GRUB_ERR_BAD_FS, "not a correct XFS BMAP node"); grub_error (GRUB_ERR_BAD_FS, "not a correct XFS BMAP node");
@@ -330,18 +555,18 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
} }
nrec = grub_be_to_cpu16 (leaf->numrecs); nrec = grub_be_to_cpu16 (leaf->numrecs);
keys = &leaf->keys[0]; keys = grub_xfs_btree_keys(node->data, leaf);
recoffset = ((node->data->bsize - ((char *) &leaf->keys recoffset = ((node->data->bsize - ((char *) keys
- (char *) leaf)) - (char *) leaf))
/ (2 * sizeof (grub_uint64_t))); / (2 * sizeof (grub_uint64_t)));
} }
while (leaf->level); while (leaf->level);
exts = (grub_xfs_extent *) keys; exts = (struct grub_xfs_extent *) keys;
} }
else if (node->inode.format == XFS_INODE_FORMAT_EXT) else if (node->inode.format == XFS_INODE_FORMAT_EXT)
{ {
nrec = grub_be_to_cpu32 (node->inode.nextents); nrec = grub_be_to_cpu32 (node->inode.nextents);
exts = &node->inode.data.extents[0]; exts = (struct grub_xfs_extent *) grub_xfs_inode_data(&node->inode);
} }
else else
{ {
@@ -379,13 +604,13 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
POS. Return the amount of read bytes in READ. */ POS. Return the amount of read bytes in READ. */
static grub_ssize_t static grub_ssize_t
grub_xfs_read_file (grub_fshelp_node_t node, grub_xfs_read_file (grub_fshelp_node_t node,
grub_disk_read_hook_t read_hook, void *read_hook_data, grub_disk_read_hook_t read_hook, void *read_hook_data,
grub_off_t pos, grub_size_t len, char *buf) grub_off_t pos, grub_size_t len, char *buf, grub_uint32_t header_size)
{ {
return grub_fshelp_read_file (node->data->disk, node, return grub_fshelp_read_file (node->data->disk, node,
read_hook, read_hook_data, read_hook, read_hook_data,
pos, len, buf, grub_xfs_read_block, pos, len, buf, grub_xfs_read_block,
grub_be_to_cpu64 (node->inode.size), grub_be_to_cpu64 (node->inode.size) + header_size,
node->data->sblock.log2_bsize node->data->sblock.log2_bsize
- GRUB_DISK_SECTOR_BITS, 0); - GRUB_DISK_SECTOR_BITS, 0);
} }
@@ -394,23 +619,34 @@ grub_xfs_read_file (grub_fshelp_node_t node,
static char * static char *
grub_xfs_read_symlink (grub_fshelp_node_t node) grub_xfs_read_symlink (grub_fshelp_node_t node)
{ {
int size = grub_be_to_cpu64 (node->inode.size); grub_ssize_t size = grub_be_to_cpu64 (node->inode.size);
if (size < 0)
{
grub_error (GRUB_ERR_BAD_FS, "invalid symlink");
return 0;
}
switch (node->inode.format) switch (node->inode.format)
{ {
case XFS_INODE_FORMAT_INO: case XFS_INODE_FORMAT_INO:
return grub_strndup (node->inode.data.raw, size); return grub_strndup (grub_xfs_inode_data(&node->inode), size);
case XFS_INODE_FORMAT_EXT: case XFS_INODE_FORMAT_EXT:
{ {
char *symlink; char *symlink;
grub_ssize_t numread; grub_ssize_t numread;
int off = 0;
if (node->data->hascrc)
off = 56;
symlink = grub_malloc (size + 1); symlink = grub_malloc (size + 1);
if (!symlink) if (!symlink)
return 0; return 0;
numread = grub_xfs_read_file (node, 0, 0, 0, size, symlink); node->inode.size = grub_be_to_cpu64 (size + off);
numread = grub_xfs_read_file (node, 0, 0, off, size, symlink, off);
if (numread != size) if (numread != size)
{ {
grub_free (symlink); grub_free (symlink);
@@ -456,9 +692,7 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename,
struct grub_fshelp_node *fdiro; struct grub_fshelp_node *fdiro;
grub_err_t err; grub_err_t err;
fdiro = grub_malloc (sizeof (struct grub_fshelp_node) fdiro = grub_malloc (grub_xfs_fshelp_size(ctx->diro->data) + 1);
- sizeof (struct grub_xfs_inode)
+ (1 << ctx->diro->data->sblock.log2_inode) + 1);
if (!fdiro) if (!fdiro)
{ {
grub_print_error (); grub_print_error ();
@@ -496,24 +730,18 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
{ {
case XFS_INODE_FORMAT_INO: case XFS_INODE_FORMAT_INO:
{ {
struct grub_xfs_dir_entry *de = &diro->inode.data.dir.direntry[0]; struct grub_xfs_dir_header *head = (struct grub_xfs_dir_header *) grub_xfs_inode_data(&diro->inode);
int smallino = !diro->inode.data.dir.dirhead.smallino; struct grub_xfs_dir_entry *de = grub_xfs_inline_de(head);
int smallino = !head->largeino;
int i; int i;
grub_uint64_t parent; grub_uint64_t parent;
/* If small inode numbers are used to pack the direntry, the /* If small inode numbers are used to pack the direntry, the
parent inode number is small too. */ parent inode number is small too. */
if (smallino) if (smallino)
{ parent = grub_be_to_cpu32 (head->parent.i4);
parent = grub_be_to_cpu32 (diro->inode.data.dir.dirhead.parent.i4);
parent = grub_cpu_to_be64 (parent);
/* The header is a bit smaller than usual. */
de = (struct grub_xfs_dir_entry *) ((char *) de - 4);
}
else else
{ parent = grub_be_to_cpu64 (head->parent.i8);
parent = diro->inode.data.dir.dirhead.parent.i8;
}
/* Synthesize the direntries for `.' and `..'. */ /* Synthesize the direntries for `.' and `..'. */
if (iterate_dir_call_hook (diro->ino, ".", &ctx)) if (iterate_dir_call_hook (diro->ino, ".", &ctx))
@@ -522,12 +750,10 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
if (iterate_dir_call_hook (parent, "..", &ctx)) if (iterate_dir_call_hook (parent, "..", &ctx))
return 1; return 1;
for (i = 0; i < diro->inode.data.dir.dirhead.count; i++) for (i = 0; i < head->count; i++)
{ {
grub_uint64_t ino; grub_uint64_t ino;
grub_uint8_t *inopos = (((grub_uint8_t *) de) grub_uint8_t *inopos = grub_xfs_inline_de_inopos(dir->data, de);
+ sizeof (struct grub_xfs_dir_entry)
+ de->len - 1);
grub_uint8_t c; grub_uint8_t c;
/* inopos might be unaligned. */ /* inopos might be unaligned. */
@@ -545,7 +771,6 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
| (((grub_uint64_t) inopos[5]) << 16) | (((grub_uint64_t) inopos[5]) << 16)
| (((grub_uint64_t) inopos[6]) << 8) | (((grub_uint64_t) inopos[6]) << 8)
| (((grub_uint64_t) inopos[7]) << 0); | (((grub_uint64_t) inopos[7]) << 0);
ino = grub_cpu_to_be64 (ino);
c = de->name[de->len]; c = de->name[de->len];
de->name[de->len] = '\0'; de->name[de->len] = '\0';
@@ -553,10 +778,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
return 1; return 1;
de->name[de->len] = c; de->name[de->len] = c;
de = ((struct grub_xfs_dir_entry *) de = grub_xfs_inline_next_de(dir->data, head, de);
(((char *) de)+ sizeof (struct grub_xfs_dir_entry) + de->len
+ ((smallino ? sizeof (grub_uint32_t)
: sizeof (grub_uint64_t))) - 1));
} }
break; break;
} }
@@ -583,19 +805,15 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
>> dirblk_log2); >> dirblk_log2);
blk++) blk++)
{ {
/* The header is skipped, the first direntry is stored struct grub_xfs_dir2_entry *direntry =
from byte 16. */ grub_xfs_first_de(dir->data, dirblock);
int pos = 16;
int entries; int entries;
int tail_start = (dirblk_size struct grub_xfs_dirblock_tail *tail =
- sizeof (struct grub_xfs_dirblock_tail)); grub_xfs_dir_tail(dir->data, dirblock);
struct grub_xfs_dirblock_tail *tail;
tail = (struct grub_xfs_dirblock_tail *) &dirblock[tail_start];
numread = grub_xfs_read_file (dir, 0, 0, numread = grub_xfs_read_file (dir, 0, 0,
blk << dirblk_log2, blk << dirblk_log2,
dirblk_size, dirblock); dirblk_size, dirblock, 0);
if (numread != dirblk_size) if (numread != dirblk_size)
return 0; return 0;
@@ -603,14 +821,11 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
- grub_be_to_cpu32 (tail->leaf_stale)); - grub_be_to_cpu32 (tail->leaf_stale));
/* Iterate over all entries within this block. */ /* Iterate over all entries within this block. */
while (pos < (dirblk_size while ((char *)direntry < (char *)tail)
- (int) sizeof (struct grub_xfs_dir2_entry)))
{ {
struct grub_xfs_dir2_entry *direntry;
grub_uint8_t *freetag; grub_uint8_t *freetag;
char *filename; char *filename;
direntry = (struct grub_xfs_dir2_entry *) &dirblock[pos];
freetag = (grub_uint8_t *) direntry; freetag = (grub_uint8_t *) direntry;
if (grub_get_unaligned16 (freetag) == 0XFFFF) if (grub_get_unaligned16 (freetag) == 0XFFFF)
@@ -618,17 +833,20 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
grub_uint8_t *skip = (freetag + sizeof (grub_uint16_t)); grub_uint8_t *skip = (freetag + sizeof (grub_uint16_t));
/* This entry is not used, go to the next one. */ /* This entry is not used, go to the next one. */
pos += grub_be_to_cpu16 (grub_get_unaligned16 (skip)); direntry = (struct grub_xfs_dir2_entry *)
(((char *)direntry) +
grub_be_to_cpu16 (grub_get_unaligned16 (skip)));
continue; continue;
} }
filename = &dirblock[pos + sizeof (*direntry)]; filename = (char *)(direntry + 1);
/* The byte after the filename is for the tag, which /* The byte after the filename is for the filetype, padding, or
is not used by GRUB. So it can be overwritten. */ tag, which is not used by GRUB. So it can be overwritten. */
filename[direntry->len] = '\0'; filename[direntry->len] = '\0';
if (iterate_dir_call_hook (direntry->inode, filename, &ctx)) if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode),
filename, &ctx))
{ {
grub_free (dirblock); grub_free (dirblock);
return 1; return 1;
@@ -641,8 +859,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
break; break;
/* Select the next directory entry. */ /* Select the next directory entry. */
pos = GRUB_XFS_NEXT_DIRENT (pos, direntry->len); direntry = grub_xfs_next_de(dir->data, direntry);
pos = GRUB_XFS_ROUND_TO_DIRENT (pos);
} }
} }
grub_free (dirblock); grub_free (dirblock);
@@ -667,36 +884,35 @@ grub_xfs_mount (grub_disk_t disk)
if (!data) if (!data)
return 0; return 0;
grub_dprintf("xfs", "Reading sb\n");
/* Read the superblock. */ /* Read the superblock. */
if (grub_disk_read (disk, 0, 0, if (grub_disk_read (disk, 0, 0,
sizeof (struct grub_xfs_sblock), &data->sblock)) sizeof (struct grub_xfs_sblock), &data->sblock))
goto fail; goto fail;
if (grub_strncmp ((char *) (data->sblock.magic), "XFSB", 4) if (!grub_xfs_sb_valid(data))
|| data->sblock.log2_bsize < GRUB_DISK_SECTOR_BITS goto fail;
|| ((int) data->sblock.log2_bsize
+ (int) data->sblock.log2_dirblk) >= 27)
{
grub_error (GRUB_ERR_BAD_FS, "not a XFS filesystem");
goto fail;
}
data = grub_realloc (data, data = grub_realloc (data,
sizeof (struct grub_xfs_data) sizeof (struct grub_xfs_data)
- sizeof (struct grub_xfs_inode) - sizeof (struct grub_xfs_inode)
+ (1 << data->sblock.log2_inode) + 1); + grub_xfs_inode_size(data) + 1);
if (! data) if (! data)
goto fail; goto fail;
data->diropen.data = data; data->diropen.data = data;
data->diropen.ino = data->sblock.rootino; data->diropen.ino = grub_be_to_cpu64(data->sblock.rootino);
data->diropen.inode_read = 1; data->diropen.inode_read = 1;
data->bsize = grub_be_to_cpu32 (data->sblock.bsize); data->bsize = grub_be_to_cpu32 (data->sblock.bsize);
data->agsize = grub_be_to_cpu32 (data->sblock.agsize); data->agsize = grub_be_to_cpu32 (data->sblock.agsize);
data->hasftype = grub_xfs_sb_hasftype(data);
data->hascrc = grub_xfs_sb_hascrc(data);
data->disk = disk; data->disk = disk;
data->pos = 0; data->pos = 0;
grub_dprintf("xfs", "Reading root ino %"PRIuGRUB_UINT64_T"\n",
grub_cpu_to_be64(data->sblock.rootino));
grub_xfs_read_inode (data, data->diropen.ino, &data->diropen.inode); grub_xfs_read_inode (data, data->diropen.ino, &data->diropen.inode);
@@ -799,10 +1015,7 @@ grub_xfs_open (struct grub_file *file, const char *name)
if (fdiro != &data->diropen) if (fdiro != &data->diropen)
{ {
grub_memcpy (&data->diropen, fdiro, grub_memcpy (&data->diropen, fdiro, grub_xfs_fshelp_size(data));
sizeof (struct grub_fshelp_node)
- sizeof (struct grub_xfs_inode)
+ (1 << data->sblock.log2_inode));
grub_free (fdiro); grub_free (fdiro);
} }
@@ -832,7 +1045,7 @@ grub_xfs_read (grub_file_t file, char *buf, grub_size_t len)
return grub_xfs_read_file (&data->diropen, return grub_xfs_read_file (&data->diropen,
file->read_hook, file->read_hook_data, file->read_hook, file->read_hook_data,
file->offset, len, buf); file->offset, len, buf, 0);
} }
+120 -46
View File
@@ -252,7 +252,6 @@ struct grub_zfs_data
uberblock_t current_uberblock; uberblock_t current_uberblock;
int mounted;
grub_uint64_t guid; grub_uint64_t guid;
}; };
@@ -281,12 +280,17 @@ grub_crypto_cipher_handle_t (*grub_zfs_load_key) (const struct grub_zfs_key *key
*/ */
#define MAX_SUPPORTED_FEATURE_STRLEN 50 #define MAX_SUPPORTED_FEATURE_STRLEN 50
static const char *spa_feature_names[] = { static const char *spa_feature_names[] = {
"org.illumos:lz4_compress",NULL "org.illumos:lz4_compress",
"com.delphix:hole_birth",
"com.delphix:embedded_data",
"com.delphix:extensible_dataset",
"org.open-zfs:large_blocks",
NULL
}; };
static int static int
check_feature(const char *name, grub_uint64_t val, struct grub_zfs_dir_ctx *ctx); check_feature(const char *name, grub_uint64_t val, struct grub_zfs_dir_ctx *ctx);
static int static grub_err_t
check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data ); check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data );
static grub_err_t static grub_err_t
@@ -957,7 +961,7 @@ nvpair_value (const char *nvp,char **val,
static grub_err_t static grub_err_t
check_pool_label (struct grub_zfs_data *data, check_pool_label (struct grub_zfs_data *data,
struct grub_zfs_device_desc *diskdesc, struct grub_zfs_device_desc *diskdesc,
int *inserted) int *inserted, int original)
{ {
grub_uint64_t pool_state, txg = 0; grub_uint64_t pool_state, txg = 0;
char *nvlist,*features; char *nvlist,*features;
@@ -1081,11 +1085,12 @@ check_pool_label (struct grub_zfs_data *data,
grub_dprintf ("zfs", "check 11 passed\n"); grub_dprintf ("zfs", "check 11 passed\n");
if (data->mounted && data->guid != poolguid) if (original)
return grub_error (GRUB_ERR_BAD_FS, "another zpool");
else
data->guid = poolguid; data->guid = poolguid;
if (data->guid != poolguid)
return grub_error (GRUB_ERR_BAD_FS, "another zpool");
{ {
char *nv; char *nv;
nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE); nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE);
@@ -1186,7 +1191,7 @@ scan_disk (grub_device_t dev, struct grub_zfs_data *data,
} }
grub_dprintf ("zfs", "label ok %d\n", label); grub_dprintf ("zfs", "label ok %d\n", label);
err = check_pool_label (data, &desc, inserted); err = check_pool_label (data, &desc, inserted, original);
if (err || !*inserted) if (err || !*inserted)
{ {
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
@@ -1751,7 +1756,7 @@ zio_read_gang (blkptr_t * bp, grub_zfs_endian_t endian, dva_t * dva, void *buf,
for (i = 0; i < SPA_GBH_NBLKPTRS; i++) for (i = 0; i < SPA_GBH_NBLKPTRS; i++)
{ {
if (zio_gb->zg_blkptr[i].blk_birth == 0) if (BP_IS_HOLE(&zio_gb->zg_blkptr[i]))
continue; continue;
err = zio_read_data (&zio_gb->zg_blkptr[i], endian, buf, data); err = zio_read_data (&zio_gb->zg_blkptr[i], endian, buf, data);
@@ -1800,6 +1805,39 @@ zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian, void *buf,
return err; return err;
} }
/*
* buf must be at least BPE_GET_PSIZE(bp) bytes long (which will never be
* more than BPE_PAYLOAD_SIZE bytes).
*/
static grub_err_t
decode_embedded_bp_compressed(const blkptr_t *bp, void *buf)
{
grub_size_t psize, i;
grub_uint8_t *buf8 = buf;
grub_uint64_t w = 0;
const grub_uint64_t *bp64 = (const grub_uint64_t *)bp;
psize = BPE_GET_PSIZE(bp);
/*
* Decode the words of the block pointer into the byte array.
* Low bits of first word are the first byte (little endian).
*/
for (i = 0; i < psize; i++)
{
if (i % sizeof (w) == 0)
{
/* beginning of a word */
w = *bp64;
bp64++;
if (!BPE_IS_PAYLOADWORD(bp, bp64))
bp64++;
}
buf8[i] = BF64_GET(w, (i % sizeof (w)) * 8, 8);
}
return GRUB_ERR_NONE;
}
/* /*
* Read in a block of data, verify its checksum, decompress if needed, * Read in a block of data, verify its checksum, decompress if needed,
* and put the uncompressed data in buf. * and put the uncompressed data in buf.
@@ -1818,12 +1856,26 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf,
*buf = NULL; *buf = NULL;
checksum = (grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 40) & 0xff; checksum = (grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 40) & 0xff;
comp = (grub_zfs_to_cpu64((bp)->blk_prop, endian)>>32) & 0xff; comp = (grub_zfs_to_cpu64((bp)->blk_prop, endian)>>32) & 0x7f;
encrypted = ((grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 60) & 3); encrypted = ((grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 60) & 3);
lsize = (BP_IS_HOLE(bp) ? 0 : if (BP_IS_EMBEDDED(bp))
(((grub_zfs_to_cpu64 ((bp)->blk_prop, endian) & 0xffff) + 1) {
<< SPA_MINBLOCKSHIFT)); if (BPE_GET_ETYPE(bp) != BP_EMBEDDED_TYPE_DATA)
psize = get_psize (bp, endian); return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"unsupported embedded BP (type=%u)\n",
BPE_GET_ETYPE(bp));
lsize = BPE_GET_LSIZE(bp);
psize = BF64_GET_SB(grub_zfs_to_cpu64 ((bp)->blk_prop, endian), 25, 7, 0, 1);
}
else
{
lsize = (BP_IS_HOLE(bp) ? 0 :
(((grub_zfs_to_cpu64 ((bp)->blk_prop, endian) & 0xffff) + 1)
<< SPA_MINBLOCKSHIFT));
psize = get_psize (bp, endian);
}
grub_dprintf("zfs", "zio_read: E %d: size %" PRIdGRUB_SSIZE "/%"
PRIdGRUB_SSIZE "\n", (int)BP_IS_EMBEDDED(bp), lsize, psize);
if (size) if (size)
*size = lsize; *size = lsize;
@@ -1837,33 +1889,41 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf,
"compression algorithm %s not supported\n", decomp_table[comp].name); "compression algorithm %s not supported\n", decomp_table[comp].name);
if (comp != ZIO_COMPRESS_OFF) if (comp != ZIO_COMPRESS_OFF)
{ /* It's not really necessary to align to 16, just for safety. */
/* It's not really necessary to align to 16, just for safety. */ compbuf = grub_malloc (ALIGN_UP (psize, 16));
compbuf = grub_malloc (ALIGN_UP (psize, 16));
if (! compbuf)
return grub_errno;
}
else else
compbuf = *buf = grub_malloc (lsize); compbuf = *buf = grub_malloc (lsize);
if (! compbuf)
return grub_errno;
grub_dprintf ("zfs", "endian = %d\n", endian); grub_dprintf ("zfs", "endian = %d\n", endian);
err = zio_read_data (bp, endian, compbuf, data); if (BP_IS_EMBEDDED(bp))
err = decode_embedded_bp_compressed(bp, compbuf);
else
{
err = zio_read_data (bp, endian, compbuf, data);
/* FIXME is it really necessary? */
if (comp != ZIO_COMPRESS_OFF)
grub_memset (compbuf + psize, 0, ALIGN_UP (psize, 16) - psize);
}
if (err) if (err)
{ {
grub_free (compbuf); grub_free (compbuf);
*buf = NULL; *buf = NULL;
return err; return err;
} }
grub_memset (compbuf, 0, ALIGN_UP (psize, 16) - psize);
err = zio_checksum_verify (zc, checksum, endian, if (!BP_IS_EMBEDDED(bp))
compbuf, psize);
if (err)
{ {
grub_dprintf ("zfs", "incorrect checksum\n"); err = zio_checksum_verify (zc, checksum, endian,
grub_free (compbuf); compbuf, psize);
*buf = NULL; if (err)
return err; {
grub_dprintf ("zfs", "incorrect checksum\n");
grub_free (compbuf);
*buf = NULL;
return err;
}
} }
if (encrypted) if (encrypted)
@@ -1975,7 +2035,7 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf,
dn->endian) dn->endian)
<< SPA_MINBLOCKSHIFT; << SPA_MINBLOCKSHIFT;
*buf = grub_malloc (size); *buf = grub_malloc (size);
if (*buf) if (!*buf)
{ {
err = grub_errno; err = grub_errno;
break; break;
@@ -2013,12 +2073,14 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf,
*/ */
static grub_err_t static grub_err_t
mzap_lookup (mzap_phys_t * zapobj, grub_zfs_endian_t endian, mzap_lookup (mzap_phys_t * zapobj, grub_zfs_endian_t endian,
int objsize, const char *name, grub_uint64_t * value, grub_uint32_t objsize, const char *name, grub_uint64_t * value,
int case_insensitive) int case_insensitive)
{ {
int i, chunks; grub_uint32_t i, chunks;
mzap_ent_phys_t *mzap_ent = zapobj->mz_chunk; mzap_ent_phys_t *mzap_ent = zapobj->mz_chunk;
if (objsize < MZAP_ENT_LEN)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), name);
chunks = objsize / MZAP_ENT_LEN - 1; chunks = objsize / MZAP_ENT_LEN - 1;
for (i = 0; i < chunks; i++) for (i = 0; i < chunks; i++)
{ {
@@ -2426,7 +2488,7 @@ zap_lookup (dnode_end_t * zap_dnode, const char *name, grub_uint64_t *val,
struct grub_zfs_data *data, int case_insensitive) struct grub_zfs_data *data, int case_insensitive)
{ {
grub_uint64_t block_type; grub_uint64_t block_type;
int size; grub_uint32_t size;
void *zapbuf; void *zapbuf;
grub_err_t err; grub_err_t err;
grub_zfs_endian_t endian; grub_zfs_endian_t endian;
@@ -2434,7 +2496,7 @@ zap_lookup (dnode_end_t * zap_dnode, const char *name, grub_uint64_t *val,
grub_dprintf ("zfs", "looking for '%s'\n", name); grub_dprintf ("zfs", "looking for '%s'\n", name);
/* Read in the first block of the zap object data. */ /* Read in the first block of the zap object data. */
size = grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, size = (grub_uint32_t) grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec,
zap_dnode->endian) << SPA_MINBLOCKSHIFT; zap_dnode->endian) << SPA_MINBLOCKSHIFT;
err = dmu_read (zap_dnode, 0, &zapbuf, &endian, data); err = dmu_read (zap_dnode, 0, &zapbuf, &endian, data);
if (err) if (err)
@@ -2820,7 +2882,10 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
err = dmu_read (&(dnode_path->dn), block, &t, 0, data); err = dmu_read (&(dnode_path->dn), block, &t, 0, data);
if (err) if (err)
return err; {
grub_free (sym_value);
return err;
}
movesize = sym_sz - block * blksz; movesize = sym_sz - block * blksz;
if (movesize > blksz) if (movesize > blksz)
@@ -2835,6 +2900,8 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn,
if (!path_buf) if (!path_buf)
{ {
grub_free (oldpathbuf); grub_free (oldpathbuf);
if (free_symval)
grub_free (sym_value);
return grub_errno; return grub_errno;
} }
grub_memcpy (path, sym_value, sym_sz); grub_memcpy (path, sym_value, sym_sz);
@@ -3018,7 +3085,7 @@ get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname,
grub_dprintf ("zfs", "alive\n"); grub_dprintf ("zfs", "alive\n");
err = dnode_get (mosmdn, objnum, DMU_OT_DSL_DIR, mdn, data); err = dnode_get (mosmdn, objnum, 0, mdn, data);
if (err) if (err)
return err; return err;
@@ -3051,7 +3118,7 @@ get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname,
if (err) if (err)
return err; return err;
err = dnode_get (mosmdn, objnum, DMU_OT_DSL_DIR, mdn, data); err = dnode_get (mosmdn, objnum, 0, mdn, data);
if (err) if (err)
return err; return err;
@@ -3206,8 +3273,7 @@ dnode_get_fullpath (const char *fullpath, struct subvolume *subvol,
grub_dprintf ("zfs", "endian = %d\n", subvol->mdn.endian); grub_dprintf ("zfs", "endian = %d\n", subvol->mdn.endian);
err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, &subvol->mdn, err = dnode_get (&(data->mos), headobj, 0, &subvol->mdn, data);
data);
if (err) if (err)
{ {
grub_free (fsname); grub_free (fsname);
@@ -3603,7 +3669,12 @@ zfs_mount (grub_device_t dev)
if (ub->ub_version >= SPA_VERSION_FEATURES && if (ub->ub_version >= SPA_VERSION_FEATURES &&
check_mos_features(&((objset_phys_t *) osp)->os_meta_dnode,ub_endian, check_mos_features(&((objset_phys_t *) osp)->os_meta_dnode,ub_endian,
data) != 0) data) != 0)
return NULL; {
grub_error (GRUB_ERR_BAD_FS, "Unsupported features in pool");
grub_free (osp);
zfs_unmount (data);
return NULL;
}
/* Got the MOS. Save it at the memory addr MOS. */ /* Got the MOS. Save it at the memory addr MOS. */
grub_memmove (&(data->mos.dn), &((objset_phys_t *) osp)->os_meta_dnode, grub_memmove (&(data->mos.dn), &((objset_phys_t *) osp)->os_meta_dnode,
@@ -3612,8 +3683,6 @@ zfs_mount (grub_device_t dev)
ub_endian) >> 63) & 1; ub_endian) >> 63) & 1;
grub_free (osp); grub_free (osp);
data->mounted = 1;
return data; return data;
} }
@@ -3903,7 +3972,7 @@ fill_fs_info (struct grub_dirhook_info *info,
{ {
headobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) DN_BONUS (&mdn.dn))->dd_head_dataset_obj, mdn.endian); headobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) DN_BONUS (&mdn.dn))->dd_head_dataset_obj, mdn.endian);
err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, &mdn, data); err = dnode_get (&(data->mos), headobj, 0, &mdn, data);
if (err) if (err)
{ {
grub_dprintf ("zfs", "failed here\n"); grub_dprintf ("zfs", "failed here\n");
@@ -3981,7 +4050,12 @@ iterate_zap (const char *name, grub_uint64_t val, struct grub_zfs_dir_ctx *ctx)
dnode_end_t dn; dnode_end_t dn;
grub_memset (&info, 0, sizeof (info)); grub_memset (&info, 0, sizeof (info));
dnode_get (&(ctx->data->subvol.mdn), val, 0, &dn, ctx->data); err = dnode_get (&(ctx->data->subvol.mdn), val, 0, &dn, ctx->data);
if (err)
{
grub_print_error ();
return 0;
}
if (dn.dn.dn_bonustype == DMU_OT_SA) if (dn.dn.dn_bonustype == DMU_OT_SA)
{ {
@@ -4202,11 +4276,11 @@ check_feature (const char *name, grub_uint64_t val,
* errnum: Failure. * errnum: Failure.
*/ */
static int static grub_err_t
check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data ) check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data )
{ {
grub_uint64_t objnum; grub_uint64_t objnum;
grub_uint8_t errnum = 0; grub_err_t errnum = 0;
dnode_end_t dn,mosmdn; dnode_end_t dn,mosmdn;
mzap_phys_t* mzp; mzap_phys_t* mzp;
grub_zfs_endian_t endianzap; grub_zfs_endian_t endianzap;
+12 -5
View File
@@ -238,7 +238,7 @@ grub_gcm_decrypt (grub_crypto_cipher_handle_t cipher,
grub_crypto_xor (out + 16 * i, in + 16 * i, mul, csize); grub_crypto_xor (out + 16 * i, in + 16 * i, mul, csize);
} }
for (j = 0; j < 8; j++) for (j = 0; j < 8; j++)
mac[15 - j] ^= ((psize * 8) >> (8 * j)); mac[15 - j] ^= ((((grub_uint64_t) psize) * 8) >> (8 * j));
grub_gcm_mul (mac, h); grub_gcm_mul (mac, h);
if (mac_out) if (mac_out)
@@ -354,6 +354,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
if (err) if (err)
{ {
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
grub_crypto_cipher_close (cipher);
continue; continue;
} }
@@ -362,6 +363,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
if (err) if (err)
{ {
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
grub_crypto_cipher_close (cipher);
continue; continue;
} }
@@ -372,6 +374,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
{ {
grub_dprintf ("zfs", "key loading failed\n"); grub_dprintf ("zfs", "key loading failed\n");
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
grub_crypto_cipher_close (cipher);
continue; continue;
} }
@@ -381,21 +384,25 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key,
{ {
grub_dprintf ("zfs", "key loading failed\n"); grub_dprintf ("zfs", "key loading failed\n");
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
grub_crypto_cipher_close (cipher);
continue; continue;
} }
ret = grub_crypto_cipher_open (GRUB_CIPHER_AES); ret = grub_crypto_cipher_open (GRUB_CIPHER_AES);
if (!ret) if (!ret)
{ {
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
grub_crypto_cipher_close (cipher);
continue; continue;
} }
err = grub_crypto_cipher_set_key (ret, decrypted, keylen); err = grub_crypto_cipher_set_key (ret, decrypted, keylen);
if (err) if (err)
{ {
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
grub_crypto_cipher_close (ret); grub_crypto_cipher_close (ret);
continue; grub_crypto_cipher_close (cipher);
} continue;
}
grub_crypto_cipher_close (cipher);
return ret; return ret;
} }
return NULL; return NULL;
+4 -2
View File
@@ -106,8 +106,10 @@ grub_gfxmenu_icon_manager_set_theme_path (grub_gfxmenu_icon_manager_t mgr,
const char *path) const char *path)
{ {
/* Clear the cache if the theme path has changed. */ /* Clear the cache if the theme path has changed. */
if (((mgr->theme_path == 0) != (path == 0)) if (mgr->theme_path == 0 && path == 0)
|| (grub_strcmp (mgr->theme_path, path) != 0)) return;
if (mgr->theme_path == 0 || path == 0
|| grub_strcmp (mgr->theme_path, path) != 0)
grub_gfxmenu_icon_manager_clear_cache (mgr); grub_gfxmenu_icon_manager_clear_cache (mgr);
grub_free (mgr->theme_path); grub_free (mgr->theme_path);
+2
View File
@@ -774,6 +774,8 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
view->canvas->component.ops->destroy (view->canvas); view->canvas->component.ops->destroy (view->canvas);
view->canvas = grub_gui_canvas_new (); view->canvas = grub_gui_canvas_new ();
if (!view->canvas)
goto fail;
((grub_gui_component_t) view->canvas) ((grub_gui_component_t) view->canvas)
->ops->set_bounds ((grub_gui_component_t) view->canvas, ->ops->set_bounds ((grub_gui_component_t) view->canvas,
&view->screen); &view->screen);
+8 -4
View File
@@ -1,5 +1,5 @@
/* Hierarchical argument parsing help output /* Hierarchical argument parsing help output
Copyright (C) 1995-2005, 2007, 2009-2013 Free Software Foundation, Inc. Copyright (C) 1995-2005, 2007, 2009-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>. Written by Miles Bader <miles@gnu.ai.mit.edu>.
@@ -650,7 +650,7 @@ hol_find_entry (struct hol *hol, const char *name)
return 0; return 0;
} }
/* If an entry with the long option NAME occurs in HOL, set it's special /* If an entry with the long option NAME occurs in HOL, set its special
sort position to GROUP. */ sort position to GROUP. */
static void static void
hol_set_group (struct hol *hol, const char *name, int group) hol_set_group (struct hol *hol, const char *name, int group)
@@ -1507,11 +1507,15 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
if (vt) if (vt)
{ {
if (post) if (post)
inp_text = vt + 1; {
inp_text = vt + 1;
if (! *inp_text)
inp_text = 0;
}
else else
{ {
inp_text_len = vt - argp->doc; inp_text_len = vt - argp->doc;
inp_text = __strndup (argp->doc, inp_text_len); inp_text = inp_text_len ? __strndup (argp->doc, inp_text_len) : 0;
} }
} }
else else
+17 -1
View File
@@ -1161,6 +1161,19 @@ grub_gzio_open (grub_file_t io, const char *name __attribute__ ((unused)))
return file; return file;
} }
static grub_uint8_t
mod_31 (grub_uint16_t v)
{
/* At most 2 iterations for any number that
we can get here.
In any case faster than real division. */
while (v > 0x1f)
v = (v & 0x1f) + (v >> 5);
if (v == 0x1f)
return 0;
return v;
}
static int static int
test_zlib_header (grub_gzio_t gzio) test_zlib_header (grub_gzio_t gzio)
{ {
@@ -1178,7 +1191,10 @@ test_zlib_header (grub_gzio_t gzio)
return 0; return 0;
} }
if ((cmf * 256U + flg) % 31U) /* Usually it would be: (cmf * 256 + flg) % 31 != 0. */
/* But 256 == 8 (31). */
/* By multiplying by 4 and using 32 == 1 (31). We get our formula. */
if (mod_31 (cmf + flg * 4) != 0)
{ {
grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, N_("unsupported gzip format")); grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, N_("unsupported gzip format"));
return 0; return 0;
@@ -58,15 +58,11 @@ FUNCTION(__aeabi_lmul)
ldmfd sp!, {r4, fp} ldmfd sp!, {r4, fp}
bx lr bx lr
.macro division parent .macro division32 parent
sub sp, sp, #8 @ Allocate naturally aligned 64-bit space sub sp, sp, #8 @ Allocate naturally aligned 64-bit space
stmfd sp!, {r3,lr} @ Dummy r3 to maintain stack alignment stmfd sp!, {r3,lr} @ Dummy r3 to maintain stack alignment
add r3, sp, #8 @ Set r3 to address of 64-bit space add r2, sp, #8 @ Set r2 to address of 64-bit space
str r3, [sp] @ Stack parameter, pointer to 64-bit space
mov r2, r1
mov r1, #0
mov r3, #0
bl \parent bl \parent
ldr r1, [sp, #8] @ Extract remainder ldr r1, [sp, #8] @ Extract remainder
ldmfd sp!, {r3,lr} @ Pop into an unused arg/scratch register ldmfd sp!, {r3,lr} @ Pop into an unused arg/scratch register
@@ -75,8 +71,9 @@ FUNCTION(__aeabi_lmul)
.endm .endm
FUNCTION(__aeabi_uidivmod) FUNCTION(__aeabi_uidivmod)
division grub_divmod64 division32 grub_divmod32
FUNCTION(__aeabi_idivmod)
division32 grub_divmod32s
/* /*
* Null divide-by-zero handler * Null divide-by-zero handler
Loaded 100 of 284 files, more files were not shown because too many files have changed in this diff. Show more