Copy a file found in our --copy-dest handling. */
| 910 | |
| 911 | /* Copy a file found in our --copy-dest handling. */ |
| 912 | static int copy_altdest_file(const char *src, const char *dest, struct file_struct *file) |
| 913 | { |
| 914 | char buf[MAXPATHLEN]; |
| 915 | const char *copy_to, *partialptr; |
| 916 | int save_preserve_xattrs = preserve_xattrs; |
| 917 | int ok, fd_w; |
| 918 | |
| 919 | if (inplace) { |
| 920 | /* Let copy_file open the destination in place. */ |
| 921 | fd_w = -1; |
| 922 | copy_to = dest; |
| 923 | } else { |
| 924 | fd_w = open_tmpfile(buf, dest, file); |
| 925 | if (fd_w < 0) |
| 926 | return -1; |
| 927 | copy_to = buf; |
| 928 | } |
| 929 | cleanup_set(copy_to, NULL, NULL, -1, -1); |
| 930 | if (copy_file(src, copy_to, fd_w, file->mode) < 0) { |
| 931 | if (INFO_GTE(COPY, 1)) { |
| 932 | rsyserr(FINFO, errno, "copy_file %s => %s", |
| 933 | full_fname(src), copy_to); |
| 934 | } |
| 935 | /* Try to clean up. */ |
| 936 | unlink(copy_to); |
| 937 | cleanup_disable(); |
| 938 | return -1; |
| 939 | } |
| 940 | partialptr = partial_dir ? partial_dir_fname(dest) : NULL; |
| 941 | preserve_xattrs = 0; /* xattrs were copied with file */ |
| 942 | ok = finish_transfer(dest, copy_to, src, partialptr, file, 1, 0); |
| 943 | preserve_xattrs = save_preserve_xattrs; |
| 944 | cleanup_disable(); |
| 945 | return ok ? 0 : -1; |
| 946 | } |
| 947 | |
| 948 | /* This is only called for regular files. We return -2 if we've finished |
| 949 | * handling the file, -1 if no dest-linking occurred, or a non-negative |
no test coverage detected