Large file support and stat vs stat64 in extension modules

Ben Escoto ben at remove.Stanford.EDU
Wed Sep 11 13:00:02 EDT 2002


On Wed, 11 Sep 2002 06:22:08 -0700, Skip Montanaro wrote:

> Did you #include <sys/stat.h>?

Yes, but perhaps I'm not including something else.  Here is a short
program (test.c):

#include <sys/stat.h>

main()
{
  struct stat st;
  if (stat("/home/ben/work/big/bigfile", &st) != 0)
      perror("Error");
  else printf("OK\n");
}

when I "gcc test.c; ./a.out" it says: "Error: Value too large for defined
data type".  I assume in my extension module the same thing is happening. 
What needs to be defined so that this works?  Looking through
posixmodule.c it doesn't seem to define __USE_FILE_OFFSET64 or
__USE_LARGEFILE64, yet it gets things right.

> 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.

I am using distutils so don't have a Configure.in.  But I think there are
two separate problems:  firstly getting the stat() call to work without
raising an error, and secondly interpreting the filled in stat structure.
Perhaps I will have problems with #2 later, but I'm still on #1 for now.
As far as I can tell HAVE_LARGEFILE_SUPPORT, off_t, and long long don't
affect this first step.

    Thanks a lot for your help!


-- 
Ben Escoto



More information about the Python-list mailing list