[Patch]: Truncate
Corinna Vinschen
vinschen@redhat.com
Sun Aug 22 15:55:00 GMT 2004
Hi Pierre,
Looks good to me. But wouldn't it be better to fill in the zeros only
if SetEndOfFile succeeded? That would avoid a lengthy write operation
if the application was, say, too optimistic about the space left on disk.
Corinna
On Aug 21 18:36, Pierre A. Humblet wrote:
> 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
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader mailto:cygwin@cygwin.com
Red Hat, Inc.
More information about the Cygwin-patches
mailing list