diff --git a/CHANGES b/CHANGES index d57e5ef08e..b33425796c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +4361. [cleanup] Where supported, file modification times returned + by isc_file_getmodtime() are now accurate to the + nanosecond. [RT #41968] + 4360. [bug] Silence spurious 'bad key type' message when there is a existing TSIG key. [RT #42195] diff --git a/configure b/configure index b886de4e27..c7f362bce1 100755 --- a/configure +++ b/configure @@ -722,6 +722,7 @@ IRS_PLATFORM_USEDECLSPEC LWRES_PLATFORM_USEDECLSPEC ISC_PLATFORM_USEDECLSPEC ISC_PLATFORM_RLIMITTYPE +ISC_PLATFORM_HAVESTATNSEC ISC_PLATFORM_HAVESYSUNH LWRES_PLATFORM_QUADFORMAT ISC_PLATFORM_QUADFORMAT @@ -19096,6 +19097,34 @@ $as_echo "#define NEED_OPTARG 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# +# Check for nanoseconds in file stats +# +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking st_mtim.tv_nsec" >&5 +$as_echo_n "checking st_mtim.tv_nsec... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +struct stat s; return(s.st_mtim.tv_nsec); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + ISC_PLATFORM_HAVESTATNSEC="#define ISC_PLATFORM_HAVESTATNSEC 1" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ISC_PLATFORM_HAVESTATNSEC="#undef ISC_PLATFORM_HAVESTATNSEC" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + # # BSD/OS, and perhaps some others, don't define rlim_t. # diff --git a/configure.in b/configure.in index 2799501fc8..70e2097390 100644 --- a/configure.in +++ b/configure.in @@ -3485,6 +3485,17 @@ AC_TRY_COMPILE([ GEN_NEED_OPTARG="-DNEED_OPTARG=1" AC_DEFINE(NEED_OPTARG, 1, [Defined if extern char *optarg is not declared.])]) +# +# Check for nanoseconds in file stats +# +AC_MSG_CHECKING(st_mtim.tv_nsec) +AC_TRY_COMPILE([#include ],[struct stat s; return(s.st_mtim.tv_nsec);], + [AC_MSG_RESULT(yes) + ISC_PLATFORM_HAVESTATNSEC="#define ISC_PLATFORM_HAVESTATNSEC 1"], + [AC_MSG_RESULT(no) + ISC_PLATFORM_HAVESTATNSEC="#undef ISC_PLATFORM_HAVESTATNSEC"]) +AC_SUBST(ISC_PLATFORM_HAVESTATNSEC) + # # BSD/OS, and perhaps some others, don't define rlim_t. # diff --git a/lib/isc/include/isc/platform.h.in b/lib/isc/include/isc/platform.h.in index 2c6e2a51ac..99d08ba514 100644 --- a/lib/isc/include/isc/platform.h.in +++ b/lib/isc/include/isc/platform.h.in @@ -249,6 +249,11 @@ */ @ISC_PLATFORM_KRB5HEADER@ +/* + * Define if the system has nanosecond-level accuracy in file stats. + */ +@ISC_PLATFORM_HAVESTATNSEC@ + /* * Type used for resource limits. */ diff --git a/lib/isc/unix/file.c b/lib/isc/unix/file.c index 1f51d001fa..1013cb5d86 100644 --- a/lib/isc/unix/file.c +++ b/lib/isc/unix/file.c @@ -149,11 +149,11 @@ isc_file_getmodtime(const char *file, isc_time_t *modtime) { result = file_stats(file, &stats); if (result == ISC_R_SUCCESS) - /* - * XXXDCL some operating systems provide nanoseconds, too, - * such as BSD/OS via st_mtimespec. - */ +#ifdef ISC_PLATFORM_HAVESTATNSEC + isc_time_set(modtime, stats.st_mtime, stats.st_mtim.tv_nsec); +#else isc_time_set(modtime, stats.st_mtime, 0); +#endif return (result); }