+extern int blocking_io;
+extern int cvs_exclude;
+extern int delete_mode;
+extern int delete_excluded;
+extern int delete_after;
+extern int daemon_over_rsh;
+extern int do_stats;
+extern int dry_run;
+extern int list_only;
+extern int local_server;
+extern int log_got_error;
+extern int module_id;
+extern int orig_umask;
+extern int preserve_hard_links;
+extern int recurse;
+extern int relative_paths;
+extern int rsync_port;
+extern int read_batch;
+extern int write_batch;
+extern int filesfrom_fd;
+extern pid_t cleanup_child_pid;
+extern char *files_from;
+extern char *remote_filesfrom_file;
+extern char *rsync_path;
+extern char *shell_cmd;
+extern struct file_list *batch_flist;
+
/* there's probably never more than at most 2 outstanding child processes,
* but set it higher just in case.
/* there's probably never more than at most 2 outstanding child processes,
* but set it higher just in case.
/* status of requested child no longer available.
* check to see if it was processed by the sigchld_handler.
*/
/* status of requested child no longer available.
* check to see if it was processed by the sigchld_handler.
*/
if (am_daemon) {
log_exit(0, __FILE__, __LINE__);
if (f == -1 || !am_sender) return;
}
if (am_daemon) {
log_exit(0, __FILE__, __LINE__);
if (f == -1 || !am_sender) return;
}
int64 r;
stats.total_written = read_longint(f);
/* store total_read in a temporary, read_longint changes it */
int64 r;
stats.total_written = read_longint(f);
/* store total_read in a temporary, read_longint changes it */
- if (!am_sender && !send_stats) {
- /* missing the bytes written by the generator */
- rprintf(FINFO, "\nCannot show stats as receiver because remote protocol version is less than 20\n");
- rprintf(FINFO, "Use --stats -v to show stats\n");
- return;
- }
rprintf(FINFO,"\nNumber of files: %d\n", stats.num_files);
rprintf(FINFO,"Number of files transferred: %d\n",
stats.num_transferred_files);
rprintf(FINFO,"\nNumber of files: %d\n", stats.num_files);
rprintf(FINFO,"Number of files transferred: %d\n",
stats.num_transferred_files);
getpid(),
am_server ? "server " : "",
am_daemon ? "daemon " : "",
getpid(),
am_server ? "server " : "",
am_daemon ? "daemon " : "",
rprintf(FINFO, " arena: %10d (bytes from sbrk)\n", mi.arena);
rprintf(FINFO, " ordblks: %10d (chunks not in use)\n", mi.ordblks);
rprintf(FINFO, " smblks: %10d\n", mi.smblks);
rprintf(FINFO, " hblks: %10d (chunks from mmap)\n", mi.hblks);
rprintf(FINFO, " hblkhd: %10d (bytes from mmap)\n", mi.hblkhd);
rprintf(FINFO, " arena: %10d (bytes from sbrk)\n", mi.arena);
rprintf(FINFO, " ordblks: %10d (chunks not in use)\n", mi.ordblks);
rprintf(FINFO, " smblks: %10d\n", mi.smblks);
rprintf(FINFO, " hblks: %10d (chunks from mmap)\n", mi.hblks);
rprintf(FINFO, " hblkhd: %10d (bytes from mmap)\n", mi.hblkhd);
rprintf(FINFO, " usmblks: %10d\n", mi.usmblks);
rprintf(FINFO, " fsmblks: %10d\n", mi.fsmblks);
rprintf(FINFO, " uordblks: %10d (bytes used)\n", mi.uordblks);
rprintf(FINFO, " usmblks: %10d\n", mi.usmblks);
rprintf(FINFO, " fsmblks: %10d\n", mi.fsmblks);
rprintf(FINFO, " uordblks: %10d (bytes used)\n", mi.uordblks);
-static pid_t do_cmd(char *cmd,char *machine,char *user,char *path,int *f_in,int *f_out)
+static pid_t do_cmd(char *cmd, char *machine, char *user, char *path,
+ int *f_in, int *f_out)
if (do_stat(name,&st) == 0) {
if (S_ISDIR(st.st_mode)) {
if (do_stat(name,&st) == 0) {
if (S_ISDIR(st.st_mode)) {
- if (!push_dir(name, 0)) {
- rprintf(FERROR, "push_dir %s failed: %s (1)\n",
- full_fname(name), strerror(errno));
+ if (!push_dir(name)) {
+ rsyserr(FERROR, errno, "push_dir#1 %s failed",
+ full_fname(name));
- rprintf(FERROR, "mkdir %s failed: %s\n",
- full_fname(name), strerror(errno));
+ rsyserr(FERROR, errno, "mkdir %s failed", full_fname(name));
exit_cleanup(RERR_FILEIO);
} else {
if (verbose > 0)
rprintf(FINFO,"created directory %s\n",name);
}
exit_cleanup(RERR_FILEIO);
} else {
if (verbose > 0)
rprintf(FINFO,"created directory %s\n",name);
}
- if (!push_dir(name, 0)) {
- rprintf(FERROR, "push_dir %s failed: %s (2)\n",
- full_fname(name), strerror(errno));
+ if (!push_dir(name)) {
+ rsyserr(FERROR, errno, "push_dir#2 %s failed",
+ full_fname(name));
static void do_server_sender(int f_in, int f_out, int argc,char *argv[])
{
int i;
struct file_list *flist;
char *dir = argv[0];
static void do_server_sender(int f_in, int f_out, int argc,char *argv[])
{
int i;
struct file_list *flist;
char *dir = argv[0];
- if (!relative_paths && !push_dir(dir, 0)) {
- rprintf(FERROR, "push_dir %s failed: %s (3)\n",
- full_fname(dir), strerror(errno));
+ if (am_daemon && lp_write_only(module_id) && am_sender) {
+ rprintf(FERROR, "ERROR: module is write only\n");
+ exit_cleanup(RERR_SYNTAX);
+ return;
+ }
+
+ if (!relative_paths && !push_dir(dir)) {
+ rsyserr(FERROR, errno, "push_dir#3 %s failed",
+ full_fname(dir));
io_start_buffering_in(f_in);
io_start_buffering_out(f_out);
send_files(flist,f_out,f_in);
io_start_buffering_in(f_in);
io_start_buffering_out(f_out);
send_files(flist,f_out,f_in);
if (fd_pair(error_pipe) < 0) {
rprintf(FERROR,"error pipe failed in do_recv\n");
exit_cleanup(RERR_SOCKETIO);
}
if (fd_pair(error_pipe) < 0) {
rprintf(FERROR,"error pipe failed in do_recv\n");
exit_cleanup(RERR_SOCKETIO);
}
/* finally we go to sleep until our parent kills us
* with a USR2 signal. We sleep for a short time as on
* some OSes a signal won't interrupt a sleep! */
/* finally we go to sleep until our parent kills us
* with a USR2 signal. We sleep for a short time as on
* some OSes a signal won't interrupt a sleep! */
- if (verbose > 2)
- rprintf(FINFO,"server_recv(%d) starting pid=%d\n",argc,(int)getpid());
+ if (verbose > 2) {
+ rprintf(FINFO, "server_recv(%d) starting pid=%ld\n",
+ argc, (long)getpid());
+ }
if (am_daemon && lp_read_only(module_id) && !am_sender) {
rprintf(FERROR,"ERROR: module is read only\n");
if (am_daemon && lp_read_only(module_id) && !am_sender) {
rprintf(FERROR,"ERROR: module is read only\n");
- if (!am_daemon && !push_dir(dir, 0)) {
- rprintf(FERROR, "push_dir %s failed: %s (4)\n",
- full_fname(dir), strerror(errno));
+ if (!am_daemon && !push_dir(dir)) {
+ rsyserr(FERROR, errno, "push_dir#4 %s failed",
+ full_fname(dir));
void start_server(int f_in, int f_out, int argc, char *argv[])
{
void start_server(int f_in, int f_out, int argc, char *argv[])
{
struct file_list *flist = NULL;
int status = 0, status2 = 0;
char *local_name = NULL;
struct file_list *flist = NULL;
int status = 0, status2 = 0;
char *local_name = NULL;
* (implemented by forking "pwd" and reading its output) doesn't
* work when there are other child processes. Also, on all systems
* that implement getcwd that way "pwd" can't be found after chroot. */
* (implemented by forking "pwd" and reading its output) doesn't
* work when there are other child processes. Also, on all systems
* that implement getcwd that way "pwd" can't be found after chroot. */
if (write_batch && !am_server) {
write_batch_argvs_file(orig_argc, orig_argv);
if (write_batch && !am_server) {
write_batch_argvs_file(orig_argc, orig_argv);