extern struct stats stats;
extern dev_t filesystem_dev;
extern char *backup_dir;
-@@ -320,22 +322,27 @@ static void do_delete_pass(struct file_l
+@@ -348,22 +350,27 @@ static void do_delete_pass(struct file_l
rprintf(FINFO, " \r");
}
int32 iflags, uchar fnamecmp_type, char *xname)
{
if (statret >= 0) { /* A from-dest-dir statret can == 1! */
-@@ -343,20 +350,24 @@ void itemize(struct file_struct *file, i
+@@ -371,20 +378,24 @@ void itemize(struct file_struct *file, i
: S_ISDIR(file->mode) ? !omit_dir_times
: !S_ISLNK(file->mode);
} else
iflags |= ITEM_IS_NEW;
-@@ -609,7 +620,7 @@ void check_for_finished_hlinks(int itemi
+@@ -637,7 +648,7 @@ void check_for_finished_hlinks(int itemi
* 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,
int maybe_ATTRS_REPORT, enum logcode code)
{
int best_match = -1;
-@@ -618,7 +629,7 @@ static int try_dests_reg(struct file_str
+@@ -646,7 +657,7 @@ static int try_dests_reg(struct file_str
do {
pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname);
continue;
switch (match_level) {
case 0:
-@@ -626,16 +637,20 @@ static int try_dests_reg(struct file_str
+@@ -654,16 +665,20 @@ static int try_dests_reg(struct file_str
match_level = 1;
/* FALL THROUGH */
case 1:
continue;
best_match = j;
match_level = 3;
-@@ -650,7 +665,7 @@ static int try_dests_reg(struct file_str
+@@ -678,7 +693,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;
}
-@@ -658,7 +673,7 @@ static int try_dests_reg(struct file_str
+@@ -686,7 +701,7 @@ static int try_dests_reg(struct file_str
#ifdef SUPPORT_HARD_LINKS
if (link_dest) {
int i = itemizing && (verbose > 1 || stdout_format_has_i > 1);
cmpbuf, 1, i, code) < 0)
goto try_a_copy;
if (preserve_hard_links && file->link_u.links) {
-@@ -668,8 +683,13 @@ static int try_dests_reg(struct file_str
+@@ -696,8 +711,13 @@ static int try_dests_reg(struct file_str
}
} else
#endif
if (verbose > 1 && maybe_ATTRS_REPORT) {
rprintf(FCLIENT, "%s is uptodate\n", fname);
}
-@@ -685,8 +705,13 @@ static int try_dests_reg(struct file_str
+@@ -713,8 +733,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)
-@@ -707,7 +732,7 @@ static int try_dests_reg(struct file_str
+@@ -735,7 +760,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,
int maybe_ATTRS_REPORT, enum logcode code)
{
char lnk[MAXPATHLEN];
-@@ -739,24 +764,24 @@ static int try_dests_non(struct file_str
+@@ -767,24 +792,24 @@ static int try_dests_non(struct file_str
do {
pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname);
continue;
break;
#endif
-@@ -770,7 +795,7 @@ static int try_dests_non(struct file_str
+@@ -798,7 +823,7 @@ static int try_dests_non(struct file_str
break;
case TYPE_SPECIAL:
case TYPE_DEVICE:
continue;
break;
#ifdef SUPPORT_LINKS
-@@ -787,7 +812,11 @@ static int try_dests_non(struct file_str
+@@ -815,7 +840,11 @@ static int try_dests_non(struct file_str
match_level = 2;
best_match = j;
}
match_level = 3;
best_match = j;
break;
-@@ -800,7 +829,7 @@ static int try_dests_non(struct file_str
+@@ -828,7 +857,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;
}
-@@ -831,7 +860,15 @@ static int try_dests_non(struct file_str
+@@ -859,7 +888,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",
-@@ -844,6 +881,7 @@ static int try_dests_non(struct file_str
+@@ -872,6 +909,7 @@ static int try_dests_non(struct file_str
}
static int phase = 0;
/* Acts on the_file_list->file's ndx'th item, whose name is fname. If a dir,
* make sure it exists, and has the right permissions/timestamp info. For
-@@ -865,7 +903,8 @@ static void recv_generator(char *fname,
+@@ -893,7 +931,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;
-@@ -921,6 +960,9 @@ static void recv_generator(char *fname,
+@@ -949,6 +988,9 @@ static void recv_generator(char *fname,
} else if (!dry_run)
return;
}
if (dry_run > 1) {
statret = -1;
stat_errno = ENOENT;
-@@ -928,7 +970,7 @@ static void recv_generator(char *fname,
+@@ -956,7 +998,7 @@ static void recv_generator(char *fname,
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",
-@@ -940,6 +982,10 @@ static void recv_generator(char *fname,
+@@ -968,6 +1010,10 @@ static void recv_generator(char *fname,
}
if (fuzzy_basis)
need_fuzzy_dirlist = 1;
}
parent_dirname = dn;
-@@ -948,7 +994,7 @@ static void recv_generator(char *fname,
+@@ -976,7 +1022,7 @@ static void recv_generator(char *fname,
need_fuzzy_dirlist = 0;
}
keep_dirlinks && S_ISDIR(file->mode));
stat_errno = errno;
}
-@@ -966,8 +1012,9 @@ static void recv_generator(char *fname,
+@@ -994,8 +1040,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)) {
-@@ -976,8 +1023,8 @@ static void recv_generator(char *fname,
+@@ -1004,8 +1051,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. */
- if (statret == 0 && !S_ISDIR(st.st_mode)) {
-- if (delete_item(fname, st.st_mode, del_opts) < 0)
+- if (delete_item(fname, st.st_mode, "directory", del_opts) != 0)
+ if (statret == 0 && !S_ISDIR(sx.st.st_mode)) {
-+ if (delete_item(fname, sx.st.st_mode, del_opts) < 0)
++ if (delete_item(fname, sx.st.st_mode, "directory", del_opts) != 0)
return;
statret = -1;
}
-@@ -986,14 +1033,14 @@ static void recv_generator(char *fname,
+@@ -1014,14 +1061,14 @@ static void recv_generator(char *fname,
dry_run++;
}
real_ret = statret;
itemizing, maybe_ATTRS_REPORT, code);
if (j == -2) {
itemizing = 0;
-@@ -1002,7 +1049,11 @@ static void recv_generator(char *fname,
+@@ -1030,7 +1077,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) {
-@@ -1022,21 +1073,21 @@ static void recv_generator(char *fname,
+@@ -1050,21 +1101,21 @@ static void recv_generator(char *fname,
return;
}
}
if (preserve_links && S_ISLNK(file->mode)) {
#ifdef SUPPORT_LINKS
-@@ -1054,15 +1105,15 @@ static void recv_generator(char *fname,
+@@ -1082,15 +1133,15 @@ static void recv_generator(char *fname,
char lnk[MAXPATHLEN];
int len;
if (preserve_hard_links && file->link_u.links)
hard_link_cluster(file, ndx, itemizing, code);
if (remove_source_files == 1)
-@@ -1071,10 +1122,10 @@ static void recv_generator(char *fname,
+@@ -1099,10 +1150,10 @@ static void recv_generator(char *fname,
}
/* Not the right symlink (or not a symlink), so
* delete it. */
-- if (delete_item(fname, st.st_mode, del_opts) < 0)
-+ if (delete_item(fname, sx.st.st_mode, del_opts) < 0)
+- if (delete_item(fname, st.st_mode, "symlink", del_opts) != 0)
++ if (delete_item(fname, sx.st.st_mode, "symlink", del_opts) != 0)
return;
} else if (basis_dir[0] != NULL) {
- int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &st,
itemizing, maybe_ATTRS_REPORT, code);
if (j == -2) {
#ifndef CAN_HARDLINK_SYMLINK
-@@ -1090,7 +1141,7 @@ static void recv_generator(char *fname,
+@@ -1118,7 +1169,7 @@ static void recv_generator(char *fname,
statret = 1;
}
if (preserve_hard_links && file->link_u.links
itemizing, code, HL_SKIP))
return;
if (do_symlink(file->u.link, fname) != 0) {
-@@ -1099,7 +1150,7 @@ static void recv_generator(char *fname,
+@@ -1127,7 +1178,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)
-@@ -1119,25 +1170,30 @@ static void recv_generator(char *fname,
- if ((am_root && preserve_devices && IS_DEVICE(file->mode))
- || (preserve_specials && IS_SPECIAL(file->mode))) {
+@@ -1149,31 +1200,36 @@ static void recv_generator(char *fname,
if (statret == 0) {
-- if ((IS_DEVICE(file->mode) && !IS_DEVICE(st.st_mode))
-- || (IS_SPECIAL(file->mode) && !IS_SPECIAL(st.st_mode)))
-+ if ((IS_DEVICE(file->mode) && !IS_DEVICE(sx.st.st_mode))
-+ || (IS_SPECIAL(file->mode) && !IS_SPECIAL(sx.st.st_mode)))
- statret = -1;
-- else if ((st.st_mode & ~CHMOD_BITS) == (file->mode & ~CHMOD_BITS)
-- && st.st_rdev == file->u.rdev) {
-+ else if ((sx.st.st_mode & ~CHMOD_BITS) == (file->mode & ~CHMOD_BITS)
-+ && sx.st.st_rdev == file->u.rdev) {
+ char *t;
+ if (IS_DEVICE(file->mode)) {
+- if (!IS_DEVICE(st.st_mode))
++ if (!IS_DEVICE(sx.st.st_mode))
+ statret = -1;
+ t = "device file";
+ } else {
+- if (!IS_SPECIAL(st.st_mode))
++ if (!IS_SPECIAL(sx.st.st_mode))
+ statret = -1;
+ t = "special file";
+ }
+ if (statret == 0
+- && (st.st_mode & ~CHMOD_BITS) == (file->mode & ~CHMOD_BITS)
+- && st.st_rdev == file->u.rdev) {
++ && (sx.st.st_mode & ~CHMOD_BITS) == (file->mode & ~CHMOD_BITS)
++ && sx.st.st_rdev == file->u.rdev) {
/* The device or special file is identical. */
- if (itemizing)
- itemize(file, ndx, 0, &st, 0, 0, NULL);
- return;
+ goto cleanup;
}
-- if (delete_item(fname, st.st_mode, del_opts) < 0)
-+ if (delete_item(fname, sx.st.st_mode, del_opts) < 0)
+- if (delete_item(fname, st.st_mode, t, del_opts) != 0)
++ if (delete_item(fname, sx.st.st_mode, t, del_opts) != 0)
return;
} else if (basis_dir[0] != NULL) {
- int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &st,
itemizing, maybe_ATTRS_REPORT, code);
if (j == -2) {
#ifndef CAN_HARDLINK_SPECIAL
-@@ -1153,7 +1209,7 @@ static void recv_generator(char *fname,
+@@ -1189,7 +1245,7 @@ static void recv_generator(char *fname,
statret = 1;
}
if (preserve_hard_links && file->link_u.links
itemizing, code, HL_SKIP))
return;
if (verbose > 2) {
-@@ -1166,7 +1222,11 @@ static void recv_generator(char *fname,
+@@ -1202,7 +1258,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)
-@@ -1176,7 +1236,7 @@ static void recv_generator(char *fname,
+@@ -1212,7 +1272,7 @@ static void recv_generator(char *fname,
if (remove_source_files == 1)
goto return_with_success;
}
}
if (!S_ISREG(file->mode)) {
-@@ -1210,7 +1270,7 @@ static void recv_generator(char *fname,
+@@ -1246,7 +1306,7 @@ static void recv_generator(char *fname,
}
if (update_only && statret == 0
if (verbose > 1)
rprintf(FINFO, "%s is newer\n", fname);
return;
-@@ -1219,20 +1279,20 @@ static void recv_generator(char *fname,
+@@ -1255,20 +1315,20 @@ static void recv_generator(char *fname,
fnamecmp = fname;
fnamecmp_type = FNAMECMP_FNAME;
- if (statret == 0 && !S_ISREG(st.st_mode)) {
-- if (delete_item(fname, st.st_mode, del_opts) != 0)
+- if (delete_item(fname, st.st_mode, "regular file", del_opts) != 0)
+ if (statret == 0 && !S_ISREG(sx.st.st_mode)) {
-+ if (delete_item(fname, sx.st.st_mode, del_opts) != 0)
++ if (delete_item(fname, sx.st.st_mode, "regular file", del_opts) != 0)
return;
statret = -1;
stat_errno = ENOENT;
}
if (j >= 0) {
fnamecmp = fnamecmpbuf;
-@@ -1242,7 +1302,7 @@ static void recv_generator(char *fname,
+@@ -1278,7 +1338,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
-@@ -1261,7 +1321,7 @@ static void recv_generator(char *fname,
+@@ -1297,7 +1357,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;
-@@ -1270,7 +1330,7 @@ static void recv_generator(char *fname,
+@@ -1306,7 +1366,7 @@ static void recv_generator(char *fname,
if (statret != 0) {
if (preserve_hard_links && file->link_u.links
itemizing, code, HL_SKIP))
return;
if (stat_errno == ENOENT)
-@@ -1280,39 +1340,52 @@ static void recv_generator(char *fname,
+@@ -1316,39 +1376,52 @@ static void recv_generator(char *fname,
return;
}
fnamecmp = partialptr;
fnamecmp_type = FNAMECMP_PARTIAL_DIR;
statret = 0;
-@@ -1336,17 +1409,21 @@ static void recv_generator(char *fname,
+@@ -1372,17 +1445,21 @@ static void recv_generator(char *fname,
pretend_missing:
/* pretend the file didn't exist */
if (preserve_hard_links && file->link_u.links
}
if (!(back_file = make_file(fname, NULL, NULL, 0, NO_FILTERS))) {
close(fd);
-@@ -1357,7 +1434,7 @@ static void recv_generator(char *fname,
+@@ -1393,7 +1470,7 @@ static void recv_generator(char *fname,
full_fname(backupptr));
free(back_file);
close(fd);
}
if ((f_copy = do_open(backupptr,
O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600)) < 0) {
-@@ -1365,14 +1442,14 @@ static void recv_generator(char *fname,
+@@ -1401,14 +1478,14 @@ static void recv_generator(char *fname,
full_fname(backupptr));
free(back_file);
close(fd);
}
if (verbose > 2)
-@@ -1390,24 +1467,32 @@ static void recv_generator(char *fname,
+@@ -1426,24 +1503,32 @@ 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);
-@@ -1420,6 +1505,13 @@ static void recv_generator(char *fname,
+@@ -1456,6 +1541,13 @@ static void recv_generator(char *fname,
}
close(fd);
}
void generate_files(int f_out, struct file_list *flist, char *local_name)
-@@ -1479,6 +1571,8 @@ void generate_files(int f_out, struct fi
+@@ -1515,6 +1607,8 @@ void generate_files(int f_out, struct fi
* notice that and let us know via the redo pipe (or its closing). */
ignore_timeout = 1;
dit(bf(--chmod)) This option tells rsync to apply one or more
comma-separated "chmod" strings to the permission of the files in the
transfer. The resulting value is treated as though it was the permissions
-@@ -1389,8 +1403,8 @@ if the receiving rsync is at least versi
+@@ -1394,8 +1408,8 @@ if the receiving rsync is at least versi
with older versions of rsync, but that also turns on the output of other
verbose messages).
type of update being done, bf(X) is replaced by the file-type, and the
other letters represent attributes that may be output if they are being
modified.
-@@ -1439,7 +1453,11 @@ quote(itemization(
+@@ -1444,7 +1458,11 @@ quote(itemization(
sender's value (requires bf(--owner) and super-user privileges).
it() A bf(g) means the group is different and is being updated to the
sender's value (requires bf(--group) and the authority to set the group).