関数 | |
static char const * | rerr_name (int code) |
static void | logit (int priority, char *buf) |
static void | syslog_init () |
static void | logfile_open (void) |
void | log_init (void) |
void | logfile_close (void) |
void | logfile_reopen (void) |
static void | filtered_fwrite (FILE *f, const char *buf, int len, int use_isprint) |
void | rwrite (enum logcode code, char *buf, int len) |
void | rprintf (enum logcode code, const char *format,...) |
void | rsyserr (enum logcode code, int errcode, const char *format,...) |
void | rflush (enum logcode code) |
static void | log_formatted (enum logcode code, char *format, char *op, struct file_struct *file, struct stats *initial_stats, int iflags, char *hlink) |
int | log_format_has (const char *format, char esc) |
void | log_item (struct file_struct *file, struct stats *initial_stats, int iflags, char *hlink) |
void | maybe_log_item (struct file_struct *file, int iflags, int itemizing, char *buf) |
void | log_delete (char *fname, int mode) |
void | log_exit (int code, const char *file, int line) |
変数 | |
int | verbose |
int | dry_run |
int | am_daemon |
int | am_server |
int | am_sender |
int | local_server |
int | quiet |
int | module_id |
int | msg_fd_out |
int | allow_8bit_chars |
int | protocol_version |
int | preserve_times |
int | log_format_has_i |
int | log_format_has_o_or_i |
int | daemon_log_format_has_o_or_i |
mode_t | orig_umask |
char * | auth_user |
char * | log_format |
iconv_t | ic_chck |
static int | log_initialised |
static int | logfile_was_closed |
static char * | logfname |
static FILE * | logfile |
stats | stats |
int | log_got_error = 0 |
struct { | |
int code | |
char const * name | |
} | rerr_names [] |
static char const* rerr_name | ( | int | code | ) | [static] |
参照先 name・rerr_names.
参照元 log_exit().
00099 { 00100 int i; 00101 for (i = 0; rerr_names[i].name; i++) { 00102 if (rerr_names[i].code == code) 00103 return rerr_names[i].name; 00104 } 00105 return NULL; 00106 }
static void logit | ( | int | priority, | |
char * | buf | |||
) | [static] |
参照先 logfile・logfile_reopen()・logfile_was_closed・timestring().
参照元 rwrite()・syslog_init().
00109 { 00110 if (logfile_was_closed) 00111 logfile_reopen(); 00112 if (logfile) { 00113 fprintf(logfile,"%s [%d] %s", 00114 timestring(time(NULL)), (int)getpid(), buf); 00115 fflush(logfile); 00116 } else { 00117 syslog(priority, "%s", buf); 00118 } 00119 }
static void syslog_init | ( | ) | [static] |
参照先 logit().
参照元 log_init()・logfile_open().
00122 { 00123 static int been_here = 0; 00124 int options = LOG_PID; 00125 00126 if (been_here) 00127 return; 00128 been_here = 1; 00129 00130 #ifdef LOG_NDELAY 00131 options |= LOG_NDELAY; 00132 #endif 00133 00134 #ifdef LOG_DAEMON 00135 openlog("rsyncd", options, lp_syslog_facility()); 00136 #else 00137 openlog("rsyncd", options); 00138 #endif 00139 00140 #ifndef LOG_NDELAY 00141 logit(LOG_INFO, "rsyncd started\n"); 00142 #endif 00143 }
static void logfile_open | ( | void | ) | [static] |
参照先 errno・FERROR・FINFO・logfile・logfname・orig_umask・rprintf()・rsyserr()・syslog_init().
参照元 log_init()・logfile_reopen().
00146 { 00147 mode_t old_umask = umask(022 | orig_umask); 00148 logfile = fopen(logfname, "a"); 00149 umask(old_umask); 00150 if (!logfile) { 00151 int fopen_errno = errno; 00152 /* Rsync falls back to using syslog on failure. */ 00153 syslog_init(); 00154 rsyserr(FERROR, fopen_errno, 00155 "failed to open log-file %s", logfname); 00156 rprintf(FINFO, "Ignoring \"log file\" setting.\n"); 00157 } 00158 }
void log_init | ( | void | ) |
参照先 log_initialised・logfile_open()・logfname・syslog_init().
参照元 daemon_main()・rsync_module()・rwrite().
00161 { 00162 time_t t; 00163 00164 if (log_initialised) 00165 return; 00166 log_initialised = 1; 00167 00168 /* this looks pointless, but it is needed in order for the 00169 * C library on some systems to fetch the timezone info 00170 * before the chroot */ 00171 t = time(NULL); 00172 localtime(&t); 00173 00174 /* optionally use a log file instead of syslog */ 00175 logfname = lp_log_file(); 00176 if (logfname && *logfname) 00177 logfile_open(); 00178 else 00179 syslog_init(); 00180 }
void logfile_close | ( | void | ) |
参照先 logfile・logfile_was_closed.
参照元 start_accept_loop().
00183 { 00184 if (logfile) { 00185 logfile_was_closed = 1; 00186 fclose(logfile); 00187 logfile = NULL; 00188 } 00189 }
void logfile_reopen | ( | void | ) |
参照先 logfile_open()・logfile_was_closed.
参照元 logit()・start_accept_loop().
00192 { 00193 if (logfile_was_closed) { 00194 logfile_was_closed = 0; 00195 logfile_open(); 00196 } 00197 }
static void filtered_fwrite | ( | FILE * | f, | |
const char * | buf, | |||
int | len, | |||
int | use_isprint | |||
) | [static] |
参照元 rwrite().
00200 { 00201 const char *s, *end = buf + len; 00202 for (s = buf; s < end; s++) { 00203 if ((s < end - 4 00204 && *s == '\\' && s[1] == '#' 00205 && isdigit(*(uchar*)(s+2)) 00206 && isdigit(*(uchar*)(s+3)) 00207 && isdigit(*(uchar*)(s+4))) 00208 || (*s != '\t' 00209 && ((use_isprint && !isprint(*(uchar*)s)) 00210 || *(uchar*)s < ' '))) { 00211 if (s != buf && fwrite(buf, s - buf, 1, f) != 1) 00212 exit_cleanup(RERR_MESSAGEIO); 00213 fprintf(f, "\\#%03o", *(uchar*)s); 00214 buf = s + 1; 00215 } 00216 } 00217 if (buf != end && fwrite(buf, end - buf, 1, f) != 1) 00218 exit_cleanup(RERR_MESSAGEIO); 00219 }
void rwrite | ( | enum logcode | code, | |
char * | buf, | |||
int | len | |||
) |
参照先 allow_8bit_chars・am_daemon・am_server・errno・FCLIENT・FERROR・filtered_fwrite()・FINFO・FLOG・FNAME・FSOCKERR・ic_chck・io_multiplex_write()・log_got_error・log_init()・log_initialised・logit()・msg_fd_out・quiet・send_msg()・strlcpy().
参照元 log_formatted()・open_socket_in()・read_msg_fd()・readfd_unbuffered()・rprintf()・rsyserr().
00225 { 00226 int trailing_CR_or_NL; 00227 FILE *f = NULL; 00228 00229 if (len < 0) 00230 exit_cleanup(RERR_MESSAGEIO); 00231 00232 if (quiet && code == FINFO) 00233 return; 00234 00235 if (am_server && msg_fd_out >= 0) { 00236 /* Pass the message to our sibling. */ 00237 send_msg((enum msgcode)code, buf, len); 00238 return; 00239 } 00240 00241 if (code == FSOCKERR) /* This gets simplified for a non-sibling. */ 00242 code = FERROR; 00243 00244 if (code == FCLIENT) 00245 code = FINFO; 00246 else if (am_daemon) { 00247 static int in_block; 00248 char msg[2048]; 00249 int priority = code == FERROR ? LOG_WARNING : LOG_INFO; 00250 00251 if (in_block) 00252 return; 00253 in_block = 1; 00254 if (!log_initialised) 00255 log_init(); 00256 strlcpy(msg, buf, MIN((int)sizeof msg, len + 1)); 00257 logit(priority, msg); 00258 in_block = 0; 00259 00260 if (code == FLOG || !am_server) 00261 return; 00262 } else if (code == FLOG) 00263 return; 00264 00265 if (am_server) { 00266 /* Pass the message to the non-server side. */ 00267 if (io_multiplex_write((enum msgcode)code, buf, len)) 00268 return; 00269 if (am_daemon) { 00270 /* TODO: can we send the error to the user somehow? */ 00271 return; 00272 } 00273 } 00274 00275 switch (code) { 00276 case FERROR: 00277 log_got_error = 1; 00278 f = stderr; 00279 goto pre_scan; 00280 case FINFO: 00281 f = am_server ? stderr : stdout; 00282 pre_scan: 00283 while (len > 1 && *buf == '\n') { 00284 fputc(*buf, f); 00285 buf++; 00286 len--; 00287 } 00288 break; 00289 case FNAME: 00290 f = am_server ? stderr : stdout; 00291 break; 00292 default: 00293 exit_cleanup(RERR_MESSAGEIO); 00294 } 00295 00296 trailing_CR_or_NL = len && (buf[len-1] == '\n' || buf[len-1] == '\r') 00297 ? buf[--len] : 0; 00298 00299 #if defined HAVE_ICONV_OPEN && defined HAVE_ICONV_H 00300 if (ic_chck != (iconv_t)-1) { 00301 char convbuf[1024]; 00302 char *in_buf = buf, *out_buf = convbuf; 00303 size_t in_cnt = len, out_cnt = sizeof convbuf - 1; 00304 00305 iconv(ic_chck, NULL, 0, NULL, 0); 00306 while (iconv(ic_chck, &in_buf,&in_cnt, 00307 &out_buf,&out_cnt) == (size_t)-1) { 00308 if (out_buf != convbuf) { 00309 filtered_fwrite(f, convbuf, out_buf - convbuf, 0); 00310 out_buf = convbuf; 00311 out_cnt = sizeof convbuf - 1; 00312 } 00313 if (errno == E2BIG) 00314 continue; 00315 fprintf(f, "\\#%03o", *(uchar*)in_buf++); 00316 in_cnt--; 00317 } 00318 if (out_buf != convbuf) 00319 filtered_fwrite(f, convbuf, out_buf - convbuf, 0); 00320 } else 00321 #endif 00322 filtered_fwrite(f, buf, len, !allow_8bit_chars); 00323 00324 if (trailing_CR_or_NL) { 00325 fputc(trailing_CR_or_NL, f); 00326 fflush(f); 00327 } 00328 }
void rprintf | ( | enum logcode | code, | |
const char * | format, | |||
... | ||||
) |
参照先 buf・rwrite()・vsnprintf().
参照元 _exit_cleanup()・add_rule()・auth_server()・change_sacl_perms()・check_name()・check_timeout()・clean_flist()・client_name()・client_run()・compare_addrinfo_sockaddr()・copy_argv()・daemon_main()・daemon_usage()・default_perms_for_dir()・delete_in_dir()・do_cmd()・do_delete_pass()・do_recv()・do_section()・do_server_recv()・do_server_sender()・dup_acl()・emit_filelist_progress()・establish_proxy_connection()・expand_file_acl_index_list()・expand_ida_list()・expand_rsync_acl_list()・expand_smb_acl_list()・find_file_acl_index()・find_file_xal_index()・find_fuzzy()・finish_filelist_progress()・finish_transfer()・flist_expand()・generate_and_send_sums()・generate_files()・get_backup_name()・get_local_name()・get_next_gen_i()・get_secret()・get_tmpname()・getpassf()・handle_delayed_updates()・hard_link_check()・hard_link_one()・hash_search()・io_printf()・is_in_group()・keep_backup()・list_file_entry()・log_exit()・log_formatted()・logfile_open()・lookup_name()・lp_do_parameter()・make_acl()・make_file()・make_simple_backup()・map_parameter()・map_ptr()・match_address()・match_report()・match_sums()・matched()・open_socket_in()・open_socket_out()・open_socket_out_wrapped()・OpenConfFile()・option_error()・out_of_memory()・output_flist()・output_summary()・overflow_exit()・pack_smb_acl()・Parameter()・parse_arguments()・parse_filter_file()・parse_merge_name()・parse_rule()・parse_rule_tok()・pm_process()・pop_local_filters()・print_child_argv()・print_rsync_version()・push_keep_backup_acl()・push_local_filters()・read_final_goodbye()・read_item_attrs()・read_longint()・read_msg_fd()・read_stream_flags()・read_sum_head()・read_vstring()・readfd_unbuffered()・readlink_stat()・receive_acl()・receive_data()・receive_file_entry()・receive_rsync_acl()・receive_sums()・receive_xattr()・recv_add_gid()・recv_add_uid()・recv_deflated_token()・recv_file_list()・recv_files()・recv_generator()・report_filter_result()・robust_unlink()・rprint_progress()・rsync_module()・rsync_xal_get()・rsync_xal_set()・Section()・see_deflate_token()・send_deflated_token()・send_directory()・send_file_list()・send_files()・send_if_directory()・send_rules()・set_acl()・set_boolean()・set_file_attrs()・set_keep_backup_acl()・set_modtime()・set_refuse_options()・set_socket_options()・setup_iconv()・setup_protocol()・show_malloc_stats()・sock_exec()・start_accept_loop()・start_client()・start_daemon()・start_filelist_progress()・start_inband_exchange()・start_socket_client()・store_access_in_entry()・successful_send()・sum_sizes_sqroot()・try_bind_local()・try_dests_non()・try_dests_reg()・unpack_smb_acl()・usage()・whine_about_eof()・write_longint()・write_vstring()・writefd().
00333 { 00334 va_list ap; 00335 char buf[BIGPATHBUFLEN]; 00336 size_t len; 00337 00338 va_start(ap, format); 00339 len = vsnprintf(buf, sizeof buf, format, ap); 00340 va_end(ap); 00341 00342 /* Deal with buffer overruns. Instead of panicking, just 00343 * truncate the resulting string. (Note that configure ensures 00344 * that we have a vsnprintf() that doesn't ever return -1.) */ 00345 if (len > sizeof buf - 1) { 00346 static const char ellipsis[] = "[...]"; 00347 00348 /* Reset length, and zero-terminate the end of our buffer */ 00349 len = sizeof buf - 1; 00350 buf[len] = '\0'; 00351 00352 /* Copy the ellipsis to the end of the string, but give 00353 * us one extra character: 00354 * 00355 * v--- null byte at buf[sizeof buf - 1] 00356 * abcdefghij0 00357 * -> abcd[...]00 <-- now two null bytes at end 00358 * 00359 * If the input format string has a trailing newline, 00360 * we copy it into that extra null; if it doesn't, well, 00361 * all we lose is one byte. */ 00362 memcpy(buf+len-sizeof ellipsis, ellipsis, sizeof ellipsis); 00363 if (format[strlen(format)-1] == '\n') { 00364 buf[len-1] = '\n'; 00365 } 00366 } 00367 00368 rwrite(code, buf, len); 00369 }
void rsyserr | ( | enum logcode | code, | |
int | errcode, | |||
const char * | format, | |||
... | ||||
) |
参照先 buf・rwrite()・snprintf()・vsnprintf().
参照元 client_sockaddr()・copy_file()・daemon_main()・delete_item()・do_cmd()・do_recv()・do_server_recv()・do_server_sender()・establish_proxy_connection()・finish_transfer()・generate_files()・get_local_name()・get_secret()・getpassf()・handle_delayed_updates()・hard_link_check()・hard_link_one()・keep_backup()・local_child()・logfile_open()・main()・make_bak_dir()・make_file()・make_simple_backup()・map_ptr()・maybe_hard_link()・OpenConfFile()・parse_filter_file()・piped_child()・read_timeout()・receive_data()・recv_files()・recv_generator()・rsync_module()・send_directory()・send_file_list()・send_files()・set_file_attrs()・set_socket_options()・sock_exec()・start_accept_loop()・try_dests_non()・try_dests_reg()・wait_process_with_flush()・write_batch_shell_file()・writefd_unbuffered().
00380 { 00381 va_list ap; 00382 char buf[BIGPATHBUFLEN]; 00383 size_t len; 00384 00385 strcpy(buf, RSYNC_NAME ": "); 00386 len = (sizeof RSYNC_NAME ": ") - 1; 00387 00388 va_start(ap, format); 00389 len += vsnprintf(buf + len, sizeof buf - len, format, ap); 00390 va_end(ap); 00391 00392 if (len < sizeof buf) { 00393 len += snprintf(buf + len, sizeof buf - len, 00394 ": %s (%d)\n", strerror(errcode), errcode); 00395 } 00396 if (len >= sizeof buf) 00397 exit_cleanup(RERR_MESSAGEIO); 00398 00399 rwrite(code, buf, len); 00400 }
void rflush | ( | enum logcode | code | ) |
参照先 am_daemon・am_server・FERROR・FINFO・FLOG.
参照元 start_filelist_progress().
00403 { 00404 FILE *f = NULL; 00405 00406 if (am_daemon) { 00407 return; 00408 } 00409 00410 if (code == FLOG) { 00411 return; 00412 } 00413 00414 if (code == FERROR) { 00415 f = stderr; 00416 } 00417 00418 if (code == FINFO) { 00419 if (am_server) 00420 f = stderr; 00421 else 00422 f = stdout; 00423 } 00424 00425 if (!f) exit_cleanup(RERR_MESSAGEIO); 00426 fflush(f); 00427 }
static void log_formatted | ( | enum logcode | code, | |
char * | format, | |||
char * | op, | |||
struct file_struct * | file, | |||
struct stats * | initial_stats, | |||
int | iflags, | |||
char * | hlink | |||
) | [static] |
参照先 am_daemon・am_sender・auth_user・buf・clean_fname()・client_addr()・client_name()・file_struct::dir・f_name()・FERROR・file_struct::gid・file_struct::length・file_struct::link・local_server・lp_name()・lp_path()・memmove()・file_struct::mode・file_struct::modtime・module_id・pathjoin()・permstring()・preserve_times・file_struct::root・rprintf()・rwrite()・snprintf()・stats・strlcat()・strlcpy()・timestring()・stats::total_read・stats::total_written・file_struct::u・file_struct::uid.
参照元 log_delete()・log_item().
00434 { 00435 char buf[MAXPATHLEN+1024], buf2[MAXPATHLEN], fmt[32]; 00436 char *p, *s, *n; 00437 size_t len, total; 00438 int64 b; 00439 00440 *fmt = '%'; 00441 00442 /* We expand % codes one by one in place in buf. We don't 00443 * copy in the terminating null of the inserted strings, but 00444 * rather keep going until we reach the null of the format. */ 00445 total = strlcpy(buf, format, sizeof buf); 00446 if (total > MAXPATHLEN) { 00447 rprintf(FERROR, "log-format string is WAY too long!\n"); 00448 exit_cleanup(RERR_MESSAGEIO); 00449 } 00450 buf[total++] = '\n'; 00451 buf[total] = '\0'; 00452 00453 for (p = buf; (p = strchr(p, '%')) != NULL; ) { 00454 s = p++; 00455 n = fmt + 1; 00456 if (*p == '-') 00457 *n++ = *p++; 00458 while (isdigit(*(uchar*)p) && n - fmt < (int)(sizeof fmt) - 8) 00459 *n++ = *p++; 00460 if (!*p) 00461 break; 00462 *n = '\0'; 00463 n = NULL; 00464 00465 switch (*p) { 00466 case 'h': 00467 if (am_daemon) 00468 n = client_name(0); 00469 break; 00470 case 'a': 00471 if (am_daemon) 00472 n = client_addr(0); 00473 break; 00474 case 'l': 00475 strlcat(fmt, ".0f", sizeof fmt); 00476 snprintf(buf2, sizeof buf2, fmt, 00477 (double)file->length); 00478 n = buf2; 00479 break; 00480 case 'U': 00481 strlcat(fmt, "ld", sizeof fmt); 00482 snprintf(buf2, sizeof buf2, fmt, 00483 (long)file->uid); 00484 n = buf2; 00485 break; 00486 case 'G': 00487 if (file->gid == GID_NONE) 00488 n = "DEFAULT"; 00489 else { 00490 strlcat(fmt, "ld", sizeof fmt); 00491 snprintf(buf2, sizeof buf2, fmt, 00492 (long)file->gid); 00493 n = buf2; 00494 } 00495 break; 00496 case 'p': 00497 strlcat(fmt, "ld", sizeof fmt); 00498 snprintf(buf2, sizeof buf2, fmt, 00499 (long)getpid()); 00500 n = buf2; 00501 break; 00502 case 'M': 00503 n = timestring(file->modtime); 00504 { 00505 char *cp = n; 00506 while ((cp = strchr(cp, ' ')) != NULL) 00507 *cp = '-'; 00508 } 00509 break; 00510 case 'B': 00511 n = buf2 + MAXPATHLEN - PERMSTRING_SIZE; 00512 permstring(n - 1, file->mode); /* skip the type char */ 00513 break; 00514 case 'o': 00515 n = op; 00516 break; 00517 case 'f': 00518 n = f_name(file, NULL); 00519 if (am_sender && file->dir.root) { 00520 pathjoin(buf2, sizeof buf2, 00521 file->dir.root, n); 00522 clean_fname(buf2, 0); 00523 if (fmt[1]) 00524 strlcpy(n, buf2, MAXPATHLEN); 00525 else 00526 n = buf2; 00527 } else 00528 clean_fname(n, 0); 00529 if (*n == '/') 00530 n++; 00531 break; 00532 case 'n': 00533 n = f_name(file, NULL); 00534 if (S_ISDIR(file->mode)) 00535 strlcat(n, "/", MAXPATHLEN); 00536 break; 00537 case 'L': 00538 if (hlink && *hlink) { 00539 n = hlink; 00540 strcpy(buf2, " => "); 00541 } else if (S_ISLNK(file->mode) && file->u.link) { 00542 n = file->u.link; 00543 strcpy(buf2, " -> "); 00544 } else { 00545 n = ""; 00546 if (!fmt[1]) 00547 break; 00548 strcpy(buf2, " "); 00549 } 00550 strlcat(fmt, "s", sizeof fmt); 00551 snprintf(buf2 + 4, sizeof buf2 - 4, fmt, n); 00552 n = buf2; 00553 break; 00554 case 'm': 00555 n = lp_name(module_id); 00556 break; 00557 case 't': 00558 n = timestring(time(NULL)); 00559 break; 00560 case 'P': 00561 n = lp_path(module_id); 00562 break; 00563 case 'u': 00564 n = auth_user; 00565 break; 00566 case 'b': 00567 if (am_sender) { 00568 b = stats.total_written - 00569 initial_stats->total_written; 00570 } else { 00571 b = stats.total_read - 00572 initial_stats->total_read; 00573 } 00574 strlcat(fmt, ".0f", sizeof fmt); 00575 snprintf(buf2, sizeof buf2, fmt, (double)b); 00576 n = buf2; 00577 break; 00578 case 'c': 00579 if (!am_sender) { 00580 b = stats.total_written - 00581 initial_stats->total_written; 00582 } else { 00583 b = stats.total_read - 00584 initial_stats->total_read; 00585 } 00586 strlcat(fmt, ".0f", sizeof fmt); 00587 snprintf(buf2, sizeof buf2, fmt, (double)b); 00588 n = buf2; 00589 break; 00590 case 'i': 00591 if (iflags & ITEM_DELETED) { 00592 n = "*deleting"; 00593 break; 00594 } 00595 n = buf2 + MAXPATHLEN - 32; 00596 n[0] = iflags & ITEM_LOCAL_CHANGE 00597 ? iflags & ITEM_XNAME_FOLLOWS ? 'h' : 'c' 00598 : !(iflags & ITEM_TRANSFER) ? '.' 00599 : !local_server && *op == 's' ? '<' : '>'; 00600 n[1] = S_ISDIR(file->mode) ? 'd' 00601 : IS_SPECIAL(file->mode) ? 'S' 00602 : IS_DEVICE(file->mode) ? 'D' 00603 : S_ISLNK(file->mode) ? 'L' : 'f'; 00604 n[2] = !(iflags & ITEM_REPORT_CHECKSUM) ? '.' : 'c'; 00605 n[3] = !(iflags & ITEM_REPORT_SIZE) ? '.' : 's'; 00606 n[4] = !(iflags & ITEM_REPORT_TIME) ? '.' 00607 : !preserve_times || S_ISLNK(file->mode) ? 'T' : 't'; 00608 n[5] = !(iflags & ITEM_REPORT_PERMS) ? '.' : 'p'; 00609 n[6] = !(iflags & ITEM_REPORT_OWNER) ? '.' : 'o'; 00610 n[7] = !(iflags & ITEM_REPORT_GROUP) ? '.' : 'g'; 00611 n[8] = '.'; 00612 n[9] = '\0'; 00613 00614 if (iflags & (ITEM_IS_NEW|ITEM_MISSING_DATA)) { 00615 char ch = iflags & ITEM_IS_NEW ? '+' : '?'; 00616 int i; 00617 for (i = 2; n[i]; i++) 00618 n[i] = ch; 00619 } else if (n[0] == '.' || n[0] == 'h' 00620 || (n[0] == 'c' && n[1] == 'f')) { 00621 int i; 00622 for (i = 2; n[i]; i++) { 00623 if (n[i] != '.') 00624 break; 00625 } 00626 if (!n[i]) { 00627 for (i = 2; n[i]; i++) 00628 n[i] = ' '; 00629 } 00630 } 00631 break; 00632 } 00633 00634 /* "n" is the string to be inserted in place of this % code. */ 00635 if (!n) 00636 continue; 00637 if (n != buf2 && fmt[1]) { 00638 strlcat(fmt, "s", sizeof fmt); 00639 snprintf(buf2, sizeof buf2, fmt, n); 00640 n = buf2; 00641 } 00642 len = strlen(n); 00643 00644 /* Subtract the length of the escape from the string's size. */ 00645 total -= p - s + 1; 00646 00647 if (len + total >= (size_t)sizeof buf) { 00648 rprintf(FERROR, 00649 "buffer overflow expanding %%%c -- exiting\n", 00650 p[0]); 00651 exit_cleanup(RERR_MESSAGEIO); 00652 } 00653 00654 /* Shuffle the rest of the string along to make space for n */ 00655 if (len != (size_t)(p - s + 1)) 00656 memmove(s + len, p + 1, total - (s - buf) + 1); 00657 total += len; 00658 00659 /* Insert the contents of string "n", but NOT its null. */ 00660 if (len) 00661 memcpy(s, n, len); 00662 00663 /* Skip over inserted string; continue looking */ 00664 p = s + len; 00665 } 00666 00667 rwrite(code, buf, total); 00668 }
int log_format_has | ( | const char * | format, | |
char | esc | |||
) |
参照元 rsync_module().
00673 { 00674 const char *p; 00675 00676 if (!format) 00677 return 0; 00678 00679 for (p = format; (p = strchr(p, '%')) != NULL; ) { 00680 if (*++p == '-') 00681 p++; 00682 while (isdigit(*(uchar*)p)) 00683 p++; 00684 if (!*p) 00685 break; 00686 if (*p == esc) 00687 return 1; 00688 } 00689 return 0; 00690 }
void log_item | ( | struct file_struct * | file, | |
struct stats * | initial_stats, | |||
int | iflags, | |||
char * | hlink | |||
) |
参照先 am_sender・am_server・FLOG・FNAME・log_format・log_formatted()・module_id.
参照元 itemize()・maybe_log_item()・recv_files()・send_files().
00695 { 00696 char *s_or_r = am_sender ? "send" : "recv"; 00697 00698 if (lp_transfer_logging(module_id)) { 00699 log_formatted(FLOG, lp_log_format(module_id), s_or_r, 00700 file, initial_stats, iflags, hlink); 00701 } else if (log_format && !am_server) { 00702 log_formatted(FNAME, log_format, s_or_r, 00703 file, initial_stats, iflags, hlink); 00704 } 00705 }
void maybe_log_item | ( | struct file_struct * | file, | |
int | iflags, | |||
int | itemizing, | |||
char * | buf | |||
) |
参照先 am_daemon・am_server・dry_run・log_format_has_i・log_item()・file_struct::mode・stats・verbose.
参照元 recv_files()・send_files().
00709 { 00710 int significant_flags = iflags & SIGNIFICANT_ITEM_FLAGS; 00711 int see_item = itemizing && (significant_flags || *buf 00712 || log_format_has_i > 1 || (verbose > 1 && log_format_has_i)); 00713 int local_change = iflags & ITEM_LOCAL_CHANGE && significant_flags; 00714 if (am_server) { 00715 if (am_daemon && !dry_run && see_item) 00716 log_item(file, &stats, iflags, buf); 00717 } else if (see_item || local_change || *buf 00718 || (S_ISDIR(file->mode) && significant_flags)) 00719 log_item(file, &stats, iflags, buf); 00720 }
void log_delete | ( | char * | fname, | |
int | mode | |||
) |
参照先 am_daemon・am_server・file_struct::basename・daemon_log_format_has_o_or_i・dry_run・FCLIENT・FLOG・log_format・log_format_has_o_or_i・log_formatted()・file_struct::mode・module_id・MSG_DELETED・protocol_version・send_msg()・stats・verbose.
参照元 delete_item()・readfd_unbuffered().
00723 { 00724 static struct file_struct file; 00725 int len = strlen(fname); 00726 char *fmt; 00727 00728 file.mode = mode; 00729 file.basename = fname; 00730 00731 if (!verbose && !log_format) 00732 ; 00733 else if (am_server && protocol_version >= 29 && len < MAXPATHLEN) { 00734 if (S_ISDIR(mode)) 00735 len++; /* directories include trailing null */ 00736 send_msg(MSG_DELETED, fname, len); 00737 } else { 00738 fmt = log_format_has_o_or_i ? log_format : "deleting %n"; 00739 log_formatted(FCLIENT, fmt, "del.", &file, &stats, 00740 ITEM_DELETED, NULL); 00741 } 00742 00743 if (!am_daemon || dry_run || !lp_transfer_logging(module_id)) 00744 return; 00745 00746 fmt = daemon_log_format_has_o_or_i ? lp_log_format(module_id) : "deleting %n"; 00747 log_formatted(FLOG, fmt, "del.", &file, &stats, ITEM_DELETED, NULL); 00748 }
void log_exit | ( | int | code, | |
const char * | file, | |||
int | line | |||
) |
参照先 FERROR・FINFO・FLOG・name・rerr_name()・rprintf()・stats・stats::total_read・stats::total_size・stats::total_written・who_am_i().
参照元 _exit_cleanup()・handle_stats().
00757 { 00758 if (code == 0) { 00759 rprintf(FLOG,"sent %.0f bytes received %.0f bytes total size %.0f\n", 00760 (double)stats.total_written, 00761 (double)stats.total_read, 00762 (double)stats.total_size); 00763 } else { 00764 const char *name; 00765 00766 name = rerr_name(code); 00767 if (!name) 00768 name = "unexplained error"; 00769 00770 /* VANISHED is not an error, only a warning */ 00771 if (code == RERR_VANISHED) { 00772 rprintf(FINFO, "rsync warning: %s (code %d) at %s(%d) [%s=%s]\n", 00773 name, code, file, line, who_am_i(), RSYNC_VERSION); 00774 } else { 00775 rprintf(FERROR, "rsync error: %s (code %d) at %s(%d) [%s=%s]\n", 00776 name, code, file, line, who_am_i(), RSYNC_VERSION); 00777 } 00778 } 00779 }
int local_server |
int module_id |
clientserver.c の 60 行で定義されています。
int allow_8bit_chars |
int protocol_version |
int preserve_times |
int log_format_has_i |
mode_t orig_umask |
char* auth_user |
char* log_format |
iconv_t ic_chck |
int log_initialised [static] |
int logfile_was_closed [static] |
char* logfname [static] |
FILE* logfile [static] |
int log_got_error = 0 |
int code |
char const* name |
struct { ... } rerr_names[] |
参照元 rerr_name().