Joaquin Peralta

My Personal weblog.

Using LFS

Sometime your personal program can’t write files of more that 2Gb, a reasons for this is the use of LFS.

For using LFS in user programs, the programs have to use the LFS API. This involves recompilation and changes of programs. The API is documented in the glibc manual (the libc info pages) which can be read with e.g. "info libc".

In a nutshell for using LFS you can choose either of the following:

  • Compile your programs with "gcc -D_FILE_OFFSET_BITS=64". This forces all file access calls to use the 64 bit variants. Several types change also, e.g. off_t becomes off64_t. It’s therefore important to always use the correct types and to not use e.g. int instead of off_t. For portability with other platforms you should use getconf LFS_CFLAGS which will return -D_FILE_OFFSET_BITS=64 on Linux platforms but might return something else on e.g. Solaris. For linking, you should use the link flags that are reported via getconf LFS_LDFLAGS. On Linux systems, you do not need special link flags.
  • Define _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE. With these defines you can use the LFS functions like open64 directly.
  • Use the O_LARGEFILE flag with open to operate on large files

In the mostly of the case with the first option you correct the problem and can write more of 2Gb of data in the files output of your program.

Thanks to this constributions : Eduardo Valdebenito (i don’t know your personal web-page)

JP.

October 19, 2006 - Posted by jperalta | GNU/Linux | | 1 Comment

1 Comment »

  1. [...] jperalta.wordpress.com [...]

    Pingback by Munpack - File size limit exceeded | Sysadmin Tips | April 7, 2009 | Reply


Leave a comment