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:
authorCorinna Vinschen <corinna@vinschen.de>2001-08-15 14:48:43 +0400
committerCorinna Vinschen <corinna@vinschen.de>2001-08-15 14:48:43 +0400
commit91a1423a877aa2464b290cc42f362ffa6f46d434 (patch)
tree93398755d22f93b7276d6018f029c60b5f396593 /winsup/cygwin/times.cc
parent2a9366ff49627dc65e265c14485d892c9352e256 (diff)
* times.cc (utimes): Revert previous change. Just open the
file using FILE_WRITE_ATTRIBUTES instead of GENERIC_WRITE on NT/W2K.
Diffstat (limited to 'winsup/cygwin/times.cc')
-rw-r--r--winsup/cygwin/times.cc36
1 files changed, 4 insertions, 32 deletions
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index 29327e213..860cc55b4 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -449,8 +449,6 @@ utimes (const char *path, struct timeval *tvp)
int res = 0;
struct timeval tmp[2];
path_conv win32 (path);
- PSECURITY_DESCRIPTOR sd = NULL;
- DWORD sd_size;
if (win32.error)
{
@@ -461,8 +459,10 @@ utimes (const char *path, struct timeval *tvp)
/* MSDN suggests using FILE_FLAG_BACKUP_SEMANTICS for accessing
the times of directories. FIXME: what about Win95??? */
+ /* Note: It's not documented in MSDN that FILE_WRITE_ATTRIBUTES is
+ sufficient to change the timestamps... */
HANDLE h = CreateFileA (win32.get_win32 (),
- GENERIC_WRITE,
+ iswinnt ? FILE_WRITE_ATTRIBUTES : GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
&sec_none_nih,
OPEN_EXISTING,
@@ -477,38 +477,13 @@ utimes (const char *path, struct timeval *tvp)
/* What we can do with directories more? */
res = 0;
}
- else if (allow_ntsec && win32.has_acls ())
- {
- /* The following hack allows setting the correct filetime
- on NTFS with ntsec ON even when the file is R/O for the
- current user. This solves the `cp -p' problem and allows
- a more UNIX like behaviour. Basically we save the file's
- current security descriptor, change the file access so
- that we have write access (if possible) and if that worked
- fine, reset the old security descriptor at the end of the
- function. */
- sd_size = 4096;
- sd = (PSECURITY_DESCRIPTOR) alloca (sd_size);
- if (read_sd (win32.get_win32 (), sd, &sd_size) <= 0)
- sd = NULL;
- else if (set_file_attribute (TRUE, win32.get_win32 (), 0600))
- sd = NULL;
- else
- h = CreateFileA (win32.get_win32 (),
- GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- &sec_none_nih,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
- 0);
- }
else
{
res = -1;
__seterrno ();
}
}
- if (h != INVALID_HANDLE_VALUE)
+ else
{
if (tvp == 0)
{
@@ -544,9 +519,6 @@ utimes (const char *path, struct timeval *tvp)
CloseHandle (h);
}
- if (sd)
- write_sd (win32.get_win32 (), sd, sd_size);
-
syscall_printf ("%d = utimes (%s, %x); (h%d)",
res, path, tvp, h);
return res;