This is the mail archive of the
cygwin-talk@cygwin.com
mailing list for the cygwin project.
Re: find prints wrong file size for files >2GB
- From: Yitzchak Scott-Thoennes <sthoenna at efn dot org>
- To: cygwin-talk at cygwin dot com
- Date: Mon, 6 Dec 2004 04:05:15 -0800
- Subject: Re: find prints wrong file size for files >2GB
- Organization: bs"d
- References: <41B43182.9AEE4F96@hot.pl>
- Reply-to: Talk Amongst Yourselves <cygwin-talk at cygwin dot com>
On Mon, Dec 06, 2004 at 11:16:34AM +0100, Jacek Trzmiel wrote:
>
> Win2kSP4+patches, cygwin1.dll 1.5.11, findutils 4.1.7-4
>
> Test case below.
>
>
> $ cat >truncate.c <<EOF
> #include <unistd.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <errno.h>
>
> int main(int argc, char **argv) {
> off_t size;
> char *endptr = argv[2];
>
> if (argc != 3) {
> fprintf(stderr, "usage: truncate path size\n");
> exit(1);
> }
>
> errno = 0;
> size = strtoull(argv[2], &endptr, 10);
> if (!endptr || endptr == argv[2] || *endptr || size < 0 ||
> (size == 0 && errno)) {
> fprintf(stderr, "truncate: invalid size\n");
> exit(1);
> }
> printf("truncating %s to %lld bytes\n", argv[1], size);
>
> if (truncate(argv[1], size)) {
> int saveerr = errno;
> perror("truncate");
> fprintf(stderr, "errno was %d\n", saveerr);
> exit(1);
> }
> exit(0);
> }
Now wait a minute; that was *my* testcase! Oh, well.
I hearby place that code in the public domain; retroactively for
Jacek Trzmiel's benefit.
Would a truncate.exe be welcome in one of the cygwin packages? I
kind of thought there was one on some unixes but a search didn't
turn up anything.