From 1c82a1e1e54eb585cd37c875604193f5b977d24e Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sun, 12 Apr 2020 15:45:22 -0700 Subject: [PATCH] A few file-data improvements. --- configure.ac | 1 + flist.c | 10 +++++----- generator.c | 4 ++-- rsync.c | 2 +- rsync.h | 11 ++++++----- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index 5ca7a55e..8e44eca4 100644 --- a/configure.ac +++ b/configure.ac @@ -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 5a29d6e9..a67e3653 100644 --- 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; diff --git a/generator.c b/generator.c index 1955bc81..7ec924cf 100644 --- a/generator.c +++ b/generator.c @@ -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 f4af4945..4659d123 100644 --- 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 3f239f06..c6cb0992 100644 --- a/rsync.h +++ b/rsync.h @@ -54,10 +54,10 @@ #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) -- 2.47.2