extern char *backup_dir;
extern char *backup_suffix;
extern int backup_suffix_len;
-@@ -509,22 +511,27 @@ static void do_delete_pass(struct file_l
+@@ -512,22 +514,27 @@ static void do_delete_pass(struct file_l
rprintf(FINFO, " \r");
}
const char *xname)
{
if (statret >= 0) { /* A from-dest-dir statret can == 1! */
-@@ -532,20 +539,24 @@ void itemize(struct file_struct *file, i
+@@ -535,20 +542,24 @@ void itemize(struct file_struct *file, i
: S_ISDIR(file->mode) ? !omit_dir_times
: !S_ISLNK(file->mode);
} else
iflags |= ITEM_IS_NEW;
-@@ -799,7 +810,7 @@ void check_for_finished_hlinks(int itemi
+@@ -784,7 +795,7 @@ static int find_fuzzy(struct file_struct
* handling the file, -1 if no dest-linking occurred, or a non-negative
* value if we found an alternate basis file. */
static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
enum logcode code)
{
int best_match = -1;
-@@ -808,7 +819,7 @@ static int try_dests_reg(struct file_str
+@@ -793,7 +804,7 @@ static int try_dests_reg(struct file_str
do {
pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname);
continue;
switch (match_level) {
case 0:
-@@ -816,16 +827,20 @@ static int try_dests_reg(struct file_str
+@@ -801,16 +812,20 @@ static int try_dests_reg(struct file_str
match_level = 1;
/* FALL THROUGH */
case 1:
continue;
best_match = j;
match_level = 3;
-@@ -840,7 +855,7 @@ static int try_dests_reg(struct file_str
+@@ -825,7 +840,7 @@ static int try_dests_reg(struct file_str
if (j != best_match) {
j = best_match;
pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname);
return -1;
}
-@@ -850,16 +865,25 @@ static int try_dests_reg(struct file_str
+@@ -835,16 +850,25 @@ static int try_dests_reg(struct file_str
if (!hard_link_one(file, fname, cmpbuf, 1))
goto try_a_copy;
if (preserve_hard_links && F_IS_HLINKED(file))
if (verbose > 1 && maybe_ATTRS_REPORT)
rprintf(FCLIENT, "%s is uptodate\n", fname);
return -2;
-@@ -876,8 +900,13 @@ static int try_dests_reg(struct file_str
+@@ -861,8 +885,13 @@ static int try_dests_reg(struct file_str
}
return -1;
}
set_file_attrs(fname, file, NULL, 0);
if (maybe_ATTRS_REPORT
&& ((!itemizing && verbose && match_level == 2)
-@@ -888,7 +917,7 @@ static int try_dests_reg(struct file_str
+@@ -873,7 +902,7 @@ static int try_dests_reg(struct file_str
}
#ifdef SUPPORT_HARD_LINKS
if (preserve_hard_links && F_IS_HLINKED(file))
#endif
return -2;
}
-@@ -900,7 +929,7 @@ static int try_dests_reg(struct file_str
+@@ -885,7 +914,7 @@ static int try_dests_reg(struct file_str
* handling the file, or -1 if no dest-linking occurred, or a non-negative
* value if we found an alternate basis file. */
static int try_dests_non(struct file_struct *file, char *fname, int ndx,
enum logcode code)
{
char lnk[MAXPATHLEN];
-@@ -933,24 +962,24 @@ static int try_dests_non(struct file_str
+@@ -918,24 +947,24 @@ static int try_dests_non(struct file_str
do {
pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname);
continue;
break;
#endif
-@@ -965,7 +994,7 @@ static int try_dests_non(struct file_str
+@@ -950,7 +979,7 @@ static int try_dests_non(struct file_str
case TYPE_SPECIAL:
case TYPE_DEVICE:
devp = F_RDEV_P(file);
continue;
break;
#ifdef SUPPORT_LINKS
-@@ -982,7 +1011,11 @@ static int try_dests_non(struct file_str
+@@ -967,7 +996,11 @@ static int try_dests_non(struct file_str
match_level = 2;
best_match = j;
}
match_level = 3;
best_match = j;
break;
-@@ -995,7 +1028,7 @@ static int try_dests_non(struct file_str
+@@ -980,7 +1013,7 @@ static int try_dests_non(struct file_str
if (j != best_match) {
j = best_match;
pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname);
return -1;
}
-@@ -1026,7 +1059,15 @@ static int try_dests_non(struct file_str
+@@ -1011,7 +1044,15 @@ static int try_dests_non(struct file_str
: ITEM_LOCAL_CHANGE
+ (match_level == 3 ? ITEM_XNAME_FOLLOWS : 0);
char *lp = match_level == 3 ? "" : NULL;
}
if (verbose > 1 && maybe_ATTRS_REPORT) {
rprintf(FCLIENT, "%s%s is uptodate\n",
-@@ -1039,6 +1080,7 @@ static int try_dests_non(struct file_str
+@@ -1024,6 +1065,7 @@ static int try_dests_non(struct file_str
}
static int phase = 0;
+static int dflt_perms;
- /* Acts on cur_flist->file's ndx'th item, whose name is fname. If a dir,
+ /* Acts on the indicated item in cur_flist whose name is fname. If a dir,
* make sure it exists, and has the right permissions/timestamp info. For
-@@ -1059,7 +1101,8 @@ static void recv_generator(char *fname,
+@@ -1044,7 +1086,8 @@ static void recv_generator(char *fname,
static int need_fuzzy_dirlist = 0;
struct file_struct *fuzzy_file = NULL;
int fd = -1, f_copy = -1;
struct file_struct *back_file = NULL;
int statret, real_ret, stat_errno;
char *fnamecmp, *partialptr, *backupptr = NULL;
-@@ -1104,6 +1147,9 @@ static void recv_generator(char *fname,
+@@ -1089,6 +1132,9 @@ static void recv_generator(char *fname,
return;
}
}
if (dry_run > 1) {
if (fuzzy_dirlist) {
flist_free(fuzzy_dirlist);
-@@ -1116,7 +1162,7 @@ static void recv_generator(char *fname,
+@@ -1101,7 +1147,7 @@ static void recv_generator(char *fname,
const char *dn = file->dirname ? file->dirname : ".";
if (parent_dirname != dn && strcmp(parent_dirname, dn) != 0) {
if (relative_paths && !implied_dirs
&& create_directory_path(fname) < 0) {
rsyserr(FERROR, errno,
"recv_generator: mkdir %s failed",
-@@ -1128,6 +1174,10 @@ static void recv_generator(char *fname,
+@@ -1113,6 +1159,10 @@ static void recv_generator(char *fname,
}
if (fuzzy_basis)
need_fuzzy_dirlist = 1;
}
parent_dirname = dn;
-@@ -1137,7 +1187,7 @@ static void recv_generator(char *fname,
+@@ -1122,7 +1172,7 @@ static void recv_generator(char *fname,
need_fuzzy_dirlist = 0;
}
keep_dirlinks && S_ISDIR(file->mode));
stat_errno = errno;
}
-@@ -1163,8 +1213,9 @@ static void recv_generator(char *fname,
+@@ -1148,8 +1198,9 @@ static void recv_generator(char *fname,
* mode based on the local permissions and some heuristics. */
if (!preserve_perms) {
int exists = statret == 0
}
if (S_ISDIR(file->mode)) {
-@@ -1173,8 +1224,8 @@ static void recv_generator(char *fname,
+@@ -1158,8 +1209,8 @@ static void recv_generator(char *fname,
* file of that name and it is *not* a directory, then
* we need to delete it. If it doesn't exist, then
* (perhaps recursively) create it. */
return;
statret = -1;
}
-@@ -1183,14 +1234,14 @@ static void recv_generator(char *fname,
+@@ -1168,14 +1219,14 @@ static void recv_generator(char *fname,
dry_run++;
}
real_ret = statret;
itemizing, code);
if (j == -2) {
itemizing = 0;
-@@ -1199,7 +1250,11 @@ static void recv_generator(char *fname,
+@@ -1184,7 +1235,11 @@ static void recv_generator(char *fname,
statret = 1;
}
if (itemizing && f_out != -1) {
statret ? ITEM_LOCAL_CHANGE : 0, 0, NULL);
}
if (real_ret != 0 && do_mkdir(fname,file->mode) < 0 && errno != EEXIST) {
-@@ -1213,31 +1268,31 @@ static void recv_generator(char *fname,
+@@ -1198,31 +1253,31 @@ static void recv_generator(char *fname,
"*** Skipping any contents from this failed directory ***\n");
missing_below = F_DEPTH(file);
file->flags |= FLAG_MISSING_DIR;
#endif
if (preserve_links && S_ISLNK(file->mode)) {
-@@ -1257,28 +1312,28 @@ static void recv_generator(char *fname,
+@@ -1242,28 +1297,28 @@ static void recv_generator(char *fname,
char lnk[MAXPATHLEN];
int len;
itemizing, code);
if (j == -2) {
#ifndef CAN_HARDLINK_SYMLINK
-@@ -1287,7 +1342,7 @@ static void recv_generator(char *fname,
+@@ -1272,7 +1327,7 @@ static void recv_generator(char *fname,
} else
#endif
if (!copy_dest)
itemizing = 0;
code = FNONE;
} else if (j >= 0)
-@@ -1295,7 +1350,7 @@ static void recv_generator(char *fname,
+@@ -1280,7 +1335,7 @@ static void recv_generator(char *fname,
}
#ifdef SUPPORT_HARD_LINKS
if (preserve_hard_links && F_HLINK_NOT_LAST(file))
#endif
if (do_symlink(sl, fname) != 0) {
rsyserr(FERROR, errno, "symlink %s -> \"%s\" failed",
-@@ -1303,7 +1358,7 @@ static void recv_generator(char *fname,
+@@ -1288,7 +1343,7 @@ static void recv_generator(char *fname,
} else {
set_file_attrs(fname, file, NULL, 0);
if (itemizing) {
ITEM_LOCAL_CHANGE, 0, NULL);
}
if (code != FNONE && verbose)
-@@ -1319,7 +1374,7 @@ static void recv_generator(char *fname,
+@@ -1304,7 +1359,7 @@ static void recv_generator(char *fname,
goto return_with_success;
}
#endif
}
if ((am_root && preserve_devices && IS_DEVICE(file->mode))
-@@ -1329,33 +1384,38 @@ static void recv_generator(char *fname,
+@@ -1314,33 +1369,38 @@ static void recv_generator(char *fname,
if (statret == 0) {
char *t;
if (IS_DEVICE(file->mode)) {
itemizing, code);
if (j == -2) {
#ifndef CAN_HARDLINK_SPECIAL
-@@ -1364,7 +1424,7 @@ static void recv_generator(char *fname,
+@@ -1349,7 +1409,7 @@ static void recv_generator(char *fname,
} else
#endif
if (!copy_dest)
itemizing = 0;
code = FNONE;
} else if (j >= 0)
-@@ -1372,7 +1432,7 @@ static void recv_generator(char *fname,
+@@ -1357,7 +1417,7 @@ static void recv_generator(char *fname,
}
#ifdef SUPPORT_HARD_LINKS
if (preserve_hard_links && F_HLINK_NOT_LAST(file))
#endif
if (verbose > 2) {
rprintf(FINFO, "mknod(%s, 0%o, [%ld,%ld])\n",
-@@ -1385,7 +1445,11 @@ static void recv_generator(char *fname,
+@@ -1370,7 +1430,11 @@ static void recv_generator(char *fname,
} else {
set_file_attrs(fname, file, NULL, 0);
if (itemizing) {
ITEM_LOCAL_CHANGE, 0, NULL);
}
if (code != FNONE && verbose)
-@@ -1397,14 +1461,14 @@ static void recv_generator(char *fname,
+@@ -1382,14 +1446,14 @@ static void recv_generator(char *fname,
if (remove_source_files == 1)
goto return_with_success;
}
}
if (max_size > 0 && F_LENGTH(file) > max_size) {
-@@ -1413,7 +1477,7 @@ static void recv_generator(char *fname,
+@@ -1398,7 +1462,7 @@ static void recv_generator(char *fname,
fname = f_name(file, NULL);
rprintf(FINFO, "%s is over max-size\n", fname);
}
}
if (min_size > 0 && F_LENGTH(file) < min_size) {
if (verbose > 1) {
-@@ -1421,39 +1485,39 @@ static void recv_generator(char *fname,
+@@ -1406,39 +1470,39 @@ static void recv_generator(char *fname,
fname = f_name(file, NULL);
rprintf(FINFO, "%s is under min-size\n", fname);
}
}
if (j >= 0) {
fnamecmp = fnamecmpbuf;
-@@ -1463,7 +1527,7 @@ static void recv_generator(char *fname,
+@@ -1448,7 +1512,7 @@ static void recv_generator(char *fname,
}
real_ret = statret;
if (partial_dir && (partialptr = partial_dir_fname(fname)) != NULL
&& link_stat(partialptr, &partial_st, 0) == 0
-@@ -1482,7 +1546,7 @@ static void recv_generator(char *fname,
+@@ -1467,7 +1531,7 @@ static void recv_generator(char *fname,
rprintf(FINFO, "fuzzy basis selected for %s: %s\n",
fname, fnamecmpbuf);
}
statret = 0;
fnamecmp = fnamecmpbuf;
fnamecmp_type = FNAMECMP_FUZZY;
-@@ -1492,45 +1556,50 @@ static void recv_generator(char *fname,
+@@ -1477,45 +1541,50 @@ static void recv_generator(char *fname,
if (statret != 0) {
#ifdef SUPPORT_HARD_LINKS
if (preserve_hard_links && F_HLINK_NOT_LAST(file))
+ goto cleanup;
return_with_success:
if (!dry_run)
- send_msg_int(MSG_SUCCESS, ndx + cur_flist->ndx_start);
+ send_msg_int(MSG_SUCCESS, ndx);
- return;
+ goto cleanup;
}
fnamecmp = partialptr;
fnamecmp_type = FNAMECMP_PARTIAL_DIR;
statret = 0;
-@@ -1555,16 +1624,20 @@ static void recv_generator(char *fname,
+@@ -1540,16 +1609,20 @@ static void recv_generator(char *fname,
/* pretend the file didn't exist */
#ifdef SUPPORT_HARD_LINKS
if (preserve_hard_links && F_HLINK_NOT_LAST(file))
}
if (!(back_file = make_file(fname, NULL, NULL, 0, NO_FILTERS))) {
close(fd);
-@@ -1575,7 +1648,7 @@ static void recv_generator(char *fname,
+@@ -1560,7 +1633,7 @@ static void recv_generator(char *fname,
full_fname(backupptr));
unmake_file(back_file);
close(fd);
}
if ((f_copy = do_open(backupptr,
O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600)) < 0) {
-@@ -1583,14 +1656,14 @@ static void recv_generator(char *fname,
+@@ -1568,14 +1641,14 @@ static void recv_generator(char *fname,
full_fname(backupptr));
unmake_file(back_file);
close(fd);
}
if (verbose > 2)
-@@ -1614,26 +1687,34 @@ static void recv_generator(char *fname,
+@@ -1599,26 +1672,34 @@ static void recv_generator(char *fname,
iflags |= ITEM_BASIS_TYPE_FOLLOWS;
if (fnamecmp_type == FNAMECMP_FUZZY)
iflags |= ITEM_XNAME_FOLLOWS;
if (f_copy >= 0) {
close(f_copy);
-@@ -1646,6 +1727,13 @@ static void recv_generator(char *fname,
+@@ -1631,6 +1712,13 @@ static void recv_generator(char *fname,
}
close(fd);
+ return;
}
- static void touch_up_dirs(struct file_list *flist, int ndx,
-@@ -1742,6 +1830,8 @@ void generate_files(int f_out, char *loc
+ static void touch_up_dirs(struct file_list *flist, int ndx)
+@@ -1799,6 +1887,8 @@ void generate_files(int f_out, const cha
* notice that and let us know via the redo pipe (or its closing). */
ignore_timeout = 1;