fish: fuse: Add -m dev:mnt:opts to allow mount options to be specified.
[libguestfs.git] / fish / fish.c
index 4a960dc..65a0c1d 100644 (file)
@@ -1,5 +1,5 @@
 /* guestfish - the filesystem interactive shell
- * Copyright (C) 2009-2010 Red Hat Inc.
+ * Copyright (C) 2009-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
@@ -74,6 +74,7 @@ static int override_progress_bars = -1;
 guestfs_h *g;
 
 int read_only = 0;
+int live = 0;
 int quit = 0;
 int verbose = 0;
 int remote_control_listen = 0;
@@ -98,18 +99,9 @@ usage (int status)
     fprintf (stdout,
            _("%s: guest filesystem shell\n"
              "%s lets you edit virtual machine filesystems\n"
-             "Copyright (C) 2009-2010 Red Hat Inc.\n"
+             "Copyright (C) 2009-2011 Red Hat Inc.\n"
              "Usage:\n"
              "  %s [--options] cmd [: cmd : cmd ...]\n"
-             "  %s [--ro] -i -a disk-image\n"
-             "  %s [--ro] -i -d libvirt-domain\n"
-             "or for interactive use:\n"
-             "  %s\n"
-             "or from a shell script:\n"
-             "  %s <<EOF\n"
-             "  cmd\n"
-             "  ...\n"
-             "  EOF\n"
              "Options:\n"
              "  -h|--cmd-help        List available commands\n"
              "  -h|--cmd-help cmd    Display detailed help on 'cmd'\n"
@@ -124,7 +116,8 @@ usage (int status)
              "  -i|--inspector       Automatically mount filesystems\n"
              "  --keys-from-stdin    Read passphrases from stdin\n"
              "  --listen             Listen for remote commands\n"
-             "  -m|--mount dev[:mnt] Mount dev on mnt (if omitted, /)\n"
+             "  --live               Connect to a live virtual machine\n"
+             "  -m|--mount dev[:mnt[:opts]] Mount dev on mnt (if omitted, /)\n"
              "  -n|--no-sync         Don't autosync\n"
              "  -N|--new type        Create prepared disk (test1.img, ...)\n"
              "  --progress-bars      Enable progress bars even when not interactive\n"
@@ -134,11 +127,21 @@ usage (int status)
              "  --selinux            Enable SELinux support\n"
              "  -v|--verbose         Verbose messages\n"
              "  -V|--version         Display version and exit\n"
+             "  -w|--rw              Mount read-write\n"
              "  -x                   Echo each command before executing it\n"
+             "\n"
+             "To examine a disk image, ISO, hard disk, filesystem etc:\n"
+             "  %s [--ro|--rw] -i -a /path/to/disk.img\n"
+             "or\n"
+             "  %s [--ro|--rw] -i -d name-of-libvirt-domain\n"
+             "\n"
+             "--ro recommended to avoid any writes to the disk image.  If -i option fails\n"
+             "run again without -i and use 'run' + 'list-filesystems' + 'mount' cmds.\n"
+             "\n"
              "For more information, see the manpage %s(1).\n"),
              program_name, program_name, program_name,
              program_name, program_name, program_name,
-             program_name, program_name, program_name);
+             program_name);
   }
   exit (status);
 }
@@ -173,6 +176,7 @@ main (int argc, char *argv[])
     { "inspector", 0, 0, 'i' },
     { "keys-from-stdin", 0, 0, 0 },
     { "listen", 0, 0, 0 },
+    { "live", 0, 0, 0 },
     { "mount", 1, 0, 'm' },
     { "new", 1, 0, 'N' },
     { "no-dest-paths", 0, 0, 'D' },
@@ -277,6 +281,8 @@ main (int argc, char *argv[])
           format = optarg;
       } else if (STREQ (long_options[option_index].name, "csh")) {
         remote_control_csh = 1;
+      } else if (STREQ (long_options[option_index].name, "live")) {
+        live = 1;
       } else {
         fprintf (stderr, _("%s: unknown long option: %s (%d)\n"),
                  program_name, long_options[option_index].name, option_index);
@@ -494,7 +500,8 @@ main (int argc, char *argv[])
     : (optind >= argc && isatty (0));
 
   if (progress_bars)
-    guestfs_set_progress_callback (g, progress_callback, NULL);
+    guestfs_set_event_callback (g, progress_callback,
+                                GUESTFS_EVENT_PROGRESS, 0, NULL);
 
   /* Interactive, shell script, or command(s) on the command line? */
   if (optind >= argc) {
@@ -678,7 +685,10 @@ parse_command_line (char *buf, int *exit_on_error_rtn)
   int r;
   const size_t argv_len = sizeof pcmd.argv / sizeof pcmd.argv[0];
 
-  pcmd.pipe = NULL;
+  /* Note that pcmd.pipe must be set to NULL for correct usage.  Other
+   * fields do not need to be, but this silences a gcc warning.
+   */
+  memset (&pcmd, 0, sizeof pcmd);
 
  again:
   /* Skip any initial whitespace before the command. */