1488 Commits

Author SHA1 Message Date
Richard Jones
9847e0c07d Implement '*grep*' family of commands. 2009-07-29 18:10:48 +01:00
Richard Jones
25c4b0190c Don't show empty CD devices (RHBZ#514505). 2009-07-29 15:03:59 +01:00
Richard Jones
549bba81e7 Pass '-z' parameter to 'file' command so it looks inside compressed files.
Also we deprecate the old 'zfile' command.
2009-07-28 15:29:23 +01:00
Richard Jones
75c9b770ad Need to declare asprintf_nowarn as inline to avoid gcc complaining. 2009-07-28 15:23:28 +01:00
Richard Jones
0f2e9c84e9 Replace shell_quote function with %Q and %R printf specifiers.
%Q => simple shell quoted string
%R => path will be prefixed by /sysroot

eg. snprintf (cmd, sizeof cmd, "cat %R", path); system (cmd);
2009-07-28 10:57:57 +01:00
Richard Jones
26f69f706e Fix typo in error message. 2009-07-22 21:18:01 +01:00
Richard W.M. Jones
e315e0723e Generator: Implement RBufferOut and "read-file" call.
This commit implements the RBufferOut type for returning
arbitrary 8 bit data from calls.

We also implement the guestfs_read_file call to read a
whole file that can contain any 8 bit content, but up to
a limit of ~ 2 MB.
2009-07-21 11:18:34 +01:00
Richard Jones
78029b529a Make /sysroot path configurable.
Currently /sysroot is hard-coded throughout the daemon code.

This patch turns the path into a variable so that we can change
it in future, for example to allow standalone mode to be implemented.

This patch was tested by running all the C API tests successfully.
2009-07-18 10:43:52 +01:00
Richard W.M. Jones
7428b0a70c New commands: 'mkmountpoint' and 'rmmountpoint'
These specialized commands are used to create additional mountpoints
before mounting filesystems.  They are only used where you want to
mount several unrelated or read-only filesystems together, and need
additional care to use correctly.

Here is how to use these calls to unpack the "Russian doll" nest
of a Fedora 11 live CD:

 add-ro Fedora-11-i686-Live.iso
 run
 mkmountpoint /cd
 mkmountpoint /squash
 mkmountpoint /ext3
 mount /dev/sda /cd
 mount-loop /cd/LiveOS/squashfs.img /squash
 mount-loop /squash/LiveOS/ext3fs.img /ext3

The inner filesystem is now unpacked under the /ext3 mountpoint.
2009-07-15 23:12:02 +01:00
Richard W.M. Jones
7fc3faabc7 New command: 'mountpoints' which returns a hash of device -> mountpoint. 2009-07-15 22:25:51 +01:00
Richard W.M. Jones
72c6cc02e2 RHEL 5: header was called <sys/xattr.h> 2009-07-14 14:34:57 +01:00
Richard W.M. Jones
74ee9390d3 Fix: daemon/xattr.c can now compile even when no xattr support. 2009-07-14 14:31:18 +01:00
Richard W.M. Jones
2600359b9b Support for Linux extended attributes.
This commit adds six calls to support Linux extended attributes.
They are:
  getxattrs     list all extended attributes for a file or directory
  setxattr      add/replace an extended attribute
  removexattr   remove an extended attribute
  lgetxattrs    \
  lsetxattr     (same as above, but operate on symbolic links)
  lremovexattr  /

See attr(5) for more information.

This also adds support for the FBuffer field type, which maps to
an XDR opaque<> or a C (int, char *) pair.
2009-07-14 13:32:16 +01:00
Richard Jones
7d41d75c1d Implement new 'zfile' command, to show file type inside compressed files. 2009-07-13 18:00:07 +01:00
Richard Jones
d5532e9ad2 Generate structs and struct lists generically.
This modifies the way that struct and struct lists are generated
(for return values) so that there is no need to add an explicit
new type when adding a new structure.

All tests pass, and the C API should be compatible.

