RE: rsync exit codes
John == John L Allen Allen writes: John But I do agree it would be nice if the man page documented John them. Or, better still, if rsync itself simply told you what they meant ;-) --- log.c.orig Sat Jan 29 06:35:03 2000 +++ log.c Wed Oct 18 14:01:26 2000 @@ -25,6 +25,29 @@ static FILE *logfile; static int log_error_fd = -1; +static const struct errdesc { int c; const char *s; const char *d; } errcodes[] = { + { RERR_SYNTAX, RERR_SYNTAX, syntax or usage error }, + { RERR_PROTOCOL,RERR_PROTOCOL,protocol incompatibility }, + { RERR_FILESELECT, RERR_FILESELECT, errors selecting input/output files, dirs +}, + { RERR_UNSUPPORTED, RERR_UNSUPPORTED, requested action not supported }, + { RERR_SOCKETIO,RERR_SOCKETIO,error in socket IO }, + { RERR_FILEIO, RERR_FILEIO, error in file IO }, + { RERR_STREAMIO,RERR_STREAMIO,error in rsync protocol data stream }, + { RERR_MESSAGEIO, RERR_MESSAGEIO, errors with program diagnostics }, + { RERR_IPC, RERR_IPC, error in IPC code }, + { RERR_SIGNAL, RERR_SIGNAL, status returned when sent SIGUSR1, SIGINT +}, + { RERR_WAITCHILD, RERR_WAITCHILD, some error returned by waitpid() }, + { RERR_MALLOC, RERR_MALLOC, error allocating core memory buffers }, + { RERR_TIMEOUT, RERR_TIMEOUT, timeout in data send/receive }, +}; + +static const struct errdesc *geterrdesc(int code) +{ +int i; +for ( i = 0; i sizeof(errcodes)/sizeof(*errcodes); ++i ) +if ( code == errcodes[i].c ) break; +return ( i sizeof(errcodes)/sizeof(*errcodes) ? errcodes[i] : NULL ); +} static void logit(int priority, char *buf) { @@ -324,12 +347,16 @@ /* called when the transfer is interrupted for some reason */ void log_exit(int code, const char *file, int line) { +const struct errdesc *pd = NULL; if (code == 0) { extern struct stats stats; rprintf(FLOG,wrote %.0f bytes read %.0f bytes total size %.0f\n, (double)stats.total_written, (double)stats.total_read, (double)stats.total_size); +} else if ( (pd = geterrdesc(code)) != NULL ) { +rprintf(FLOG,transfer interrupted - %s (code %d, %s) at %s(%d)\n, +pd-d, code, pd-s, file, line); } else { rprintf(FLOG,transfer interrupted (code %d) at %s(%d)\n, code, file, line); @@ -349,4 +376,3 @@ rprintf(FINFO,%s\n, fname); } - In concert with that, I'd also tried to ensure that all error messages always get logged somewhere (i.e. never just get lost, as could currently happen for certain server errors if the sibling is unreachable). I refactored the logging code to try to make it more clear where the messages were to be routed. In the process, it is possible that I may have unknowingly/inadvertently violated some design intentions (e.g. I seem to remember Dave Dykstra mentioning that certain server errors were not logged to the client for security reasons - I may have busted that, sorry). Anyway, here is the patch (which is totally separate from the first one: you can safely opt-in to the first and opt-out from this one). --- log.c.orig Tue Oct 24 12:11:06 2000 +++ log.c Tue Oct 24 12:45:12 2000 @@ -51,6 +51,7 @@ static void logit(int priority, char *buf) { +log_open(); if (logfile) { fprintf(logfile,%s [%d] %s, timestring(time(NULL)), (int)getpid(), buf); @@ -113,10 +114,13 @@ void rwrite(enum logcode code, char *buf, int len) { FILE *f=NULL; +int need_remote = 0; +int need_local = 1; extern int am_daemon; extern int am_server; extern int quiet; /* recursion can happen with certain fatal conditions */ +static int depth = 0; if (quiet code == FINFO) return; @@ -124,53 +128,78 @@ buf[len] = 0; -if (code == FLOG) { -if (am_daemon) logit(LOG_INFO, buf); -return; -} +++depth; -/* first try to pass it off the our sibling */ -if (am_server io_error_write(log_error_fd, code, buf, len)) { -return; -} +switch ( code ) { + +case FINFO: +f = ( am_server ? stderr : stdout ); +need_remote = ( am_server ? 1 : 0 ); +need_local = 1; +break; + +case FLOG: +f = NULL; +need_remote = 0; +need_local = ( am_daemon ? 1 : 0 ); +break; + +case FERROR: +f = stderr; +need_remote = ( am_server ? 1 : 0 ); +need_local = 1; +break; + +default: +f = stderr; +
Re: rsync exit codes
On Wed, May 30, 2001 at 10:30:07AM -0400, Neil Schellenberger wrote: Content-Description: message body text John == John L Allen Allen writes: John But I do agree it would be nice if the man page documented John them. Or, better still, if rsync itself simply told you what they meant ;-) The source currently in rsync's CVS already does this. Martin put that in. ... In concert with that, I'd also tried to ensure that all error messages always get logged somewhere (i.e. never just get lost, as could currently happen for certain server errors if the sibling is unreachable). I refactored the logging code to try to make it more clear where the messages were to be routed. In the process, it is possible that I may have unknowingly/inadvertently violated some design intentions (e.g. I seem to remember Dave Dykstra mentioning that certain server errors were not logged to the client for security reasons - I may have busted that, sorry). Anyway, here is the patch (which is totally separate from the first one: you can safely opt-in to the first and opt-out from this one). Martin Tridge will need to decide about that patch. I think Tridge will probably not want all the messages sent to the client of a daemon. - Dave Dykstra
RE: rsync exit codes
You could try errcode.h: /* error codes returned by rsync */ #define RERR_SYNTAX 1 /* syntax or usage error */ #define RERR_PROTOCOL 2 /* protocol incompatibility */ #define RERR_FILESELECT 3 /* errors selecting input/output files, dirs */ #define RERR_UNSUPPORTED 4 /* requested action not supported */ #define RERR_SOCKETIO 10 /* error in socket IO */ #define RERR_FILEIO 11 /* error in file IO */ #define RERR_STREAMIO 12 /* error in rsync protocol data stream */ #define RERR_MESSAGEIO 13 /* errors with program diagnostics */ #define RERR_IPC14 /* error in IPC code */ #define RERR_SIGNAL 20 /* status returned when sent SIGUSR1, SIGINT */ #define RERR_WAITCHILD 21 /* some error returned by waitpid() */ #define RERR_MALLOC 22 /* error allocating core memory buffers */ #define RERR_TIMEOUT30 /* timeout in data send/receive */ But I do agree it would be nice if the man page documented them. John. -Original Message- From: Ken Versteeg [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 29, 2001 02:18 PM To: [EMAIL PROTECTED] Subject: rsync exit codes Hi, Where can I find an explanation of rsync's exit codes? I've checked the man pages and the web site but don't see anything. Specifically, I'm looking for an explanation of exit status 20? Thanks, Ken (pls reply to me directly, I'm not currently subscribe to the mailing list. Thanks) -- Ken Versteeg Berbee 5520 Research Park Dr. Madison, WI 53711 [EMAIL PROTECTED] (608)298.1246 pager:376.6573 cell:212.2556 Berbee...putting the E in business.
RE: rsync exit codes
Ken, have a look at errorcode.h in the distribution source of 2.4.6 20 is commented as status returned when sent SIGUSR1 or SIGINT -- the later being the most useful clue to your problem (you would probably know if you sent SIGUSR1 to your running rsync. Greg -Original Message- From: Ken Versteeg [mailto:[EMAIL PROTECTED]] Sent: Wednesday, 30 May 2001 4:18 AM To: [EMAIL PROTECTED] Subject: rsync exit codes Hi, Where can I find an explanation of rsync's exit codes? I've checked the man pages and the web site but don't see anything. Specifically, I'm looking for an explanation of exit status 20? Thanks, Ken (pls reply to me directly, I'm not currently subscribe to the mailing list. Thanks) -- Ken Versteeg Berbee 5520 Research Park Dr. Madison, WI 53711 [EMAIL PROTECTED] (608)298.1246 pager:376.6573 cell:212.2556 Berbee...putting the E in business.
Re: rsync exit codes
On Wed, May 30, 2001 at 10:50:37AM +1000, Greg Burley [EMAIL PROTECTED] wrote: | have a look at errorcode.h in the distribution source of 2.4.6 | 20 is commented as status returned when sent SIGUSR1 or SIGINT -- the later | being the most useful clue to your problem (you would probably know if you | sent SIGUSR1 to your running rsync. Hmm. It has long annoyed me that rsync returns exit code 20 after successfully updating the target. (No, I don't send it any signals.) I only get zero if both sides are the same before the sync. I would have expected: - both sides the same - exit zero - both sides different and -n used - non-zero - both sides different, no -n, successful update - zero - both sides different, no -n, unsuccessful update - non-zero This doesn't seem to be the case. -- Cameron Simpson, DoD#743[EMAIL PROTECTED]http://www.zip.com.au/~cs/ The Microsoft manuals, of course, are just a load of self-serving propaganda written by tekkies under the supervision of public relations folks. - David Lloyd-Jones