diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2010-10-07 18:03:26 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2010-10-07 18:03:26 +0400 |
commit | dd0821e345930f91ab6984a442950d51bb6c9b4c (patch) | |
tree | c3ca7aca3de5cdee9e43b0731e0d1f8e473c1dca /winsup/cygwin/fhandler_disk_file.cc | |
parent | ca11a4f34f763483b1f18b6e7147272af9f8f697 (diff) |
* fhandler.h (fhandler_base::get_stat_access): Delete.
* fhandler_disk_file.cc (fhandler_base::fstat_helper): Always check
executable suffix to get x-bits for .exe files also in notexec case.
Always reopen file when checking for file header.
* ntdll.h (wait_pending): Delete.
* path.cc (symlink_info::check_shortcut): Drop call to wait_pending
since file is always opened for sync IO.
(symlink_info::check_sysfile): Ditto.
(MIN_STAT_ACCESS): Remove.
(FULL_STAT_ACCESS): Remove.
(symlink_info::check): Drop access flag. Revert to open file with
just read attributes access. Reorder symlink check to check for
reparse points first. Don't check reparse points for anything else,
even on remote drives. Open file for GENERIC_READ when trying to
read shortcuts or system-bit symlinks. Accommodate dropped access
flag in call to path_conv_handle::set.
* path.h (class path_conv_handle): Drop access flag and accommodate
all related methods.
Diffstat (limited to 'winsup/cygwin/fhandler_disk_file.cc')
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 13ed5ed5e..aea62a1b2 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -591,7 +591,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf, { buf->st_mode |= S_IFREG; /* Check suffix for executable file. */ - if (pc.exec_state () == dont_know_if_executable) + if (pc.exec_state () != is_executable) { PUNICODE_STRING path = pc.get_nt_native_path (); @@ -604,34 +604,28 @@ fhandler_base::fstat_helper (struct __stat64 *buf, shebang scripts. */ if (pc.exec_state () == dont_know_if_executable) { - LARGE_INTEGER off = { QuadPart:0LL }; - char magic[3]; + OBJECT_ATTRIBUTES attr; NTSTATUS status = 0; IO_STATUS_BLOCK io; - bool opened = false; - if (h == get_handle ()) - { - /* We have been opened via fstat. We have to re-open the - file. Either the file is not opened for reading, or the - read will change the file position. */ - OBJECT_ATTRIBUTES attr; - pc.init_reopen_attr (&attr, h); - status = NtOpenFile (&h, SYNCHRONIZE | FILE_READ_DATA, - &attr, &io, FILE_SHARE_VALID_FLAGS, - FILE_OPEN_FOR_BACKUP_INTENT - | FILE_OPEN_REPARSE_POINT); - if (!NT_SUCCESS (status)) - debug_printf ("%p = NtOpenFile(%S)", status, - pc.get_nt_native_path ()); - else - opened = true; - } - if (NT_SUCCESS (status)) + /* We have to re-open the file. Either the file is not opened + for reading, or the read will change the file position of the + original handle. */ + pc.init_reopen_attr (&attr, h); + status = NtOpenFile (&h, SYNCHRONIZE | FILE_READ_DATA, + &attr, &io, FILE_SHARE_VALID_FLAGS, + FILE_OPEN_FOR_BACKUP_INTENT + | FILE_SYNCHRONOUS_IO_NONALERT); + if (!NT_SUCCESS (status)) + debug_printf ("%p = NtOpenFile(%S)", status, + pc.get_nt_native_path ()); + else { + LARGE_INTEGER off = { QuadPart:0LL }; + char magic[3]; + status = NtReadFile (h, NULL, NULL, NULL, &io, magic, 3, &off, NULL); - status = wait_pending (status, h, io); if (!NT_SUCCESS (status)) debug_printf ("%p = NtReadFile(%S)", status, pc.get_nt_native_path ()); @@ -641,9 +635,8 @@ fhandler_base::fstat_helper (struct __stat64 *buf, pc.set_exec (); buf->st_mode |= STD_XBITS; } + NtClose (h); } - if (opened) - NtClose (h); } } if (pc.exec_state () == is_executable) |