[Patch]: Truncate

Pierre A. Humblet pierre@phumblet.no-ip.org
Sat Aug 21 22:40:00 GMT 2004


This fixes ftruncate64 on 9x.
It now passes all truncate tests in the testsuite.

Pierre

2004-08-22  Pierre Humblet <pierre.humblet@ieee.org>

	* syscalls.cc (ftruncate64): On 9x, call write with a zero length
	to zero fill when the file is extended.

Index: syscalls.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/syscalls.cc,v
retrieving revision 1.342
diff -u -p -r1.342 syscalls.cc
--- syscalls.cc 3 Aug 2004 14:37:26 -0000       1.342
+++ syscalls.cc 21 Aug 2004 22:28:28 -0000
@@ -1692,6 +1692,9 @@ ftruncate64 (int fd, _off64_t length)
              _off64_t prev_loc = cfd->lseek (0, SEEK_CUR);
 
              cfd->lseek (length, SEEK_SET);
+             /* Fill the space with 0, if needed */
+             if (wincap.has_lseek_bug ())
+               cfd->write (&res, 0);
              if (!SetEndOfFile (h))
                __seterrno ();
              else



More information about the Cygwin-patches mailing list