delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1999/08/13/18:26:58

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-developers-unsubscribe-archive-cygwin-developers=delorie DOT com AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-developers-help AT sourceware DOT cygnus DOT com>,
<http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com
Message-ID: <37B49BBB.CD2A1D9A@vinschen.de>
Date: Sat, 14 Aug 1999 00:27:07 +0200
From: Corinna Vinschen <corinna AT vinschen DOT de>
X-Mailer: Mozilla 4.6 [en] (WinNT; I)
X-Accept-Language: de,en
MIME-Version: 1.0
To: Chris Faylor <cgf AT cygnus DOT com>
CC: cygdev <cygwin-developers AT sourceware DOT cygnus DOT com>
Subject: Patch: error in fhandler_base read/write code

This is a multi-part message in MIME format.
--------------135B1228C4B1FF425F549C08
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

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 AT vinschen DOT 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.
--------------135B1228C4B1FF425F549C08
Content-Type: text/plain; charset=us-ascii;
 name="rw-patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="rw-patch"

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)


--------------135B1228C4B1FF425F549C08--


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019