Mail Archives: djgpp-workers/2001/08/08/17:19:04
> Date: Wed, 08 Aug 2001 22:17:21 +0300
> From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
>
> > For example, its emulation of the 'stat'
> > system call should return -1 on files larger than 2GB, and should set
> > errno to EOVERFLOW in that case.
>
> Why? `stat' does support files up to 4GB - 2bytes; it has no reason
> to fail.
No, it doesn't support those files, because it doesn't represent their
sizes correctly. For example, if the file size is 2147483650 bytes,
it returns a st_size value of -2147483646. This isn't correct.
A similar situation arises in GNU/Linux, Solaris, and other hosts.
For example, on my Solaris 8 host:
$ cat >t.c <<'EOF'
#include <stdio.h>
#include <sys/stat.h>
int main () {
struct stat st;
if (fstat (0, &st) != 0)
perror ("fstat");
}
EOF
$ gcc t.c
$ echo x | dd bs=1024k oseek=2048 >large
0+1 records in
0+1 records out
$ ls -l large
-rw-rw-r-- 1 eggert eggert 2147483650 Aug 8 14:00 large
$ ./a.out <large
fstat: Value too large for defined data type
Here we also have a case where the filesystem and some apps can
support a file whose size is 2147483650, but in the default Solaris 8
compilation model (which is analogous to DGJPP's only compilation
model in that off_t is 32 bits), fstat cannot represent the resulting
size correctly. And the default-model Solaris 8 fstat does the right
thing: it returns -1 with errno == EOVERFLOW.
> The latest released version doesn't even support more than 2GB
In that case, please consider my message to be an early warning of the
problem. When you add support for files in the 2GB - 4GB range,
please increase off_t to be a type wider than 32 bits; or please
modify all the off_t-related system calls to return EOVERFLOW for
offsets greater than 2**31-1. I prefer the former solution, but
either solution will do, and either will be more reliable and robust
than modifying all the GNU applications to deal with this gratuitous
incompatibility with POSIX.
- Raw text -