stat syscall/negative st_size

From: Thorsten Kukuk (kukuk@suse.de)
Date: Mon Apr 10 2000 - 15:37:05 EST


Hi,

I found one problem with stat and files which have a size
between 2 and 4 GB.

On mips, ppc and sparc, the field st_size of struct stat is
off_t (signed long). glibc also uses off_t for the st_size field.
On the other architectures it is unsigned long.
Now the kernel returns a negative value for files bigger 2GB
on mips, ppc and sparc. This causes problems if you try to
cast this field to unsigned long long, which would work on Intel
(but not if you use the glibc header files, here you have the
same problem: casting a signed long to a unsinged long long).

My question is: Shouldn't the kernel return an error code, if
the filesize is bigger then 2GB ? Then the application knows
that it has to call stat64.
Or should we add an extra check in the glibc stat wrapper,
which generates the error ?
I think the kernel shouldn't return negative file sizes in
a stat call.

Comments ?

  Thorsten

-- 
Thorsten Kukuk       http://www.suse.de/~kukuk/       kukuk@suse.de
SuSE GmbH            Schanzaeckerstr. 10            90443 Nuernberg
Linux is like a Vorlon.  It is incredibly powerful, gives terse,
cryptic answers and has a lot of things going on in the background.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Apr 15 2000 - 21:00:14 EST