--- embedaddon/rsync/main.c 2013/10/14 07:51:14 1.1.1.2 +++ embedaddon/rsync/main.c 2016/11/01 09:54:32 1.1.1.3 @@ -4,7 +4,7 @@ * Copyright (C) 1996-2001 Andrew Tridgell * Copyright (C) 1996 Paul Mackerras * Copyright (C) 2001, 2002 Martin Pool - * Copyright (C) 2003-2013 Wayne Davison + * Copyright (C) 2003-2015 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 @@ -77,6 +77,8 @@ extern size_t bwlimit_writemax; extern unsigned int module_dirlen; extern BOOL flist_receiving_enabled; extern BOOL shutting_down; +extern BOOL want_progress_now; +extern int backup_dir_len; extern int basis_dir_cnt; extern struct stats stats; extern char *stdout_format; @@ -851,13 +853,25 @@ static int do_recv(int f_in, int f_out, char *local_na } if (backup_dir) { - int ret = make_path(backup_dir_buf, MKP_DROP_NAME); /* drops trailing slash */ - if (ret < 0) - exit_cleanup(RERR_SYNTAX); - if (ret) - rprintf(FINFO, "Created backup_dir %s\n", backup_dir_buf); - else if (INFO_GTE(BACKUP, 1)) + STRUCT_STAT st; + int ret; + if (backup_dir_len > 1) + backup_dir_buf[backup_dir_len-1] = '\0'; + ret = do_stat(backup_dir_buf, &st); + if (ret != 0 || !S_ISDIR(st.st_mode)) { + if (ret == 0) { + rprintf(FERROR, "The backup-dir is not a directory: %s\n", backup_dir_buf); + exit_cleanup(RERR_SYNTAX); + } + if (errno != ENOENT) { + rprintf(FERROR, "Failed to stat %s: %s\n", backup_dir_buf, strerror(errno)); + exit_cleanup(RERR_FILEIO); + } + rprintf(FINFO, "(new) backup_dir is %s\n", backup_dir_buf); + } else if (INFO_GTE(BACKUP, 1)) rprintf(FINFO, "backup_dir is %s\n", backup_dir_buf); + if (backup_dir_len > 1) + backup_dir_buf[backup_dir_len-1] = '/'; } io_flush(FULL_FLUSH); @@ -1010,11 +1024,12 @@ static void do_server_recv(int f_in, int f_out, int ar filesfrom_fd = -1; } - flist = recv_file_list(f_in); + flist = recv_file_list(f_in, -1); if (!flist) { rprintf(FERROR,"server_recv: recv_file_list error\n"); exit_cleanup(RERR_FILESELECT); } + if (inc_recurse && file_total == 1) recv_additional_file_list(f_in); @@ -1184,7 +1199,7 @@ int client_run(int f_in, int f_out, pid_t pid, int arg if (write_batch && !am_server) start_write_batch(f_in); - flist = recv_file_list(f_in); + flist = recv_file_list(f_in, -1); if (inc_recurse && file_total == 1) recv_additional_file_list(f_in); @@ -1412,12 +1427,12 @@ static int start_client(int argc, char *argv[]) } -static RETSIGTYPE sigusr1_handler(UNUSED(int val)) +static void sigusr1_handler(UNUSED(int val)) { exit_cleanup(RERR_SIGNAL1); } -static RETSIGTYPE sigusr2_handler(UNUSED(int val)) +static void sigusr2_handler(UNUSED(int val)) { if (!am_server) output_summary(); @@ -1427,8 +1442,17 @@ static RETSIGTYPE sigusr2_handler(UNUSED(int val)) _exit(0); } -RETSIGTYPE remember_children(UNUSED(int val)) +#ifdef SIGINFO +static void siginfo_handler(UNUSED(int val)) { + + if (!am_server) + want_progress_now = True; +} +#endif + +void remember_children(UNUSED(int val)) +{ #ifdef WNOHANG int cnt, status; pid_t pid; @@ -1488,7 +1512,7 @@ const char *get_panic_action(void) * should just look at the environment variable, but I'm a bit leery * of a signal sending us into a busy loop. **/ -static RETSIGTYPE rsync_panic_handler(UNUSED(int whatsig)) +static void rsync_panic_handler(UNUSED(int whatsig)) { char cmd_buf[300]; int ret, pid_int = getpid(); @@ -1525,6 +1549,9 @@ int main(int argc,char *argv[]) SIGACTMASK(SIGFPE, rsync_panic_handler); SIGACTMASK(SIGABRT, rsync_panic_handler); SIGACTMASK(SIGBUS, rsync_panic_handler); +#endif +#ifdef SIGINFO + SIGACTMASK(SIGINFO, siginfo_handler); #endif starttime = time(NULL);