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
path: root/winsup
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
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')
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc32
-rw-r--r--winsup/cygwin/times.cc31
3 files changed, 51 insertions, 19 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 22410fa22..2314db392 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,12 @@
2005-10-19 Christopher Faylor <cgf@timesys.com>
+ * 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.
+
+2005-10-19 Christopher Faylor <cgf@timesys.com>
+
* pinfo.cc (_pinfo::dup_proc_pipe): Make warning more severe by
actually printing it.
(_pinfo::alert_parent): Fix comment. Don't send to parent if we are in
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;
}
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index 851139c32..cc4de9746 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -22,6 +22,7 @@ details. */
#include "path.h"
#include "fhandler.h"
#include "dtable.h"
+#include "cygheap.h"
#include "pinfo.h"
#include "hires.h"
#include "cygtls.h"
@@ -445,21 +446,37 @@ extern "C" int
utimes (const char *path, const struct timeval *tvp)
{
int res = -1;
- fhandler_base *fh;
+ path_conv win32 (path, PC_SYM_FOLLOW);
+ fhandler_base *fh = NULL;
+ bool fromfd = false;
- if (!(fh = build_fh_name (path, NULL, PC_SYM_FOLLOW)))
- goto error;
+ cygheap_fdenum cfd;
+ while (cfd.next () >= 0)
+ if (strcmp (cfd->get_win32_name (), win32) == 0)
+ {
+ fh = cfd;
+ fromfd = true;
+ break;
+ }
+
+ if (!fh)
+ {
+ if (!(fh = build_fh_name (path, NULL, PC_SYM_FOLLOW)))
+ goto error;
if (fh->error ())
{
debug_printf ("got %d error from build_fh_name", fh->error ());
set_errno (fh->error ());
}
- else
- res = fh->utimes (tvp);
+ }
+
+ res = fh->utimes (tvp);
+
+ if (!fromfd)
+ delete fh;
- delete fh;
- error:
+error:
syscall_printf ("%d = utimes (%s, %p)", res, path, tvp);
return res;
}