X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fdirent%2Freaddir.c;h=569fc70577378836df852b9187a53d1bddbc3cde;hb=37cd1676395e5ebdae3f372bf59d4fef54be9818;hp=98ec029e6b983bb9de2d3a86d2cf296dac5dd325;hpb=571744447c23f91feb6439948f3a619aca850dfb;p=musl diff --git a/src/dirent/readdir.c b/src/dirent/readdir.c index 98ec029e..569fc705 100644 --- a/src/dirent/readdir.c +++ b/src/dirent/readdir.c @@ -1,16 +1,22 @@ #include +#include +#include #include "__dirent.h" -#include "libc.h" +#include "syscall.h" -int __getdents(int, struct dirent *, size_t); +typedef char dirstream_buf_alignment_check[1-2*(int)( + offsetof(struct __dirstream, buf) % sizeof(off_t))]; struct dirent *readdir(DIR *dir) { struct dirent *de; if (dir->buf_pos >= dir->buf_end) { - int len = __getdents(dir->fd, (void *)dir->buf, sizeof dir->buf); - if (len <= 0) return 0; + int len = __syscall(SYS_getdents, dir->fd, dir->buf, sizeof dir->buf); + if (len <= 0) { + if (len < 0 && len != -ENOENT) errno = -len; + return 0; + } dir->buf_end = len; dir->buf_pos = 0; } @@ -20,4 +26,4 @@ struct dirent *readdir(DIR *dir) return de; } -LFS64(readdir); +weak_alias(readdir, readdir64);