| 986 | |
| 987 | |
| 988 | static int do_recv(int f_in, int f_out, char *local_name) |
| 989 | { |
| 990 | int pid; |
| 991 | int exit_code = 0; |
| 992 | int error_pipe[2]; |
| 993 | |
| 994 | /* The receiving side mustn't obey this, or an existing symlink that |
| 995 | * points to an identical file won't be replaced by the referent. */ |
| 996 | copy_links = copy_dirlinks = copy_unsafe_links = 0; |
| 997 | |
| 998 | #ifdef SUPPORT_HARD_LINKS |
| 999 | if (preserve_hard_links && !inc_recurse) |
| 1000 | match_hard_links(first_flist); |
| 1001 | #endif |
| 1002 | |
| 1003 | if (fd_pair(error_pipe) < 0) { |
| 1004 | rsyserr(FERROR, errno, "pipe failed in do_recv"); |
| 1005 | exit_cleanup(RERR_IPC); |
| 1006 | } |
| 1007 | |
| 1008 | if (backup_dir) { |
| 1009 | STRUCT_STAT st; |
| 1010 | int ret; |
| 1011 | if (backup_dir_len > 1) |
| 1012 | backup_dir_buf[backup_dir_len-1] = '\0'; |
| 1013 | ret = do_stat(backup_dir_buf, &st); |
| 1014 | if (ret != 0 || !S_ISDIR(st.st_mode)) { |
| 1015 | if (ret == 0) { |
| 1016 | rprintf(FERROR, "The backup-dir is not a directory: %s\n", backup_dir_buf); |
| 1017 | exit_cleanup(RERR_SYNTAX); |
| 1018 | } |
| 1019 | if (errno != ENOENT) { |
| 1020 | rprintf(FERROR, "Failed to stat %s: %s\n", backup_dir_buf, strerror(errno)); |
| 1021 | exit_cleanup(RERR_FILEIO); |
| 1022 | } |
| 1023 | if (INFO_GTE(BACKUP, 1)) |
| 1024 | rprintf(FINFO, "(new) backup_dir is %s\n", backup_dir_buf); |
| 1025 | } else if (INFO_GTE(BACKUP, 1)) |
| 1026 | rprintf(FINFO, "backup_dir is %s\n", backup_dir_buf); |
| 1027 | if (backup_dir_len > 1) |
| 1028 | backup_dir_buf[backup_dir_len-1] = '/'; |
| 1029 | } |
| 1030 | |
| 1031 | if (tmpdir) { |
| 1032 | STRUCT_STAT st; |
| 1033 | int ret = do_stat(tmpdir, &st); |
| 1034 | if (ret < 0 || !S_ISDIR(st.st_mode)) { |
| 1035 | if (ret == 0) { |
| 1036 | rprintf(FERROR, "The temp-dir is not a directory: %s\n", tmpdir); |
| 1037 | exit_cleanup(RERR_SYNTAX); |
| 1038 | } |
| 1039 | if (errno == ENOENT) { |
| 1040 | rprintf(FERROR, "The temp-dir does not exist: %s\n", tmpdir); |
| 1041 | exit_cleanup(RERR_SYNTAX); |
| 1042 | } |
| 1043 | rprintf(FERROR, "Failed to stat temp-dir %s: %s\n", tmpdir, strerror(errno)); |
| 1044 | exit_cleanup(RERR_FILEIO); |
| 1045 | } |
no test coverage detected