sys_getdents

来源:互联网 发布:windows时间同步频率 编辑:程序博客网 时间:2024/06/05 13:22



http://linux.die.net/man/2/getdents


int getdents(unsigned int fd, struct linux_dirent *dirp,             unsigned int count);

fd指目录文件描述符。可以用sys_open创建。

dirp指目录信息,其大小由第3个参数指定,dirp在使用时注意先分配内存。

count 目录信息的大小。如果count指定的比较小,可以通过循环,反复获取接下来的dirp.

例子,

while(1)  /* 如果count指定的比较小,这里就会反复获取目录的下半身 */

{

       char pcbuf[1024];

       int nRead = getdents(fd, pcbuf, 1024);

       if(nRead == -1 )   /* 没有找到目录等错误 */

      {

            return ERR;

      } 

      else if(nRead == 0) /* 读到目录结尾*/

      {

           break;

      }

     /* 操作pcbuf内容 */

}

0 0
原创粉丝点击