是否只需要 O_LARGEFILE 来写入大文件?

发布于 2024-09-02 11:55:49 字数 412 浏览 7 评论 0原文

如果我只想写入一个大文件 (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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盗心人 2024-09-09 11:55:49

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 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.

绝對不後悔。 2024-09-09 11:55:49

IIRC 如果您

#define _LARGEFILE_SOURCE
#define _FILE_OFFSET_BITS 64

在所有其他包含之前执行此操作,则无需传递此标志。

另外查看

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文