242 Commits

Author SHA1 Message Date
Richard Jones
01fedcde05 fish: Add 'please wait' message when launching (and interactive). 2010-05-08 09:37:25 +01:00
Richard Jones
bece54704b fish: Make 'launch' function static.
This commit makes the launch function static and private to
'fish.c', and changes the generator so the function is no longer
called for the 'run/launch' command.
2010-05-08 09:25:32 +01:00
Richard Jones
8e007581c9 fish: Make '-x' option enable traces instead of using separate echo path.
Previously we had separate code paths for echoing commands (-x)
and tracing (guestfs_set_trace).  This just unifies that so that
the guestfish -x option enables tracing.
2010-05-08 09:04:28 +01:00
Richard Jones
78d2523ec8 fish: Add 'man' command which opens the manual. 2010-04-24 09:11:37 +01:00
Richard Jones
d054dfb2f9 fish: Fix segfault in '-a' option.
This fixes a segfault in the guestfish -a option which you would
get when using guestfish 1.3.6.
2010-04-23 14:15:12 +01:00
Richard Jones
4a9b979a31 fish: Add -N option for making prepared disk images.
Previously you might have typed:

$ guestfish
><fs> alloc test1.img 100M
><fs> run
><fs> part-disk /dev/sda mbr
><fs> mkfs ext4 /dev/sda1

now you can do the same with:

$ guestfish -N fs:ext4

Some tests have also been updated to use this new
functionality.
2010-04-22 18:07:11 +01:00
Richard Jones
3119aa687d fish: Allow -<<END as a syntax for uploading "heredocs".
For example:

    ><fs> upload -<<END /foo
    some data
    some more data
    END
    ><fs> cat /foo
    some data
    some more data
2010-04-19 15:08:45 +01:00
Richard Jones
ad752b80d7 fish: Allow '-' prefix on command line to override exit on error (RHBZ#578407).
Allow -cmd on the command line to mean that normal exit on error
behaviour is overridden, ie. we will not exit.

This allows you to do:

  guestfish -- command : -command : command

with the second command allowing errors.  (Note that '--' is required
to stop getopt parsing -command as an option).

Also this fixes the remote case which is what the original
bug report was about.
2010-04-13 22:09:21 +01:00
Richard Jones
4c50f4c38d fish: Print extended help when the user types an unknown command first.
$ guestfish /tmp/disk.img
/tmp/disk.img: unknown command
Did you mean to open a disk image?  guestfish -a disk.img
For a list of commands:             guestfish -h
For complete documentation:         man guestfish
2010-04-07 12:06:07 +01:00
Richard Jones
9e397cc16b Mac OS X: setlocale function requires <locale.h> header file. 2010-03-22 10:41:45 +00:00
Richard Jones
dd12eaefb5 Mac OS X: implement readline functions.
OS X has an older version of readline with some differences
in the names of functions.
2010-03-22 10:41:45 +00:00
Richard Jones
f93cbe5756 Use mount-options instead of mount to avoid implicit -o sync.
guestfs_mount adds -o sync implicitly.  This causes a very large
performance problem for write-intensive programs (eg. virt-v2v).

Document this as a "gotcha".

Change the tests, guestfish, Sys::Guestfs::Lib, guestmount to use
mount-options instead.

(Note that this gotcha does not affect mount-ro).

The source of the performance problem was first identified by
Matthew Booth.
2010-02-10 10:46:23 +00:00
Richard Jones
a6025c11d9 Set locale in C programs so l10n works (RHBZ#559962).
This commit adds the calls to setlocale &c to all of the current
C programs.

It also adds l10n support to hivexget and hivexml which lacked them
previously.

To test this, try:

LANG=pa_IN.UTF-8 guestfish --cmd-help

(You can only do this test after installing the package, or at
least the 'pa.mo' mo-file in the correct place).
2010-01-29 15:11:59 +00:00
Jim Meyering
4d45c45f09 maint: use EXIT_SUCCESS and EXIT_FAILURE, not 0 and 1 in "usage", too
Convert by running these commands:
perl -pi -e 's/\b(usage ?)\(1\)/$1(EXIT_FAILURE)/' \
  fish/fish.c fuse/guestmount.c
perl -pi -e 's/\b(usage ?)\(0\)/$1(EXIT_SUCCESS)/' \
  fish/fish.c fuse/guestmount.c
* fish/fish.c (main): Replace 0/1 with EXIT_SUCCESS/EXIT_FAILURE.
* fuse/guestmount.c (main): Likewise.
2009-11-20 12:14:32 +00:00
Jim Meyering
c372c7c23a maint: use EXIT_SUCCESS and EXIT_FAILURE, not 0 and 1 to exit
Convert all uses automatically, via these two commands:
git grep -l '\<exit *(1)' \
  | grep -vEf .x-sc_prohibit_magic_number_exit \
  | xargs --no-run-if-empty \
    perl -pi -e 's/\b(exit ?)\(1\)/$1(EXIT_FAILURE)/'
git grep -l '\<exit *(0)' \
  | grep -vEf .x-sc_prohibit_magic_number_exit \
  | xargs --no-run-if-empty \
  perl -pi -e 's/\b(exit ?)\(0\)/$1(EXIT_SUCCESS)/'
* .x-sc_prohibit_magic_number_exit: New file.

Edit (RWMJ): Don't change Java code.
2009-11-20 12:14:14 +00:00
Richard Jones
3fc9951016 fish: Improve output of guestfish -h cmd
Display this output like a short manual page.

Don't put <..> around the parameters to the command.
2009-11-17 20:14:47 +00:00
Jim Meyering
c9d9498458 change strncasecmp() == 0 to STRCASEEQLEN()
git grep -l 'strncasecmp *([^=]*== *0'|xargs \
  perl -pi -e 's/\bstrncasecmp( *\(.*?\)) *== *0\b/STRCASEEQLEN$1/g'
2009-11-09 22:42:02 +01:00
Jim Meyering
0c20bd8ea7 change strncasecmp() == 0 to STRCASENEQLEN()
git grep -l 'strncasecmp *([^=]*!= *0'|xargs \
  perl -pi -e 's/\bstrncasecmp( *\(.*?\)) *!= *0\b/STRCASENEQLEN$1/g'
2009-11-09 22:42:01 +01:00
Jim Meyering
539bf7e898 use STREQ, not strcmp: part 2
git grep -l 'strcmp *([^=]*!= *0'|xargs \
  perl -pi -e 's/\bstrcmp( *\(.*?\)) *!= *0\b/STRNEQ$1/g'
2009-11-09 22:34:16 +01:00
Jim Meyering
9a8889e4d0 use STREQ, not strcmp: part 1
git grep -l 'strcmp *([^=]*== *0'|xargs \
  perl -pi -e 's/\bstrcmp( *\(.*?\)) *== *0/STREQ$1/g'
2009-11-09 22:34:16 +01:00
Jim Meyering
29842da137 convert strcasecmp(...) != 0 to STRCASENEQ(...)
git grep -E -l 'strcasecmp *\(.*!= ?0\b'|xargs \
  perl -pi -e 's/\bstrcasecmp( ?\(.*?\)) != 0/STRCASENEQ$1/g'
2009-11-09 22:34:16 +01:00
Jim Meyering
9353c6253d convert uses of strcasecmp to STRCASEEQ
git grep -l 'strcasecmp *([^=]*== *0'| xargs \
  perl -pi -e 's/\bstrcasecmp( *\(.*?\)) *== *0/STRCASEEQ$1/'
2009-11-09 22:34:16 +01:00
Richard Jones
857954dfbd fish: Allow <nn>P and <nn>E for petabyte and exabyte allocations. 2009-11-04 21:51:35 +00:00
Richard Jones
3266e51054 fish: Allow <nn>T for terabyte allocations. 2009-11-04 18:03:58 +00:00
Richard Jones
5ce72e039c fish: New command 'sparse', like 'alloc' but to generate sparse files.
With sparse you can make sparse files, which is fun because you
can experiment with really large devices:

  ><fs> sparse /tmp/test.img 100G
  ><fs> run
  ><fs> sfdiskM /dev/vda ,
  ><fs> mkfs ext2 /dev/vda1    # very long pause here ...
  ><fs> mount /dev/vda1 /

To see the real (ie. allocated) size of the sparse file, use the du
command, eg:

  ><fs> !du -h /tmp/test.img
  1.6G -rw-rw-r-- 1 rjones rjones 100G 2009-11-04 17:40 /tmp/test.img
2009-11-04 17:42:03 +00:00
Richard Jones
ec02f0da15 guestfish: Add win: prefix to use Windows paths.
Add a win: prefix for path arguments in guestfish:

><fs> file win:c:\windows\system32\config\system.log
MS Windows registry file, NT/2000 or above
2009-10-26 15:09:20 +00:00
Jim Meyering
6a14f1c250 avoid use of all ctype macros
* cfg.mk (disable_temporarily): Don't disable sc_avoid_ctype_macros.
* fish/tilde.c: Remove unnecessary inclusion of ctype.h.
* bootstrap: Add gnulib's c-ctype module to the list.
* daemon/m4/gnulib-cache.m4: Likewise.
* daemon/ext2.c: Include "c-ctype.h", not <ctype.h>.
Use c_isspace, etc, rather than isspace.
* daemon/guestfsd.c: Likewise.
* daemon/lvm.c: Likewise.
* daemon/proto.c: Likewise.
* fish/fish.c: Likewise.
* fish/tilde.c: Likewise.
* src/generator.ml: Likewise.
* src/guestfs.c: Likewise.
* examples/to-xml.c: Likewise.
* examples/Makefile.am (to_xml_CPPFLAGS): Add -I$(top_srcdir)/gnulib/lib
so inclusion of "c-ctype.h" works.
(to_xml_CPPFLAGS): Rename from to_xml_CFLAGS.
2009-09-24 11:00:44 +02:00
Richard Jones
8869adf1e8 Remove guestfs_wait_ready (turn it into a no-op).
This commit changes guestfs_launch so that it both launches
the appliance and waits until it is ready (ie. the daemon communicates
back to us).

Since we removed the pretence that we could implement a low-level
asynchronous API, the need to call launch() followed by wait_ready()
has looked a bit silly.

Now guestfs_wait_ready() is basically a no-op.  It is left in the
API for backwards compatibility.  Any calls to guestfs_wait_ready()
can be removed from client code.
2009-09-21 12:01:51 +01:00
Richard Jones
acbcbfaf39 Move decl out for C99 compliance. 2009-09-14 20:16:52 +01:00
Matthew Booth
22cee80bc2 guestfish: Enable grouping in string lists
This change adds the ability to group entries in a string list with single
quotes. So the string:
  "'foo bar'"
becomes 1 token rather than 2. Consequently single quotes must now be escaped:
  "\'"
resolves to a literal single quote.

Incidentally, this change also alters another, probably unintentional behaviour
of the previous implementation, in that tokens are separated by any amount of
whitespace rather than a single whitespace character. I.e.:
  "a  b"
resolves to:
  'a' 'b'
rather than:
  'a' '' 'b'
That last syntax can be used if an empty argument is still desired. Whitespace
is now also defined to include tabs.

parse_string_list can also now fail if it contains an unmatched open quote.
2009-09-14 13:59:01 +01:00
Jim Meyering
8817709009 build: don't define _GNU_SOURCE manually
Now that we're using gnulib in earnest, any manual definition
would provoke a redefinition warning.
* fish/fish.c (_GNU_SOURCE): Don't define.
* fish/destpaths.c (_GNU_SOURCE): Likewise.
* src/guestfs.c (_GNU_SOURCE): Likewise.
* bootstrap (modules): Add asprintf, strchrnul, strerror, strndup
and vasprintf.
* fish/fish.c (main): Set argv[0] to sanitized program_name, so
functions like getopt_long that use argv[0] use the clean name.
2009-08-24 18:15:13 +02:00
Jim Meyering
b9a691af0f guestfish: diagnose stdout write failure
Use gnulib's closeout module to ensure any failure to write to
stdout is detected and reported.
* fish/fish.c: Include "closeout.h".
(main): Call atexit (close_stdout);
* bootstrap (modules): Add closeout.
2009-08-24 18:15:13 +02:00
Jim Meyering
8e6d1e1a31 guestfish: don't try to diagnose getopt failure
* fish/fish.c: ... getopt_long already does that.  Instead, suggest
"Try `guestfish --help' for more information."
2009-08-24 18:15:13 +02:00
Jim Meyering
6cd965e007 guestfish: write --help to stdout, use gnulib's progname module
* fish/fish.c: Include "progname.h".
(main): Call set_program_name to initialize.
Don't hard-code guestfish everywhere.  Use program_name.
However, be careful when modifying argv[0], since it is used
in the hopes that it is an absolute file name.
(usage): Don't spew all of --help for a mis-typed option.
Split long lines.
2009-08-24 18:15:06 +02:00
Jim Meyering
78e2a30b90 fish.c: don't perform arithmetic on void* pointers
* fish/fish.c (xwrite): Use char*.
2009-08-21 15:24:25 +02:00
Jim Meyering
fbd7db9406 fish.c: avoid signed/unsigned-comparison warning
* fish/fish.c (script): Change type of index to "unsigned int".
2009-08-21 15:24:25 +02:00
Jim Meyering
7b2d9feb82 fish.c: avoid "assignment discards qualifiers..." warning
* fish/fish.c (main): Cast-away-const.
* fish/fish.h (bad_cast): Define.  Safer than using an actual cast.
2009-08-21 15:24:25 +02:00
Jim Meyering
6aa44937d5 guestfish: detect more failed syscalls
* fish/fish.c (issue_command): Detect/diagnose more failed syscalls.
2009-08-19 13:27:13 +02:00
Jim Meyering
adf20c0c4d adjust const "**" pointers to avoid warnings
Also, ...
* src/generator.ml: Add DeviceList type, and propagate that change
out to all calling/interface code.
2009-08-17 11:40:24 +02:00
Richard Jones
8249460acf guestfish: Add --selinux option. 2009-08-13 20:45:06 +01:00
Jim Meyering
2f1a50d816 Convert all TABs-as-indentation to spaces.
Do it by running this command:
[exempted files are matched via .x-sc_TAB_in_indentation]

  git ls-files \
    | pcregrep -vf .x-sc_TAB_in_indentation \
    | xargs pcregrep -l '^ *\t' \
    | xargs perl -MText::Tabs -ni -le \
      '$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_'
2009-08-03 17:17:57 +02:00
Jim Meyering
58e7e42033 build: reenable "syntax-check" rule: sc_const_long_option
* cfg.mk (disable_temporarily): Remove sc_const_long_option.
* daemon/guestfsd.c (main): Declare long_options to be "const".
* fish/fish.c (main): Likewise.
* test-tool/test-tool.c (main): Likewise.
2009-08-03 15:14:31 +02:00
Richard Jones
f8f1057809 guestfish: Make more strings translatable.
However this doesn't yet attempt to translate the POD
command documentation.  We need a plan to do that.
2009-07-29 21:34:06 +01:00
Richard W.M. Jones
3082681cc6 guestfish -iv should print virt-inspector command (for debugging). 2009-07-24 15:46:15 +01:00
Richard Jones
9449b0fce4 guestfish: Add tilde expansion for paths (RHBZ#511372).
This commit adds tilde expansion for local users in guestfish:

  ><fs> echo "~"
  ~
  ><fs> echo ~
  /home/rjones
  ><fs> echo ~foo
  ~foo
  ><fs> echo ~rjones/bar
  /home/rjones/bar
  ><fs> echo ~roo
  ~roo
  ><fs> echo ~root/foo
  /root/foo
  ><fs> echo ~root
  /root
2009-07-15 11:39:04 +01:00
Richard Jones
a86aa7d152 Guestfish feature: remote control of guestfish over a pipe.
The use case is to have a long-running guestfish process in
a shell script, and thus to avoid the overhead of starting
guestfish each time.  Do:

 eval `guestfish --listen`

 guestfish --remote somecmd
 guestfish --remote someothercmd
 guestfish --remote exit

This patch also supports having multiple guestfish processes
at the same time.

The protocol is simple XDR messages over a Unix domain socket.
2009-07-14 14:08:31 +01:00
Richard W.M. Jones
ad64aff834 Guestfish: implement -x option, echo commands before executing them. 2009-07-11 21:35:03 +01:00
Richard W.M. Jones
89dfb94d3e Fix: '-D' was not recognized as a parameter to guestfish. 2009-07-11 21:33:41 +01:00
Richard W.M. Jones
625d0bd561 Guestfish: Add 'reopen' command to reopen the libguestfs handle. 2009-07-11 21:20:17 +01:00
Richard W.M. Jones
b48dea6217 Add missing documentation for "more" command in guestfish help output. 2009-07-11 21:07:57 +01:00