Add new optional argument to copy-out: 'numericowner', 'excludes',
'xattrs', 'selinux', and 'acls'. Pass them straight to tar-out,
so
it is possible to tweak how the files are extracted from the guest,
and locally saved.
---
generator/actions.ml | 37 +++++++++++++++++++++++++++++++++++--
gobject/Makefile.inc | 2 ++
lib/copy-in-out.c | 29 ++++++++++++++++++++++++++---
3 files changed, 63 insertions(+), 5 deletions(-)
diff --git a/generator/actions.ml b/generator/actions.ml
index 990eacb..9015a1a 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -3437,8 +3437,9 @@ Wildcards cannot be used." };
{ defaults with
name = "copy_out"; added = (1, 29, 24);
- style = RErr, [Pathname "remotepath"; String "localdir"], [];
+ style = RErr, [Pathname "remotepath"; String "localdir"], [OBool
"numericowner"; OStringList "excludes"; OBool "xattrs";
OBool "selinux"; OBool "acls"];
visibility = VPublicNoFish;
+ once_had_no_optargs = true;
shortdesc = "copy remote files or directories out of an image";
longdesc = "\
C<guestfs_copy_out> copies remote files or directories recursively
@@ -3449,7 +3450,39 @@ To download to the current directory, use C<.> as in:
C<guestfs_copy_out> /home .
-Wildcards cannot be used." };
+Wildcards cannot be used.
+
+The other optional arguments are:
+
+=over 4
+
+=item C<numericowner>
+
+If set to true, the destination file will contain UID/GID numbers
+matching these in the sources, instead of using user/group names.
+Note this applies only if C<remotepath> is a directory.
+
+=item C<excludes>
+
+A list of wildcards. Files are excluded if they match any of the
+wildcards. Note they are used only if C<remotepath> is a directory.
+
+=item C<xattrs>
+
+If set to true, extended attributes are restored.
+Note this applies only if C<remotepath> is a directory.
+
+=item C<selinux>
+
+If set to true, SELinux contexts are restored.
+Note this applies only if C<remotepath> is a directory.
+
+=item C<acls>
+
+If set to true, POSIX ACLs are restored.
+Note this applies only if C<remotepath> is a directory.
+
+=back" };
{ defaults with
name = "set_identifier"; added = (1, 31, 14);
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
index 55a137e..76482f7 100644
--- a/gobject/Makefile.inc
+++ b/gobject/Makefile.inc
@@ -67,6 +67,7 @@ guestfs_gobject_headers= \
include/guestfs-gobject/optargs-copy_device_to_file.h \
include/guestfs-gobject/optargs-copy_file_to_device.h \
include/guestfs-gobject/optargs-copy_file_to_file.h \
+ include/guestfs-gobject/optargs-copy_out.h \
include/guestfs-gobject/optargs-cpio_out.h \
include/guestfs-gobject/optargs-disk_create.h \
include/guestfs-gobject/optargs-download_blocks.h \
@@ -158,6 +159,7 @@ guestfs_gobject_sources= \
src/optargs-copy_device_to_file.c \
src/optargs-copy_file_to_device.c \
src/optargs-copy_file_to_file.c \
+ src/optargs-copy_out.c \
src/optargs-cpio_out.c \
src/optargs-disk_create.c \
src/optargs-download_blocks.c \
diff --git a/lib/copy-in-out.c b/lib/copy-in-out.c
index a4e39f8..cf2a9d6 100644
--- a/lib/copy-in-out.c
+++ b/lib/copy-in-out.c
@@ -131,8 +131,9 @@ child_setup (guestfs_h *g, void *data)
}
int
-guestfs_impl_copy_out (guestfs_h *g,
- const char *remotepath, const char *localdir)
+guestfs_impl_copy_out_opts (guestfs_h *g,
+ const char *remotepath, const char *localdir,
+ const struct guestfs_copy_out_opts_argv *optargs)
{
struct stat statbuf;
int r;
@@ -170,6 +171,7 @@ guestfs_impl_copy_out (guestfs_h *g,
struct copy_out_child_data data;
char fdbuf[64];
int fd;
+ struct guestfs_tar_out_opts_argv tar_optargs = { .bitmask = 0 };
r = guestfs_is_dir (g, remotepath);
if (r == -1)
@@ -210,7 +212,28 @@ guestfs_impl_copy_out (guestfs_h *g,
snprintf (fdbuf, sizeof fdbuf, "/dev/fd/%d", fd);
- r = guestfs_tar_out (g, remotepath, fdbuf);
+ if (optargs->bitmask & GUESTFS_COPY_OUT_OPTS_NUMERICOWNER_BITMASK) {
+ tar_optargs.numericowner = optargs->numericowner;
+ tar_optargs.bitmask |= GUESTFS_TAR_OUT_OPTS_NUMERICOWNER_BITMASK;
+ }
+ if (optargs->bitmask & GUESTFS_COPY_OUT_OPTS_EXCLUDES_BITMASK) {
+ tar_optargs.excludes = optargs->excludes;
+ tar_optargs.bitmask |= GUESTFS_TAR_OUT_OPTS_EXCLUDES_BITMASK;
+ }
+ if (optargs->bitmask & GUESTFS_COPY_OUT_OPTS_XATTRS_BITMASK) {
+ tar_optargs.xattrs = optargs->xattrs;
+ tar_optargs.bitmask |= GUESTFS_TAR_OUT_OPTS_XATTRS_BITMASK;
+ }
+ if (optargs->bitmask & GUESTFS_COPY_OUT_OPTS_SELINUX_BITMASK) {
+ tar_optargs.selinux = optargs->selinux;
+ tar_optargs.bitmask |= GUESTFS_TAR_OUT_OPTS_SELINUX_BITMASK;
+ }
+ if (optargs->bitmask & GUESTFS_COPY_OUT_OPTS_ACLS_BITMASK) {
+ tar_optargs.acls = optargs->acls;
+ tar_optargs.bitmask |= GUESTFS_TAR_OUT_OPTS_ACLS_BITMASK;
+ }
+
+ r = guestfs_tar_out_opts_argv (g, remotepath, fdbuf, &tar_optargs);
if (close (fd) == -1) {
perrorf (g, "close (tar-output subprocess)");
--
2.9.3