extern int do_fsck (const char *fstype, const char *device);
extern int do_zero (const char *device);
extern int do_grub_install (const char *root, const char *device);
+extern int do_cp (const char *src, const char *dest);
+extern int do_cp_a (const char *src, const char *dest);
+extern int do_mv (const char *src, const char *dest);
xdr_free ((xdrproc_t) xdr_guestfs_grub_install_args, (char *) &args);
}
+static void cp_stub (XDR *xdr_in)
+{
+ int r;
+ struct guestfs_cp_args args;
+ const char *src;
+ const char *dest;
+
+ memset (&args, 0, sizeof args);
+
+ if (!xdr_guestfs_cp_args (xdr_in, &args)) {
+ reply_with_error ("%s: daemon failed to decode procedure arguments", "cp");
+ return;
+ }
+ src = args.src;
+ dest = args.dest;
+
+ r = do_cp (src, dest);
+ if (r == -1)
+ /* do_cp has already called reply_with_error */
+ goto done;
+
+ reply (NULL, NULL);
+done:
+ xdr_free ((xdrproc_t) xdr_guestfs_cp_args, (char *) &args);
+}
+
+static void cp_a_stub (XDR *xdr_in)
+{
+ int r;
+ struct guestfs_cp_a_args args;
+ const char *src;
+ const char *dest;
+
+ memset (&args, 0, sizeof args);
+
+ if (!xdr_guestfs_cp_a_args (xdr_in, &args)) {
+ reply_with_error ("%s: daemon failed to decode procedure arguments", "cp_a");
+ return;
+ }
+ src = args.src;
+ dest = args.dest;
+
+ r = do_cp_a (src, dest);
+ if (r == -1)
+ /* do_cp_a has already called reply_with_error */
+ goto done;
+
+ reply (NULL, NULL);
+done:
+ xdr_free ((xdrproc_t) xdr_guestfs_cp_a_args, (char *) &args);
+}
+
+static void mv_stub (XDR *xdr_in)
+{
+ int r;
+ struct guestfs_mv_args args;
+ const char *src;
+ const char *dest;
+
+ memset (&args, 0, sizeof args);
+
+ if (!xdr_guestfs_mv_args (xdr_in, &args)) {
+ reply_with_error ("%s: daemon failed to decode procedure arguments", "mv");
+ return;
+ }
+ src = args.src;
+ dest = args.dest;
+
+ r = do_mv (src, dest);
+ if (r == -1)
+ /* do_mv has already called reply_with_error */
+ goto done;
+
+ reply (NULL, NULL);
+done:
+ xdr_free ((xdrproc_t) xdr_guestfs_mv_args, (char *) &args);
+}
+
void dispatch_incoming_message (XDR *xdr_in)
{
switch (proc_nr) {
case GUESTFS_PROC_GRUB_INSTALL:
grub_install_stub (xdr_in);
break;
+ case GUESTFS_PROC_CP:
+ cp_stub (xdr_in);
+ break;
+ case GUESTFS_PROC_CP_A:
+ cp_a_stub (xdr_in);
+ break;
+ case GUESTFS_PROC_MV:
+ mv_stub (xdr_in);
+ break;
default:
reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr);
}
printf ("%-20s %s\n", "command", "run a command from the guest filesystem");
printf ("%-20s %s\n", "command-lines", "run a command, returning lines");
printf ("%-20s %s\n", "config", "add qemu parameters");
+ printf ("%-20s %s\n", "cp", "copy a file");
+ printf ("%-20s %s\n", "cp-a", "copy a file or directory recursively");
printf ("%-20s %s\n", "debug", "debugging and internals");
printf ("%-20s %s\n", "download", "download a file to the local machine");
printf ("%-20s %s\n", "exists", "test if file or directory exists");
printf ("%-20s %s\n", "mount-ro", "mount a guest disk, read-only");
printf ("%-20s %s\n", "mount-vfs", "mount a guest disk with mount options and vfstype");
printf ("%-20s %s\n", "mounts", "show mounted filesystems");
+ printf ("%-20s %s\n", "mv", "move a file");
printf ("%-20s %s\n", "pvcreate", "create an LVM physical volume");
printf ("%-20s %s\n", "pvremove", "remove an LVM physical volume");
printf ("%-20s %s\n", "pvs", "list the LVM physical volumes (PVs)");
if (strcasecmp (cmd, "grub_install") == 0 || strcasecmp (cmd, "grub-install") == 0)
pod2text ("grub-install - install GRUB", " grub-install <root> <device>\n\nThis command installs GRUB (the Grand Unified Bootloader) on\nC<device>, with the root directory being C<root>.");
else
+ if (strcasecmp (cmd, "cp") == 0)
+ pod2text ("cp - copy a file", " cp <src> <dest>\n\nThis copies a file from C<src> to C<dest> where C<dest> is\neither a destination filename or destination directory.");
+ else
+ if (strcasecmp (cmd, "cp_a") == 0 || strcasecmp (cmd, "cp-a") == 0)
+ pod2text ("cp-a - copy a file or directory recursively", " cp-a <src> <dest>\n\nThis copies a file or directory from C<src> to C<dest>\nrecursively using the C<cp -a> command.");
+ else
+ if (strcasecmp (cmd, "mv") == 0)
+ pod2text ("mv - move a file", " mv <src> <dest>\n\nThis moves a file from C<src> to C<dest> where C<dest> is\neither a destination filename or destination directory.");
+ else
display_builtin_command (cmd);
}
return r;
}
+static int run_cp (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *src;
+ const char *dest;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ src = argv[0];
+ dest = argv[1];
+ r = guestfs_cp (g, src, dest);
+ return r;
+}
+
+static int run_cp_a (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *src;
+ const char *dest;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ src = argv[0];
+ dest = argv[1];
+ r = guestfs_cp_a (g, src, dest);
+ return r;
+}
+
+static int run_mv (const char *cmd, int argc, char *argv[])
+{
+ int r;
+ const char *src;
+ const char *dest;
+ if (argc != 2) {
+ fprintf (stderr, "%s should have 2 parameter(s)\n", cmd);
+ fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+ return -1;
+ }
+ src = argv[0];
+ dest = argv[1];
+ r = guestfs_mv (g, src, dest);
+ return r;
+}
+
int run_action (const char *cmd, int argc, char *argv[])
{
if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0)
if (strcasecmp (cmd, "grub_install") == 0 || strcasecmp (cmd, "grub-install") == 0)
return run_grub_install (cmd, argc, argv);
else
+ if (strcasecmp (cmd, "cp") == 0)
+ return run_cp (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "cp_a") == 0 || strcasecmp (cmd, "cp-a") == 0)
+ return run_cp_a (cmd, argc, argv);
+ else
+ if (strcasecmp (cmd, "mv") == 0)
+ return run_mv (cmd, argc, argv);
+ else
{
fprintf (stderr, "%s: unknown command\n", cmd);
return -1;
"command",
"command-lines",
"config",
+ "cp",
+ "cp-a",
"debug",
"download",
"exists",
"mount-ro",
"mount-vfs",
"mounts",
+ "mv",
"path",
"pvcreate",
"pvremove",
C<value> can be NULL.
+=head2 cp
+
+ cp src dest
+
+This copies a file from C<src> to C<dest> where C<dest> is
+either a destination filename or destination directory.
+
+=head2 cp-a
+
+ cp-a src dest
+
+This copies a file or directory from C<src> to C<dest>
+recursively using the C<cp -a> command.
+
=head2 debug
debug subcmd 'extraargs ...'
Some internal mounts are not shown.
+=head2 mv
+
+ mv src dest
+
+This moves a file from C<src> to C<dest> where C<dest> is
+either a destination filename or destination directory.
+
=head2 pvcreate
pvcreate device
This function returns 0 on success or -1 on error.
+=head2 guestfs_cp
+
+ int guestfs_cp (guestfs_h *handle,
+ const char *src,
+ const char *dest);
+
+This copies a file from C<src> to C<dest> where C<dest> is
+either a destination filename or destination directory.
+
+This function returns 0 on success or -1 on error.
+
+=head2 guestfs_cp_a
+
+ int guestfs_cp_a (guestfs_h *handle,
+ const char *src,
+ const char *dest);
+
+This copies a file or directory from C<src> to C<dest>
+recursively using the C<cp -a> command.
+
+This function returns 0 on success or -1 on error.
+
=head2 guestfs_debug
char *guestfs_debug (guestfs_h *handle,
(like L<environ(3)>), or NULL if there was an error.
I<The caller must free the strings and the array after use>.
+=head2 guestfs_mv
+
+ int guestfs_mv (guestfs_h *handle,
+ const char *src,
+ const char *dest);
+
+This moves a file from C<src> to C<dest> where C<dest> is
+either a destination filename or destination directory.
+
+This function returns 0 on success or -1 on error.
+
=head2 guestfs_pvcreate
int guestfs_pvcreate (guestfs_h *handle,
private native void _grub_install (long g, String root, String device)
throws LibGuestFSException;
+ /**
+ * copy a file
+ *
+ * This copies a file from "src" to "dest" where "dest" is
+ * either a destination filename or destination directory.
+ *
+ * @throws LibGuestFSException
+ */
+ public void cp (String src, String dest)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("cp: handle is closed");
+ _cp (g, src, dest);
+ }
+ private native void _cp (long g, String src, String dest)
+ throws LibGuestFSException;
+
+ /**
+ * copy a file or directory recursively
+ *
+ * This copies a file or directory from "src" to "dest"
+ * recursively using the "cp -a" command.
+ *
+ * @throws LibGuestFSException
+ */
+ public void cp_a (String src, String dest)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("cp_a: handle is closed");
+ _cp_a (g, src, dest);
+ }
+ private native void _cp_a (long g, String src, String dest)
+ throws LibGuestFSException;
+
+ /**
+ * move a file
+ *
+ * This moves a file from "src" to "dest" where "dest" is
+ * either a destination filename or destination directory.
+ *
+ * @throws LibGuestFSException
+ */
+ public void mv (String src, String dest)
+ throws LibGuestFSException
+ {
+ if (g == 0)
+ throw new LibGuestFSException ("mv: handle is closed");
+ _mv (g, src, dest);
+ }
+ private native void _mv (long g, String src, String dest)
+ throws LibGuestFSException;
+
}
}
}
+JNIEXPORT void JNICALL
+Java_com_redhat_et_libguestfs_GuestFS__1cp
+ (JNIEnv *env, jobject obj, jlong jg, jstring jsrc, jstring jdest)
+{
+ guestfs_h *g = (guestfs_h *) (long) jg;
+ int r;
+ const char *src;
+ const char *dest;
+
+ src = (*env)->GetStringUTFChars (env, jsrc, NULL);
+ dest = (*env)->GetStringUTFChars (env, jdest, NULL);
+ r = guestfs_cp (g, src, dest);
+ (*env)->ReleaseStringUTFChars (env, jsrc, src);
+ (*env)->ReleaseStringUTFChars (env, jdest, dest);
+ if (r == -1) {
+ throw_exception (env, guestfs_last_error (g));
+ return ;
+ }
+}
+
+JNIEXPORT void JNICALL
+Java_com_redhat_et_libguestfs_GuestFS__1cp_1a
+ (JNIEnv *env, jobject obj, jlong jg, jstring jsrc, jstring jdest)
+{
+ guestfs_h *g = (guestfs_h *) (long) jg;
+ int r;
+ const char *src;
+ const char *dest;
+
+ src = (*env)->GetStringUTFChars (env, jsrc, NULL);
+ dest = (*env)->GetStringUTFChars (env, jdest, NULL);
+ r = guestfs_cp_a (g, src, dest);
+ (*env)->ReleaseStringUTFChars (env, jsrc, src);
+ (*env)->ReleaseStringUTFChars (env, jdest, dest);
+ if (r == -1) {
+ throw_exception (env, guestfs_last_error (g));
+ return ;
+ }
+}
+
+JNIEXPORT void JNICALL
+Java_com_redhat_et_libguestfs_GuestFS__1mv
+ (JNIEnv *env, jobject obj, jlong jg, jstring jsrc, jstring jdest)
+{
+ guestfs_h *g = (guestfs_h *) (long) jg;
+ int r;
+ const char *src;
+ const char *dest;
+
+ src = (*env)->GetStringUTFChars (env, jsrc, NULL);
+ dest = (*env)->GetStringUTFChars (env, jdest, NULL);
+ r = guestfs_mv (g, src, dest);
+ (*env)->ReleaseStringUTFChars (env, jsrc, src);
+ (*env)->ReleaseStringUTFChars (env, jdest, dest);
+ if (r == -1) {
+ throw_exception (env, guestfs_last_error (g));
+ return ;
+ }
+}
+
external fsck : t -> string -> string -> int = "ocaml_guestfs_fsck"
external zero : t -> string -> unit = "ocaml_guestfs_zero"
external grub_install : t -> string -> string -> unit = "ocaml_guestfs_grub_install"
+external cp : t -> string -> string -> unit = "ocaml_guestfs_cp"
+external cp_a : t -> string -> string -> unit = "ocaml_guestfs_cp_a"
+external mv : t -> string -> string -> unit = "ocaml_guestfs_mv"
val grub_install : t -> string -> string -> unit
(** install GRUB *)
+val cp : t -> string -> string -> unit
+(** copy a file *)
+
+val cp_a : t -> string -> string -> unit
+(** copy a file or directory recursively *)
+
+val mv : t -> string -> string -> unit
+(** move a file *)
+
CAMLreturn (rv);
}
+CAMLprim value
+ocaml_guestfs_cp (value gv, value srcv, value destv)
+{
+ CAMLparam3 (gv, srcv, destv);
+ CAMLlocal1 (rv);
+
+ guestfs_h *g = Guestfs_val (gv);
+ if (g == NULL)
+ caml_failwith ("cp: used handle after closing it");
+
+ const char *src = String_val (srcv);
+ const char *dest = String_val (destv);
+ int r;
+
+ caml_enter_blocking_section ();
+ r = guestfs_cp (g, src, dest);
+ caml_leave_blocking_section ();
+ if (r == -1)
+ ocaml_guestfs_raise_error (g, "cp");
+
+ rv = Val_unit;
+ CAMLreturn (rv);
+}
+
+CAMLprim value
+ocaml_guestfs_cp_a (value gv, value srcv, value destv)
+{
+ CAMLparam3 (gv, srcv, destv);
+ CAMLlocal1 (rv);
+
+ guestfs_h *g = Guestfs_val (gv);
+ if (g == NULL)
+ caml_failwith ("cp_a: used handle after closing it");
+
+ const char *src = String_val (srcv);
+ const char *dest = String_val (destv);
+ int r;
+
+ caml_enter_blocking_section ();
+ r = guestfs_cp_a (g, src, dest);
+ caml_leave_blocking_section ();
+ if (r == -1)
+ ocaml_guestfs_raise_error (g, "cp_a");
+
+ rv = Val_unit;
+ CAMLreturn (rv);
+}
+
+CAMLprim value
+ocaml_guestfs_mv (value gv, value srcv, value destv)
+{
+ CAMLparam3 (gv, srcv, destv);
+ CAMLlocal1 (rv);
+
+ guestfs_h *g = Guestfs_val (gv);
+ if (g == NULL)
+ caml_failwith ("mv: used handle after closing it");
+
+ const char *src = String_val (srcv);
+ const char *dest = String_val (destv);
+ int r;
+
+ caml_enter_blocking_section ();
+ r = guestfs_mv (g, src, dest);
+ caml_leave_blocking_section ();
+ if (r == -1)
+ ocaml_guestfs_raise_error (g, "mv");
+
+ rv = Val_unit;
+ CAMLreturn (rv);
+}
+
if (r == -1)
croak ("grub_install: %s", guestfs_last_error (g));
+void
+cp (g, src, dest)
+ guestfs_h *g;
+ char *src;
+ char *dest;
+PREINIT:
+ int r;
+ PPCODE:
+ r = guestfs_cp (g, src, dest);
+ if (r == -1)
+ croak ("cp: %s", guestfs_last_error (g));
+
+void
+cp_a (g, src, dest)
+ guestfs_h *g;
+ char *src;
+ char *dest;
+PREINIT:
+ int r;
+ PPCODE:
+ r = guestfs_cp_a (g, src, dest);
+ if (r == -1)
+ croak ("cp_a: %s", guestfs_last_error (g));
+
+void
+mv (g, src, dest)
+ guestfs_h *g;
+ char *src;
+ char *dest;
+PREINIT:
+ int r;
+ PPCODE:
+ r = guestfs_mv (g, src, dest);
+ if (r == -1)
+ croak ("mv: %s", guestfs_last_error (g));
+
C<value> can be NULL.
+=item $h->cp ($src, $dest);
+
+This copies a file from C<src> to C<dest> where C<dest> is
+either a destination filename or destination directory.
+
+=item $h->cp_a ($src, $dest);
+
+This copies a file or directory from C<src> to C<dest>
+recursively using the C<cp -a> command.
+
=item $result = $h->debug ($subcmd, \@extraargs);
The C<$h-E<gt>debug> command exposes some internals of
Some internal mounts are not shown.
+=item $h->mv ($src, $dest);
+
+This moves a file from C<src> to C<dest> where C<dest> is
+either a destination filename or destination directory.
+
=item $h->pvcreate ($device);
This creates an LVM physical volume on the named C<device>,
return py_r;
}
+static PyObject *
+py_guestfs_cp (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ int r;
+ const char *src;
+ const char *dest;
+
+ if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_cp",
+ &py_g, &src, &dest))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_cp (g, src, dest);
+ if (r == -1) {
+ PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+ return NULL;
+ }
+
+ Py_INCREF (Py_None);
+ py_r = Py_None;
+ return py_r;
+}
+
+static PyObject *
+py_guestfs_cp_a (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ int r;
+ const char *src;
+ const char *dest;
+
+ if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_cp_a",
+ &py_g, &src, &dest))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_cp_a (g, src, dest);
+ if (r == -1) {
+ PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+ return NULL;
+ }
+
+ Py_INCREF (Py_None);
+ py_r = Py_None;
+ return py_r;
+}
+
+static PyObject *
+py_guestfs_mv (PyObject *self, PyObject *args)
+{
+ PyObject *py_g;
+ guestfs_h *g;
+ PyObject *py_r;
+ int r;
+ const char *src;
+ const char *dest;
+
+ if (!PyArg_ParseTuple (args, (char *) "Oss:guestfs_mv",
+ &py_g, &src, &dest))
+ return NULL;
+ g = get_handle (py_g);
+
+ r = guestfs_mv (g, src, dest);
+ if (r == -1) {
+ PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+ return NULL;
+ }
+
+ Py_INCREF (Py_None);
+ py_r = Py_None;
+ return py_r;
+}
+
static PyMethodDef methods[] = {
{ (char *) "create", py_guestfs_create, METH_VARARGS, NULL },
{ (char *) "close", py_guestfs_close, METH_VARARGS, NULL },
{ (char *) "fsck", py_guestfs_fsck, METH_VARARGS, NULL },
{ (char *) "zero", py_guestfs_zero, METH_VARARGS, NULL },
{ (char *) "grub_install", py_guestfs_grub_install, METH_VARARGS, NULL },
+ { (char *) "cp", py_guestfs_cp, METH_VARARGS, NULL },
+ { (char *) "cp_a", py_guestfs_cp_a, METH_VARARGS, NULL },
+ { (char *) "mv", py_guestfs_mv, METH_VARARGS, NULL },
{ NULL, NULL, 0, NULL }
};
"""
return libguestfsmod.grub_install (self._o, root, device)
+ def cp (self, src, dest):
+ u"""This copies a file from "src" to "dest" where "dest" is
+ either a destination filename or destination directory.
+ """
+ return libguestfsmod.cp (self._o, src, dest)
+
+ def cp_a (self, src, dest):
+ u"""This copies a file or directory from "src" to "dest"
+ recursively using the "cp -a" command.
+ """
+ return libguestfsmod.cp_a (self._o, src, dest)
+
+ def mv (self, src, dest):
+ u"""This moves a file from "src" to "dest" where "dest" is
+ either a destination filename or destination directory.
+ """
+ return libguestfsmod.mv (self._o, src, dest)
+
return Qnil;
}
+static VALUE ruby_guestfs_cp (VALUE gv, VALUE srcv, VALUE destv)
+{
+ guestfs_h *g;
+ Data_Get_Struct (gv, guestfs_h, g);
+ if (!g)
+ rb_raise (rb_eArgError, "%s: used handle after closing it", "cp");
+
+ const char *src = StringValueCStr (srcv);
+ if (!src)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "src", "cp");
+ const char *dest = StringValueCStr (destv);
+ if (!dest)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "dest", "cp");
+
+ int r;
+
+ r = guestfs_cp (g, src, dest);
+ if (r == -1)
+ rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+ return Qnil;
+}
+
+static VALUE ruby_guestfs_cp_a (VALUE gv, VALUE srcv, VALUE destv)
+{
+ guestfs_h *g;
+ Data_Get_Struct (gv, guestfs_h, g);
+ if (!g)
+ rb_raise (rb_eArgError, "%s: used handle after closing it", "cp_a");
+
+ const char *src = StringValueCStr (srcv);
+ if (!src)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "src", "cp_a");
+ const char *dest = StringValueCStr (destv);
+ if (!dest)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "dest", "cp_a");
+
+ int r;
+
+ r = guestfs_cp_a (g, src, dest);
+ if (r == -1)
+ rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+ return Qnil;
+}
+
+static VALUE ruby_guestfs_mv (VALUE gv, VALUE srcv, VALUE destv)
+{
+ guestfs_h *g;
+ Data_Get_Struct (gv, guestfs_h, g);
+ if (!g)
+ rb_raise (rb_eArgError, "%s: used handle after closing it", "mv");
+
+ const char *src = StringValueCStr (srcv);
+ if (!src)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "src", "mv");
+ const char *dest = StringValueCStr (destv);
+ if (!dest)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "dest", "mv");
+
+ int r;
+
+ r = guestfs_mv (g, src, dest);
+ if (r == -1)
+ rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+ return Qnil;
+}
+
/* Initialize the module. */
void Init__guestfs ()
{
ruby_guestfs_zero, 1);
rb_define_method (c_guestfs, "grub_install",
ruby_guestfs_grub_install, 2);
+ rb_define_method (c_guestfs, "cp",
+ ruby_guestfs_cp, 2);
+ rb_define_method (c_guestfs, "cp_a",
+ ruby_guestfs_cp_a, 2);
+ rb_define_method (c_guestfs, "mv",
+ ruby_guestfs_mv, 2);
}
return 0;
}
+struct cp_ctx {
+ /* This flag is set by the callbacks, so we know we've done
+ * the callbacks as expected, and in the right sequence.
+ * 0 = not called, 1 = reply_cb called.
+ */
+ int cb_sequence;
+ struct guestfs_message_header hdr;
+ struct guestfs_message_error err;
+};
+
+static void cp_reply_cb (guestfs_h *g, void *data, XDR *xdr)
+{
+ guestfs_main_loop *ml = guestfs_get_main_loop (g);
+ struct cp_ctx *ctx = (struct cp_ctx *) data;
+
+ /* This should definitely not happen. */
+ if (ctx->cb_sequence != 0) {
+ ctx->cb_sequence = 9999;
+ error (g, "%s: internal error: reply callback called twice", "guestfs_cp");
+ return;
+ }
+
+ ml->main_loop_quit (ml, g);
+
+ if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
+ error (g, "%s: failed to parse reply header", "guestfs_cp");
+ return;
+ }
+ if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
+ if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
+ error (g, "%s: failed to parse reply error", "guestfs_cp");
+ return;
+ }
+ goto done;
+ }
+ done:
+ ctx->cb_sequence = 1;
+}
+
+int guestfs_cp (guestfs_h *g,
+ const char *src,
+ const char *dest)
+{
+ struct guestfs_cp_args args;
+ struct cp_ctx ctx;
+ guestfs_main_loop *ml = guestfs_get_main_loop (g);
+ int serial;
+
+ if (check_state (g, "guestfs_cp") == -1) return -1;
+ guestfs_set_busy (g);
+
+ memset (&ctx, 0, sizeof ctx);
+
+ args.src = (char *) src;
+ args.dest = (char *) dest;
+ serial = guestfs__send_sync (g, GUESTFS_PROC_CP,
+ (xdrproc_t) xdr_guestfs_cp_args, (char *) &args);
+ if (serial == -1) {
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ guestfs__switch_to_receiving (g);
+ ctx.cb_sequence = 0;
+ guestfs_set_reply_callback (g, cp_reply_cb, &ctx);
+ (void) ml->main_loop_run (ml, g);
+ guestfs_set_reply_callback (g, NULL, NULL);
+ if (ctx.cb_sequence != 1) {
+ error (g, "%s reply failed, see earlier error messages", "guestfs_cp");
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_CP, serial) == -1) {
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
+ error (g, "%s", ctx.err.error_message);
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ guestfs_set_ready (g);
+ return 0;
+}
+
+struct cp_a_ctx {
+ /* This flag is set by the callbacks, so we know we've done
+ * the callbacks as expected, and in the right sequence.
+ * 0 = not called, 1 = reply_cb called.
+ */
+ int cb_sequence;
+ struct guestfs_message_header hdr;
+ struct guestfs_message_error err;
+};
+
+static void cp_a_reply_cb (guestfs_h *g, void *data, XDR *xdr)
+{
+ guestfs_main_loop *ml = guestfs_get_main_loop (g);
+ struct cp_a_ctx *ctx = (struct cp_a_ctx *) data;
+
+ /* This should definitely not happen. */
+ if (ctx->cb_sequence != 0) {
+ ctx->cb_sequence = 9999;
+ error (g, "%s: internal error: reply callback called twice", "guestfs_cp_a");
+ return;
+ }
+
+ ml->main_loop_quit (ml, g);
+
+ if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
+ error (g, "%s: failed to parse reply header", "guestfs_cp_a");
+ return;
+ }
+ if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
+ if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
+ error (g, "%s: failed to parse reply error", "guestfs_cp_a");
+ return;
+ }
+ goto done;
+ }
+ done:
+ ctx->cb_sequence = 1;
+}
+
+int guestfs_cp_a (guestfs_h *g,
+ const char *src,
+ const char *dest)
+{
+ struct guestfs_cp_a_args args;
+ struct cp_a_ctx ctx;
+ guestfs_main_loop *ml = guestfs_get_main_loop (g);
+ int serial;
+
+ if (check_state (g, "guestfs_cp_a") == -1) return -1;
+ guestfs_set_busy (g);
+
+ memset (&ctx, 0, sizeof ctx);
+
+ args.src = (char *) src;
+ args.dest = (char *) dest;
+ serial = guestfs__send_sync (g, GUESTFS_PROC_CP_A,
+ (xdrproc_t) xdr_guestfs_cp_a_args, (char *) &args);
+ if (serial == -1) {
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ guestfs__switch_to_receiving (g);
+ ctx.cb_sequence = 0;
+ guestfs_set_reply_callback (g, cp_a_reply_cb, &ctx);
+ (void) ml->main_loop_run (ml, g);
+ guestfs_set_reply_callback (g, NULL, NULL);
+ if (ctx.cb_sequence != 1) {
+ error (g, "%s reply failed, see earlier error messages", "guestfs_cp_a");
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_CP_A, serial) == -1) {
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
+ error (g, "%s", ctx.err.error_message);
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ guestfs_set_ready (g);
+ return 0;
+}
+
+struct mv_ctx {
+ /* This flag is set by the callbacks, so we know we've done
+ * the callbacks as expected, and in the right sequence.
+ * 0 = not called, 1 = reply_cb called.
+ */
+ int cb_sequence;
+ struct guestfs_message_header hdr;
+ struct guestfs_message_error err;
+};
+
+static void mv_reply_cb (guestfs_h *g, void *data, XDR *xdr)
+{
+ guestfs_main_loop *ml = guestfs_get_main_loop (g);
+ struct mv_ctx *ctx = (struct mv_ctx *) data;
+
+ /* This should definitely not happen. */
+ if (ctx->cb_sequence != 0) {
+ ctx->cb_sequence = 9999;
+ error (g, "%s: internal error: reply callback called twice", "guestfs_mv");
+ return;
+ }
+
+ ml->main_loop_quit (ml, g);
+
+ if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) {
+ error (g, "%s: failed to parse reply header", "guestfs_mv");
+ return;
+ }
+ if (ctx->hdr.status == GUESTFS_STATUS_ERROR) {
+ if (!xdr_guestfs_message_error (xdr, &ctx->err)) {
+ error (g, "%s: failed to parse reply error", "guestfs_mv");
+ return;
+ }
+ goto done;
+ }
+ done:
+ ctx->cb_sequence = 1;
+}
+
+int guestfs_mv (guestfs_h *g,
+ const char *src,
+ const char *dest)
+{
+ struct guestfs_mv_args args;
+ struct mv_ctx ctx;
+ guestfs_main_loop *ml = guestfs_get_main_loop (g);
+ int serial;
+
+ if (check_state (g, "guestfs_mv") == -1) return -1;
+ guestfs_set_busy (g);
+
+ memset (&ctx, 0, sizeof ctx);
+
+ args.src = (char *) src;
+ args.dest = (char *) dest;
+ serial = guestfs__send_sync (g, GUESTFS_PROC_MV,
+ (xdrproc_t) xdr_guestfs_mv_args, (char *) &args);
+ if (serial == -1) {
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ guestfs__switch_to_receiving (g);
+ ctx.cb_sequence = 0;
+ guestfs_set_reply_callback (g, mv_reply_cb, &ctx);
+ (void) ml->main_loop_run (ml, g);
+ guestfs_set_reply_callback (g, NULL, NULL);
+ if (ctx.cb_sequence != 1) {
+ error (g, "%s reply failed, see earlier error messages", "guestfs_mv");
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_MV, serial) == -1) {
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ if (ctx.hdr.status == GUESTFS_STATUS_ERROR) {
+ error (g, "%s", ctx.err.error_message);
+ guestfs_set_ready (g);
+ return -1;
+ }
+
+ guestfs_set_ready (g);
+ return 0;
+}
+
extern int guestfs_fsck (guestfs_h *handle, const char *fstype, const char *device);
extern int guestfs_zero (guestfs_h *handle, const char *device);
extern int guestfs_grub_install (guestfs_h *handle, const char *root, const char *device);
+extern int guestfs_cp (guestfs_h *handle, const char *src, const char *dest);
+extern int guestfs_cp_a (guestfs_h *handle, const char *src, const char *dest);
+extern int guestfs_mv (guestfs_h *handle, const char *src, const char *dest);
}
bool_t
+xdr_guestfs_cp_args (XDR *xdrs, guestfs_cp_args *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_string (xdrs, &objp->src, ~0))
+ return FALSE;
+ if (!xdr_string (xdrs, &objp->dest, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_guestfs_cp_a_args (XDR *xdrs, guestfs_cp_a_args *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_string (xdrs, &objp->src, ~0))
+ return FALSE;
+ if (!xdr_string (xdrs, &objp->dest, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_guestfs_mv_args (XDR *xdrs, guestfs_mv_args *objp)
+{
+ register int32_t *buf;
+
+ if (!xdr_string (xdrs, &objp->src, ~0))
+ return FALSE;
+ if (!xdr_string (xdrs, &objp->dest, ~0))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
xdr_guestfs_procedure (XDR *xdrs, guestfs_procedure *objp)
{
register int32_t *buf;
};
typedef struct guestfs_grub_install_args guestfs_grub_install_args;
+struct guestfs_cp_args {
+ char *src;
+ char *dest;
+};
+typedef struct guestfs_cp_args guestfs_cp_args;
+
+struct guestfs_cp_a_args {
+ char *src;
+ char *dest;
+};
+typedef struct guestfs_cp_a_args guestfs_cp_a_args;
+
+struct guestfs_mv_args {
+ char *src;
+ char *dest;
+};
+typedef struct guestfs_mv_args guestfs_mv_args;
+
enum guestfs_procedure {
GUESTFS_PROC_MOUNT = 1,
GUESTFS_PROC_SYNC = 2,
GUESTFS_PROC_FSCK = 84,
GUESTFS_PROC_ZERO = 85,
GUESTFS_PROC_GRUB_INSTALL = 86,
- GUESTFS_PROC_NR_PROCS = 86 + 1,
+ GUESTFS_PROC_CP = 87,
+ GUESTFS_PROC_CP_A = 88,
+ GUESTFS_PROC_MV = 89,
+ GUESTFS_PROC_NR_PROCS = 89 + 1,
};
typedef enum guestfs_procedure guestfs_procedure;
#define GUESTFS_MESSAGE_MAX 4194304
extern bool_t xdr_guestfs_fsck_ret (XDR *, guestfs_fsck_ret*);
extern bool_t xdr_guestfs_zero_args (XDR *, guestfs_zero_args*);
extern bool_t xdr_guestfs_grub_install_args (XDR *, guestfs_grub_install_args*);
+extern bool_t xdr_guestfs_cp_args (XDR *, guestfs_cp_args*);
+extern bool_t xdr_guestfs_cp_a_args (XDR *, guestfs_cp_a_args*);
+extern bool_t xdr_guestfs_mv_args (XDR *, guestfs_mv_args*);
extern bool_t xdr_guestfs_procedure (XDR *, guestfs_procedure*);
extern bool_t xdr_guestfs_message_direction (XDR *, guestfs_message_direction*);
extern bool_t xdr_guestfs_message_status (XDR *, guestfs_message_status*);
extern bool_t xdr_guestfs_fsck_ret ();
extern bool_t xdr_guestfs_zero_args ();
extern bool_t xdr_guestfs_grub_install_args ();
+extern bool_t xdr_guestfs_cp_args ();
+extern bool_t xdr_guestfs_cp_a_args ();
+extern bool_t xdr_guestfs_mv_args ();
extern bool_t xdr_guestfs_procedure ();
extern bool_t xdr_guestfs_message_direction ();
extern bool_t xdr_guestfs_message_status ();
string device<>;
};
+struct guestfs_cp_args {
+ string src<>;
+ string dest<>;
+};
+
+struct guestfs_cp_a_args {
+ string src<>;
+ string dest<>;
+};
+
+struct guestfs_mv_args {
+ string src<>;
+ string dest<>;
+};
+
enum guestfs_procedure {
GUESTFS_PROC_MOUNT = 1,
GUESTFS_PROC_SYNC = 2,
GUESTFS_PROC_FSCK = 84,
GUESTFS_PROC_ZERO = 85,
GUESTFS_PROC_GRUB_INSTALL = 86,
+ GUESTFS_PROC_CP = 87,
+ GUESTFS_PROC_CP_A = 88,
+ GUESTFS_PROC_MV = 89,
GUESTFS_PROC_NR_PROCS
};
fprintf (stderr, "warning: \"guestfs_get_e2uuid\" has no tests\n");
}
+static int test_mv_0 (void)
+{
+ /* InitBasicFS for mv (0): create ext2 on /dev/sda1 */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_umount_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_lvm_remove_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *lines[] = {
+ ",",
+ NULL
+ };
+ int r;
+ suppress_error = 0;
+ r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkfs (g, "ext2", "/dev/sda1");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mount (g, "/dev/sda1", "/");
+ if (r == -1)
+ return -1;
+ }
+ /* TestOutput for mv (0) */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_write_file (g, "/old", "file content", 0);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mv (g, "/old", "/new");
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *r;
+ suppress_error = 0;
+ r = guestfs_cat (g, "/new");
+ if (r == NULL)
+ return -1;
+ if (strcmp (r, "file content") != 0) {
+ fprintf (stderr, "test_mv_0: expected \"file content\" but got \"%s\"\n", r);
+ return -1;
+ }
+ free (r);
+ }
+ return 0;
+}
+
+static int test_mv_1 (void)
+{
+ /* InitBasicFS for mv (1): create ext2 on /dev/sda1 */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_umount_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_lvm_remove_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *lines[] = {
+ ",",
+ NULL
+ };
+ int r;
+ suppress_error = 0;
+ r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkfs (g, "ext2", "/dev/sda1");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mount (g, "/dev/sda1", "/");
+ if (r == -1)
+ return -1;
+ }
+ /* TestOutputFalse for mv (1) */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_write_file (g, "/old", "file content", 0);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mv (g, "/old", "/new");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_is_file (g, "/old");
+ if (r == -1)
+ return -1;
+ if (r) {
+ fprintf (stderr, "test_mv_1: expected false, got true\n");
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static int test_cp_a_0 (void)
+{
+ /* InitBasicFS for cp_a (0): create ext2 on /dev/sda1 */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_umount_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_lvm_remove_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *lines[] = {
+ ",",
+ NULL
+ };
+ int r;
+ suppress_error = 0;
+ r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkfs (g, "ext2", "/dev/sda1");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mount (g, "/dev/sda1", "/");
+ if (r == -1)
+ return -1;
+ }
+ /* TestOutput for cp_a (0) */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkdir (g, "/olddir");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkdir (g, "/newdir");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_write_file (g, "/olddir/file", "file content", 0);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_cp_a (g, "/olddir", "/newdir");
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *r;
+ suppress_error = 0;
+ r = guestfs_cat (g, "/newdir/olddir/file");
+ if (r == NULL)
+ return -1;
+ if (strcmp (r, "file content") != 0) {
+ fprintf (stderr, "test_cp_a_0: expected \"file content\" but got \"%s\"\n", r);
+ return -1;
+ }
+ free (r);
+ }
+ return 0;
+}
+
+static int test_cp_0 (void)
+{
+ /* InitBasicFS for cp (0): create ext2 on /dev/sda1 */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_umount_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_lvm_remove_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *lines[] = {
+ ",",
+ NULL
+ };
+ int r;
+ suppress_error = 0;
+ r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkfs (g, "ext2", "/dev/sda1");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mount (g, "/dev/sda1", "/");
+ if (r == -1)
+ return -1;
+ }
+ /* TestOutput for cp (0) */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_write_file (g, "/old", "file content", 0);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_cp (g, "/old", "/new");
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *r;
+ suppress_error = 0;
+ r = guestfs_cat (g, "/new");
+ if (r == NULL)
+ return -1;
+ if (strcmp (r, "file content") != 0) {
+ fprintf (stderr, "test_cp_0: expected \"file content\" but got \"%s\"\n", r);
+ return -1;
+ }
+ free (r);
+ }
+ return 0;
+}
+
+static int test_cp_1 (void)
+{
+ /* InitBasicFS for cp (1): create ext2 on /dev/sda1 */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_umount_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_lvm_remove_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *lines[] = {
+ ",",
+ NULL
+ };
+ int r;
+ suppress_error = 0;
+ r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkfs (g, "ext2", "/dev/sda1");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mount (g, "/dev/sda1", "/");
+ if (r == -1)
+ return -1;
+ }
+ /* TestOutputTrue for cp (1) */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_write_file (g, "/old", "file content", 0);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_cp (g, "/old", "/new");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_is_file (g, "/old");
+ if (r == -1)
+ return -1;
+ if (!r) {
+ fprintf (stderr, "test_cp_1: expected true, got false\n");
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static int test_cp_2 (void)
+{
+ /* InitBasicFS for cp (2): create ext2 on /dev/sda1 */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_umount_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_lvm_remove_all (g);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *lines[] = {
+ ",",
+ NULL
+ };
+ int r;
+ suppress_error = 0;
+ r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkfs (g, "ext2", "/dev/sda1");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mount (g, "/dev/sda1", "/");
+ if (r == -1)
+ return -1;
+ }
+ /* TestOutput for cp (2) */
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_write_file (g, "/old", "file content", 0);
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_mkdir (g, "/dir");
+ if (r == -1)
+ return -1;
+ }
+ {
+ int r;
+ suppress_error = 0;
+ r = guestfs_cp (g, "/old", "/dir/new");
+ if (r == -1)
+ return -1;
+ }
+ {
+ char *r;
+ suppress_error = 0;
+ r = guestfs_cat (g, "/dir/new");
+ if (r == NULL)
+ return -1;
+ if (strcmp (r, "file content") != 0) {
+ fprintf (stderr, "test_cp_2: expected \"file content\" but got \"%s\"\n", r);
+ return -1;
+ }
+ free (r);
+ }
+ return 0;
+}
+
static int test_grub_install_0 (void)
{
/* InitBasicFS for grub_install (0): create ext2 on /dev/sda1 */
exit (1);
}
- nr_tests = 95;
+ nr_tests = 101;
test_num++;
+ printf ("%3d/%3d test_mv_0\n", test_num, nr_tests);
+ if (test_mv_0 () == -1) {
+ printf ("test_mv_0 FAILED\n");
+ failed++;
+ }
+ test_num++;
+ printf ("%3d/%3d test_mv_1\n", test_num, nr_tests);
+ if (test_mv_1 () == -1) {
+ printf ("test_mv_1 FAILED\n");
+ failed++;
+ }
+ test_num++;
+ printf ("%3d/%3d test_cp_a_0\n", test_num, nr_tests);
+ if (test_cp_a_0 () == -1) {
+ printf ("test_cp_a_0 FAILED\n");
+ failed++;
+ }
+ test_num++;
+ printf ("%3d/%3d test_cp_0\n", test_num, nr_tests);
+ if (test_cp_0 () == -1) {
+ printf ("test_cp_0 FAILED\n");
+ failed++;
+ }
+ test_num++;
+ printf ("%3d/%3d test_cp_1\n", test_num, nr_tests);
+ if (test_cp_1 () == -1) {
+ printf ("test_cp_1 FAILED\n");
+ failed++;
+ }
+ test_num++;
+ printf ("%3d/%3d test_cp_2\n", test_num, nr_tests);
+ if (test_cp_2 () == -1) {
+ printf ("test_cp_2 FAILED\n");
+ failed++;
+ }
+ test_num++;
printf ("%3d/%3d test_grub_install_0\n", test_num, nr_tests);
if (test_grub_install_0 () == -1) {
printf ("test_grub_install_0 FAILED\n");