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