Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-10-19 20:50:43 +0400
committerChristopher Faylor <me@cgf.cx>2005-10-19 20:50:43 +0400
commit5a90915d415cf179e91e8ee9a73c3640015a64af (patch)
tree655c51848a1e061aec2add477e38eec04d676af0 /winsup/cygwin/fhandler_disk_file.cc
parentb3982520d36f3aedbd579bfe5a9eb208c4943923 (diff)
* fhandler_disk_file.cc (fhandler_base::utimes_fs): Use existing handle if
fhandler has one. * times.cc (utimes): Scan open fds for matching paths and use existing fhandler if one exists.
Diffstat (limited to 'winsup/cygwin/fhandler_disk_file.cc')
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc32
1 files changed, 20 insertions, 12 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 48904788e..9f30b562f 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -865,20 +865,27 @@ fhandler_base::utimes_fs (const struct timeval *tvp)
{
FILETIME lastaccess, lastwrite;
struct timeval tmp[2];
+ bool closeit;
- query_open (query_write_attributes);
- if (!open_fs (O_BINARY, 0))
- {
- /* It's documented in MSDN that FILE_WRITE_ATTRIBUTES is sufficient
- to change the timestamps. Unfortunately it's not sufficient for a
- remote HPFS which requires GENERIC_WRITE, so we just retry to open
- for writing, though this fails for R/O files of course. */
- query_open (no_query);
- if (!open_fs (O_WRONLY | O_BINARY, 0))
+ if (get_handle ())
+ closeit = false;
+ else
+ {
+ query_open (query_write_attributes);
+ if (!open_fs (O_BINARY, 0))
{
- syscall_printf ("Opening file failed");
- return -1;
+ /* It's documented in MSDN that FILE_WRITE_ATTRIBUTES is sufficient
+ to change the timestamps. Unfortunately it's not sufficient for a
+ remote HPFS which requires GENERIC_WRITE, so we just retry to open
+ for writing, though this fails for R/O files of course. */
+ query_open (no_query);
+ if (!open_fs (O_WRONLY | O_BINARY, 0))
+ {
+ syscall_printf ("Opening file failed");
+ return -1;
+ }
}
+ closeit = true;
}
if (nohandle ()) /* Directory query_open on 9x. */
@@ -909,7 +916,8 @@ fhandler_base::utimes_fs (const struct timeval *tvp)
return -1;
}
- close ();
+ if (closeit)
+ close ();
return 0;
}