From 65f08dbfe004038f5937b703f43d19877b0e15f2 Mon Sep 17 00:00:00 2001 From: Richard Laager Date: Fri, 3 Feb 2012 11:02:06 +0100 Subject: [PATCH] * util/grub-probe.c (probe): Don't crash on canonicalize_file_name failure. Put back lost PRINT_DRIVE. --- ChangeLog | 6 ++++++ util/getroot.c | 5 +---- util/grub-probe.c | 12 ++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index df35f1246..5d675ca6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-02-03 Richard Laager + + * util/grub-probe.c (probe): Don't crash on canonicalize_file_name + failure. + Put back lost PRINT_DRIVE. + 2012-02-03 Richard Laager * util/getroot.c (find_root_devices_from_libzfs): Fix compilation error. diff --git a/util/getroot.c b/util/getroot.c index 868c6d875..f2ae3e29a 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -846,10 +846,7 @@ grub_guess_root_devices (const char *dir) int root, dm; *cur = canonicalize_file_name (tmp); if (*cur == NULL) - { - grub_util_error (_("failed to get canonical path of %s"), tmp); - break; - } + grub_util_error (_("failed to get canonical path of %s"), tmp); free (tmp); root = (strcmp (*cur, "/dev/root") == 0); dm = (strncmp (*cur, "/dev/dm-", sizeof ("/dev/dm-") - 1) == 0); diff --git a/util/grub-probe.c b/util/grub-probe.c index 1d1a82230..ce38f9c9f 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -323,6 +323,8 @@ probe (const char *path, char **device_names, char delim) if (path != NULL) { grub_path = canonicalize_file_name (path); + if (! grub_path) + grub_util_error (_("failed to get canonical path of %s"), path); device_names = grub_guess_root_devices (grub_path); free (grub_path); } @@ -358,6 +360,16 @@ probe (const char *path, char **device_names, char delim) } *curdrive = 0; + if (print == PRINT_DRIVE) + { + for (curdrive = drives_names; *curdrive; curdrive++) + { + printf ("(%s)", *curdrive); + putchar (delim); + } + goto end; + } + if (print == PRINT_FS || print == PRINT_FS_UUID || print == PRINT_FS_LABEL) {