This is the mail archive of the cygwin-developers@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch: error in fhandler_base read/write code


Hi!

I have found two errors in fhandler code:
- In case of an error fhandler_base::raw_read always returns the error
  code EACCES.
- fhandler_base::raw_write always returns bytes_written if the windows
  error is ERROR_DISK_FULL. This results in an endless loop e.g. in
  cp command if bytes_written is 0.

While changing the above behaviour I found that ERROR_DISK_FULL is
not handled by errno.cc.

Regards,
Corinna


ChangeLog:
==========

Sat Aug 14 0:10:00  Corinna Vinschen  <corinna@vinschen.de>

	* fhandler.cc (fhandler_base::raw_read): `set_errno (EACCES)'
	replaced with `__seterrno_from_win_error (errcode)'.
	(fhandler_base::raw_write): In case of ERROR_DISK_FULL, return
	bytes_written only if bytes_written > 0.
	* errno.cc: Map ERROR_DISK_FULL to ENOSPC.
Index: errno.cc
===================================================================
RCS file: /src/cvsroot/winsup-990808/errno.cc,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 errno.cc
--- errno.cc	1999/08/09 10:50:55	1.1.1.1
+++ errno.cc	1999/08/13 22:05:10
@@ -102,6 +102,7 @@ errmap[] =
   X (CRC,                       EIO),
   X (NEGATIVE_SEEK,             EINVAL),
   X (NOT_READY,                 ENOMEDIUM),
+  X (DISK_FULL,		        ENOSPC),
   { 0, NULL, 0}
 };
 
Index: fhandler.cc
===================================================================
RCS file: /src/cvsroot/winsup-990808/fhandler.cc,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 fhandler.cc
--- fhandler.cc	1999/08/09 10:50:55	1.1.1.1
+++ fhandler.cc	1999/08/13 22:09:15
@@ -218,7 +218,7 @@ fhandler_base::raw_read (void *ptr, size
 	  break;
 	default:
 	  syscall_printf ("ReadFile %s failed, %E", unix_path_name_);
-	  set_errno (EACCES);
+          __seterrno_from_win_error (errcode);
 	  return -1;
 	  break;
 	}
@@ -267,7 +267,8 @@ fhandler_base::raw_write (const void *pt
 
   if (!WriteFile (get_handle(), ptr, len, &bytes_written, 0))
     {
-      if (GetLastError () == ERROR_DISK_FULL)
+      if (GetLastError () == ERROR_DISK_FULL
+          && bytes_written > 0)
 	return bytes_written;
       __seterrno ();
       if (get_errno () == EPIPE)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]