From: Paul Eggert Date: Fri, 16 Sep 2005 07:03:44 +0000 (+0000) Subject: Merge changes from gnulib for file system sub-second time stamps. X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=2f800ce3fb9c38360e1b6dac70ee0d8ceae72c6a;p=chaz%2Ftar Merge changes from gnulib for file system sub-second time stamps. * configure.ac: Remove checks for struct stat.st_spare1, struct stat.st_atim.tv_nsec, struct stat.st_atimespec.tv_nsec, struct stat.st_atimensec, as gnulib now does this for us. Similarly for LIB_CLOCK_GETTIME. * gnulib.modules: Add stat-time. * lib/.cvsignore: Add stat-time.h. * src/common.h: Include stat-time.h. (timespec_lt): Remove. All callers changed to use timespec_cmp. (get_stat_atime, get_stat_ctime, get_stat_mtime): (set_stat_atime, set_stat_ctime, set_stat_mtime): Remove; now defined by stat-time.h. --- diff --git a/ChangeLog b/ChangeLog index e10b9fe..dcc627a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2005-09-16 Paul Eggert + + Merge changes from gnulib for file system sub-second time stamps. + * configure.ac: Remove checks for struct stat.st_spare1, struct + stat.st_atim.tv_nsec, struct stat.st_atimespec.tv_nsec, struct + stat.st_atimensec, as gnulib now does this for us. + Similarly for LIB_CLOCK_GETTIME. + * gnulib.modules: Add stat-time. + * lib/.cvsignore: Add stat-time.h. + * src/common.h: Include stat-time.h. + (timespec_lt): Remove. All callers changed to use timespec_cmp. + (get_stat_atime, get_stat_ctime, get_stat_mtime): + (set_stat_atime, set_stat_ctime, set_stat_mtime): + Remove; now defined by stat-time.h. + 2005-09-14 Sergey Poznyakoff * src/incremen.c (list_dumpdir): New function. Used to dump diff --git a/configure.ac b/configure.ac index 0985f74..d6849fc 100644 --- a/configure.ac +++ b/configure.ac @@ -88,27 +88,6 @@ tar_GNULIB # paxutils modules tar_PAXUTILS -AC_CHECK_MEMBERS([struct stat.st_spare1, struct stat.st_atim.tv_nsec, struct stat.st_atimespec.tv_nsec, struct stat.st_atimensec], , , - [ -#include -#include ]) - -# Save and restore LIBS so e.g., -lrt, isn't added to it. Otherwise, *all* -# programs in the package would end up linked with that potentially-shared -# library, inducing unnecessary run-time overhead. - -# Solaris 2.5.1 needs -lposix4 to get the clock_gettime function. -# Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4. -tar_save_LIBS=$LIBS - LIB_CLOCK_GETTIME= - AC_SEARCH_LIBS(clock_gettime, [rt posix4]) - case "$ac_cv_search_clock_gettime" in - -l*) LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime;; - esac - AC_SUBST(LIB_CLOCK_GETTIME) - AC_CHECK_FUNCS(clock_gettime) -LIBS=$tar_save_LIBS - AC_CHECK_FUNCS(fsync lstat mkfifo readlink strerror symlink setlocale utimes) AC_CHECK_DECLS([getgrgid],,, [#include ]) AC_CHECK_DECLS([getpwuid],,, [#include ]) diff --git a/gnulib.modules b/gnulib.modules index 0d8eaff..7e3b1ef 100644 --- a/gnulib.modules +++ b/gnulib.modules @@ -32,6 +32,7 @@ safe-read save-cwd savedir setenv +stat-time stdbool stpcpy strdup diff --git a/lib/.cvsignore b/lib/.cvsignore index ceb861c..21c24ea 100644 --- a/lib/.cvsignore +++ b/lib/.cvsignore @@ -132,6 +132,7 @@ setenv.c setenv.h size_max.h stat-macros.h +stat-time.h stdbool.h stdbool_.h stpcpy.c diff --git a/src/common.h b/src/common.h index 0cd9c3b..be7f35d 100644 --- a/src/common.h +++ b/src/common.h @@ -55,6 +55,7 @@ #include #include #include +#include #include #define obstack_chunk_alloc xmalloc #define obstack_chunk_free free @@ -188,15 +189,7 @@ GLOBAL struct timespec newer_mtime_option; /* Return true if the struct stat ST's M time is less than newer_mtime_option. */ #define OLDER_STAT_TIME(st, m) \ - timespec_lt (get_stat_##m##time (&st), newer_mtime_option) - -/* Return true if A < B. */ -static inline bool -timespec_lt (struct timespec a, struct timespec b) -{ - return (a.tv_sec < b.tv_sec - || (a.tv_sec == b.tv_sec && a.tv_nsec < b.tv_nsec)); -} + (timespec_cmp (get_stat_##m##time (&st), newer_mtime_option) < 0) /* Zero if there is no recursion, otherwise FNM_LEADING_DIR. */ GLOBAL int recursion_option; @@ -646,120 +639,3 @@ bool sparse_diff_file (int, struct tar_stat_info *); /* Module utf8.c */ bool string_ascii_p (const char *str); bool utf8_convert (bool to_utf, char const *input, char **output); - - -/* FIXME: The following should get moved into gnulib. */ - -static inline struct timespec -get_stat_atime (struct stat const *st) -{ -#if defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC - return st->st_atim; -#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC - return st->st_atimespec; -#else - struct timespec t; - t.tv_sec = st->st_atime; -# if defined HAVE_STRUCT_STAT_ST_ATIMENSEC - t.tv_nsec = st->stat.st_atimensec; -# elif defined HAVE_STRUCT_STAT_ST_SPARE1 - t.tv_nsec = st->stat.st_spare1 * 1000; -# else - t.tv_nsec = 0; -# endif - return t; -#endif -} - -static inline struct timespec -get_stat_ctime (struct stat const *st) -{ -#if defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC - return st->st_ctim; -#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC - return st->st_ctimespec; -#else - struct timespec t; - t.tv_sec = st->st_ctime; -# if defined HAVE_STRUCT_STAT_ST_ATIMENSEC - t.tv_nsec = st->stat.st_ctimensec; -# elif defined HAVE_STRUCT_STAT_ST_SPARE1 - t.tv_nsec = st->stat.st_spare1 * 1000; -# else - t.tv_nsec = 0; -# endif - return t; -#endif -} - -static inline struct timespec -get_stat_mtime (struct stat const *st) -{ -#if defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC - return st->st_mtim; -#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC - return st->st_mtimespec; -#else - struct timespec t; - t.tv_sec = st->st_mtime; -# if defined HAVE_STRUCT_STAT_ST_ATIMENSEC - t.tv_nsec = st->stat.st_mtimensec; -# elif defined HAVE_STRUCT_STAT_ST_SPARE1 - t.tv_nsec = st->stat.st_spare1 * 1000; -# else - t.tv_nsec = 0; -# endif - return t; -#endif -} - -static inline void -set_stat_atime (struct stat *st, struct timespec t) -{ -#if defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC - st->st_atim = t; -#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC - st->st_atimespec = t; -#else - st->st_atime = t.tv_sec; -# if defined HAVE_STRUCT_STAT_ST_ATIMENSEC - st->stat.st_atimensec = t.tv_nsec; -# elif defined HAVE_STRUCT_STAT_ST_SPARE1 - st->stat.st_spare1 = t.tv_nsec / 1000; -# endif -#endif -} - -static inline void -set_stat_ctime (struct stat *st, struct timespec t) -{ -#if defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC - st->st_ctim = t; -#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC - st->st_ctimespec = t; -#else - st->st_ctime = t.tv_sec; -# if defined HAVE_STRUCT_STAT_ST_ATIMENSEC - st->stat.st_ctimensec = t.tv_nsec; -# elif defined HAVE_STRUCT_STAT_ST_SPARE1 - st->stat.st_spare1 = t.tv_nsec / 1000; -# endif -#endif -} - -static inline void -set_stat_mtime (struct stat *st, struct timespec t) -{ -#if defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC - st->st_mtim = t; -#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC - st->st_mtimespec = t; -#else - st->st_mtime = t.tv_sec; -# if defined HAVE_STRUCT_STAT_ST_ATIMENSEC - st->stat.st_mtimensec = t.tv_nsec; -# elif defined HAVE_STRUCT_STAT_ST_SPARE1 - st->stat.st_spare1 = t.tv_nsec / 1000; -# endif -#endif -} diff --git a/src/extract.c b/src/extract.c index d835813..80f2f9c 100644 --- a/src/extract.c +++ b/src/extract.c @@ -200,11 +200,11 @@ check_time (char const *file_name, struct timespec t) if (t.tv_sec <= 0) WARN ((0, 0, _("%s: implausibly old time stamp %s"), file_name, tartime (t, true))); - else if (timespec_lt (start_time, t)) + else if (timespec_cmp (start_time, t) < 0) { struct timespec now; gettime (&now); - if (timespec_lt (now, t)) + if (timespec_cmp (now, t) < 0) { unsigned long int ds = t.tv_sec - now.tv_sec; int dns = t.tv_nsec - now.tv_nsec;