find prints wrong file size for files >2GB
Yitzchak Scott-Thoennes
sthoenna@efn.org
Mon Dec 6 12:05:00 GMT 2004
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.
More information about the Cygwin-talk
mailing list