summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_disk_file.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2007-07-19 17:22:34 +0000
committerCorinna Vinschen <corinna@vinschen.de>2007-07-19 17:22:34 +0000
commite25b3402ac1b18d3c0ccde2faba94b8ad42ad09a (patch)
tree0b9eb53724fcc16ed6365eeb58fb58306c14ac00 /winsup/cygwin/fhandler_disk_file.cc
parent91d2f6eebffcc8aa492b59c99f429aa41d09e82e (diff)
downloadcygnal-e25b3402ac1b18d3c0ccde2faba94b8ad42ad09a.tar.gz
cygnal-e25b3402ac1b18d3c0ccde2faba94b8ad42ad09a.tar.bz2
cygnal-e25b3402ac1b18d3c0ccde2faba94b8ad42ad09a.zip
* fhandler_disk_file.cc (fhandler_base::fstat_by_name): Use
NtQueryFullAttributesFile instead of FindFirstFile. (fhandler_base::fstat_fs): Drop check for exec_state. Drop check for invalid characters. * ntdll.h (struct _FILE_NETWORK_OPEN_INFORMATION): Define. (NtQueryFullAttributesFile): Declare.
Diffstat (limited to 'winsup/cygwin/fhandler_disk_file.cc')
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc51
1 files changed, 22 insertions, 29 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index a2b2bf093..5d37d04d5 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -272,34 +272,35 @@ fhandler_base::fstat_by_handle (struct __stat64 *buf)
int __stdcall
fhandler_base::fstat_by_name (struct __stat64 *buf)
{
- int res;
- HANDLE handle;
- WIN32_FIND_DATA local;
+ int res = -1;
+ NTSTATUS status;
+ OBJECT_ATTRIBUTES attr;
+ FILE_NETWORK_OPEN_INFORMATION fnoi;
if (!pc.exists ())
{
debug_printf ("already determined that pc does not exist");
set_errno (ENOENT);
- res = -1;
}
- else if ((handle = FindFirstFile (pc, &local)) != INVALID_HANDLE_VALUE)
+ else if (NT_SUCCESS (status = NtQueryFullAttributesFile (
+ pc.get_object_attr (attr, sec_none_nih), &fnoi)))
{
- FindClose (handle);
if (pc.is_rep_symlink ())
- local.dwFileAttributes &= ~FILE_ATTRIBUTE_DIRECTORY;
- pc.file_attributes (local.dwFileAttributes);
+ fnoi.FileAttributes &= ~FILE_ATTRIBUTE_DIRECTORY;
+ pc.file_attributes (fnoi.FileAttributes);
res = fstat_helper (buf,
- local.ftLastWriteTime, /* see fstat_helper comment */
- local.ftLastAccessTime,
- local.ftLastWriteTime,
- local.ftCreationTime,
- pc.volser (),
- (ULONGLONG) local.nFileSizeHigh << 32
- | local.nFileSizeLow,
- -1LL,
- 0ULL,
- 1,
- local.dwFileAttributes);
+ *(FILETIME *) (fnoi.ChangeTime.QuadPart
+ ? &fnoi.ChangeTime
+ : &fnoi.LastWriteTime),
+ *(FILETIME *) &fnoi.LastAccessTime,
+ *(FILETIME *) &fnoi.LastWriteTime,
+ *(FILETIME *) &fnoi.CreationTime,
+ pc.volser (),
+ fnoi.EndOfFile.QuadPart,
+ fnoi.AllocationSize.QuadPart,
+ 0ULL,
+ 1,
+ fnoi.FileAttributes);
}
else if (pc.isdir ())
{
@@ -309,8 +310,7 @@ fhandler_base::fstat_by_name (struct __stat64 *buf)
}
else
{
- debug_printf ("FindFirstFile failed for '%s', %E", (char *) pc);
- __seterrno ();
+ __seterrno_from_nt_status (status);
res = -1;
}
return res;
@@ -330,14 +330,7 @@ fhandler_base::fstat_fs (struct __stat64 *buf)
else
return fstat_by_handle (buf);
}
- /* If we don't care if the file is executable or we already know if it is,
- then just do a "query open" as it is apparently much faster. */
- if (pc.exec_state () != dont_know_if_executable)
- {
- if (pc.fs_is_fat () && !strpbrk (get_win32_name (), "?*|<>"))
- return fstat_by_name (buf);
- query_open (query_stat_control);
- }
+ query_open (query_stat_control);
if (!(oret = open_fs (open_flags, 0)) && get_errno () == EACCES)
{
/* If we couldn't open the file, try a query open with no permissions.