- Moved the err_list* stuff here from log.c and renamed them msg_list*.
[rsync/rsync.git] / generator.c
index c388537..b325a3b 100644 (file)
@@ -78,11 +78,8 @@ static int skip_file(char *fname, struct file_struct *file, STRUCT_STAT *st)
                        }
                }
                file_checksum(fname,sum,st->st_size);
-               if (protocol_version < 21) {
-                       return (memcmp(sum,file->sum,2) == 0);
-               } else {
-                       return (memcmp(sum,file->sum,MD4_SUM_LENGTH) == 0);
-               }
+               return memcmp(sum, file->u.sum, protocol_version < 21 ? 2
+                                                       : MD4_SUM_LENGTH) == 0;
        }
 
        if (size_only) {
@@ -339,10 +336,10 @@ void recv_generator(char *fname, struct file_struct *file, int i, int f_out)
                int l;
                extern int safe_symlinks;
 
-               if (safe_symlinks && unsafe_symlink(file->link, fname)) {
+               if (safe_symlinks && unsafe_symlink(file->u.link, fname)) {
                        if (verbose) {
                                rprintf(FINFO, "ignoring unsafe symlink %s -> \"%s\"\n",
-                                       full_fname(fname), file->link);
+                                       full_fname(fname), file->u.link);
                        }
                        return;
                }
@@ -353,7 +350,7 @@ void recv_generator(char *fname, struct file_struct *file, int i, int f_out)
                                /* A link already pointing to the
                                 * right place -- no further action
                                 * required. */
-                               if (strcmp(lnk,file->link) == 0) {
+                               if (strcmp(lnk,file->u.link) == 0) {
                                        set_perms(fname,file,&st,1);
                                        return;
                                }
@@ -363,13 +360,13 @@ void recv_generator(char *fname, struct file_struct *file, int i, int f_out)
                         * in place. */
                        delete_file(fname);
                }
-               if (do_symlink(file->link,fname) != 0) {
+               if (do_symlink(file->u.link,fname) != 0) {
                        rprintf(FERROR, "symlink %s -> \"%s\" failed: %s\n",
-                               full_fname(fname), file->link, strerror(errno));
+                               full_fname(fname), file->u.link, strerror(errno));
                } else {
                        set_perms(fname,file,NULL,0);
                        if (verbose) {
-                               rprintf(FINFO,"%s -> %s\n", fname,file->link);
+                               rprintf(FINFO,"%s -> %s\n", fname,file->u.link);
                        }
                }
 #endif
@@ -380,12 +377,12 @@ void recv_generator(char *fname, struct file_struct *file, int i, int f_out)
        if (am_root && preserve_devices && IS_DEVICE(file->mode)) {
                if (statret != 0 ||
                    st.st_mode != file->mode ||
-                   (DEV64_T)st.st_rdev != file->rdev) {
+                   (DEV64_T)st.st_rdev != file->u.rdev) {
                        delete_file(fname);
                        if (verbose > 2)
                                rprintf(FINFO,"mknod(%s,0%o,0x%x)\n",
-                                       fname,(int)file->mode,(int)file->rdev);
-                       if (do_mknod(fname,file->mode,file->rdev) != 0) {
+                                       fname,(int)file->mode,(int)file->u.rdev);
+                       if (do_mknod(fname,file->mode,file->u.rdev) != 0) {
                                rprintf(FERROR, "mknod %s failed: %s\n",
                                        full_fname(fname), strerror(errno));
                        } else {
@@ -400,7 +397,7 @@ void recv_generator(char *fname, struct file_struct *file, int i, int f_out)
        }
 #endif
 
-       if (preserve_hard_links && check_hard_link(file)) {
+       if (preserve_hard_links && file->link_u.links && file->F_HEAD != file) {
                if (verbose > 1) {
                        rprintf(FINFO, "recv_generator: \"%s\" is a hard link\n",
                                f_name(file));
@@ -525,8 +522,7 @@ void recv_generator(char *fname, struct file_struct *file, int i, int f_out)
 }
 
 
-
-void generate_files(int f,struct file_list *flist,char *local_name,int f_recv)
+void generate_files(int f, struct file_list *flist, char *local_name)
 {
        int i;
        int phase=0;
@@ -580,7 +576,7 @@ void generate_files(int f,struct file_list *flist,char *local_name,int f_recv)
 
        /* files can cycle through the system more than once
         * to catch initial checksum errors */
-       for (i = read_int(f_recv); i != -1; i = read_int(f_recv)) {
+       while ((i = get_redo_num()) != -1) {
                struct file_struct *file = flist->files[i];
                recv_generator(local_name? local_name
                             : f_name_to(file,fbuf,sizeof fbuf), file, i, f);