Could someone please explain, what exactly this O_LARGEFILE
option does to support opening of large files.
And can there be any side effects of compiling with -D_FILE_OFFSET_BITS=64
flag. In other words, when compiled with this option do we have to make sure something.
Asked
Active
Viewed 1,020 times
3
-
possible duplicate of [Is O_LARGEFILE needed just to write a large file?](http://stackoverflow.com/questions/2888425/is-o-largefile-needed-just-to-write-a-large-file) – Cédric Julien Jan 02 '12 at 14:09
2 Answers
1
From man 2 open
:
O_LARGEFILE
(LFS) Allow files whose sizes cannot be represented in an off_t (but can be represented in an off64_t) to be opened. The _LARGE‐
FILE64_SOURCE macro must be defined in order to obtain this definition. Setting the _FILE_OFFSET_BITS feature test macro to 64 (rather
than using O_LARGEFILE) is the preferred method of obtaining method of accessing large files on 32-bit systems (see fea‐
ture_test_macros(7)).
Edit: (ie. RTM :P)

Funk Forty Niner
- 74,450
- 15
- 68
- 141

Ricardo Cárdenes
- 9,004
- 1
- 21
- 34
-
The manpage usually doesn't point out the reason directly, so sometimes people like OP and me may want some confirmation from others, ensuring that we get it right. – Rick Oct 26 '21 at 06:53
1
Use _FILE_OFFSET_BITS in preference to O_LARGEFILE. These are used on 32 bit systems to allow opening files so large that they exceed the range of a 32bit file pointer.
No, you don't have to do anything special. If you are on 64bit Linux it makes no difference anyway.

jim mcnamara
- 16,005
- 2
- 34
- 51