~ubuntu-branches/ubuntu/trusty/musl/trusty-proposed

« back to all changes in this revision

Viewing changes to src/dirent/readdir.c

  • Committer: Package Import Robot
  • Author(s): Kevin Bortis
  • Date: 2013-09-20 20:54:14 UTC
  • Revision ID: package-import@ubuntu.com-20130920205414-5b61trtmma18w58o
Tags: upstream-0.9.13
ImportĀ upstreamĀ versionĀ 0.9.13

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <dirent.h>
 
2
#include <fcntl.h>
 
3
#include <sys/stat.h>
 
4
#include <errno.h>
 
5
#include <stdlib.h>
 
6
#include <limits.h>
 
7
#include "__dirent.h"
 
8
#include "syscall.h"
 
9
#include "libc.h"
 
10
 
 
11
int __getdents(int, struct dirent *, size_t);
 
12
 
 
13
struct dirent *readdir(DIR *dir)
 
14
{
 
15
        struct dirent *de;
 
16
        
 
17
        if (dir->buf_pos >= dir->buf_end) {
 
18
                int len = __getdents(dir->fd, (void *)dir->buf, sizeof dir->buf);
 
19
                if (len <= 0) return 0;
 
20
                dir->buf_end = len;
 
21
                dir->buf_pos = 0;
 
22
        }
 
23
        de = (void *)(dir->buf + dir->buf_pos);
 
24
        dir->buf_pos += de->d_reclen;
 
25
        dir->tell = de->d_off;
 
26
        return de;
 
27
}
 
28
 
 
29
LFS64(readdir);