diff --git a/src/dirent/__dirent.h b/src/dirent/__dirent.h index 101b0368..828a5f17 100644 --- a/src/dirent/__dirent.h +++ b/src/dirent/__dirent.h @@ -1,9 +1,11 @@ struct __dirstream { - int fd; off_t tell; + int fd; int buf_pos; int buf_end; volatile int lock[1]; + /* Any changes to this struct must preserve the property: + * offsetof(struct __dirent, buf) % sizeof(off_t) == 0 */ char buf[2048]; }; diff --git a/src/dirent/readdir.c b/src/dirent/readdir.c index 2cf0632c..dc5f3edb 100644 --- a/src/dirent/readdir.c +++ b/src/dirent/readdir.c @@ -1,9 +1,13 @@ #include #include +#include #include "__dirent.h" #include "syscall.h" #include "libc.h" +typedef char dirstream_buf_alignment_check[1-2*(int)( + offsetof(struct __dirstream, buf) % sizeof(off_t))]; + int __getdents(int, struct dirent *, size_t); struct dirent *readdir(DIR *dir)