I have also inspected the changes that are made to the generated
code by hand.
2009-07-07 13:42:34 +01:00
Richard Jones
51d0620ad9 Don't die if reply message is oversized (RHBZ#509597). 2009-07-05 16:06:36 +01:00
Matthew Booth
349814e9d9 Make it possible to build in a separate directory
This patch allows you to do:
mkdir build
cd build
../configure ...
make

This will output all generated files to the build directory. Given that
autogen automatically runs configure, you can also do:

BUILDDIR=./build ./autogen.sh

which will do the right thing.

Also:

* Fix a dependency bug which means that guestfs_protocol.h
  isn't automatically rebuilt.
* Re-running autogen.sh with no arguments won't blow away your previous
  configure arguments.
2009-07-03 16:16:51 +01:00
Jim Meyering
0cc0e9e39f avoid leak upon failed realloc
* daemon/guestfsd.c (commandrv): Free original buffer (rather
than leaking it) if realloc fails.
2009-07-03 17:04:21 +02:00
Jim Meyering
a7b73d4a1e remove trailing blanks 2009-07-03 17:04:21 +02:00
Jim Meyering
e9f5144537 daemon/readdir: avoid a small leak
* daemon/readdir.c (do_readdir): Free both p and v.name, in case
only one of the allocations failed.
2009-07-03 17:04:21 +02:00
Richard W.M. Jones
b2c76a898b Add 'sfdiskM' command.
This command is a saner interface to partitioning.

All partition sizes are specified in megabytes (not cylinders).
You don't need to specify the cyls/heads/secs parameters.

All the test code has been updated to use this, so it is now
CHS-independent (eg. when CHS changes as between IDE and virtio).
2009-07-02 21:50:30 +01:00
Richard W.M. Jones
62e41312ac Add list of function_names to the daemon.
Messages which include the proc_nr can now also include the
name of the actual function being called.
2009-07-02 15:11:59 +01:00
Richard W.M. Jones
c127ad3d4a In verbose mode, daemon will display the time elapsed for each command. 2009-07-02 14:12:24 +01:00
Jim Meyering
0bfadd6908 avoid automake failure
* daemon/configure.ac: Use AM_PROG_CC_C_O, not AC_PROG_CC_C_O.
2009-07-02 14:25:12 +02:00
Richard W.M. Jones
b3cb0b04eb Remove generated code from git.
Git users now require the OCaml compiler in order to regenerate
the generated code after a checkout.

Generated code will remain in the tarball, so users of the
source tarball will not need the OCaml compiler.
2009-07-02 11:51:16 +01:00
Richard W.M. Jones
5186251f8f Add 'readdir' call.
This adds a readdir call (mostly intended for programs).  The
return value is a list of guestfs_dirent structures.

This adds the new types 'struct guestfs_dirent' and
'struct guestfs_dirent_list', along with all the code to
return these in the different language bindings.

Also includes additional tests for OCaml and Perl bindings
to test this.
2009-07-02 10:11:55 +01:00
Richard W.M. Jones
99e28249d5 Call 'udevadm settle' after operations which add/remove device nodes.
Because udev operates asynchronously, we found errors which were
caused by a previous command (eg. sfdisk or pvremove) creating
or removing a device, and that change not having happened by the
time the next command was run.

This patch adds calls to '/sbin/udevadm settle' after any commands
which can add or remove device nodes.

If udev is not being used or not available, this should have no
effect.  The command fails and this is silently ignored.
2009-07-01 17:15:24 +01:00
Richard W.M. Jones
3e2d925717 All instances of 'pclose' now check for return value != 0.
We are generally interested that the subcommand ran without
error, ie. had exit status of 0.  'pclose' returns the exit
status, so we now check that pclose (fp) != 0.
2009-07-01 17:13:39 +01:00
Richard W.M. Jones
fe27753ae5 Fix error handling of external sfdisk command.
Should use 'pclose' instead of 'fclose' (although fclose happens
to work because of glibc internals).

The result of pclose is the exit status of the command, so we
need to test this is != 0.
2009-07-01 16:36:13 +01:00
Richard W.M. Jones
4513f2ec7b Change to use virtio_blk (virtio block device) by default.
virtio_blk is the fast, virt-native block device driver
supported by qemu and KVM.  Note that virtio_blk device
names are called /dev/vd*.

