diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2011-01-08 10:15:39 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2011-01-10 09:42:07 +0000 |
commit | 03ac08e5230d0e51f94e72ba2849c2ef13ed217b (patch) | |
tree | b5913ffa7bce17ad39661bd1755ce35d194686e0 | |
parent | 03097193078ad01c33148716726a03262e3c72ab (diff) | |
download | libguestfs-03ac08e5230d0e51f94e72ba2849c2ef13ed217b.tar.gz libguestfs-03ac08e5230d0e51f94e72ba2849c2ef13ed217b.tar.xz libguestfs-03ac08e5230d0e51f94e72ba2849c2ef13ed217b.zip |
virt-filesystems: Ignore errors when getting label and UUID (RHBZ#668112).
If virt-filesystems was pointed to an image that contained
bogus or blank filesystems, then calls to vfs-label and/or vfs-uuid
could fail, resulting in errors like this:
libguestfs: error: vfs_label: /dev/vda1:
These errors can be ignored and shouldn't stop virt-filesystems
from working.
(cherry picked from commit 97339a0f43d687efac6f7edafdf21e4b8d9b35e8)
-rw-r--r-- | cat/virt-filesystems.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/cat/virt-filesystems.c b/cat/virt-filesystems.c index 987882d3..cd991e85 100644 --- a/cat/virt-filesystems.c +++ b/cat/virt-filesystems.c @@ -33,6 +33,15 @@ #include "guestfs.h" #include "options.h" +#define DISABLE_GUESTFS_ERRORS_FOR(stmt) do { \ + guestfs_error_handler_cb old_error_cb; \ + void *old_error_data; \ + old_error_cb = guestfs_get_error_handler (g, &old_error_data); \ + guestfs_set_error_handler (g, NULL, NULL); \ + stmt; \ + guestfs_set_error_handler (g, old_error_cb, old_error_data); \ + } while (0) + /* These globals are shared with options.c. */ guestfs_h *g; @@ -438,14 +447,28 @@ do_output_filesystems (void) * otherwise pass them as NULL. */ if ((columns & COLUMN_VFS_LABEL)) { - vfs_label = guestfs_vfs_label (g, fses[i]); - if (vfs_label == NULL) - exit (EXIT_FAILURE); + DISABLE_GUESTFS_ERRORS_FOR ( + vfs_label = guestfs_vfs_label (g, fses[i]); + ); + if (vfs_label == NULL) { + vfs_label = strdup (""); + if (!vfs_label) { + perror ("strdup"); + exit (EXIT_FAILURE); + } + } } if ((columns & COLUMN_UUID)) { - vfs_uuid = guestfs_vfs_uuid (g, fses[i]); - if (vfs_uuid == NULL) - exit (EXIT_FAILURE); + DISABLE_GUESTFS_ERRORS_FOR ( + vfs_uuid = guestfs_vfs_uuid (g, fses[i]); + ); + if (vfs_uuid == NULL) { + vfs_uuid = strdup (""); + if (!vfs_uuid) { + perror ("strdup"); + exit (EXIT_FAILURE); + } + } } if ((columns & COLUMN_SIZE)) { size = guestfs_blockdev_getsize64 (g, fses[i]); |