Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
New API: cp-r
This runs 'cp -rP' and is useful for copying when the target
doesn't support file owners or permissions (ie. FAT).
  • Loading branch information
rwmjones committed May 9, 2013
1 parent e7e8a1b commit d661456
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
6 changes: 6 additions & 0 deletions daemon/cpmv.c
Expand Up @@ -42,6 +42,12 @@ do_cp_a (const char *src, const char *dest)
return cpmv_cmd (str_cp, "-a", src, dest);
}

int
do_cp_r (const char *src, const char *dest)
{
return cpmv_cmd (str_cp, "-rP", src, dest);
}

int
do_mv (const char *src, const char *dest)
{
Expand Down
22 changes: 22 additions & 0 deletions generator/actions.ml
Expand Up @@ -11146,6 +11146,28 @@ about the contents of this file, see L<extlinux(1)>.
See also C<guestfs_syslinux>." };

{ defaults with
name = "cp_r";
style = RErr, [Pathname "src"; Pathname "dest"], [];
proc_nr = Some 401;
tests = [
InitScratchFS, Always, TestResultString (
[["mkdir"; "/cp_r1"];
["mkdir"; "/cp_r2"];
["write"; "/cp_r1/file"; "file content"];
["cp_r"; "/cp_r1"; "/cp_r2"];
["cat"; "/cp_r2/cp_r1/file"]], "file content")
];
shortdesc = "copy a file or directory recursively";
longdesc = "\
This copies a file or directory from C<src> to C<dest>
recursively using the C<cp -rP> command.
Most users should use C<guestfs_cp_a> instead. This command
is useful when you don't want to preserve permissions, because
the target filesystem does not support it (primarily when
writing to DOS FAT filesystems)." };

]

(* Non-API meta-commands available only in guestfish.
Expand Down
2 changes: 1 addition & 1 deletion src/MAX_PROC_NR
@@ -1 +1 @@
400
401

0 comments on commit d661456

Please sign in to comment.