}
-#define SC_CHECKSUM_CHANGED (1<<0)
-#define SC_SYMLINK_CHANGED (1<<1)
-#define SC_SENDING_FILE (1<<2)
-#define SC_NO_BASIS (1<<3)
-#define SC_NO_NL (1<<4)
-
-static void showchg(const char *fname, struct file_struct *file, int statret,
- STRUCT_STAT *st, int flags)
+#define SID_UPDATING ITEM_UPDATING
+#define SID_REPORT_CHECKSUM ITEM_REPORT_CHECKSUM
+#define SID_NO_DEST_AND_NO_UPDATE (1<<16)
+
+static void itemize(struct file_struct *file, int statret, STRUCT_STAT *st,
+ int32 sflags, int f_out, int ndx)
{
- static char ch[] = "*XcstpogDL";
- int keep_time;
- char *s;
-
- ch[0] = flags & SC_SENDING_FILE ? '*' : ' ';
- ch[1] = S_ISDIR(file->mode) ? 'd' : IS_DEVICE(file->mode) ? 'D'
- : S_ISLNK(file->mode) ? 'L' : 'f';
-
- if (statret < 0) {
- for (s = ch + 2; *s; ) *s++ = '+';
- goto print_it;
- }
-
- keep_time = !preserve_times ? 0
- : S_ISDIR(file->mode) ? !omit_dir_times : !S_ISLNK(file->mode);
-
- ch[2] = !(flags & SC_CHECKSUM_CHANGED) ? '-' : 'c';
- ch[3] = !S_ISREG(file->mode) || file->length == st->st_size ? '-' : 's';
- ch[4] = flags & SC_SENDING_FILE && !keep_time ? 'T'
- : !keep_time || file->modtime == st->st_mtime ? '-' : 't';
- ch[5] = !preserve_perms || file->mode == st->st_mode ? '-' : 'p';
- ch[6] = !am_root || !preserve_uid || file->uid == st->st_uid ? '-' : 'o';
- ch[7] = preserve_gid && file->gid != GID_NONE && st->st_gid != file->gid ? 'g' : '-';
- ch[8] = IS_DEVICE(file->mode) && file->u.rdev != st->st_rdev ? 'D' : '-';
- ch[9] = flags & SC_SYMLINK_CHANGED ? 'L' : '-';
-
- if (flags & SC_NO_BASIS)
- ch[4] = ch[5] = ch[6] = ch[7] = '-';
-
- s = ch + 2;
- if (!(flags & SC_SENDING_FILE))
- while (*s == '-') s++;
- if (*s) {
- print_it:
- rprintf(FINFO, "%s %s%s%s", ch, safe_fname(fname),
- ch[1] == 'd' ? "/" : "",
- flags & SC_NO_NL ? "" : "\n");
+ int iflags = sflags & (SID_UPDATING | SID_REPORT_CHECKSUM);
+
+ if (statret >= 0) {
+ if (S_ISREG(file->mode) && file->length != st->st_size)
+ iflags |= ITEM_REPORT_SIZE;
+ if (!(sflags & SID_NO_DEST_AND_NO_UPDATE)) {
+ int keep_time = !preserve_times ? 0
+ : S_ISDIR(file->mode) ? !omit_dir_times
+ : !S_ISLNK(file->mode);
+
+ if ((iflags & ITEM_UPDATING && !keep_time)
+ || (keep_time && file->modtime != st->st_mtime))
+ iflags |= ITEM_REPORT_TIME;
+ if (preserve_perms && file->mode != st->st_mode)
+ iflags |= ITEM_REPORT_PERMS;
+ if (preserve_uid && am_root && file->uid != st->st_uid)
+ iflags |= ITEM_REPORT_OWNER;
+ if (preserve_gid && file->gid != GID_NONE
+ && st->st_gid != file->gid)
+ iflags |= ITEM_REPORT_GROUP;
+ }
+ } else
+ iflags |= ITEM_IS_NEW | ITEM_UPDATING;
+
+ if (iflags && !read_batch) {
+ if (ndx >= 0)
+ write_int(f_out, ndx);
+ write_short(f_out, iflags);
}
}
char *fnamecmp, *partialptr, *backupptr = NULL;
char fnamecmpbuf[MAXPATHLEN];
uchar fnamecmp_type;
+ int maybe_DEL_TERSE = itemize_changes ? 0 : DEL_TERSE;
if (list_only)
return;
* we need to delete it. If it doesn't exist, then
* (perhaps recursively) create it. */
if (statret == 0 && !S_ISDIR(st.st_mode)) {
- delete_file(fname, DEL_TERSE);
+ delete_file(fname, maybe_DEL_TERSE);
statret = -1;
}
if (dry_run && statret != 0 && missing_below < 0) {
missing_below = file->dir.depth;
dry_run++;
}
- if (itemize_changes && f_out != -1)
- showchg(fname, file, statret, &st, 0);
+ if (protocol_version >= 29 && f_out != -1)
+ itemize(file, statret, &st, 0, f_out, ndx);
if (statret != 0 && do_mkdir(fname,file->mode) != 0 && errno != EEXIST) {
if (!relative_paths || errno != ENOENT
|| create_directory_path(fname, orig_umask) < 0
}
}
if (set_perms(fname, file, statret ? NULL : &st, 0)
- && verbose && f_out != -1 && !itemize_changes)
+ && verbose && protocol_version < 29 && f_out != -1)
rprintf(FINFO, "%s/\n", safe_fname(fname));
if (delete_during && f_out != -1 && csum_length != SUM_LENGTH
&& (file->flags & FLAG_DEL_HERE))
* right place -- no further action
* required. */
if (strcmp(lnk, file->u.link) == 0) {
- if (itemize_changes)
- showchg(fname, file, 0, &st, 0);
+ if (protocol_version >= 29) {
+ itemize(file, 0, &st, 0,
+ f_out, ndx);
+ }
set_perms(fname, file, &st,
PERMS_REPORT);
return;
}
/* Not the right symlink (or not a symlink), so
* delete it. */
- delete_file(fname, dflag | DEL_TERSE);
+ if (S_ISLNK(st.st_mode))
+ delete_file(fname, dflag | DEL_TERSE);
+ else {
+ delete_file(fname, dflag | maybe_DEL_TERSE);
+ statret = -1;
+ }
}
if (do_symlink(file->u.link,fname) != 0) {
rsyserr(FERROR, errno, "symlink %s -> \"%s\" failed",
full_fname(fname), safe_fname(file->u.link));
} else {
set_perms(fname,file,NULL,0);
- if (itemize_changes) {
- showchg(fname, file, statret, &st,
- SC_SYMLINK_CHANGED
- | (verbose ? SC_NO_NL : 0));
- }
- if (verbose) {
- rprintf(FINFO, "%s -> %s\n",
- itemize_changes ? "" : safe_fname(fname),
- safe_fname(file->u.link));
+ if (protocol_version >= 29) {
+ itemize(file, statret, &st, SID_UPDATING,
+ f_out, ndx);
+ } else if (verbose) {
+ rprintf(FINFO, "%s -> %s\n", safe_fname(fname),
+ safe_fname(file->u.link));
}
}
#endif
}
if (am_root && preserve_devices && IS_DEVICE(file->mode)) {
- if (itemize_changes)
- showchg(fname, file, statret, &st, 0);
if (statret != 0 ||
st.st_mode != file->mode ||
st.st_rdev != file->u.rdev) {
int dflag = S_ISDIR(st.st_mode) ? DEL_DIR : 0;
- delete_file(fname, dflag | DEL_TERSE);
+ if (IS_DEVICE(st.st_mode))
+ delete_file(fname, dflag | DEL_TERSE);
+ else {
+ delete_file(fname, dflag | maybe_DEL_TERSE);
+ statret = -1;
+ }
if (verbose > 2) {
rprintf(FINFO,"mknod(%s,0%o,0x%x)\n",
safe_fname(fname),
full_fname(fname));
} else {
set_perms(fname,file,NULL,0);
- if (verbose && !itemize_changes) {
+ if (protocol_version >= 29) {
+ itemize(file, statret, &st, SID_UPDATING,
+ f_out, ndx);
+ } else if (verbose) {
rprintf(FINFO, "%s\n",
safe_fname(fname));
}
}
} else {
+ if (protocol_version >= 29) {
+ itemize(file, statret, &st, 0,
+ f_out, ndx);
+ }
set_perms(fname, file, &st, PERMS_REPORT);
}
return;
if (statret == 0 && !S_ISREG(st.st_mode)) {
int dflag = S_ISDIR(st.st_mode) ? DEL_DIR : 0;
- if (delete_file(fname, dflag | DEL_TERSE) != 0)
+ if (delete_file(fname, dflag | maybe_DEL_TERSE) != 0)
return;
statret = -1;
stat_errno = ENOENT;
else if (fnamecmp_type == FNAMECMP_FUZZY)
;
else if (unchanged_file(fnamecmp, file, &st)) {
- if (itemize_changes) {
- showchg(fname, file, statret, &st,
- fnamecmp_type == FNAMECMP_FNAME ? 0
- : SC_NO_BASIS);
+ if (protocol_version >= 29) {
+ itemize(file, statret, &st,
+ fnamecmp_type == FNAMECMP_FNAME
+ ? 0 : SID_NO_DEST_AND_NO_UPDATE,
+ f_out, ndx);
}
if (fnamecmp_type == FNAMECMP_FNAME)
set_perms(fname, file, &st, PERMS_REPORT);
notify_others:
write_int(f_out, ndx);
- if (protocol_version >= 29 && inplace && !read_batch)
- write_byte(f_out, fnamecmp_type);
+ if (protocol_version >= 29) {
+ itemize(file, statret, &st, SID_UPDATING
+ | (always_checksum ? SID_REPORT_CHECKSUM : 0),
+ f_out, -1);
+ if (inplace && !read_batch)
+ write_byte(f_out, fnamecmp_type);
+ }
if (f_out_name >= 0) {
write_byte(f_out_name, fnamecmp_type);
if (fnamecmp_type == FNAMECMP_FUZZY) {
write_buf(f_out_name, fuzzy_file->basename, len);
}
}
- if (itemize_changes) {
- showchg(fname, file, statret, &st,
- (always_checksum ? SC_CHECKSUM_CHANGED : 0)
- | SC_SENDING_FILE);
- }
if (dry_run || read_batch)
return;