- }
- }
- if (!dry_run) unlink(fname);
- if (!dry_run && symlink(file->link,fname) != 0) {
- fprintf(FERROR,"link %s -> %s : %s\n",
- fname,file->link,strerror(errno));
- } else {
- set_perms(fname,file,NULL,0);
- if (verbose)
- fprintf(FINFO,"%s -> %s\n",
- fname,file->link);
- }
-#endif
- return;
- }
-
-#ifdef HAVE_MKNOD
- if (am_root && preserve_devices && IS_DEVICE(file->mode)) {
- if (statret != 0 ||
- st.st_mode != file->mode ||
- st.st_rdev != file->rdev) {
- if (!dry_run) unlink(fname);
- if (verbose > 2)
- fprintf(FERROR,"mknod(%s,0%o,0x%x)\n",
- fname,(int)file->mode,(int)file->rdev);
- if (!dry_run &&
- mknod(fname,file->mode,file->rdev) != 0) {
- fprintf(FERROR,"mknod %s : %s\n",fname,strerror(errno));
- } else {
- set_perms(fname,file,NULL,0);
- if (verbose)
- fprintf(FINFO,"%s\n",fname);
- }
- } else {
- set_perms(fname,file,&st,1);
- }
- return;
- }
-#endif
-
- if (preserve_hard_links && check_hard_link(file)) {
- if (verbose > 1)
- fprintf(FINFO,"%s is a hard link\n",f_name(file));
- return;
- }
-
- if (!S_ISREG(file->mode)) {
- fprintf(FERROR,"skipping non-regular file %s\n",fname);
- return;
- }
-
- if (statret == -1) {
- if (errno == ENOENT) {
- write_int(f_out,i);
- if (!dry_run) send_sums(NULL,f_out);
- } else {
- if (verbose > 1)
- fprintf(FERROR,"recv_generator failed to open %s\n",fname);
- }
- return;
- }
-
- if (!S_ISREG(st.st_mode)) {
- /* its not a regular file on the receiving end, but it is on the
- sending end. If its a directory then skip it (too dangerous to
- do a recursive deletion??) otherwise try to unlink it */
- if (S_ISDIR(st.st_mode)) {
- fprintf(FERROR,"ERROR: %s is a directory\n",fname);
- return;
- }
- if (unlink(fname) != 0) {
- fprintf(FERROR,"%s : not a regular file (generator)\n",fname);
- return;
- }
-
- /* now pretend the file didn't exist */
- write_int(f_out,i);
- if (!dry_run) send_sums(NULL,f_out);
- return;
- }
-
- if (update_only && st.st_mtime > file->modtime) {
- if (verbose > 1)
- fprintf(FERROR,"%s is newer\n",fname);
- return;
- }
-
- if (skip_file(fname, file, &st)) {
- set_perms(fname,file,&st,1);
- return;
- }
-
- if (dry_run) {
- write_int(f_out,i);
- return;
- }
-
- if (whole_file) {
- write_int(f_out,i);
- send_sums(NULL,f_out);
- return;
- }
-
- /* open the file */
- fd = open(fname,O_RDONLY);