Large file support and stat vs stat64 in extension modules
Skip Montanaro
skip at pobox.com
Wed Sep 11 09:22:08 EDT 2002
If I simply use the stat() system call, I get an EOVERFLOW error
(OSError: [Errno 75] Value too large for defined data type). It seems
that I should be using the newer stat64() call, but:
Did you #include <sys/stat.h>?
Ben> 1. posixmodule.c appears just to use plain old stat(). I cannot
Ben> figure out why I get errors and it works fine. Quite a
Ben> mystery.
In /usr/include/sys/stat.h on my Mandrake 8.1 system (very similar to your
RH 7.2 I believe), stat is #defined as stat64 if __USE_FILE_OFFSET64 is
defined, which it probably is if your system supports POSIX large files.
Ben> 2. I don't know what #if defined's to put in to choose between
Ben> stat and stat64 correctly.
Shouldn't need anything.
Ben> Does anyone know how to correctly stat a file within an extension
Ben> module? Why does:
Ben> struct stat st;
Ben> res = stat("bigfile", &st)
Ben> not work for me, but in posixmodule.c the same thing (apparently)
Ben> is done and works fine?
Note that in posixmodule.c references are made to a HAVE_LARGEFILE_SUPPORT
macro. When #defined, it causes the output struct to be interpreted
differently (the sizes of some fields change).
You might scan through your configure.in file. If "long long" support is
present and sizeof(off_t) is greater than sizeof(long) and sizeof(long long)
is greater than or equal to sizeof(off_t), large file support is assumed.
--
Skip Montanaro
skip at pobox.com
consulting: http://manatee.mojam.com/~skip/resume.html
More information about the Python-list
mailing list