MCPcopy Index your code
hub / github.com/RsyncProject/rsync / try_dests_non

Function try_dests_non

generator.c:1064–1153  ·  view source on GitHub ↗

This is only called for non-regular files. We return -2 if we've finished * handling the file, or -1 if no dest-linking occurred, or a non-negative * value if we found an alternate basis file. */

Source from the content-addressed store, hash-verified

1062 * handling the file, or -1 if no dest-linking occurred, or a non-negative
1063 * value if we found an alternate basis file. */
1064static int try_dests_non(struct file_struct *file, char *fname, int ndx,
1065 char *cmpbuf, stat_x *sxp, int itemizing,
1066 enum logcode code)
1067{
1068 int best_match = -1;
1069 int match_level = 0;
1070 enum filetype ftype = get_file_type(file->mode);
1071 int j = 0;
1072
1073#ifndef SUPPORT_LINKS
1074 if (ftype == FT_SYMLINK)
1075 return -1;
1076#endif
1077 if (ftype == FT_REG || ftype == FT_UNSUPPORTED) {
1078 rprintf(FERROR,
1079 "internal: try_dests_non() called with invalid mode (%o)\n",
1080 (int)file->mode);
1081 exit_cleanup(RERR_UNSUPPORTED);
1082 }
1083
1084 do {
1085 pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname);
1086 if (link_stat(cmpbuf, &sxp->st, 0) < 0)
1087 continue;
1088 if (ftype != get_file_type(sxp->st.st_mode))
1089 continue;
1090 if (match_level < 1) {
1091 match_level = 1;
1092 best_match = j;
1093 }
1094 if (!quick_check_ok(ftype, cmpbuf, file, &sxp->st))
1095 continue;
1096 if (match_level < 2) {
1097 match_level = 2;
1098 best_match = j;
1099 }
1100 if (unchanged_attrs(cmpbuf, file, sxp)) {
1101 match_level = 3;
1102 best_match = j;
1103 break;
1104 }
1105 } while (basis_dir[++j] != NULL);
1106
1107 if (!match_level)
1108 return -1;
1109
1110 if (j != best_match) {
1111 j = best_match;
1112 pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname);
1113 if (link_stat(cmpbuf, &sxp->st, 0) < 0)
1114 return -1;
1115 }
1116
1117 if (match_level == 3) {
1118#ifdef SUPPORT_HARD_LINKS
1119 if (alt_dest_type == LINK_DEST
1120#ifndef CAN_HARDLINK_SYMLINK
1121 && !S_ISLNK(file->mode)

Callers 1

recv_generatorFunction · 0.85

Calls 10

get_file_typeFunction · 0.85
pathjoinFunction · 0.85
link_statFunction · 0.85
quick_check_okFunction · 0.85
unchanged_attrsFunction · 0.85
do_link_atFunction · 0.85
finish_hard_linkFunction · 0.85
itemizeFunction · 0.85
rprintfFunction · 0.70
rsyserrFunction · 0.70

Tested by

no test coverage detected