A few file-data improvements.
authorWayne Davison <wayne@opencoder.net>
Sun, 12 Apr 2020 22:45:22 +0000 (15:45 -0700)
committerWayne Davison <wayne@opencoder.net>
Sun, 12 Apr 2020 22:51:20 +0000 (15:51 -0700)
configure.ac
flist.c
generator.c
rsync.c
rsync.h

index 5ca7a55e3453ead1788ee032aa41469e4aee3825..8e44eca465c07fc0802884bb626255018031029b 100644 (file)
@@ -389,6 +389,7 @@ AC_CHECK_SIZEOF(int64_t)
 AC_CHECK_SIZEOF(off_t)
 AC_CHECK_SIZEOF(off64_t)
 AC_CHECK_SIZEOF(time_t)
+AC_CHECK_SIZEOF(char*)
 
 AC_C_INLINE
 
diff --git a/flist.c b/flist.c
index 5a29d6e913818b9308cb895ad7ba6e3f88861226..a67e36531ad73e3ab8de6449c07f039db05cce79 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -759,7 +759,7 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
                        struct file_struct *first = flist->files[first_hlink_ndx - flist->ndx_start];
                        file_length = F_LENGTH(first);
                        modtime = first->modtime;
-                       modtime_nsec = F_MOD_NSEC(first);
+                       modtime_nsec = F_MOD_NSEC_or_0(first);
                        mode = first->mode;
                        if (preserve_uid)
                                uid = F_OWNER(first);
@@ -944,7 +944,7 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
 #ifdef CAN_SET_NSEC
        if (modtime_nsec) {
                file->flags |= FLAG_MOD_NSEC;
-               OPT_EXTRA(file, 0)->unum = modtime_nsec;
+               F_MOD_NSEC(file) = modtime_nsec;
        }
 #endif
        file->len32 = (uint32)file_length;
@@ -955,7 +955,7 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
                exit_cleanup(RERR_UNSUPPORTED);
 #else
                file->flags |= FLAG_LENGTH64;
-               OPT_EXTRA(file, NSEC_BUMP(file))->unum = (uint32)(file_length >> 32);
+               F_HIGH_LEN(file) = (uint32)(file_length >> 32);
 #endif
        }
 #endif
@@ -1346,14 +1346,14 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
 #ifdef ST_MTIME_NSEC
        if (st.ST_MTIME_NSEC && protocol_version >= 31) {
                file->flags |= FLAG_MOD_NSEC;
-               OPT_EXTRA(file, 0)->unum = st.ST_MTIME_NSEC;
+               F_MOD_NSEC(file) = st.ST_MTIME_NSEC;
        }
 #endif
        file->len32 = (uint32)st.st_size;
 #if SIZEOF_CAPITAL_OFF_T >= 8
        if (st.st_size > 0xFFFFFFFFu && S_ISREG(st.st_mode)) {
                file->flags |= FLAG_LENGTH64;
-               OPT_EXTRA(file, NSEC_BUMP(file))->unum = (uint32)(st.st_size >> 32);
+               F_HIGH_LEN(file) = (uint32)(st.st_size >> 32);
        }
 #endif
        file->mode = st.st_mode;
