* grub-core/disk/cryptodisk.c (cryptodisk_cleanup): Disable for
now to avoid double free.
* grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_dev): Rename to
hostdisk.
* include/grub/disk.h (grub_disk_dev_id): New id HOSTDISK.
* util/grub-probe.c (escape_of_path): Always return a new copy.
(print_full_name): Escape path.
(probe): Don't call grub_util_devname_to_ofpath on NULL.
Fix hints on abstractions.
(mountinfo_entry): Increase the field size to take escaping into
account.
(find_root_device_from_libzfs): Add one byte to size of strings for
security.
* util/getroot.c [HAVE_LIMITS_H]: Include `<limits.h>'.
(find_root_device_from_libzfs): Add zpool output parser to be used
as fallback when libzfs isn't available.
LVM support for FreeBSD and GNU/kFreeBSD.
* util/lvm.c (grub_util_lvm_isvolume): Enable on FreeBSD and
GNU/kFreeBSD.
(LVM_DEV_MAPPER_STRING): Move from here ...
* include/grub/util/lvm.h (LVM_DEV_MAPPER_STRING): ... to here.
* util/getroot.c: Include `<grub/util/lvm.h>'.
(grub_util_get_dev_abstraction): Enable
grub_util_biosdisk_is_present() on FreeBSD and GNU/kFreeBSD.
Check for LVM abstraction on FreeBSD and GNU/kFreeBSD.
(grub_util_get_grub_dev): Replace "/dev/mapper/" with
`LVM_DEV_MAPPER_STRING'. Enable LVM and mdRAID only on platforms that
support it.
* util/grub-setup.c (main): Check for LVM also on FreeBSD and
GNU/kFreeBSD.
* util/grub.d/10_kfreebsd.in: Load `geom_linux_lvm' kernel module
when LVM abstraction is required for ${GRUB_DEVICE}.
* grub-core/Makefile.core.def (kernel): Remove kern/emu/getroot.c and
kern/emu/raid.c.
* grub-core/kern/emu/main.c (main): Don't try to guess root device. It's
useless.
* grub-core/kern/emu/misc.c (get_win32_path): Moved from here...
* util/getroot.c (get_win32_path): ... here.
* grub-core/kern/emu/misc.c (fini_libzfs): Moved from here...
* util/getroot.c (fini_libzfs): ... here.
* grub-core/kern/emu/misc.c (grub_get_libzfs_handle): Moved from here...
* util/getroot.c (grub_get_libzfs_handle): ... here.
* grub-core/kern/emu/misc.c (grub_find_zpool_from_dir):
Moved from here...
* util/getroot.c (grub_find_zpool_from_dir): ... here.
* grub-core/kern/emu/misc.c
(grub_make_system_path_relative_to_its_root): Moved from here...
* util/getroot.c (grub_make_system_path_relative_to_its_root): ... here.
* grub-core/kern/emu/getroot.c: Moved from here ...
* util/getroot.c: ... here. All users updated.
* grub-core/kern/emu/raid.c: Moved from here ...
* util/raid.c: ... here. All users updated.
* util/getroot.c (find_root_device): Convert block device to
character device on NetBSD.
* util/probe.c (probe): Require character device on NetBSD.
* util/hostdisk.c: NetBSD specific headers.
(configure_device_driver): new function to tune device driver
parameters (currently only for NetBSD floppy driver).
(grub_util_biosdisk_open): NetBSD specific code (get disk size
via disklabel ioctl).
(open_device): call configure_device_driver on NetBSD.
(convert_system_partition_to_system_disk): NetBSD specific code.
(device_is_wholedisk): Likewise.
(grub_util_biosdisk_get_grub_dev): Likewise.
(make_device_name): Fixed a typo in bsd_part_str.
* configure.ac: check for opendisk() and getrawpartition() on
NetBSD and set LIBUTIL.
* Makefile.in: add LIBUTIL to LIBS.
* include/grub/types.h (UNUSED): Removed since it conflicts with
NetBSD headers. All users changed to direct __attribute__ ((unused)).
Reported by Grégoire Sutre.
* util/getroot.c [__GNU__]: Include <hurd.h>, <hurd/lookup.h>, and
<hurd/fs.h>
[__GNU__] (grub_guess_root_device): Call file_name_lookup and
file_get_storage_info to implement grub_guess_root_device.
* util/hostdisk.c [__FreeBSD_kernel__]: Include sys/disk.h.
(grub_util_biosdisk_open) [__FreeBSD_kernel__]: Add support for
GNU/kFreeBSD. Check if a device is a character device. Use
DIOCGMEDIASIZE to get the size.
(convert_system_partition_to_system_disk) [__FreeBSD_kernel__]: Add
support for GNU/kFreeBSD.
(grub_util_biosdisk_get_grub_dev) [__FreeBSD_kernel__]: Check if OS_DEV
is a character device instead of a block device. Add support for
FreeBSD device names.
* util/getroot.c (find_root_device) [__FreeBSD_kernel__]: Check if ENT
is a character device instead of a block device.
* util/grub-probe.c (probe) [__FreeBSD_kernel__]: Check if DEVICE_NAME
is a character device instead of a block device.
* util/hostdisk.c [__FreeBSD__]: Include sys/disk.h.
(grub_util_biosdisk_open) [__FreeBSD__]: Add support for
FreeBSD. Check if a device is a character device. Use
DIOCGMEDIASIZE to get the size.
(convert_system_partition_to_system_disk) [__FreeBSD__]: Add
support for FreeBSD.
(grub_util_biosdisk_get_grub_dev) [__FreeBSD__]: Check if OS_DEV
is a character device instead of a block device. Add support for
FreeBSD device names.
* util/getroot.c (find_root_device) [__FreeBSD__]: Check if ENT is
a character device instead of a block device.
(grub_util_check_char_device): New function.
* util/grub-probe.c (probe) [__FreeBSD__]: Check if DEVICE_NAME is
a character device instead of a block device.
* include/grub/util/getroot.h (grub_util_check_char_device): New
prototype.
* util/getroot.c: Include <config.h>.
(grub_util_get_grub_dev): Rewrite to use asprintf for mdraid devices,
add support for /dev/md/N devices and handle LVM double dash escaping.
* configure.ac: Change host_os to cygwin for mingw.
(asprintf): New check for function.
* include/grub/symbol.h: Replace #ifndef __CYGWIN__ with
#if ! defined (__CYGWIN__) && ! defined (__MINGW32__).
* include/grub/util/misc.h: #include <config.h> and <grub/types.h>,
declear asprintf if HAVE_ASPRINTF is not set, declear fseeko, ftello,
sync, sleep and grub_util_get_disk_size for mingw.
* util/biosdisk.c (grub_util_biosdisk_open): Use grub_util_get_disk_size
to get size in mingw.
(open_device): Use flag O_BINARY if it's defined.
(find_root_device): Add dummy code for mingw.
* util/grub-mkdevicemap.c (get_floppy_disk_name): Return 0 for mingw.
(get_ide_disk_name): Return //./PHYSICALDRIVE%d for mingw.
(get_scsi_disk_name): Return 0 for mingw.
* util/hostfs.c: #include <grub/util/misc.h>.
(grub_hostfs_open): Use "rb" flag to open file, use
grub_util_get_disk_size to get disk size for mingw.
* util/misc.c: #include <windows.h> and <winioctl.h> in mingw.
(asprintf): New function if HAVE_ASPRINTF is not set.
(sync): New function for mingw.
(sleep): Likewise.
(grub_util_get_disk_size): Likewise.
* util/getroot.c (find_root_device): Skip devices that match
/dev/dm-[0-9]. This lets the real device be found for any type of
abstraction (LVM, EVMS, RAID..).
(grub_guess_root_device): Do not traverse /dev/mapper (for LVM)
and /dev/evms (for EVMS) before traversing /dev. If a /dev/dm-[0-9]
device is found first, find_root_device() will now skip it.
* util/biosdisk.c: [__CYGWIN__] Add includes.
(grub_util_biosdisk_open): Use Linux code also for Cygwin.
(get_os_disk): Move variable declarations to OS specific
parts to avoid warning.
[__GNU__] (get_os_disk): Fix /dev/sdXsN case.
[__CYGWIN__] (get_os_disk): Add Cygwin /dev/sdXN device names.
(grub_util_biosdisk_get_grub_dev): Use Linux code also for
Cygwin.
* util/getroot.c: [__CYGWIN__] Add includes.
(strip_extra_slashes): Fix "/" case.
[__CYGWIN__] (get_win32_path): New function.
[__CYGWIN__] (grub_get_prefix): Add conversion to win32 path.
[__CYGWIN__] (find_root_device): Disable.
[__CYGWIN__] (get_bootsec_serial): New function.
[__CYGWIN__] (find_cygwin_root_device): Likewise.
[__linux__] (grub_guess_root_device): Add early returns to simplify
structure.
[__CYGWIN__] (grub_guess_root_device): Call find_cygwin_root_device.
[__linux__] (grub_util_get_dev_abstraction): Enable LVM and RAID
check for Linux only.
* fs/udf.c (grub_udf_mount): Fix warning about a shadowing a
variable.
* include/grub/i386/loader.h: Change declaration of
grub_linux_boot() to match what grub_loader_set() expects.
* util/getroot.c (grub_guess_root_device): Return const char* to
fix a warning.
* util/grub-probe.c (probe): Fix a warning about uninitialized
abstraction_name variable.
* util/i386/get_disk_name.c (grub_util_get_disk_name): Mark
second argument as unused to fix a warning.
* include/grub/util/getroot.h (grub_util_check_block_device): Export new
function.
* util/getroot.c (grub_util_check_block_device): New function that
returns the given argument if it is a block device and returns NULL else.
* util/grub-probe.c (argument_is_device): New variable.
(probe): Promote device_name from a variable to an argument. Receive
device_name from grub_util_check_block_device() if path is NULL and from
grub_guess_root_device() else. Do not free() device_name anymore.
(options): Introduce new parameter '-d, --device'.
(main): Add description of the new parameter to the help screen.
Rename path variable to argument. Set argument_is_device if the '-d'
option is given. Pass argument to probe() depending on
argument_is_device.
* util/getroot.c (grub_guess_root_device): Inspect /dev/evms before
/dev (like it is done for /dev/mapper). This doesn't provide support
for EVMS, but at least it is now easy to identify the problem when it
arises.
* include/grub/util/getroot.h (grub_dev_abstraction_types): New enum.
(grub_util_get_dev_abstraction): New function prototype.
* util/getroot.c: Include `<grub/util/getroot.h>'
(grub_util_get_grub_dev): Move detection of abstraction type to ...
(grub_util_get_dev_abstraction): ... here (new function).
* util/grub-probe.c: Convert PRINT_* to an enum. Add
`PRINT_ABSTRACTION'.
(probe): Probe for abstraction type when requested.
(main): Understand `--target=abstraction'.
* util/i386/efi/grub-install.in: Add abstraction module to core
image when it is found to be necessary.
* util/i386/pc/grub-install.in: Likewise.
* util/powerpc/ieee1275/grub-install.in: Likewise.
* util/update-grub_lib.in (font_path): Return system path without
converting to GRUB path.
* util/update-grub.in: Convert system path returned by font_path()
to a GRUB path. Use `grub-probe -t abstraction' to determine what
abstraction module is needed for loading fonts (if any). Export
that as `GRUB_PRELOAD_MODULES'.
* util/grub.d/00_header.in: Process `GRUB_PRELOAD_MODULES' (print
insmod commands).
* util/getroot.c (grub_guess_root_device): Remove RAID and LVM
code, first search for device in /dev/mapper, then in /dev.
(grub_util_get_grub_dev): New function.
* include/grub/util/getroot.h (grub_util_get_grub_dev): Add
prototype.
* util/grub-probe.c (probe): Remove check for RAID, call
grub_util_get_grub_dev() instead of
grub_util_biosdisk_get_grub_dev().
* util/grub-emu.c (main): Call grub_util_get_grub_dev() instead of
grub_util_biosdisk_get_grub_dev().
* util/i386/pc/grub-setup.c (main): Likewise.