MCPcopy Create free account
hub / github.com/RsyncProject/rsync / do_recv

Function do_recv

main.c:988–1146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

986
987
988static 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 }

Callers 2

do_server_recvFunction · 0.85
client_runFunction · 0.85

Calls 15

match_hard_linksFunction · 0.85
fd_pairFunction · 0.85
do_statFunction · 0.85
strerrorFunction · 0.85
io_flushFunction · 0.85
do_forkFunction · 0.85
io_end_multiplex_outFunction · 0.85
io_start_buffering_inFunction · 0.85
io_start_multiplex_outFunction · 0.85
recv_filesFunction · 0.85
handle_statsFunction · 0.85
write_intFunction · 0.85

Tested by

no test coverage detected