diff options
author | Christopher Faylor <me@cgf.cx> | 2000-11-26 21:45:16 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-11-26 21:45:16 +0000 |
commit | fe1c7fe7a6f2a3e422c1185e3126208ce48d434b (patch) | |
tree | 5b0c94bce2af40c9ebd7fdea04de45612267e638 | |
parent | e0cdea91fe6d67230cb9f2f624c9e39865dbeca1 (diff) | |
download | cygnal-fe1c7fe7a6f2a3e422c1185e3126208ce48d434b.tar.gz cygnal-fe1c7fe7a6f2a3e422c1185e3126208ce48d434b.tar.bz2 cygnal-fe1c7fe7a6f2a3e422c1185e3126208ce48d434b.zip |
* fhandler.cc (is_at_eof): New function.
(fhandler_base::raw_read): Detect special case where last error ==
ERROR_NOACCESS but the file is at EOF. Most UNIXes do not consider this to be
an error.
-rw-r--r-- | winsup/cygwin/ChangeLog | 7 | ||||
-rw-r--r-- | winsup/cygwin/fhandler.cc | 23 |
2 files changed, 30 insertions, 0 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 09e157310..5e272dd43 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +Sun Nov 26 16:26:14 2000 Christopher Faylor <cgf@cygnus.com> + + * fhandler.cc (is_at_eof): New function. + (fhandler_base::raw_read): Detect special case where last error == + ERROR_NOACCESS but the file is at EOF. Most UNIXes do not consider + this to be an error. + Sun Nov 26 14:37:29 2000 Christopher Faylor <cgf@cygnus.com> * include/cygwin/version.h: Bump DLL minor version number to 7. diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 3efd81efb..ed0ebb42f 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -186,6 +186,26 @@ fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit } } +/* Detect if we are sitting at EOF for conditions where Windows + returns an error but UNIX doesn't. */ +static int __stdcall +is_at_eof (HANDLE h, DWORD err) +{ + DWORD size, upper1, curr; + + size = GetFileSize (h, &upper1); + if (upper1 != 0xffffffff || GetLastError () == NO_ERROR) + { + LONG upper2 = 0; + curr = SetFilePointer (h, 0, &upper2, FILE_CURRENT); + if (curr == size && upper1 == (DWORD) upper2) + return 1; + } + + SetLastError (err); + return 0; +} + /* Normal file i/o handlers. */ /* Cover function to ReadFile to achieve (as much as possible) Posix style @@ -211,6 +231,9 @@ fhandler_base::raw_read (void *ptr, size_t ulen) case ERROR_MORE_DATA: /* `bytes_read' is supposedly valid. */ break; + case ERROR_NOACCESS: + if (is_at_eof (get_handle (), errcode)) + return 0; default: syscall_printf ("ReadFile %s failed, %E", unix_path_name_); __seterrno_from_win_error (errcode); |