[GRASS-dev] Re: v.surf.rst with really big files, Re: r.random

Markus Metz markus.metz.giswork at googlemail.com
Mon Apr 6 12:33:19 EDT 2009


Helena Mitasova wrote:
> There are several problems that v.surf.rst has with large files
> (we have same problem too I just did not have
> time to look for the fix - I may ask Markus M for help because it is 
> related to things
> that he has been dealing with):
Glynn is the expert on LFS, I just follow his instructions.
>
> - one is the use of 32 bit file offset instead of off_t (see below, my 
> expertise in these issues is zero)

In the RST library, maybe just to
- use off_t for all offsets
- #include <grass/config.h> first
- find fseek and replace with G_fseek, same for ftell if used
- adjust the Makefile
is enough?

> It is my understanding that the off_t data type should be used for all
> file offsets. If the following compiler flags are set, then off_t is a
> 64 bit offset, otherwise it is 32-bits
Only true for 32bit systems, off_t is always 64bit on 64bit systems.
>
> -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
>
> The off_t data type is declared in <unistd.h>
> I am trying to rebuild at least interp2d.c, ressegm2d.c, and segmen2d.c
> to use the off_t data type. I have added the line #include <unistd.h>,
> but for some reason, the files do not recognize the off_t data type.
#include <grass/config.h>
before all other headers

See http://grass.osgeo.org/wiki/Large_File_Support

Probably not needed:
#include <sys/types.h>
because it's included through grass/gis.h
I don't think unistd.h is needed explicitly.

> So my first problem is "How can I get the grass libraries in rst_gmsl to
> recognize the off_t type?" I suspect that another problem will be that
> fseek explicitly uses long data types for offsets. I am running on Linux
> and can use the fseeko version in GNU libc 2.x which uses off_t, but
> this makes the code non-portable. The real solution would be to convert
> fseeks to lseeks, but lseek takes a integer file descriptor while fseek
> uses FILE pointers.
>
You can use G_fseek and G_ftell available in trunk.

Regards,

Markus M


More information about the grass-dev mailing list