diff -x '*~' -x configure -x config.h.in -ur grub2/include/grub/util/getroot.h test/include/grub/util/getroot.h --- grub2/include/grub/util/getroot.h 2007-07-22 01:32:25.000000000 +0200 +++ test/include/grub/util/getroot.h 2008-01-08 16:07:30.000000000 +0100 @@ -21,6 +21,6 @@ char *grub_guess_root_device (const char *dir); char *grub_get_prefix (const char *dir); -char *grub_util_get_grub_dev (const char *os_dev); +char *grub_util_get_grub_dev (const char *dev_type, const char *os_dev); #endif /* ! GRUB_UTIL_GETROOT_HEADER */ diff -x '*~' -x configure -x config.h.in -ur grub2/util/getroot.c test/util/getroot.c --- grub2/util/getroot.c 2007-07-22 01:32:31.000000000 +0200 +++ test/util/getroot.c 2008-01-08 16:11:01.000000000 +0100 @@ -239,11 +239,41 @@ return os_dev; } +static char *dev_types[] = { + "", + "lvm", + "raid", +}; + +enum { + TYPE_RAW, + TYPE_LVM, + TYPE_RAID, +}; + char * -grub_util_get_grub_dev (const char *os_dev) +grub_util_get_dev_type (const char *os_dev) { /* Check for LVM. */ if (!strncmp (os_dev, "/dev/mapper/", 12)) + return dev_types[TYPE_LVM]; + + /* Check for RAID. */ + if (!strncmp (os_dev, "/dev/md", 7)) + return dev_types[TYPE_RAID]; + + /* If it's not RAID or LVM, it should be a biosdisk. */ + return dev_types[TYPE_RAW]; +} + +char * +grub_util_get_grub_dev (const char *type, const char *os_dev) +{ + if (! type) + type = grub_util_get_dev_type (os_dev); + + /* Check for LVM. */ + if (!strcmp (type, "lvm")) { char *grub_dev = xmalloc (strlen (os_dev) - 12 + 1); @@ -253,7 +283,7 @@ } /* Check for RAID. */ - if (!strncmp (os_dev, "/dev/md", 7)) + if (!strcmp (type, "raid")) { const char *p; char *grub_dev = xmalloc (20); diff -x '*~' -x configure -x config.h.in -ur grub2/util/grub-probe.c test/util/grub-probe.c --- grub2/util/grub-probe.c 2007-07-22 21:17:26.000000000 +0200 +++ test/util/grub-probe.c 2008-01-08 16:12:38.000000000 +0100 @@ -39,10 +39,13 @@ #define _GNU_SOURCE 1 #include -#define PRINT_FS 0 -#define PRINT_DRIVE 1 -#define PRINT_DEVICE 2 -#define PRINT_PARTMAP 3 +enum { + PRINT_FS, + PRINT_DRIVE, + PRINT_DEVICE, + PRINT_PARTMAP, + PRINT_TYPE, +}; int print = PRINT_FS; @@ -74,6 +77,7 @@ { char *device_name; char *drive_name = NULL; + char *type_name; grub_device_t dev; grub_fs_t fs; @@ -87,7 +91,17 @@ goto end; } - drive_name = grub_util_get_grub_dev (device_name); + type_name = grub_util_get_dev_type (device_name); + if (! type_name) + grub_util_error ("cannot identify drive type for %s.\n", device_name); + + if (print == PRINT_TYPE) + { + printf ("(%s)\n", type_name); + goto end; + } + + drive_name = grub_util_get_grub_dev (type_name, device_name); if (! drive_name) grub_util_error ("cannot find a GRUB drive for %s.\n", device_name); diff -x '*~' -x configure -x config.h.in -ur grub2/util/i386/pc/grub-install.in test/util/i386/pc/grub-install.in --- grub2/util/i386/pc/grub-install.in 2007-12-30 09:52:06.000000000 +0100 +++ test/util/i386/pc/grub-install.in 2008-01-08 16:14:31.000000000 +0100 @@ -223,8 +223,11 @@ # filesystem will be accessible). partmap_module=`$grub_probe --target=partmap --device-map=${device_map} ${grubdir} 2> /dev/null` +# Device type module, if any (lvm, raid). +devtype_module=`$grub_probe --target=type --device-map=${device_map} ${grubdir}` + # _chain is often useful -modules="$modules $fs_module $partmap_module biosdisk _chain" +modules="$modules $fs_module $partmap_module $devtype_module biosdisk _chain" $grub_mkimage --output=${grubdir}/core.img --prefix=`make_system_path_relative_to_its_root ${grubdir}` $modules || exit 1 diff -x '*~' -x configure -x config.h.in -ur grub2/util/i386/pc/grub-setup.c test/util/i386/pc/grub-setup.c --- grub2/util/i386/pc/grub-setup.c 2008-01-05 13:20:28.000000000 +0100 +++ test/util/i386/pc/grub-setup.c 2008-01-08 16:10:30.000000000 +0100 @@ -668,7 +668,7 @@ if (! dest_dev) { /* Possibly, the user specified an OS device file. */ - dest_dev = grub_util_get_grub_dev (argv[optind]); + dest_dev = grub_util_get_grub_dev (NULL, argv[optind]); if (! dest_dev) { fprintf (stderr, "Invalid device `%s'.\n", argv[optind]); @@ -694,7 +694,7 @@ } else { - root_dev = grub_util_get_grub_dev (grub_guess_root_device (dir ? : DEFAULT_DIRECTORY)); + root_dev = grub_util_get_grub_dev (NULL, grub_guess_root_device (dir ? : DEFAULT_DIRECTORY)); if (! root_dev) { grub_util_info ("guessing the root device failed, because of `%s'", @@ -734,7 +734,7 @@ dir ? : DEFAULT_DIRECTORY, boot_file ? : DEFAULT_BOOT_FILE, core_file ? : DEFAULT_CORE_FILE, - root_dev, grub_util_get_grub_dev (devicelist[i]), 1); + root_dev, grub_util_get_grub_dev (NULL, devicelist[i]), 1); } free (raid_prefix);