diff options
author | Richard Jones <rjones@redhat.com> | 2010-04-08 16:07:32 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2010-04-08 16:07:32 +0100 |
commit | 50195d6ec4e893f894ef1bbf7af6eeda56f96600 (patch) | |
tree | 4dec25a45ec846f14392d6253b8f5501bb850a0a | |
parent | 0ce9b2bb9bcac61f7fb5dd2811d9b3b621f8309b (diff) | |
download | libguestfs-50195d6ec4e893f894ef1bbf7af6eeda56f96600.tar.gz libguestfs-50195d6ec4e893f894ef1bbf7af6eeda56f96600.tar.xz libguestfs-50195d6ec4e893f894ef1bbf7af6eeda56f96600.zip |
New API calls to upload/download txz files (RHBZ#580556).
-rw-r--r-- | appliance/packagelist.in | 2 | ||||
-rw-r--r-- | daemon/tar.c | 40 | ||||
-rw-r--r-- | images/Makefile.am | 2 | ||||
-rw-r--r-- | images/helloworld.tar.xz | bin | 0 -> 216 bytes | |||
-rw-r--r-- | src/MAX_PROC_NR | 2 | ||||
-rwxr-xr-x | src/generator.ml | 22 |
6 files changed, 59 insertions, 9 deletions
diff --git a/appliance/packagelist.in b/appliance/packagelist.in index c8674b19..842531f0 100644 --- a/appliance/packagelist.in +++ b/appliance/packagelist.in @@ -27,6 +27,7 @@ udev util-linux-ng vim-minimal + xz #elif DEBIAN == 1 bsdmainutils btrfs-tools @@ -42,6 +43,7 @@ udev util-linux vim-tiny + xz-utils #endif bash diff --git a/daemon/tar.c b/daemon/tar.c index 8088606f..5b73599a 100644 --- a/daemon/tar.c +++ b/daemon/tar.c @@ -158,8 +158,8 @@ do_tar_out (const char *dir) } /* Has one FileIn parameter. */ -int -do_tgz_in (const char *dir) +static int +do_tXz_in (const char *dir, char filter) { int err, r; FILE *fp; @@ -172,7 +172,7 @@ do_tgz_in (const char *dir) } /* "tar -C /sysroot%s -zxf -" but we have to quote the dir. */ - if (asprintf_nowarn (&cmd, "tar -C %R -zxf -", dir) == -1) { + if (asprintf_nowarn (&cmd, "tar -C %R -%cxf -", dir, filter) == -1) { err = errno; cancel_receive (); errno = err; @@ -219,9 +219,23 @@ do_tgz_in (const char *dir) return 0; } -/* Has one FileOut parameter. */ +/* Has one FileIn parameter. */ int -do_tgz_out (const char *dir) +do_tgz_in (const char *dir) +{ + return do_tXz_in (dir, 'z'); +} + +/* Has one FileIn parameter. */ +int +do_txz_in (const char *dir) +{ + return do_tXz_in (dir, 'J'); +} + +/* Has one FileOut parameter. */ +static int +do_tXz_out (const char *dir, char filter) { int r; FILE *fp; @@ -229,7 +243,7 @@ do_tgz_out (const char *dir) char buf[GUESTFS_MAX_CHUNK_SIZE]; /* "tar -C /sysroot%s -zcf - ." but we have to quote the dir. */ - if (asprintf_nowarn (&cmd, "tar -C %R -zcf - .", dir) == -1) { + if (asprintf_nowarn (&cmd, "tar -C %R -%ccf - .", dir, filter) == -1) { reply_with_perror ("asprintf"); return -1; } @@ -276,3 +290,17 @@ do_tgz_out (const char *dir) return 0; } + +/* Has one FileOut parameter. */ +int +do_tgz_out (const char *dir) +{ + return do_tXz_out (dir, 'z'); +} + +/* Has one FileOut parameter. */ +int +do_txz_out (const char *dir) +{ + return do_tXz_out (dir, 'J'); +} diff --git a/images/Makefile.am b/images/Makefile.am index c30d8c4c..ff8d46fb 100644 --- a/images/Makefile.am +++ b/images/Makefile.am @@ -23,6 +23,7 @@ builddir ?= $(top_builddir)/images EXTRA_DIST = \ helloworld.tar \ helloworld.tar.gz \ + helloworld.tar.xz \ mbr-ext2-empty.img.gz \ empty known-1 known-2 known-3 known-4 known-5 \ bin-i586-dynamic \ @@ -47,6 +48,7 @@ CLEANFILES = \ images_files_src = \ $(srcdir)/helloworld.tar \ $(srcdir)/helloworld.tar.gz \ + $(srcdir)/helloworld.tar.xz \ $(srcdir)/empty \ $(srcdir)/known-1 \ $(srcdir)/known-2 \ diff --git a/images/helloworld.tar.xz b/images/helloworld.tar.xz Binary files differnew file mode 100644 index 00000000..661f1a20 --- /dev/null +++ b/images/helloworld.tar.xz diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index 9be0dc9a..dcb6b5ba 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -228 +230 diff --git a/src/generator.ml b/src/generator.ml index 416a66fd..9d190977 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -2025,7 +2025,8 @@ The checksum is returned as a printable string."); This command uploads and unpacks local file C<tarfile> (an I<uncompressed> tar file) into C<directory>. -To upload a compressed tarball, use C<guestfs_tgz_in>."); +To upload a compressed tarball, use C<guestfs_tgz_in> +or C<guestfs_txz_in>."); ("tar_out", (RErr, [String "directory"; FileOut "tarfile"]), 70, [], [], @@ -2034,7 +2035,8 @@ To upload a compressed tarball, use C<guestfs_tgz_in>."); This command packs the contents of C<directory> and downloads it to local file C<tarfile>. -To download a compressed tarball, use C<guestfs_tgz_out>."); +To download a compressed tarball, use C<guestfs_tgz_out> +or C<guestfs_txz_out>."); ("tgz_in", (RErr, [FileIn "tarball"; String "directory"]), 71, [], [InitBasicFS, Always, TestOutput ( @@ -4355,6 +4357,22 @@ This command writes zeroes over the entire C<device>. Compare with C<guestfs_zero> which just zeroes the first few blocks of a device."); + ("txz_in", (RErr, [FileIn "tarball"; String "directory"]), 229, [], + [InitBasicFS, Always, TestOutput ( + [["txz_in"; "../images/helloworld.tar.xz"; "/"]; + ["cat"; "/hello"]], "hello\n")], + "unpack compressed tarball to directory", + "\ +This command uploads and unpacks local file C<tarball> (an +I<xz compressed> tar file) into C<directory>."); + + ("txz_out", (RErr, [Pathname "directory"; FileOut "tarball"]), 230, [], + [], + "pack directory into compressed tarball", + "\ +This command packs the contents of C<directory> and downloads +it to local file C<tarball> (as an xz compressed tar archive)."); + ] let all_functions = non_daemon_functions @ daemon_functions |