Generate a dummy 'Fedora' fedora.img in images directory for use by tests.
[libguestfs.git] / fuse / guestmount.c
index 068f7de..1b3abf9 100644 (file)
@@ -61,43 +61,15 @@ guestfs_h *g = NULL;
 int read_only = 0;
 int verbose = 0;
 int inspector = 0;
+int keys_from_stdin = 0;
+int echo_keys = 0;
 const char *libvirt_uri;
 int dir_cache_timeout = 60;
 
-/* This is ugly: guestfs errors are strings, FUSE wants -errno.  We
- * have to do the conversion as best we can.
- */
-#define MAX_ERRNO 256
-
 static int
 error (void)
 {
-  int i;
-  const char *err = guestfs_last_error (g);
-
-  if (!err)
-    return -EINVAL;
-
-  if (verbose)
-    fprintf (stderr, "%s\n", err);
-
-  /* Add a few of our own ... */
-
-  /* This indicates guestfsd died.  Translate into a hard EIO error.
-   * Arguably we could relaunch the guest if we hit this error.
-   */
-  if (strstr (err, "call launch before using this function"))
-    return -EIO;
-
-  /* See if it matches an errno string in the host. */
-  for (i = 0; i < MAX_ERRNO; ++i) {
-    const char *e = strerror (i);
-    if (e && strstr (err, e) != NULL)
-      return -i;
-  }
-
-  /* Too bad, return a generic error. */
-  return -EINVAL;
+  return -guestfs_last_errno (g);
 }
 
 static struct guestfs_xattr_list *
@@ -880,10 +852,12 @@ usage (int status)
              "  -c|--connect uri     Specify libvirt URI for -d option\n"
              "  --dir-cache-timeout  Set readdir cache timeout (default 5 sec)\n"
              "  -d|--domain guest    Add disks from libvirt guest\n"
+             "  --echo-keys          Don't turn off echo for passphrases\n"
              "  --format[=raw|..]    Force disk format for -a option\n"
              "  --fuse-help          Display extra FUSE options\n"
              "  -i|--inspector       Automatically mount filesystems\n"
              "  --help               Display help message and exit\n"
+             "  --keys-from-stdin    Read passphrases from stdin\n"
              "  -m|--mount dev[:mnt] Mount dev on mnt (if omitted, /)\n"
              "  -n|--no-sync         Don't autosync\n"
              "  -o|--option opt      Pass extra option to FUSE\n"
@@ -910,20 +884,23 @@ main (int argc, char *argv[])
   /* The command line arguments are broadly compatible with (a subset
    * of) guestfish.  Thus we have to deal mainly with -a, -m and --ro.
    */
-  static const char *options = "a:c:d:im:no:rv?Vx";
+  static const char *options = "a:c:d:im:no:rv?Vwx";
   static const struct option long_options[] = {
     { "add", 1, 0, 'a' },
     { "connect", 1, 0, 'c' },
     { "dir-cache-timeout", 1, 0, 0 },
     { "domain", 1, 0, 'd' },
+    { "echo-keys", 0, 0, 0 },
     { "format", 2, 0, 0 },
     { "fuse-help", 0, 0, 0 },
     { "help", 0, 0, HELP_OPTION },
     { "inspector", 0, 0, 'i' },
+    { "keys-from-stdin", 0, 0, 0 },
     { "mount", 1, 0, 'm' },
     { "no-sync", 0, 0, 'n' },
     { "option", 1, 0, 'o' },
     { "ro", 0, 0, 'r' },
+    { "rw", 0, 0, 'w' },
     { "selinux", 0, 0, 0 },
     { "trace", 0, 0, 'x' },
     { "verbose", 0, 0, 'v' },
@@ -1015,8 +992,11 @@ main (int argc, char *argv[])
           format = NULL;
         else
           format = optarg;
-      }
-      else {
+      } else if (STREQ (long_options[option_index].name, "keys-from-stdin")) {
+        keys_from_stdin = 1;
+      } else if (STREQ (long_options[option_index].name, "echo-keys")) {
+        echo_keys = 1;
+      } else {
         fprintf (stderr, _("%s: unknown long option: %s (%d)\n"),
                  program_name, long_options[option_index].name, option_index);
         exit (EXIT_FAILURE);
@@ -1064,6 +1044,10 @@ main (int argc, char *argv[])
       OPTION_V;
       break;
 
+    case 'w':
+      OPTION_w;
+      break;
+
     case 'x':
       OPTION_x;
       ADD_FUSE_ARG ("-f");