Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is O_LARGEFILE needed just to write a large file?

Is the O_LARGEFILE flag needed if all that I want to do is write a large file (O_WRONLY) or append to a large file (O_APPEND | O_WRONLY)?

From a thread that I read titled "Cannot write >2gb index file" on the CLucene-dev mailing list, it appears that O_LARGEFILE might be needed to write large files, but participants in that discussion are using O_RDWR, not O_WRONLY, so I am not sure.

like image 400
Daniel Trebbien Avatar asked May 22 '10 14:05

Daniel Trebbien


2 Answers

O_LARGEFILE should never be used directly by applications. It's to be used internally by the 64-bit-offset-compatible version of open in libc when it makes the syscall to the kernel (Linux, or possibly another kernel with this 64-bit-offset-mode-is-a-second-class-citizen nonsense). Just make sure to always include -D_FILE_OFFSET_BITS=64 in your CFLAGS and you'll never have to worry about anything.

like image 160
R.. GitHub STOP HELPING ICE Avatar answered Nov 06 '22 11:11

R.. GitHub STOP HELPING ICE


IIRC if you do

#define _LARGEFILE_SOURCE
#define _FILE_OFFSET_BITS 64

before all other includes you do not need to pass this flag.

additionally see

like image 36
codymanix Avatar answered Nov 06 '22 11:11

codymanix