mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 15:45:25 +00:00
RT #1667. File modification dates were wrong due to the isc_time_set routine not adding back the epoch to give the absolute Windows time and isc_file_settime not correctly making the right calls to modify the file date
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: file.c,v 1.20 2001/07/17 20:29:26 gson Exp $ */
|
/* $Id: file.c,v 1.21 2001/08/30 04:31:30 mayer Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -220,32 +220,33 @@ isc_file_getmodtime(const char *file, isc_time_t *time) {
|
|||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
isc_file_settime(const char *file, isc_time_t *time) {
|
isc_file_settime(const char *file, isc_time_t *time) {
|
||||||
struct utimbuf timem;
|
int fh;
|
||||||
|
|
||||||
REQUIRE(file != NULL && time != NULL);
|
REQUIRE(file != NULL && time != NULL);
|
||||||
|
|
||||||
/*
|
// updtime.absolute.dwLowDateTime = time->absolute.dwLowDateTime;
|
||||||
* tv_sec is at least a 32 bit quantity on all platforms we're
|
// updtime.absolute.dwHighDateTime = time->absolute.dwHighDateTime;
|
||||||
* dealing with, but it is signed on most (all?) of them,
|
|
||||||
* so we need to make sure the high bit isn't set. This unfortunately
|
|
||||||
* loses when either:
|
|
||||||
* * tv_sec becomes a signed 64 bit integer but long is 32 bits
|
|
||||||
* and isc_time_seconds > LONG_MAX, or
|
|
||||||
* * isc_time_seconds is changed to be > 32 bits but long is 32 bits
|
|
||||||
* and isc_time_seconds has at least 33 significant bits.
|
|
||||||
*/
|
|
||||||
timem.actime = timem.modtime = (long)isc_time_seconds(time);
|
|
||||||
|
|
||||||
/*
|
if ((fh = open(file, _O_RDWR | _O_BINARY)) < 0)
|
||||||
* Here is the real check for the high bit being set.
|
|
||||||
*/
|
|
||||||
if ((timem.actime &
|
|
||||||
(1UL << (sizeof(timem.actime) * CHAR_BIT - 1))) != 0)
|
|
||||||
return (ISC_R_RANGE);
|
|
||||||
|
|
||||||
if (utime(file, &timem) < 0)
|
|
||||||
return (isc__errno2result(errno));
|
return (isc__errno2result(errno));
|
||||||
|
|
||||||
|
/* set the date via the filedate system call and return. failing
|
||||||
|
* this call implies the new file times are not supported by the
|
||||||
|
* underlying file system.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!SetFileTime((HANDLE) _get_osfhandle(fh),
|
||||||
|
NULL,
|
||||||
|
&time->absolute,
|
||||||
|
&time->absolute
|
||||||
|
))
|
||||||
|
{
|
||||||
|
close(fh);
|
||||||
|
errno = EINVAL;
|
||||||
|
return (isc__errno2result(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
close(fh);
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: time.c,v 1.24 2001/08/29 05:13:42 mayer Exp $ */
|
/* $Id: time.c,v 1.25 2001/08/30 04:31:31 mayer Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Windows has a different epoch than Unix. Therefore this code sets the epoch
|
* Windows has a different epoch than Unix. Therefore this code sets the epoch
|
||||||
@@ -108,8 +108,10 @@ isc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds) {
|
|||||||
i.QuadPart = (LONGLONG)seconds * INTERVALS_PER_S
|
i.QuadPart = (LONGLONG)seconds * INTERVALS_PER_S
|
||||||
+ nanoseconds / NS_INTERVAL;
|
+ nanoseconds / NS_INTERVAL;
|
||||||
|
|
||||||
t->absolute.dwLowDateTime = i.LowPart;
|
t->absolute.dwLowDateTime = i.LowPart
|
||||||
t->absolute.dwHighDateTime = i.HighPart;
|
+ epoch.absolute.dwLowDateTime;
|
||||||
|
t->absolute.dwHighDateTime = i.HighPart
|
||||||
|
+ epoch.absolute.dwHighDateTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user