diff options
author | Christopher Faylor <me@cgf.cx> | 2002-10-23 00:41:31 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-10-23 00:41:31 +0400 |
commit | 7dcbb978e046f65c6933b7c0eee6055a0e2bb4fa (patch) | |
tree | 70cf82013ec6d9d97eee29daada8c258a9ad302c /winsup | |
parent | d525130f0403aff59eca72693d9a15648741e88e (diff) |
* fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Always consider
.exe files and '#!' shell scripts to be executable.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 55 |
2 files changed, 34 insertions, 26 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index dd05d4a8b..b0435288d 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,10 @@ 2002-10-22 Christopher Faylor <cgf@redhat.com> + * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Always + consider .exe files and '#!' shell scripts to be executable. + +2002-10-22 Christopher Faylor <cgf@redhat.com> + * cygthread.cc (cygthread::exiting): New variable. (cygthread::initialized): Delete. (cygthread::stub): Use exiting variable to determine when to exit. diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index f8a7afca1..85b8b3463 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -300,35 +300,38 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc, else { buf->st_mode |= S_IFREG; - if (pc->exec_state () == dont_know_if_executable) - { - DWORD cur, done; - char magic[3]; - - /* First retrieve current position, set to beginning - of file if not already there. */ - cur = SetFilePointer (get_handle (), 0, NULL, FILE_CURRENT); - if (cur != INVALID_SET_FILE_POINTER && - (!cur || - SetFilePointer (get_handle (), 0, NULL, FILE_BEGIN) - != INVALID_SET_FILE_POINTER)) - { - /* FIXME should we use /etc/magic ? */ - magic[0] = magic[1] = magic[2] = '\0'; - if (ReadFile (get_handle (), magic, 3, &done, NULL) && - has_exec_chars (magic, done)) - { - set_execable_p (); - pc->set_exec (); - } - SetFilePointer (get_handle (), cur, NULL, FILE_BEGIN); - } - } - if (pc->exec_state () == is_executable) - buf->st_mode |= STD_XBITS; } } + if (buf->st_mode & STD_XBITS) + /* already derived */; + else if (pc->exec_state () == is_executable) + buf->st_mode |= STD_XBITS; + else if (pc->exec_state () == dont_know_if_executable) + { + DWORD cur, done; + char magic[3]; + + /* First retrieve current position, set to beginning + of file if not already there. */ + cur = SetFilePointer (get_handle (), 0, NULL, FILE_CURRENT); + if (cur != INVALID_SET_FILE_POINTER + && (!cur || SetFilePointer (get_handle (), 0, NULL, FILE_BEGIN) + != INVALID_SET_FILE_POINTER)) + { + /* FIXME should we use /etc/magic ? */ + magic[0] = magic[1] = magic[2] = '\0'; + if (ReadFile (get_handle (), magic, 3, &done, NULL) && + has_exec_chars (magic, done)) + { + set_execable_p (); + pc->set_exec (); + buf->st_mode |= STD_XBITS; + } + SetFilePointer (get_handle (), cur, NULL, FILE_BEGIN); + } + } + buf->st_uid = uid; buf->st_gid = gid; |