Large File Support in Linux

To support files larger than 2 GiB on 32-bit systems, e.g. x86, PowerPC and MIPS, a number of changes to kernel and C library had to be done. This is called Large File Support (LFS). The support for LFS should be complete now in Linux.


Limits

LFS raises the limit of maximal file size. For 32-bit systems the limit is 231 (2 GB) but using the LFS interface on filesystems that support LFS applications can handle files as large as 263 bytes.
For 64-bit systems the file size limit is 263 bytes unless a filesystem (like NFSv2) only supports less.


Using LFS

For using LFS in user programs, the programs have to use the LFS API.


In a nutshell for using LFS you can choose either of the following:
  • Compile your programs with "gcc -D_FILE_OFFSET_BITS=64".
  • 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.

留言

熱門文章