Commit b602bf9e authored by Danny Mayer's avatar Danny Mayer

RT #1667. File modification dates were wrong due to the isc_time_set routine...

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
parent e2a35f75
......@@ -15,7 +15,7 @@
* 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>
......@@ -220,33 +220,34 @@ isc_file_getmodtime(const char *file, isc_time_t *time) {
isc_result_t
isc_file_settime(const char *file, isc_time_t *time) {
struct utimbuf timem;
int fh;
REQUIRE(file != NULL && time != NULL);
/*
* tv_sec is at least a 32 bit quantity on all platforms we're
* 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);
/*
* 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);
// updtime.absolute.dwLowDateTime = time->absolute.dwLowDateTime;
// updtime.absolute.dwHighDateTime = time->absolute.dwHighDateTime;
if (utime(file, &timem) < 0)
if ((fh = open(file, _O_RDWR | _O_BINARY)) < 0)
return (isc__errno2result(errno));
return (ISC_R_SUCCESS);
/* 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);
}
......
......@@ -15,7 +15,7 @@
* 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
......@@ -108,8 +108,10 @@ isc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds) {
i.QuadPart = (LONGLONG)seconds * INTERVALS_PER_S
+ nanoseconds / NS_INTERVAL;
t->absolute.dwLowDateTime = i.LowPart;
t->absolute.dwHighDateTime = i.HighPart;
t->absolute.dwLowDateTime = i.LowPart
+ epoch.absolute.dwLowDateTime;
t->absolute.dwHighDateTime = i.HighPart
+ epoch.absolute.dwHighDateTime;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment