DM-RAID probing
PATCH 1/1 DM-RAID probing
I've pushed this branch with improved DM-RAID probing support:
sftp://bzr.sv.gnu.org/srv/bzr/grub/branches/dmraid-probe/
This makes it possible for things like this to work:
grub-probe --target=partmap --device <DM-RAID partition device>
... which in turn makes it possible for grub-install to work when /boot/grub is on a DM-RAID device. The change is a bit involved, and requires the device-mapper userspace libraries to be effective (but I think these are pretty widespread). Could somebody have a look over this?
=== added file 'ChangeLog.dmraid-probe'
ChangeLog.dmraid-probe +16 -0
@@ -0,0 +1,16 @@ +2010-01-25 Colin Watson <[email protected]> + + * configure.ac: Check for Linux device-mapper support. + * util/hostdisk.c (device_is_mapped): New function. + (find_partition_start): New function, partly broken out from + linux_find_partition and grub_util_biosdisk_get_grub_dev but with + device-mapper support added. + (linux_find_partition): Use find_partition_start. + (convert_system_partition_to_system_disk): Add `st' argument. + Support Linux /dev/mapper/* devices if device-mapper support is + available; only DM-RAID devices are understood at present. + (find_system_device): Add `st' argument. Pass it to + convert_system_partition_to_system_disk. + (grub_util_biosdisk_get_grub_dev): Pass stat result to + find_system_device and convert_system_partition_to_system_disk. Use + find_partition_start.
=== modified file 'configure.ac'
configure.ac +17 -0
@@ -659,6 +659,23 @@ AC_SUBST([enable_grub_mkfont]) AC_SUBST([freetype_cflags]) AC_SUBST([freetype_libs]) +AC_ARG_ENABLE([device-mapper], + [AS_HELP_STRING([--enable-device-mapper], + [enable Linux device-mapper support (default=guessed)])]) +if test x"$enable_device_mapper" = xno ; then + device_mapper_excuse="explicitly disabled" +fi + +if test x"$device_mapper_excuse" = x ; then + # Check for device-mapper library. + AC_CHECK_LIB([devmapper], [dm_task_create], + [LDFLAGS="$LDFLAGS -ldevmapper" + AC_DEFINE([HAVE_DEVICE_MAPPER], [1], + [Define to 1 if you have the devmapper library.])], + [device_mapper_excuse="need devmapper library"]) + AC_SUBST([LIBDEVMAPPER]) +fi + AC_SUBST(ASFLAGS) # Output files.
=== modified file 'util/hostdisk.c'
hostdisk.c +209 -34
326 lines not on this page · raw message
Thanks,
Signature · 1 line
Colin Watson [[email protected]]
Quoted 6 lines · Colin Watson
I've pushed this branch with improved DM-RAID probing support:
sftp://bzr.sv.gnu.org/srv/bzr/grub/branches/dmraid-probe/
This makes it possible for things like this to work:
Quoted 7 lines
grub-probe --target=partmap --device <DM-RAID partition device>... which in turn makes it possible for grub-install to work when
/boot/grubis on a DM-RAID device. The change is a bit involved, and requires the device-mapper userspace libraries to be effective (but I think these are pretty widespread). Could somebody have a look over this?
I've extended this so that device iteration sees DM-RAID disk devices as well. This means that grub-mkdevicemap works (as long as you don't mind DM-RAID disk devices showing up as "(hd2)" or similar; with UUIDs it really doesn't matter much so I didn't go to the effort of inventing some other namespace for them), which in turn will mean that my patch to the Debian packaging to record the installation device using by-id paths should work with no further changes required.
Please have a look. Proper error handling with the device-mapper libraries winds up being a bit verbose, but I tried to make it as readable as I could.
=== added file 'ChangeLog.dmraid-probe'
ChangeLog.dmraid-probe +26 -0
@@ -0,0 +1,26 @@ +2010-01-26 Colin Watson <[email protected]> + + * configure.ac: Check for Linux device-mapper support. + + * util/hostdisk.c (device_is_mapped): New function. + (find_partition_start): New function, partly broken out from + linux_find_partition and grub_util_biosdisk_get_grub_dev but with + device-mapper support added. + (linux_find_partition): Use find_partition_start. + (convert_system_partition_to_system_disk): Add `st' argument. + Support Linux /dev/mapper/* devices if device-mapper support is + available; only DM-RAID devices are understood at present. + (find_system_device): Add `st' argument. Pass it to + convert_system_partition_to_system_disk. + (grub_util_biosdisk_get_grub_dev): Pass stat result to + find_system_device and convert_system_partition_to_system_disk. Use + find_partition_start. + + * conf/common.rmk (grub_mkdevicemap_SOURCES): Add kern/env.c, + kern/err.c, kern/list.c, and kern/misc.c. + * util/deviceiter.c [__linux__]: Define MINOR. + (grub_util_iterate_devices): Add support for DM-RAID disk devices. + * util/mkdevicemap.c (grub_putchar): New function. + (grub_getkey): New function. + (grub_refresh): New function. + (main): Set debug=all if -v -v is used.
=== modified file 'conf/common.rmk'
common.rmk +2 -1
@@ -3,7 +3,8 @@ sbin_UTILITIES += grub-mkdevicemap grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \ util/deviceiter.c \ - util/misc.c + util/misc.c \ + kern/env.c kern/err.c kern/list.c kern/misc.c ifeq ($(target_cpu)-$(platform), sparc64-ieee1275) grub_mkdevicemap_SOURCES += util/ieee1275/ofpath.c util/ieee1275/devicemap.c
=== modified file 'configure.ac'
configure.ac +17 -0
@@ -659,6 +659,23 @@ AC_SUBST([enable_grub_mkfont]) AC_SUBST([freetype_cflags]) AC_SUBST([freetype_libs]) +AC_ARG_ENABLE([device-mapper], + [AS_HELP_STRING([--enable-device-mapper], + [enable Linux device-mapper support (default=guessed)])]) +if test x"$enable_device_mapper" = xno ; then + device_mapper_excuse="explicitly disabled" +fi + +if test x"$device_mapper_excuse" = x ; then + # Check for device-mapper library. + AC_CHECK_LIB([devmapper], [dm_task_create], + [LDFLAGS="$LDFLAGS -ldevmapper" + AC_DEFINE([HAVE_DEVICE_MAPPER], [1], + [Define to 1 if you have the devmapper library.])], + [device_mapper_excuse="need devmapper library"]) + AC_SUBST([LIBDEVMAPPER]) +fi + AC_SUBST(ASFLAGS) # Output files.
=== modified file 'util/deviceiter.c'
deviceiter.c +140 -0
170 lines not on this page · raw message
=== modified file 'util/grub-mkdevicemap.c'
grub-mkdevicemap.c +22 -0
@@ -31,6 +31,7 @@#include <grub/util/misc.h> #include <grub/util/deviceiter.h> +#include <grub/env.h> #include <grub/i18n.h> #define _GNU_SOURCE 1
@@ -38,6 +39,24 @@#include "progname.h" +void +grub_putchar (int c) +{ +putchar (c); +} + +int +grub_getkey (void ) +{ +return -1 ; +} + +void +grub_refresh (void ) +{ +fflush (stdout); +} +static void make_device_map (const char *device_map,int floppy_disks) {
@@ -158,6 +177,9 @@ main (int argc, char *argv[]) } } +if (verbosity >1 ) +grub_env_set ("debug" ,"all" ); +make_device_map (dev_map ? :DEFAULT_DEVICE_MAP , floppy_disks);free (dev_map);
=== modified file 'util/hostdisk.c'
hostdisk.c +209 -34
326 lines not on this page · raw message
Thanks,
Signature · 1 line
Colin Watson [[email protected]]