diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2008-04-24 09:59:54 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2008-04-24 09:59:54 +0000 |
commit | eba32ec829904a40f34808374a1c53415ef7bc0b (patch) | |
tree | 9b345ab8c40ce458d77f73de9a693177a89ccbfa /winsup/cygwin/fhandler_disk_file.cc | |
parent | 0d02384a4892d1419ca12125beaf155d2af7d720 (diff) | |
download | cygnal-eba32ec829904a40f34808374a1c53415ef7bc0b.tar.gz cygnal-eba32ec829904a40f34808374a1c53415ef7bc0b.tar.bz2 cygnal-eba32ec829904a40f34808374a1c53415ef7bc0b.zip |
* cygwin.din (futimens): Export.
(utimensat): Export.
* fhandler.cc (fhandler_base::utimens): Replace fhandler_base::utimes.
Call utimens_fs.
* fhandler.h (class fhandler_base): Declare utimens_fs instead of
utimes_fs, utimens instead of utimes.
(class fhandler_disk_file): Declare utimens instead of utimes.
* fhandler_disk_file.cc (fhandler_disk_file::utimens): Replace
fhandler_disk_file::utimes.
(fhandler_base::utimens_fs): Replace fhandler_base::utimes_fs.
Implement tv_nsec handling according to SUSv4.
* syscalls.cc (utimensat): New function.
* times.cc (timespec_to_filetime): New function.
(timeval_to_timespec): New function.
(utimens_worker): Replace utimes_worker.
(utimes): Convert timeval to timespec and call utimens_worker.
(lutimes): Ditto.
(futimens): Take over implementation from futimes.
(futimes): Convert timeval to timespec and call futimens.
* winsup.h (timespec_to_filetime): Declare.
* include/cygwin/version.h: Bump API minor number.
* posix.sgml: Add SUSv4 section. Add futimens and utimensat to it.
Diffstat (limited to 'winsup/cygwin/fhandler_disk_file.cc')
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 4f81bf764..dabee7beb 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -1149,16 +1149,17 @@ fhandler_disk_file::link (const char *newpath) } int -fhandler_disk_file::utimes (const struct timeval *tvp) +fhandler_disk_file::utimens (const struct timespec *tvp) { - return utimes_fs (tvp); + return utimens_fs (tvp); } int -fhandler_base::utimes_fs (const struct timeval *tvp) +fhandler_base::utimens_fs (const struct timespec *tvp) { LARGE_INTEGER lastaccess, lastwrite; - struct timeval tmp[2]; + struct timespec timeofday; + struct timespec tmp[2]; bool closeit = false; if (!get_handle ()) @@ -1180,15 +1181,25 @@ fhandler_base::utimes_fs (const struct timeval *tvp) closeit = true; } - gettimeofday (&tmp[0], 0); + gettimeofday (reinterpret_cast<struct timeval *> (&timeofday), 0); + timeofday.tv_nsec *= 1000; if (!tvp) + tmp[1] = tmp[0] = timeofday; + else { - tmp[1] = tmp[0]; - tvp = tmp; + if ((tmp[0].tv_nsec < UTIME_NOW || tmp[0].tv_nsec > 999999999L) + || (tmp[1].tv_nsec < UTIME_NOW || tmp[1].tv_nsec > 999999999L)) + { + set_errno (EINVAL); + return -1; + } + tmp[0] = (tvp[0].tv_nsec == UTIME_NOW) ? timeofday : tvp[0]; + tmp[1] = (tvp[1].tv_nsec == UTIME_NOW) ? timeofday : tvp[1]; } - timeval_to_filetime (&tvp[0], (FILETIME *) &lastaccess); - timeval_to_filetime (&tvp[1], (FILETIME *) &lastwrite); - debug_printf ("incoming lastaccess %08x %08x", tvp[0].tv_sec, tvp[0].tv_usec); + /* UTIME_OMIT is handled in timespec_to_filetime by setting FILETIME to 0. */ + timespec_to_filetime (&tmp[0], (FILETIME *) &lastaccess); + timespec_to_filetime (&tmp[1], (FILETIME *) &lastwrite); + debug_printf ("incoming lastaccess %08x %08x", tmp[0].tv_sec, tmp[0].tv_nsec); IO_STATUS_BLOCK io; FILE_BASIC_INFORMATION fbi; |