Commit Graph

28 Commits

Author SHA1 Message Date
Richard W.M. Jones
ea71e00d1a fish: Add internal documentation to several files. 2016-05-08 20:59:36 +01:00
Richard W.M. Jones
307c83177c Update copyright dates for 2016.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2015/$1-2016/g' `git ls-files`
2016-01-02 21:19:51 +00:00
Richard W.M. Jones
ccdbbc7fe4 Fix various -Wformat problems.
Updating gnulib has caused -Wformat-signedness to be enabled.  This
has revealed many problems in C format strings.  The fixes here fall
into the following main categories:

 - Using %d with an unsigned parameter.

 - %x and %o expect an unsigned argument.

 - uid_t and gid_t are unsigned on Linux.  The safe way to print these
   is to cast them to uintmax_t and then print them using the %ju
   modifier (see http://stackoverflow.com/a/1401581).

 - Using %d to print an enum.  Since enums may be either char or int,
   I fixed this by casting the enum to int.

 - strtol_error & lzma_ret are both unsigned types.
2015-07-02 16:08:44 +01:00
Richard W.M. Jones
c5800dc97d Update copyright dates for 2015. 2015-01-17 09:08:15 +00:00
Richard W.M. Jones
2794eac739 fish: Use disk-create API to implement guestfish 'alloc' and 'sparse' commands. 2014-01-28 21:02:11 +00:00
Richard W.M. Jones
6c971faecf Update copyright dates for 2014. 2014-01-02 16:53:34 +00:00
Richard W.M. Jones
abe07ce2ca "guestfish" now means the "guest filesystem shell".
Remove the word "interactive" which implies that guestfish can only
(or often) be used interactively.
2013-04-09 23:21:42 +01:00
Richard W.M. Jones
18b7f09f36 Add support for hotplugging (adding disks) to the libvirt attach-method.
When libvirt is used, we can allow disks to be hotplugged.
guestfs_add_drive can be called after launch to hot-add a disk.

When a disk is hot-added, we first ask libvirt to add the disk to the
appliance, then we make an internal call into the appliance to get it
to wait for the disk to appear (ie. udev_settle ()).

Hot-added disks are tracked in the g->drives array.

This also adds a test.
2012-10-08 20:04:53 +01:00
Richard W.M. Jones
6aa95e87c1 Remove "convenience header" "gettext.h" and use <libintl.h> instead.
gettextize provides a local file called "gettext.h".  Remove this and
use <libintl.h> from glibc headers instead.

Most of this change is mechanical: #include <libintl.h> in every C
file which uses any gettext function.  But also we remove the
gettext.h file, and adjust the "_" macros.

Note that this effectively removes the ./configure --disable-nls
option, although we don't know if that ever worked.
2012-05-01 08:57:55 +01:00
Richard W.M. Jones
606732d02e Use O_CLOEXEC / SOCK_CLOEXEC for almost all file descriptors.
The presumption is that all file descriptors should be created with
the close-on-exec flag set.  The only exception are file descriptors
that we want passed through to exec'd subprocesses (mainly pipes and
stdin/stdout/stderr).

For open calls, we pass O_CLOEXEC as an extra flag, eg:

  fd = open ("foo", O_RDONLY|O_CLOEXEC);

This is a Linux-ism, but using a macro we can easily make it portable.

For sockets, similarly:

  sock = socket (..., SOCK_STREAM|SOCK_CLOEXEC, ...);

For accepted sockets, we use the Linux accept4 system call which
allows flags to be supplied, but we use the Gnulib 'accept4' module to
make this portable.

For dup, dup2, we use the Linux dup3 system call, and the Gnulib
modules 'dup3' and 'cloexec'.
2012-03-14 19:30:46 +00:00
Matthew Booth
04ea1375c5 Update FSF address. 2011-11-08 14:43:07 +00:00
Richard W.M. Jones
0c1d3c02a8 fish: Specify format of disks (RHBZ#642934,CVE-2010-3851).
For libvirt guests, the disk format is copied from libvirt (if
libvirt knows it).

For command line disk images, you can use --format to override
format auto-detection.
2010-10-22 17:45:06 +01:00
Richard W.M. Jones
6391d1a7cf fish: Change 'int argc' to 'size_t argc' throughout. 2010-10-21 10:50:25 +01:00
Richard W.M. Jones
0003ea2c3d generator: Generate guestfish-only commands.
The guestfish-only commands such as 'alloc' and 'edit' are
now generated from one place in the generator instead of being
spread around ad-hoc in the C code.
2010-09-18 09:38:05 +01:00
Richard Jones
d5c8d3b45b fish: Add guestfish -N bootroot and -N bootrootlv for creating boot+root disks. 2010-09-08 11:00:00 +01:00
Richard Jones
5e1aff7856 fish: Allow suffixes on number parameters (eg. 1M)
This small change uses the gnulib xstrtoll functionality to
enable suffixes on integer parameters in guestfish.  For example:

 truncate-size /file 1G

(previously you would have had to given the full number).

This also applies to the 'alloc' and 'sparse' commands (and
indirectly to the -N option).  The specification for these commands
has changed slightly, in that 'alloc foo 1MB' would now use SI
units, allocating 1000000 bytes instead of a true megabyte.  All
existing uses would use 'alloc foo 1M' which still allocates true
megabytes.
2010-05-21 14:51:53 +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
2ade61d1f8 Check error returns from posix_fallocate (RHBZ#579664).
posix_fallocate has a non-standard way to return error indications.
Thus all our calls to posix_fallocate were effectively unchecked.  For
example:

  $ guestfish alloc test.img 1P
  $ echo $?
  0
  $ ll test.img
  -rw-rw-r--. 1 rjones rjones 0 2010-04-06 11:02 test.img
  $ rm test.img

With this change, errors are detected and reported properly:

  $ ./fish/guestfish alloc test.img 1P
  fallocate: File too large

This is a fix for:
https://bugzilla.redhat.com/show_bug.cgi?id=579664
2010-04-07 12:06:07 +01:00
Richard Jones
5ebf3a3934 Mac OS X: provide alternate implementation of posix_fallocate. 2010-03-22 10:41:45 +00:00
Richard W.M. Jones
e1f5472395 Fixes for compiling on 32 bit. 2009-11-06 09:14:55 +00: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
Jim Meyering
a7b73d4a1e remove trailing blanks 2009-07-03 17:04:21 +02:00
Richard Jones
d70248333e Gettextize the source, make library strings translatable. 2009-05-21 12:01:36 +01:00
Richard Jones
c10fa84ada Implement -command (to ignore errors) in guestfish, and allow recovery from qemu process failure. 2009-05-08 15:19:51 +01:00
Richard Jones
05712b2457 'guestfish edit' commands and several bugfixes. 2009-04-15 23:54:51 +01:00
Richard Jones
612a358b89 Move guestfish 'alloc' command to a separate file. 2009-04-15 20:27:30 +01:00