是否只需要 O_LARGEFILE 来写入大文件?
如果我只想写入一个大文件 (O_WRONLY
) 或附加到一个大文件 (O_APPEND | O_WRONLY
),是否需要 O_LARGEFILE
标志>)?
从我读到的标题为“Cannot write >2gb 的帖子中索引文件”在 CLucene-dev 邮件列表上,似乎可能需要 O_LARGEFILE
来写入大文件,但该讨论的参与者正在使用 O_RDWR
,不是O_WRONLY
,所以我不确定。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
O_LARGEFILE
绝不应由应用程序直接使用。当 libc 中的 64 位偏移兼容版本的open
对内核(Linux,或者可能是具有此 64 位偏移模式的另一个内核)进行系统调用时,它将在内部使用它-是二等公民废话)。只需确保在您的CFLAGS
中始终包含-D_FILE_OFFSET_BITS=64
即可,您将永远不必担心任何事情。O_LARGEFILE
should never be used directly by applications. It's to be used internally by the 64-bit-offset-compatible version ofopen
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 yourCFLAGS
and you'll never have to worry about anything.IIRC 如果您
在所有其他包含之前执行此操作,则无需传递此标志。
另外查看
IIRC if you do
before all other includes you do not need to pass this flag.
additionally see