index 1955bc81c096fe2be0d6e1b90e162c9d0b4b1c27..7ec924cf4e7566f84f4903489d447e2a2d5434b4 100644 (file)
@@ -387,7 +387,7 @@ static void do_delete_pass(void)
 static inline int time_diff(STRUCT_STAT *stp, struct file_struct *file)
 {
 #ifdef ST_MTIME_NSEC
-       return cmp_time(stp->st_mtime, stp->ST_MTIME_NSEC, file->modtime, F_MOD_NSEC(file));
+       return cmp_time(stp->st_mtime, stp->ST_MTIME_NSEC, file->modtime, F_MOD_NSEC_or_0(file));
 #else
        return cmp_time(stp->st_mtime, 0L, file->modtime, 0L);
 #endif
@@ -2065,7 +2065,7 @@ static void touch_up_dirs(struct file_list *flist, int ndx)
                if (need_retouch_dir_times) {
                        STRUCT_STAT st;
                        if (link_stat(fname, &st, 0) == 0 && time_diff(&st, file))
-                               set_modtime(fname, file->modtime, F_MOD_NSEC(file), file->mode);
+                               set_modtime(fname, file->modtime, F_MOD_NSEC_or_0(file), file->mode);
                }
                if (counter >= loopchk_limit) {
                        if (allowed_lull)
diff --git a/rsync.c b/rsync.c
index f4af494579ffa2c7024ce1c38e256dd6977fa103..4659d1231f82ef25ca83e67a9ada60fd7c41153d 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -560,7 +560,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
          || (flags & ATTRS_SET_NANO && NSEC_BUMP(file) && (uint32)sxp->st.ST_MTIME_NSEC != F_MOD_NSEC(file))
 #endif
          )) {
-               int ret = set_modtime(fname, file->modtime, F_MOD_NSEC(file), sxp->st.st_mode);
+               int ret = set_modtime(fname, file->modtime, F_MOD_NSEC_or_0(file), sxp->st.st_mode);
                if (ret < 0) {
                        rsyserr(FERROR_XFER, errno, "failed to set times on %s",
                                full_fname(fname));
diff --git a/rsync.h b/rsync.h
index 3f239f06271e0685b5e4f4bb78e1c78d071576ff..c6cb0992cc99e0ea748bf9fa54a436e2d50c4426 100644 (file)
--- a/rsync.h
+++ b/rsync.h
 #define XMIT_SAME_TIME (1<<7)
 #define XMIT_SAME_RDEV_MAJOR (1<<8)    /* protocols 28 - now (devices only) */
 #define XMIT_NO_CONTENT_DIR (1<<8)     /* protocols 30 - now (dirs only) */
-#define XMIT_HLINKED (1<<9)            /* protocols 28 - now */
+#define XMIT_HLINKED (1<<9)            /* protocols 28 - now (non-dirs) */
 #define XMIT_SAME_DEV_pre30 (1<<10)    /* protocols 28 - 29  */
 #define XMIT_USER_NAME_FOLLOWS (1<<10) /* protocols 30 - now */
-#define XMIT_RDEV_MINOR_8_pre30 (1<<11)        /* protocols 28 - 29  */
+#define XMIT_RDEV_MINOR_8_pre30 (1<<11) /* protocols 28 - 29  */
 #define XMIT_GROUP_NAME_FOLLOWS (1<<11) /* protocols 30 - now */
 #define XMIT_HLINK_FIRST (1<<12)       /* protocols 30 - now (HLINKED files only) */
 #define XMIT_IO_ERROR_ENDLIST (1<<12)  /* protocols 31*- now (w/XMIT_EXTENDED_FLAGS) (also protocol 30 w/'f' compat flag) */
@@ -741,11 +741,12 @@ extern int xattrs_ndx;
 #if SIZEOF_INT64 < 8
 #define F_LENGTH(f) ((int64)(f)->len32)
 #else
-#define F_LENGTH(f) ((int64)(f)->len32 + ((f)->flags & FLAG_LENGTH64 \
-                  ? (int64)OPT_EXTRA(f, NSEC_BUMP(f))->unum << 32 : 0))
+#define F_HIGH_LEN(f) (OPT_EXTRA(f, NSEC_BUMP(f))->unum)
+#define F_LENGTH(f) ((int64)(f)->len32 + ((f)->flags & FLAG_LENGTH64 ? (int64)F_HIGH_LEN(f) << 32 : 0))
 #endif
 
-#define F_MOD_NSEC(f) ((f)->flags & FLAG_MOD_NSEC ? OPT_EXTRA(f, 0)->unum : 0)
+#define F_MOD_NSEC(f) OPT_EXTRA(f, 0)->unum
+#define F_MOD_NSEC_or_0(f) ((f)->flags & FLAG_MOD_NSEC ? F_MOD_NSEC(f) : 0)
 
 /* If there is a symlink string, it is always right after the basename */
 #define F_SYMLINK(f) ((f)->basename + strlen((f)->basename) + 1)