Existing scripts should continue working because device name
translation will silently change device names of the form
/dev/sd* to /dev/vd* as required.

See also:
http://libguestfs.org/guestfs.3.html#block_device_naming
2009-07-01 15:40:12 +01:00
Richard W.M. Jones
0884d8bbae Generated code for mknod, mkfifo, mknod_b, mknod_c, umask. 2009-06-30 13:10:45 +01:00
Richard W.M. Jones
f850e1f065 New commands: mknod, mkfifo, mknod_b, mknod_c and umask.
These commands are used to create block and char device
nodes or FIFOs (named pipes) in the filesystem.

The umask command is required also because the permissions
used by mknod are masked by the umask.

Also document and guarantee that the umask starts as 022.
2009-06-30 13:10:44 +01:00
Richard W.M. Jones
da8ddb2745 Generated code for the 'mkswap*' commands. 2009-06-29 20:25:20 +01:00
Richard W.M. Jones
662617ae72 Implement 'mkswap', 'mkswap_L' and 'mkswap_U' commands.
These commands are used to make Linux swap devices.  The mkswap_L
command makes one with a label.  The mkswap_U command makes one
with a known UUID.
2009-06-29 20:25:19 +01:00
Richard W.M. Jones
5d6b6a3fbb Generated code for mount-loop command. 2009-06-29 16:05:22 +01:00
Richard W.M. Jones
a548d51b70 Add mount-loop command (RHBZ#508668).
Loop device mounts don't work for the generic 'mount' commands
because the first parameter should be a file not a device.

We want to separate out files parameters from device parameters
in the long term, so this adds a new mount-loop command for this
purpose.
2009-06-29 16:03:54 +01:00
Richard W.M. Jones
25ebdcd506 Fix memory leak in daemon/mount.c:do_mount_vfs. 2009-06-29 16:00:49 +01:00
Richard W.M. Jones
c6d6f5ae1b Generated code for 'initrd-list'. 2009-06-29 15:19:10 +01:00
Richard W.M. Jones
4dff42aa13 Add 'initrd-list' command to list contents of initrd images.
Add 'initrd-list' command to list the files inside (new-style)
initrd images.  Update virt-inspector to use this instead of
the less efficient download/unpack locally method.
2009-06-29 15:16:40 +01:00
Richard W.M. Jones
e492608f2f Generated code for 'du' command. 2009-06-29 12:47:20 +01:00
Richard W.M. Jones
9a92446bca Added 'du' command.
This command estimates file usage for files and directories.
2009-06-29 12:46:59 +01:00
Richard W.M. Jones
b2ed0f4c55 Generated code for df / df-h. 2009-06-29 12:26:11 +01:00
Richard W.M. Jones
405cf2a577 Add 'df' and 'df-h' commands.
df and df-h commands can be used interactively to show disk
space usage.

Use existing statvfs command from programs.
2009-06-29 12:25:31 +01:00
Richard W.M. Jones
826020fe18 Generated code for head/tail commands. 2009-06-29 11:47:07 +01:00
Richard W.M. Jones
3854bbdecd Implement "head", "head-n", "tail", "tail-n" commands.
These commands let you view parts of a large file without
passing the whole file over the network connection.
2009-06-29 11:46:19 +01:00
Richard W.M. Jones
f450ce75b7 Generated code for 'wc_*' commands. 2009-06-29 10:09:13 +01:00
Richard W.M. Jones
7613eb0c7c Implementation of 'wc_c', 'wc_w' and 'wc_l' commands.
These commands count characters, words and lines in a file respectively.
2009-06-29 10:08:25 +01:00
Richard W.M. Jones
0574eab8bc Generated code for 'mkdtemp' command. 2009-06-24 18:25:09 +01:00
Richard W.M. Jones
8228eec990 Add mkdtemp command. 2009-06-24 18:22:37 +01:00
Richard W.M. Jones
bcb3fc0c33 Generated code for 'scrub-*' commands. 2009-06-23 15:53:44 +01:00