diff -urNad grub2-1.95+20080201~/include/grub/util/getroot.h grub2-1.95+20080201/include/grub/util/getroot.h --- grub2-1.95+20080201~/include/grub/util/getroot.h 2008-01-12 16:11:56.000000000 +0100 +++ grub2-1.95+20080201/include/grub/util/getroot.h 2008-02-03 18:14:11.000000000 +0100 @@ -29,5 +29,6 @@ char *grub_get_prefix (const char *dir); int grub_util_get_dev_abstraction (const char *os_dev); char *grub_util_get_grub_dev (const char *os_dev); +char *grub_util_check_block_device (const char *blk_dev); #endif /* ! GRUB_UTIL_GETROOT_HEADER */ diff -urNad grub2-1.95+20080201~/util/getroot.c grub2-1.95+20080201/util/getroot.c --- grub2-1.95+20080201~/util/getroot.c 2008-01-12 16:11:56.000000000 +0100 +++ grub2-1.95+20080201/util/getroot.c 2008-02-03 21:56:29.000000000 +0100 @@ -327,3 +327,17 @@ return grub_dev; } + +char * +grub_util_check_block_device (const char *blk_dev) +{ + struct stat st; + + if (stat (blk_dev, &st) < 0) + grub_util_error ("Cannot stat `%s'", blk_dev); + + if (S_ISBLK (st.st_mode)) + return strdup(blk_dev); + else + return 0; +} diff -urNad grub2-1.95+20080201~/util/grub-probe.c grub2-1.95+20080201/util/grub-probe.c --- grub2-1.95+20080201~/util/grub-probe.c 2008-01-25 23:33:57.000000000 +0100 +++ grub2-1.95+20080201/util/grub-probe.c 2008-02-03 19:30:50.000000000 +0100 @@ -50,6 +50,7 @@ }; int print = PRINT_FS; +unsigned int argument_is_device = 0; void grub_putchar (int c) @@ -84,9 +85,18 @@ int abstraction_type; grub_device_t dev = NULL; - device_name = grub_guess_root_device (path); + if (argument_is_device) + device_name = grub_util_check_block_device (path); + else + device_name = grub_guess_root_device (path); + if (! device_name) - grub_util_error ("cannot find a device for %s.\n", path); + { + if (argument_is_device) + grub_util_error ("%s is not a block device.\n", path); + else + grub_util_error ("cannot find a device for %s.\n", path); + } if (print == PRINT_DEVICE) { @@ -201,6 +211,7 @@ static struct option options[] = { + {"device", no_argument, 0, 'd'}, {"device-map", required_argument, 0, 'm'}, {"target", required_argument, 0, 't'}, {"help", no_argument, 0, 'h'}, @@ -217,10 +228,11 @@ "Try ``grub-probe --help'' for more information.\n"); else printf ("\ -Usage: grub-probe [OPTION]... PATH\n\ +Usage: grub-probe [OPTION]... [PATH|DEVICE]\n\ \n\ -Probe device information for a given path.\n\ +Probe device information for a given path or device.\n\ \n\ + -d, --device given argument is a system device, not a path\n\ -m, --device-map=FILE use FILE as the device map [default=%s]\n\ -t, --target=(fs|drive|device|partmap|abstraction)\n\ print filesystem module, GRUB drive, system device, partition map module or abstraction module [default=fs]\n\ @@ -246,13 +258,17 @@ /* Check for options. */ while (1) { - int c = getopt_long (argc, argv, "m:t:hVv", options, 0); + int c = getopt_long (argc, argv, "dm:t:hVv", options, 0); if (c == -1) break; else switch (c) { + case 'd': + argument_is_device = 1; + break; + case 'm': if (dev_map) free (dev_map);