diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2010-02-03 19:05:33 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2010-02-03 19:05:33 +0300 |
commit | 4a49c71595bb2cd4656e605b901ea6bd549679a0 (patch) | |
tree | fc0701240f20918aebcd1e021a6a88c84f192620 /winsup/cygwin | |
parent | 8b5c2e99d4726c857fbabcb82557d534a5015989 (diff) |
* fhandler_disk_file.cc (fhandler_base::fstat_helper): Workaround
another bug in NWFS. Add comment to explain why. Improve debug output
in case the NT calls to test for binary fail.
* path.h (path_conv::fs_is_cifs): New method.
(path_conv::fs_is_nwfs): New method.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 8 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 33 | ||||
-rw-r--r-- | winsup/cygwin/path.h | 2 |
3 files changed, 36 insertions, 7 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index c828e9009..9000614d5 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2010-02-03 Corinna Vinschen <corinna@vinschen.de> + + * fhandler_disk_file.cc (fhandler_base::fstat_helper): Workaround + another bug in NWFS. Add comment to explain why. Improve debug output + in case the NT calls to test for binary fail. + * path.h (path_conv::fs_is_cifs): New method. + (path_conv::fs_is_nwfs): New method. + 2010-02-02 Corinna Vinschen <corinna@vinschen.de> * include/paths.h (_PATH_MNTTAB): Define. diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index b98c70357..b6c67b955 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -659,27 +659,46 @@ fhandler_base::fstat_helper (struct __stat64 *buf, if (pc.exec_state () == dont_know_if_executable) { OBJECT_ATTRIBUTES attr; + NTSTATUS status; HANDLE h; IO_STATUS_BLOCK io; - InitializeObjectAttributes (&attr, &ro_u_empty, 0, get_handle (), - NULL); - if (NT_SUCCESS (NtOpenFile (&h, SYNCHRONIZE | FILE_READ_DATA, - &attr, &io, FILE_SHARE_VALID_FLAGS, - FILE_SYNCHRONOUS_IO_NONALERT))) + /* The NWFS implementation is frighteningly incomplete. When + re-opening a file by handle, the subsequent NtReadFile + returns with the weird status STATUS_FILE_IS_A_DIRECTORY. + We're still using the re-open by handle method for all + other filesystems since it's 8-10% faster than opening + by name. */ + if (pc.fs_is_nwfs ()) + InitializeObjectAttributes (&attr, pc.get_nt_native_path (), + OBJ_CASE_INSENSITIVE, NULL, NULL) + else + InitializeObjectAttributes (&attr, &ro_u_empty, 0, + get_handle (), NULL); + status = NtOpenFile (&h, SYNCHRONIZE | FILE_READ_DATA, + &attr, &io, FILE_SHARE_VALID_FLAGS, + FILE_SYNCHRONOUS_IO_NONALERT); + if (NT_SUCCESS (status)) { LARGE_INTEGER off = { QuadPart:0LL }; char magic[3]; - if (NT_SUCCESS (NtReadFile (h, NULL, NULL, NULL, &io, magic, - 3, &off, NULL)) + status = NtReadFile (h, NULL, NULL, NULL, &io, magic, + 3, &off, NULL); + if (NT_SUCCESS (status) && has_exec_chars (magic, io.Information)) { pc.set_exec (); buf->st_mode |= STD_XBITS; } + else + debug_printf ("%p = NtReadFile(%S)", status, + pc.get_nt_native_path ()); NtClose (h); } + else + debug_printf ("%p = NtOpenFile(%S)", status, + pc.get_nt_native_path ()); } } if (pc.exec_state () == is_executable) diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index 18eb494bc..2f583e9e7 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -234,6 +234,8 @@ class path_conv bool fs_is_netapp () const {return fs.is_netapp ();} bool fs_is_cdrom () const {return fs.is_cdrom ();} bool fs_is_mvfs () const {return fs.is_mvfs ();} + bool fs_is_cifs () const {return fs.is_cifs ();} + bool fs_is_nwfs () const {return fs.is_nwfs ();} ULONG fs_serial_number () const {return fs.serial_number ();} inline const char *set_path (const char *p) { |