[Patch]: Truncate

Corinna Vinschen vinschen@redhat.com
Mon Aug 23 11:00:00 GMT 2004


On Aug 22 17:09, Pierre A. Humblet wrote:
> In that case we can't reuse the code already present in ::write
> because when ::write calls GetFileSize it will get the length
> already updated by SetEndOfFile.

That's true.

> The way ::write is written, it will restore the FilePointer at
> the beginning of the 0 filled region if the disk gets full. But

Erm... it restores to current_position, which is the position of the
last lseek.  That's the same position which ftruncate64 would set the
EOF to.

> 2004-08-23  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 22 Aug 2004 21:00:49 -0000
> @@ -1675,7 +1675,7 @@ setmode (int fd, int mode)
> [...]
> +             /* In the lseek_bug case, this may restore the file to
> +                its initial length */

Except for this comment, which isn't valid (see above), please check it in.

>               if (!SetEndOfFile (h))
>                 __seterrno ();
>               else
> -               res = 0;
> +               res = res_bug;
>  
>               /* restore original file pointer location */
>               cfd->lseek (prev_loc, SEEK_SET);

Thanks,
Corinna

-- 
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