gpt4 book ai didi

c - 最后一个struct dirent中字段d_off的含义

转载 作者:太空狗 更新时间:2023-10-29 11:45:48 24 4
gpt4 key购买 nike

man getdensts 说在 d_off 中保留了下一个 struct dirent 的偏移量。但是在这个领域应该保留什么以备不时之需呢?我找不到这个 SVr4 标准去那里看,但是人什么也没说

最佳答案

“SVr4”表示 Unix System V Release 4 . Solaris 基于此,并且 Solaris says :

The d_off entry contains a value which is interpretable only by the filesystem that generated it. It may be supplied as an offset to lseek(2) to find the entry following the current one in a directory.

如果您查看 example in the Linux manpage ,您会找到一个使用 getdents 的程序。它不依赖于最终条目的 d_off,这显然是不确定的,而是依赖于 getdents 的返回值来确定有多少条目。

顺便说一句,Linux 联机帮助页也非常清楚地指出您不应该使用 getdents 系统调用,而且它甚至不受 GLibc 支持。请改用 POSIX readdir 接口(interface)。

关于c - 最后一个struct dirent中字段d_off的含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16714265/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com