Ist O_LARGEFILE benötigt nur eine große Datei zu schreiben?
-
04-10-2019 - |
Frage
Ist das O_LARGEFILE
Flag benötigt, wenn alles, was ich will, ist zu tun, schreibt eine große Datei (O_WRONLY
) oder Anfügen eine große Datei (O_APPEND | O_WRONLY
)?
Von einem Thread, dass ich den Titel gelesen „ Can not Schreib> 2gb Indexdatei “auf der CLucene-dev Mailing-Liste, scheint es, dass O_LARGEFILE
könnte schreiben große Dateien benötigt werden, aber die Teilnehmer in dieser Diskussion verwenden O_RDWR
, nicht O_WRONLY
, so dass ich nicht sicher bin.
Lösung
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.
Andere Tipps
IIRC if you do
#define _LARGEFILE_SOURCE
#define _FILE_OFFSET_BITS 64
before all other includes you do not need to pass this flag.