added a --relative (== -R) option. This is what Anthony Thyssen
[rsync/rsync.git] / main.c
CommitLineData
c627d613
AT
1/*
2 Copyright (C) Andrew Tridgell 1996
3 Copyright (C) Paul Mackerras 1996
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18*/
19
20#include "rsync.h"
21
22int verbose = 0;
23int always_checksum = 0;
24time_t starttime;
25off_t total_size = 0;
26int block_size=BLOCK_SIZE;
27
28char *backup_suffix = BACKUP_SUFFIX;
29
30static char *rsync_path = RSYNC_NAME;
31
32int make_backups = 0;
33int preserve_links = 0;
dc5ddbcc 34int preserve_hard_links = 0;
c627d613
AT
35int preserve_perms = 0;
36int preserve_devices = 0;
37int preserve_uid = 0;
38int preserve_gid = 0;
39int preserve_times = 0;
40int update_only = 0;
41int cvs_exclude = 0;
42int dry_run=0;
43int local_server=0;
44int ignore_times=0;
45int delete_mode=0;
46int one_file_system=0;
4fe159a8 47int remote_version=0;
dc5ddbcc 48int sparse_files=0;
70d794dc 49int do_compression=0;
7b8356d0
AT
50int am_root=0;
51int orig_umask=0;
6574b4f7 52int relative_paths=0;
70d794dc 53
34ccb63e 54extern int csum_length;
c627d613
AT
55
56int am_server = 0;
57static int sender = 0;
58int recurse = 0;
59
60static void usage(FILE *f);
61
62static void report(int f)
63{
64 int in,out,tsize;
65 time_t t = time(NULL);
66
67 if (!verbose) return;
68
69 if (am_server && sender) {
70 write_int(f,read_total());
71 write_int(f,write_total());
72 write_int(f,total_size);
73 write_flush(f);
74 return;
75 }
76
77 if (sender) {
78 in = read_total();
79 out = write_total();
80 tsize = (int)total_size;
81 } else {
82 in = read_int(f);
83 out = read_int(f);
84 tsize = read_int(f);
85 }
86
87 printf("wrote %d bytes read %d bytes %g bytes/sec\n",
88 out,in,(in+out)/(0.5 + (t-starttime)));
89 printf("total size is %d speedup is %g\n",
90 tsize,(1.0*tsize)/(in+out));
91}
92
93
94static void server_options(char **args,int *argc)
95{
96 int ac = *argc;
97 static char argstr[50];
98 static char bsize[30];
99 int i, x;
100
101 args[ac++] = "--server";
102
103 if (!sender)
104 args[ac++] = "--sender";
105
106 x = 1;
107 argstr[0] = '-';
108 for (i=0;i<verbose;i++)
109 argstr[x++] = 'v';
110 if (make_backups)
111 argstr[x++] = 'b';
112 if (update_only)
113 argstr[x++] = 'u';
114 if (dry_run)
115 argstr[x++] = 'n';
116 if (preserve_links)
117 argstr[x++] = 'l';
dc5ddbcc
AT
118 if (preserve_hard_links)
119 argstr[x++] = 'H';
c627d613
AT
120 if (preserve_uid)
121 argstr[x++] = 'o';
122 if (preserve_gid)
123 argstr[x++] = 'g';
124 if (preserve_devices)
125 argstr[x++] = 'D';
126 if (preserve_times)
127 argstr[x++] = 't';
128 if (preserve_perms)
129 argstr[x++] = 'p';
130 if (recurse)
131 argstr[x++] = 'r';
132 if (always_checksum)
133 argstr[x++] = 'c';
134 if (cvs_exclude)
135 argstr[x++] = 'C';
136 if (ignore_times)
137 argstr[x++] = 'I';
6574b4f7
AT
138 if (relative_paths)
139 argstr[x++] = 'R';
c627d613
AT
140 if (one_file_system)
141 argstr[x++] = 'x';
dc5ddbcc
AT
142 if (sparse_files)
143 argstr[x++] = 'S';
861c20b4
PM
144 if (do_compression)
145 argstr[x++] = 'z';
c627d613
AT
146 argstr[x] = 0;
147
148 if (x != 1) args[ac++] = argstr;
149
150 if (block_size != BLOCK_SIZE) {
151 sprintf(bsize,"-B%d",block_size);
152 args[ac++] = bsize;
153 }
43a481dc 154
c627d613
AT
155 if (delete_mode)
156 args[ac++] = "--delete";
157
158 *argc = ac;
159}
160
161
162
163int do_cmd(char *cmd,char *machine,char *user,char *path,int *f_in,int *f_out)
164{
165 char *args[100];
166 int i,argc=0;
167 char *tok,*p;
168
169 if (!local_server) {
170 if (!cmd)
171 cmd = getenv(RSYNC_RSH_ENV);
172 if (!cmd)
173 cmd = RSYNC_RSH;
174 cmd = strdup(cmd);
175 if (!cmd)
176 goto oom;
177
178 for (tok=strtok(cmd," ");tok;tok=strtok(NULL," ")) {
179 args[argc++] = tok;
180 }
181
7b8356d0
AT
182#if HAVE_REMSH
183 /* remsh (on HPUX) takes the arguments the other way around */
184 args[argc++] = machine;
185 if (user) {
186 args[argc++] = "-l";
187 args[argc++] = user;
188 }
189#else
c627d613
AT
190 if (user) {
191 args[argc++] = "-l";
192 args[argc++] = user;
193 }
194 args[argc++] = machine;
7b8356d0 195#endif
c627d613
AT
196 }
197
198 args[argc++] = rsync_path;
199
200 server_options(args,&argc);
201
202 if (path && *path) {
203 char *dir = strdup(path);
204 p = strrchr(dir,'/');
6574b4f7 205 if (p && !relative_paths) {
c627d613 206 *p = 0;
7b8356d0
AT
207 if (!dir[0])
208 args[argc++] = "/";
209 else
210 args[argc++] = dir;
c627d613
AT
211 p++;
212 } else {
213 args[argc++] = ".";
214 p = dir;
215 }
216 if (p[0])
217 args[argc++] = path;
218 }
219
220 args[argc] = NULL;
221
222 if (verbose > 3) {
dc5ddbcc 223 fprintf(FERROR,"cmd=");
c627d613 224 for (i=0;i<argc;i++)
dc5ddbcc
AT
225 fprintf(FERROR,"%s ",args[i]);
226 fprintf(FERROR,"\n");
c627d613
AT
227 }
228
229 return piped_child(args,f_in,f_out);
230
231oom:
232 out_of_memory("do_cmd");
233 return 0; /* not reached */
234}
235
236
237
238
239static char *get_local_name(struct file_list *flist,char *name)
240{
241 struct stat st;
242
243 if (stat(name,&st) == 0) {
244 if (S_ISDIR(st.st_mode)) {
245 if (chdir(name) != 0) {
6574b4f7 246 fprintf(FERROR,"chdir %s : %s (1)\n",name,strerror(errno));
34ccb63e 247 exit_cleanup(1);
c627d613
AT
248 }
249 return NULL;
250 }
251 if (flist->count > 1) {
dc5ddbcc 252 fprintf(FERROR,"ERROR: destination must be a directory when copying more than 1 file\n");
34ccb63e 253 exit_cleanup(1);
c627d613
AT
254 }
255 return name;
256 }
257
258 if (flist->count == 1)
259 return name;
260
261 if (!name)
262 return NULL;
263
7b8356d0 264 if (mkdir(name,0777 & ~orig_umask) != 0) {
6574b4f7 265 fprintf(FERROR,"mkdir %s : %s (1)\n",name,strerror(errno));
34ccb63e 266 exit_cleanup(1);
94481d91 267 } else {
dc5ddbcc 268 fprintf(FINFO,"created directory %s\n",name);
c627d613
AT
269 }
270
271 if (chdir(name) != 0) {
6574b4f7 272 fprintf(FERROR,"chdir %s : %s (2)\n",name,strerror(errno));
34ccb63e 273 exit_cleanup(1);
c627d613
AT
274 }
275
276 return NULL;
277}
278
279
280
281
282void do_server_sender(int argc,char *argv[])
283{
284 int i;
285 char *dir = argv[0];
286 struct file_list *flist;
287
288 if (verbose > 2)
dc5ddbcc 289 fprintf(FERROR,"server_sender starting pid=%d\n",(int)getpid());
c627d613 290
6574b4f7
AT
291 if (!relative_paths && chdir(dir) != 0) {
292 fprintf(FERROR,"chdir %s: %s (3)\n",dir,strerror(errno));
34ccb63e 293 exit_cleanup(1);
c627d613
AT
294 }
295 argc--;
296 argv++;
297
298 if (strcmp(dir,".")) {
299 int l = strlen(dir);
8bf73749
AT
300 if (strcmp(dir,"/") == 0)
301 l = 0;
c627d613
AT
302 for (i=0;i<argc;i++)
303 argv[i] += l+1;
304 }
305
306 if (argc == 0 && recurse) {
307 argc=1;
308 argv--;
309 argv[0] = ".";
310 }
311
312
a06d19e3 313 flist = send_file_list(STDOUT_FILENO,argc,argv);
c627d613
AT
314 send_files(flist,STDOUT_FILENO,STDIN_FILENO);
315 report(STDOUT_FILENO);
34ccb63e 316 exit_cleanup(0);
c627d613
AT
317}
318
319
dc5ddbcc
AT
320static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
321{
322 int pid;
323 int status=0;
c6e7fcb4 324 int recv_pipe[2];
dc5ddbcc
AT
325
326 if (preserve_hard_links)
327 init_hard_links(flist);
328
c6e7fcb4
AT
329 if (pipe(recv_pipe) < 0) {
330 fprintf(FERROR,"pipe failed in do_recv\n");
331 exit(1);
332 }
333
334
dc5ddbcc 335 if ((pid=fork()) == 0) {
c6e7fcb4 336 recv_files(f_in,flist,local_name,recv_pipe[1]);
dc5ddbcc
AT
337 if (preserve_hard_links)
338 do_hard_links(flist);
339 if (verbose > 2)
340 fprintf(FERROR,"receiver read %d\n",read_total());
341 exit_cleanup(0);
342 }
343
c6e7fcb4 344 generate_files(f_out,flist,local_name,recv_pipe[0]);
dc5ddbcc
AT
345
346 waitpid(pid, &status, 0);
347
348 return status;
349}
350
c627d613
AT
351
352void do_server_recv(int argc,char *argv[])
353{
dc5ddbcc 354 int status;
c627d613
AT
355 char *dir = NULL;
356 struct file_list *flist;
357 char *local_name=NULL;
358
359 if (verbose > 2)
dc5ddbcc 360 fprintf(FERROR,"server_recv(%d) starting pid=%d\n",argc,(int)getpid());
c627d613
AT
361
362 if (argc > 0) {
363 dir = argv[0];
364 argc--;
365 argv++;
366 if (chdir(dir) != 0) {
6574b4f7 367 fprintf(FERROR,"chdir %s : %s (4)\n",dir,strerror(errno));
34ccb63e 368 exit_cleanup(1);
c627d613
AT
369 }
370 }
371
372 if (delete_mode)
373 recv_exclude_list(STDIN_FILENO);
374
375 flist = recv_file_list(STDIN_FILENO);
376 if (!flist || flist->count == 0) {
dc5ddbcc 377 fprintf(FERROR,"nothing to do\n");
34ccb63e 378 exit_cleanup(1);
c627d613
AT
379 }
380
381 if (argc > 0) {
382 if (strcmp(dir,".")) {
383 argv[0] += strlen(dir);
384 if (argv[0][0] == '/') argv[0]++;
385 }
386 local_name = get_local_name(flist,argv[0]);
387 }
388
dc5ddbcc 389 status = do_recv(STDIN_FILENO,STDOUT_FILENO,flist,local_name);
34ccb63e 390 exit_cleanup(status);
c627d613
AT
391}
392
393
394static void usage(FILE *f)
395{
396 fprintf(f,"rsync version %s Copyright Andrew Tridgell and Paul Mackerras\n\n",
397 VERSION);
398 fprintf(f,"Usage:\t%s [options] src user@host:dest\nOR",RSYNC_NAME);
399 fprintf(f,"\t%s [options] user@host:src dest\n\n",RSYNC_NAME);
400 fprintf(f,"Options:\n");
401 fprintf(f,"-v, --verbose increase verbosity\n");
402 fprintf(f,"-c, --checksum always checksum\n");
403 fprintf(f,"-a, --archive archive mode (same as -rlptDog)\n");
404 fprintf(f,"-r, --recursive recurse into directories\n");
6574b4f7 405 fprintf(f,"-R, --relative use relative path names\n");
c627d613
AT
406 fprintf(f,"-b, --backup make backups (default ~ extension)\n");
407 fprintf(f,"-u, --update update only (don't overwrite newer files)\n");
408 fprintf(f,"-l, --links preserve soft links\n");
dc5ddbcc 409 fprintf(f,"-H, --hard-links preserve hard links\n");
c627d613
AT
410 fprintf(f,"-p, --perms preserve permissions\n");
411 fprintf(f,"-o, --owner preserve owner (root only)\n");
412 fprintf(f,"-g, --group preserve group\n");
413 fprintf(f,"-D, --devices preserve devices (root only)\n");
414 fprintf(f,"-t, --times preserve times\n");
dc5ddbcc 415 fprintf(f,"-S, --sparse handle sparse files efficiently\n");
c627d613
AT
416 fprintf(f,"-n, --dry-run show what would have been transferred\n");
417 fprintf(f,"-x, --one-file-system don't cross filesystem boundaries\n");
418 fprintf(f,"-B, --block-size SIZE checksum blocking size\n");
419 fprintf(f,"-e, --rsh COMMAND specify rsh replacement\n");
420 fprintf(f," --rsync-path PATH specify path to rsync on the remote machine\n");
421 fprintf(f,"-C, --cvs-exclude auto ignore files in the same way CVS does\n");
422 fprintf(f," --delete delete files that don't exist on the sending side\n");
423 fprintf(f,"-I, --ignore-times don't exclude files that match length and time\n");
861c20b4 424 fprintf(f,"-z, --compress compress file data\n");
c627d613
AT
425 fprintf(f," --exclude FILE exclude file FILE\n");
426 fprintf(f," --exclude-from FILE exclude files listed in FILE\n");
427 fprintf(f," --suffix SUFFIX override backup suffix\n");
428 fprintf(f," --version print version number\n");
429
430 fprintf(f,"\n");
431 fprintf(f,"the backup suffix defaults to %s\n",BACKUP_SUFFIX);
432 fprintf(f,"the block size defaults to %d\n",BLOCK_SIZE);
433}
434
435enum {OPT_VERSION,OPT_SUFFIX,OPT_SENDER,OPT_SERVER,OPT_EXCLUDE,
b98c7b81 436 OPT_EXCLUDE_FROM,OPT_DELETE,OPT_RSYNC_PATH};
c627d613 437
6574b4f7 438static char *short_options = "oblHpguDCtcahvrRIxnSe:B:z";
c627d613
AT
439
440static struct option long_options[] = {
441 {"version", 0, 0, OPT_VERSION},
442 {"server", 0, 0, OPT_SERVER},
443 {"sender", 0, 0, OPT_SENDER},
444 {"delete", 0, 0, OPT_DELETE},
445 {"exclude", 1, 0, OPT_EXCLUDE},
446 {"exclude-from",1, 0, OPT_EXCLUDE_FROM},
447 {"rsync-path", 1, 0, OPT_RSYNC_PATH},
448 {"one-file-system",0, 0, 'x'},
449 {"ignore-times",0, 0, 'I'},
450 {"help", 0, 0, 'h'},
451 {"dry-run", 0, 0, 'n'},
dc5ddbcc 452 {"sparse", 0, 0, 'S'},
c627d613
AT
453 {"cvs-exclude", 0, 0, 'C'},
454 {"archive", 0, 0, 'a'},
455 {"checksum", 0, 0, 'c'},
456 {"backup", 0, 0, 'b'},
457 {"update", 0, 0, 'u'},
458 {"verbose", 0, 0, 'v'},
459 {"recursive", 0, 0, 'r'},
6574b4f7 460 {"relative", 0, 0, 'R'},
c627d613
AT
461 {"devices", 0, 0, 'D'},
462 {"perms", 0, 0, 'p'},
463 {"links", 0, 0, 'l'},
dc5ddbcc 464 {"hard-links", 0, 0, 'H'},
c627d613
AT
465 {"owner", 0, 0, 'o'},
466 {"group", 0, 0, 'g'},
467 {"times", 0, 0, 't'},
468 {"rsh", 1, 0, 'e'},
469 {"suffix", 1, 0, OPT_SUFFIX},
470 {"block-size", 1, 0, 'B'},
861c20b4 471 {"compress", 0, 0, 'z'},
c627d613
AT
472 {0,0,0,0}};
473
474int main(int argc,char *argv[])
475{
774ef68f 476 int pid, status = 0, status2 = 0;
c627d613
AT
477 int opt;
478 int option_index;
479 char *shell_cmd = NULL;
480 char *shell_machine = NULL;
481 char *shell_path = NULL;
482 char *shell_user = NULL;
483 char *p;
484 int f_in,f_out;
485 struct file_list *flist;
486 char *local_name = NULL;
487
488 starttime = time(NULL);
7b8356d0
AT
489 am_root = (getuid() == 0);
490
491 /* we set a 0 umask so that correct file permissions can be
492 carried across */
493 orig_umask = umask(0);
c627d613
AT
494
495 while ((opt = getopt_long(argc, argv,
496 short_options, long_options, &option_index))
497 != -1) {
498 switch (opt)
499 {
500 case OPT_VERSION:
501 printf("rsync version %s protocol version %d\n",
502 VERSION,PROTOCOL_VERSION);
34ccb63e 503 exit_cleanup(0);
c627d613
AT
504
505 case OPT_SUFFIX:
506 backup_suffix = optarg;
507 break;
508
509 case OPT_RSYNC_PATH:
510 rsync_path = optarg;
511 break;
512
513 case 'I':
514 ignore_times = 1;
515 break;
516
517 case 'x':
518 one_file_system=1;
519 break;
520
521 case OPT_DELETE:
522 delete_mode = 1;
523 break;
524
525 case OPT_EXCLUDE:
526 add_exclude(optarg);
527 break;
528
529 case OPT_EXCLUDE_FROM:
530 add_exclude_file(optarg,1);
531 break;
532
533 case 'h':
dc5ddbcc 534 usage(FINFO);
34ccb63e 535 exit_cleanup(0);
c627d613
AT
536
537 case 'b':
538 make_backups=1;
539 break;
540
541 case 'n':
542 dry_run=1;
543 break;
544
dc5ddbcc
AT
545 case 'S':
546 sparse_files=1;
547 break;
548
c627d613
AT
549 case 'C':
550 cvs_exclude=1;
551 break;
552
553 case 'u':
554 update_only=1;
555 break;
556
c627d613 557 case 'l':
dc5ddbcc 558#if SUPPORT_LINKS
c627d613 559 preserve_links=1;
dc5ddbcc 560#endif
c627d613 561 break;
dc5ddbcc
AT
562
563 case 'H':
564#if SUPPORT_HARD_LINKS
565 preserve_hard_links=1;
c627d613 566#endif
dc5ddbcc 567 break;
c627d613
AT
568
569 case 'p':
570 preserve_perms=1;
571 break;
572
573 case 'o':
7b8356d0 574 preserve_uid=1;
c627d613
AT
575 break;
576
577 case 'g':
578 preserve_gid=1;
579 break;
580
581 case 'D':
7b8356d0 582 preserve_devices=1;
c627d613
AT
583 break;
584
585 case 't':
586 preserve_times=1;
587 break;
588
589 case 'c':
590 always_checksum=1;
591 break;
592
593 case 'v':
594 verbose++;
595 break;
596
597 case 'a':
598 recurse=1;
599#if SUPPORT_LINKS
600 preserve_links=1;
601#endif
602 preserve_perms=1;
603 preserve_times=1;
604 preserve_gid=1;
7b8356d0 605 if (am_root) {
c627d613
AT
606 preserve_devices=1;
607 preserve_uid=1;
7b8356d0 608 }
c627d613
AT
609 break;
610
611 case OPT_SERVER:
612 am_server = 1;
613 break;
614
615 case OPT_SENDER:
616 if (!am_server) {
dc5ddbcc 617 usage(FERROR);
34ccb63e 618 exit_cleanup(1);
c627d613
AT
619 }
620 sender = 1;
621 break;
622
623 case 'r':
624 recurse = 1;
625 break;
626
6574b4f7
AT
627 case 'R':
628 relative_paths = 1;
629 break;
630
c627d613
AT
631 case 'e':
632 shell_cmd = optarg;
633 break;
634
635 case 'B':
636 block_size = atoi(optarg);
637 break;
638
861c20b4
PM
639 case 'z':
640 do_compression = 1;
641 break;
642
c627d613 643 default:
861c20b4 644 /* fprintf(FERROR,"bad option -%c\n",opt); */
34ccb63e 645 exit_cleanup(1);
c627d613
AT
646 }
647 }
648
649 while (optind--) {
650 argc--;
651 argv++;
652 }
653
6b83141d
AT
654 signal(SIGCHLD,SIG_IGN);
655 signal(SIGINT,SIGNAL_CAST sig_int);
656 signal(SIGPIPE,SIGNAL_CAST sig_int);
657 signal(SIGHUP,SIGNAL_CAST sig_int);
658
c627d613
AT
659 if (dry_run)
660 verbose = MAX(verbose,1);
661
662 if (am_server) {
aae43eb3 663 setup_protocol(STDOUT_FILENO,STDIN_FILENO);
c627d613
AT
664
665 if (sender) {
666 recv_exclude_list(STDIN_FILENO);
667 if (cvs_exclude)
668 add_cvs_excludes();
669 do_server_sender(argc,argv);
670 } else {
671 do_server_recv(argc,argv);
672 }
34ccb63e 673 exit_cleanup(0);
c627d613
AT
674 }
675
676 if (argc < 2) {
dc5ddbcc 677 usage(FERROR);
34ccb63e 678 exit_cleanup(1);
c627d613
AT
679 }
680
681 p = strchr(argv[0],':');
682
683 if (p) {
684 sender = 0;
685 *p = 0;
686 shell_machine = argv[0];
687 shell_path = p+1;
688 argc--;
689 argv++;
690 } else {
691 sender = 1;
692
693 p = strchr(argv[argc-1],':');
694 if (!p) {
695 local_server = 1;
696 }
697
698 if (local_server) {
699 shell_machine = NULL;
700 shell_path = argv[argc-1];
701 } else {
702 *p = 0;
703 shell_machine = argv[argc-1];
704 shell_path = p+1;
705 }
706 argc--;
707 }
708
709 if (shell_machine) {
710 p = strchr(shell_machine,'@');
711 if (p) {
712 *p = 0;
713 shell_user = shell_machine;
714 shell_machine = p+1;
715 }
716 }
717
718 if (verbose > 3) {
dc5ddbcc 719 fprintf(FERROR,"cmd=%s machine=%s user=%s path=%s\n",
c627d613
AT
720 shell_cmd?shell_cmd:"",
721 shell_machine?shell_machine:"",
722 shell_user?shell_user:"",
723 shell_path?shell_path:"");
724 }
725
c627d613 726 if (!sender && argc != 1) {
dc5ddbcc 727 usage(FERROR);
34ccb63e 728 exit_cleanup(1);
c627d613
AT
729 }
730
731 pid = do_cmd(shell_cmd,shell_machine,shell_user,shell_path,&f_in,&f_out);
732
aae43eb3 733 setup_protocol(f_out,f_in);
4fe159a8 734
c627d613 735 if (verbose > 3)
dc5ddbcc 736 fprintf(FERROR,"parent=%d child=%d sender=%d recurse=%d\n",
c627d613
AT
737 (int)getpid(),pid,sender,recurse);
738
739 if (sender) {
740 if (cvs_exclude)
741 add_cvs_excludes();
742 if (delete_mode)
743 send_exclude_list(f_out);
a06d19e3 744 flist = send_file_list(f_out,argc,argv);
c627d613 745 if (verbose > 3)
dc5ddbcc 746 fprintf(FERROR,"file list sent\n");
c627d613
AT
747 send_files(flist,f_out,f_in);
748 if (verbose > 3)
dc5ddbcc 749 fprintf(FERROR,"waiting on %d\n",pid);
c627d613
AT
750 waitpid(pid, &status, 0);
751 report(-1);
34ccb63e 752 exit_cleanup(status);
c627d613
AT
753 }
754
755 send_exclude_list(f_out);
756
757 flist = recv_file_list(f_in);
758 if (!flist || flist->count == 0) {
dc5ddbcc 759 fprintf(FERROR,"nothing to do\n");
34ccb63e 760 exit_cleanup(0);
c627d613
AT
761 }
762
763 local_name = get_local_name(flist,argv[0]);
764
dc5ddbcc 765 status2 = do_recv(f_in,f_out,flist,local_name);
c627d613
AT
766
767 report(f_in);
768
769 waitpid(pid, &status, 0);
770
771 return status | status2;
772}