From 71582643154db08638ba549a389d2dec6eb7c790 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 14 Nov 2001 21:47:41 +0000 Subject: [PATCH] * fhandler.cc (fhandler_disk_file::fstat): Add setting access time and creation time to last modification time for files on filesystems not supporting multiple timestamps. (fhandler_disk_file::fstat_helper): Set access time and creation time in incoming Windows structure instead of in stat buf to avoid incorrectly overwriting Epoch timestamp. --- winsup/cygwin/ChangeLog | 9 +++++++++ winsup/cygwin/fhandler.cc | 22 ++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7a6b73ff4..61a68933b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2001-11-14 Corinna Vinschen + + * fhandler.cc (fhandler_disk_file::fstat): Add setting access time + and creation time to last modification time for files on filesystems + not supporting multiple timestamps. + (fhandler_disk_file::fstat_helper): Set access time and creation + time in incoming Windows structure instead of in stat buf to avoid + incorrectly overwriting Epoch timestamp. + 2001-11-14 Corinna Vinschen * winsup.h: Remove alloca definition since it's now defined through diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 9a177bd6e..7ccf0dde3 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1001,6 +1001,14 @@ fhandler_disk_file::fstat (struct stat *buf, path_conv *pc) if ((handle = FindFirstFile (pc->get_win32 (), &wfd)) != INVALID_HANDLE_VALUE) { + /* This is for FAT filesystems, which don't support atime/ctime */ + if (wfd.ftLastAccessTime.dwLowDateTime == 0 + && wfd.ftLastAccessTime.dwHighDateTime == 0) + wfd.ftLastAccessTime = wfd.ftLastWriteTime; + if (wfd.ftCreationTime.dwLowDateTime == 0 + && wfd.ftCreationTime.dwHighDateTime == 0) + wfd.ftCreationTime = wfd.ftLastWriteTime; + buf->st_atime = to_time_t (&wfd.ftLastAccessTime); buf->st_mtime = to_time_t (&wfd.ftLastWriteTime); buf->st_ctime = to_time_t (&wfd.ftCreationTime); @@ -1062,6 +1070,14 @@ fhandler_disk_file::fstat_helper (struct stat *buf) return -1; } + /* This is for FAT filesystems, which don't support atime/ctime */ + if (local.ftLastAccessTime.dwLowDateTime == 0 + && local.ftLastAccessTime.dwHighDateTime == 0) + local.ftLastAccessTime = local.ftLastWriteTime; + if (local.ftCreationTime.dwLowDateTime == 0 + && local.ftCreationTime.dwHighDateTime == 0) + local.ftCreationTime = local.ftLastWriteTime; + buf->st_atime = to_time_t (&local.ftLastAccessTime); buf->st_mtime = to_time_t (&local.ftLastWriteTime); buf->st_ctime = to_time_t (&local.ftCreationTime); @@ -1069,12 +1085,6 @@ fhandler_disk_file::fstat_helper (struct stat *buf) buf->st_dev = local.dwVolumeSerialNumber; buf->st_size = local.nFileSizeLow; - /* This is for FAT filesystems, which don't support atime/ctime */ - if (buf->st_atime == 0) - buf->st_atime = buf->st_mtime; - if (buf->st_ctime == 0) - buf->st_ctime = buf->st_mtime; - /* Allocate some place to determine the root directory. Need to allocate enough so that rootdir can add a trailing slash if path starts with \\. */ char root[strlen (get_win32_name ()) + 3]; -- 2.43.5