This is the mail archive of the cygwin-patches@cygwin.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]
Other format: [Raw text]

[Patch]: Truncate


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


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