extern int preserve_hard_links;
extern int protocol_version;
extern int recurse;
extern int relative_paths;
extern int rsync_port;
extern int preserve_hard_links;
extern int protocol_version;
extern int recurse;
extern int relative_paths;
extern int rsync_port;
/* 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.
*/
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)
- for (tok=strtok(cmd," ");tok;tok=strtok(NULL," ")) {
+ for (tok = strtok(cmd, " "); tok; tok = strtok(NULL, " ")) {
+ /* Comparison leaves rooms for server_options(). */
+ if (argc >= MAX_ARGS - 100) {
+ rprintf(FERROR, "internal: args[] overflowed in do_cmd()\n");
+ exit_cleanup(RERR_SYNTAX);
+ }
ret = local_child(argc, args, f_in, f_out, child_main);
} else {
ret = piped_child(args,f_in,f_out);
}
ret = local_child(argc, args, f_in, f_out, child_main);
} else {
ret = piped_child(args,f_in,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));
- 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));
static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
{
int pid;
static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
{
int pid;
- 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));
return start_socket_client(host, path, argc-1, argv+1);
}
return start_socket_client(host, path, argc-1, argv+1);
}
if (remote_filesfrom_file
&& remote_filesfrom_file != files_from + 1
&& strncmp(files_from, argv[0], p-argv[0]+1) != 0) {
if (remote_filesfrom_file
&& remote_filesfrom_file != files_from + 1
&& strncmp(files_from, argv[0], p-argv[0]+1) != 0) {
return start_socket_client(host, path, argc-1, argv);
}
return start_socket_client(host, path, argc-1, argv);
}
if (p && remote_filesfrom_file
&& remote_filesfrom_file != files_from + 1
&& strncmp(files_from, argv[argc-1], p-argv[argc-1]+1) != 0) {
if (p && remote_filesfrom_file
&& remote_filesfrom_file != files_from + 1
&& strncmp(files_from, argv[argc-1], p-argv[argc-1]+1) != 0) {
* (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);