Add an optional group ("grub") for the guestfs_grub_install API.
[libguestfs.git] / cat / virt-filesystems.c
index 580710d..10084de 100644 (file)
@@ -1,5 +1,5 @@
 /* virt-filesystems
- * Copyright (C) 2010 Red Hat Inc.
+ * Copyright (C) 2010-2011 Red Hat Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #include <inttypes.h>
 #include <unistd.h>
 #include <getopt.h>
+#include <locale.h>
 #include <assert.h>
+#include <string.h>
+#include <libintl.h>
 
 #include "c-ctype.h"
 #include "human.h"
 #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;
 
 int read_only = 1;
+int live = 0;
 int verbose = 0;
 int keys_from_stdin = 0;
 int echo_keys = 0;
@@ -90,8 +103,8 @@ usage (int status)
            _("%s: list filesystems, partitions, block devices, LVM in a VM\n"
              "Copyright (C) 2010 Red Hat Inc.\n"
              "Usage:\n"
-             "  %s [--options] -d domname file\n"
-             "  %s [--options] -a disk.img [-a disk.img ...] file\n"
+             "  %s [--options] -d domname\n"
+             "  %s [--options] -a disk.img [-a disk.img ...]\n"
              "Options:\n"
              "  -a|--add image       Add image\n"
              "  --all                Display everything\n"
@@ -292,6 +305,7 @@ main (int argc, char *argv[])
    */
   assert (read_only == 1);
   assert (inspector == 0);
+  assert (live == 0);
 
   /* Must be no extra arguments on the command line. */
   if (optind != argc)
@@ -438,14 +452,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]);