*
* Copyright (C) 1998-2001 Andrew Tridgell <tridge@samba.org>
* Copyright (C) 2000-2001 Martin Pool <mbp@samba.org>
- * Copyright (C) 2003-2007 Wayne Davison
+ * Copyright (C) 2003-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*/
#include "rsync.h"
+#include "ifuncs.h"
extern int verbose;
extern int dry_run;
extern int preserve_times;
extern int uid_ndx;
extern int gid_ndx;
+extern int progress_is_active;
extern int stdout_format_has_i;
extern int stdout_format_has_o_or_i;
extern int logfile_format_has_i;
extern int logfile_format_has_o_or_i;
+extern int receiver_symlink_times;
extern mode_t orig_umask;
extern char *auth_user;
extern char *stdout_format;
extern iconv_t ic_send, ic_recv;
#endif
extern char curr_dir[];
-extern char *module_dir;
+extern char *full_module_path;
extern unsigned int module_dirlen;
static int log_initialised;
static FILE *logfile_fp;
struct stats stats;
-int log_got_error = 0;
+int got_xfer_error = 0;
struct {
int code;
{ RERR_SIGNAL , "received SIGINT, SIGTERM, or SIGHUP" },
{ RERR_WAITCHILD , "waitpid() failed" },
{ RERR_MALLOC , "error allocating core memory buffers" },
- { RERR_PARTIAL , "some files could not be transferred" },
+ { RERR_PARTIAL , "some files/attrs were not transferred (see previous errors)" },
{ RERR_VANISHED , "some files vanished before they could be transferred" },
{ RERR_TIMEOUT , "timeout in data send/receive" },
+ { RERR_CONTIMEOUT , "timeout waiting for daemon connection" },
{ RERR_CMD_FAILED , "remote shell failed" },
{ RERR_CMD_KILLED , "remote shell killed" },
{ RERR_CMD_RUN , "remote command could not be run" },
}
/* this is the underlying (unformatted) rsync debugging function. Call
- * it with FINFO, FERROR or FLOG. Note: recursion can happen with
- * certain fatal conditions. */
+ * it with FINFO, FERROR_*, FWARNING, FLOG, or FCLIENT. Note: recursion
+ * can happen with certain fatal conditions. */
void rwrite(enum logcode code, const char *buf, int len, int is_utf8)
{
int trailing_CR_or_NL;
if (am_server && msg_fd_out >= 0) {
assert(!is_utf8);
- /* Pass the message to our sibling. */
+ /* Pass the message to our sibling in native charset. */
send_msg((enum msgcode)code, buf, len, 0);
return;
}
- if (code == FSOCKERR) /* This gets simplified for a non-sibling. */
+ if (code == FERROR_SOCKET) /* This gets simplified for a non-sibling. */
code = FERROR;
+ else if (code == FERROR_UTF8) {
+ is_utf8 = 1;
+ code = FERROR;
+ }
if (code == FCLIENT)
code = FINFO;
else if (am_daemon || logfile_name) {
static int in_block;
char msg[2048];
- int priority = code == FERROR ? LOG_WARNING : LOG_INFO;
+ int priority = code == FINFO || code == FLOG ? LOG_INFO : LOG_WARNING;
if (in_block)
return;
} else if (code == FLOG)
return;
- if (quiet && code != FERROR)
+ if (quiet && code == FINFO)
return;
if (am_server) {
+ enum msgcode msg = (enum msgcode)code;
+ if (protocol_version < 30) {
+ if (msg == MSG_ERROR)
+ msg = MSG_ERROR_XFER;
+ else if (msg == MSG_WARNING)
+ msg = MSG_INFO;
+ }
/* Pass the message to the non-server side. */
- if (send_msg((enum msgcode)code, buf, len, !is_utf8))
+ if (send_msg(msg, buf, len, !is_utf8))
return;
if (am_daemon) {
/* TODO: can we send the error to the user somehow? */
}
switch (code) {
+ case FERROR_XFER:
+ got_xfer_error = 1;
+ /* FALL THROUGH */
case FERROR:
- log_got_error = 1;
+ case FWARNING:
f = stderr;
break;
case FINFO:
exit_cleanup(RERR_MESSAGEIO);
}
+ if (progress_is_active && !am_server) {
+ fputc('\n', f);
+ progress_is_active = 0;
+ }
+
trailing_CR_or_NL = len && (buf[len-1] == '\n' || buf[len-1] == '\r')
? buf[--len] : 0;
}
}
-/* This is the rsync debugging function. Call it with FINFO, FERROR or
- * FLOG. */
+/* This is the rsync debugging function. Call it with FINFO, FERROR_*,
+ * FWARNING, FLOG, or FCLIENT. */
void rprintf(enum logcode code, const char *format, ...)
{
va_list ap;
if (am_daemon || code == FLOG)
return;
- if (code == FERROR || am_server)
- f = stderr;
- else
+ if (code == FINFO && !am_server)
f = stdout;
+ else
+ f = stderr;
fflush(f);
}
break;
case 'M':
n = c = timestring(file->modtime);
- while ((c = strchr(p, ' ')) != NULL)
+ while ((c = strchr(c, ' ')) != NULL)
*c = '-';
break;
case 'B':
n = timestring(time(NULL));
break;
case 'P':
- n = module_dir;
+ n = full_module_path;
break;
case 'u':
n = auth_user;
break;
case 'i':
if (iflags & ITEM_DELETED) {
- n = "*deleting";
+ n = "*deleting ";
break;
}
n = c = buf2 + MAXPATHLEN - 32;
? iflags & ITEM_XNAME_FOLLOWS ? 'h' : 'c'
: !(iflags & ITEM_TRANSFER) ? '.'
: !local_server && *op == 's' ? '<' : '>';
- c[1] = S_ISDIR(file->mode) ? 'd'
- : IS_SPECIAL(file->mode) ? 'S'
- : IS_DEVICE(file->mode) ? 'D'
- : S_ISLNK(file->mode) ? 'L' : 'f';
- c[2] = !(iflags & ITEM_REPORT_CHECKSUM) ? '.' : 'c';
- c[3] = !(iflags & ITEM_REPORT_SIZE) ? '.' : 's';
- c[4] = !(iflags & ITEM_REPORT_TIME) ? '.'
- : !preserve_times || S_ISLNK(file->mode) ? 'T' : 't';
+ if (S_ISLNK(file->mode)) {
+ c[1] = 'L';
+ c[3] = '.';
+ c[4] = !(iflags & ITEM_REPORT_TIME) ? '.'
+ : !preserve_times || !receiver_symlink_times
+ || (iflags & ITEM_REPORT_TIMEFAIL) ? 'T' : 't';
+ } else {
+ c[1] = S_ISDIR(file->mode) ? 'd'
+ : IS_SPECIAL(file->mode) ? 'S'
+ : IS_DEVICE(file->mode) ? 'D' : 'f';
+ c[3] = !(iflags & ITEM_REPORT_SIZE) ? '.' : 's';
+ c[4] = !(iflags & ITEM_REPORT_TIME) ? '.'
+ : !preserve_times ? 'T' : 't';
+ }
+ c[2] = !(iflags & ITEM_REPORT_CHANGE) ? '.' : 'c';
c[5] = !(iflags & ITEM_REPORT_PERMS) ? '.' : 'p';
c[6] = !(iflags & ITEM_REPORT_OWNER) ? '.' : 'o';
c[7] = !(iflags & ITEM_REPORT_GROUP) ? '.' : 'g';
/* VANISHED is not an error, only a warning */
if (code == RERR_VANISHED) {
- rprintf(FINFO, "rsync warning: %s (code %d) at %s(%d) [%s=%s]\n",
+ rprintf(FWARNING, "rsync warning: %s (code %d) at %s(%d) [%s=%s]\n",
name, code, file, line, who_am_i(), RSYNC_VERSION);
} else {
rprintf(FERROR, "rsync error: %s (code %d) at %s(%d) [%s=%s]\n",