[GRASS-dev] fseeko() in libiostream

Glynn Clements glynn at gclements.plus.com
Wed Oct 8 02:15:00 EDT 2008


Paul Kelly wrote:

> > I'm not sure if this is by design or by accident that it 
> > works like this but it's quite neat really.
> 
> Sorry that was a confusing statement - I meant that the fact that the large 
> file support in config.h can be activated by #define USE_LARGEFILES 1 is 
> confusing, as there is also a Makefile variable called USE_LARGEFILES that 
> is set in the configure script.

The configure script doesn't define USE_LARGEFILES in config.h because
this would enable LFS globally, but not all modules are capable of
using it (i.e. some code may store offsets in an int or long, or
calculate offsets using "int"s, or use fseek/ftell.

If code cannot handle large files, it's better if it simply refuses to
open large files rather than opening them then silently failing (in
unpredictable and possibly destructive ways) when the 2GiB mark is
reached.

Code which is known to be LFS-capable normally has the following in
its Makefile:

	ifneq ($(USE_LARGEFILES),)
		EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
	endif

This should probably be changed to:

	ifneq ($(USE_LARGEFILES),)
		EXTRA_CFLAGS = -DUSE_LARGEFILES=1
	endif

Or we could just make a concerted effort to ensure that all code is
LFS-capable, and enable LFS globally. It's basically a matter of
identifying all uses of lseek(), fseek() and ftell(), and either
confirming that the code is already safe or fixing it.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list