diff options
Diffstat (limited to 'libc/misc')
-rw-r--r-- | libc/misc/dirent/alphasort.c | 1 | ||||
-rw-r--r-- | libc/misc/dirent/alphasort64.c | 3 | ||||
-rw-r--r-- | libc/misc/dirent/closedir.c | 1 | ||||
-rw-r--r-- | libc/misc/dirent/dirfd.c | 1 | ||||
-rw-r--r-- | libc/misc/dirent/dirstream.h | 21 | ||||
-rw-r--r-- | libc/misc/dirent/opendir.c | 9 | ||||
-rw-r--r-- | libc/misc/dirent/readdir64.c | 9 | ||||
-rw-r--r-- | libc/misc/dirent/rewinddir.c | 1 | ||||
-rw-r--r-- | libc/misc/dirent/scandir.c | 1 | ||||
-rw-r--r-- | libc/misc/dirent/scandir64.c | 3 | ||||
-rw-r--r-- | libc/misc/dirent/seekdir.c | 3 | ||||
-rw-r--r-- | libc/misc/dirent/telldir.c | 3 |
12 files changed, 38 insertions, 18 deletions
diff --git a/libc/misc/dirent/alphasort.c b/libc/misc/dirent/alphasort.c index d7a1d8d93..dcf970070 100644 --- a/libc/misc/dirent/alphasort.c +++ b/libc/misc/dirent/alphasort.c @@ -1,3 +1,4 @@ +#include <dirent.h> #include <string.h> #include "dirstream.h" diff --git a/libc/misc/dirent/alphasort64.c b/libc/misc/dirent/alphasort64.c index 94194e0c6..bddf65ea7 100644 --- a/libc/misc/dirent/alphasort64.c +++ b/libc/misc/dirent/alphasort64.c @@ -1,11 +1,12 @@ #include <features.h> +#ifdef __UCLIBC_HAVE_LFS__ #define _FILE_OFFSET_BITS 64 #define __USE_LARGEFILE64 #define __USE_FILE_OFFSET64 +#include <dirent.h> #include <string.h> #include "dirstream.h" -#ifdef __UCLIBC_HAVE_LFS__ int alphasort64(const void * a, const void * b) { diff --git a/libc/misc/dirent/closedir.c b/libc/misc/dirent/closedir.c index a2ac83b17..3b6337b5f 100644 --- a/libc/misc/dirent/closedir.c +++ b/libc/misc/dirent/closedir.c @@ -1,3 +1,4 @@ +#include <dirent.h> #include <errno.h> #include <stdlib.h> #include <unistd.h> diff --git a/libc/misc/dirent/dirfd.c b/libc/misc/dirent/dirfd.c index d6c1e6647..b658b5a9c 100644 --- a/libc/misc/dirent/dirfd.c +++ b/libc/misc/dirent/dirfd.c @@ -1,3 +1,4 @@ +#include <dirent.h> #include <errno.h> #include "dirstream.h" diff --git a/libc/misc/dirent/dirstream.h b/libc/misc/dirent/dirstream.h index 8131ffce7..dc5c5732a 100644 --- a/libc/misc/dirent/dirstream.h +++ b/libc/misc/dirent/dirstream.h @@ -24,12 +24,23 @@ Cambridge, MA 02139, USA. */ #define _DIRSTREAM_H 1 +#include <features.h> #include <sys/types.h> -#include <dirent.h> #ifdef _POSIX_THREADS #include <pthread.h> #endif + +#ifdef __UCLIBC_HAVE_LFS__ +#ifndef __USE_LARGEFILE64 +# define __USE_LARGEFILE64 +#endif +# define stuff_t __off64_t +#else +# define stuff_t __off_t +#endif + + /* For now, syscall readdir () only supports one entry at a time. It * will be changed in the future. #define NUMENT 3 @@ -48,19 +59,19 @@ struct __dirstream { int dd_fd; /* offset of the next dir entry in buffer */ - off_t dd_nextloc; + stuff_t dd_nextloc; /* bytes of valid entries in buffer */ - size_t dd_size; + stuff_t dd_size; /* -> directory buffer */ void *dd_buf; /* offset of the next dir entry in directory. */ - off_t dd_nextoff; + stuff_t dd_nextoff; /* total size of buffer */ - size_t dd_max; + stuff_t dd_max; enum {unknown, have_getdents, no_getdents} dd_getdents; diff --git a/libc/misc/dirent/opendir.c b/libc/misc/dirent/opendir.c index 25b5873e1..e2a6000ca 100644 --- a/libc/misc/dirent/opendir.c +++ b/libc/misc/dirent/opendir.c @@ -37,19 +37,20 @@ DIR *opendir(const char *name) return NULL; } + ptr->dd_fd = fd; + ptr->dd_nextloc = ptr->dd_size = ptr->dd_nextoff = 0; + ptr->dd_getdents = unknown; + ptr->dd_max = statbuf.st_blksize; if (ptr->dd_max < 512) ptr->dd_max = 512; - if (!(buf = malloc(ptr->dd_max))) { + if (!(buf = calloc(1, ptr->dd_max))) { close(fd); free(ptr); __set_errno(ENOMEM); return NULL; } - ptr->dd_fd = fd; - ptr->dd_nextoff = ptr->dd_nextloc = ptr->dd_size = 0; ptr->dd_buf = buf; - ptr->dd_getdents = unknown; return ptr; } diff --git a/libc/misc/dirent/readdir64.c b/libc/misc/dirent/readdir64.c index d0f28030b..c8f3b8d46 100644 --- a/libc/misc/dirent/readdir64.c +++ b/libc/misc/dirent/readdir64.c @@ -1,7 +1,9 @@ #include <features.h> +#ifdef __UCLIBC_HAVE_LFS__ #define _FILE_OFFSET_BITS 64 #define __USE_LARGEFILE64 #define __USE_FILE_OFFSET64 +#include <dirent.h> #include <errno.h> #include <stdlib.h> #include <string.h> @@ -9,8 +11,6 @@ #include <dirent.h> #include "dirstream.h" -#ifdef __UCLIBC_HAVE_LFS__ - extern int getdents64 __P ((unsigned int fd, struct dirent64 *dirp, unsigned int count)); @@ -33,7 +33,7 @@ struct dirent64 *readdir64(DIR * dir) /* read dir->dd_max bytes of directory entries. */ result = getdents64(dir->dd_fd, dir->dd_buf, dir->dd_max); - /* We assume we have getdents (). */ + /* We assume we have getdents64 (). */ dir->dd_getdents = have_getdents; if (result <= 0) { result = -result; @@ -63,6 +63,5 @@ struct dirent64 *readdir64(DIR * dir) return de; } -#endif /* __UCLIBC_HAVE_LFS__ */ - +#endif /* __UCLIBC_HAVE_LFS__ */ diff --git a/libc/misc/dirent/rewinddir.c b/libc/misc/dirent/rewinddir.c index 2fff9101c..495594089 100644 --- a/libc/misc/dirent/rewinddir.c +++ b/libc/misc/dirent/rewinddir.c @@ -1,3 +1,4 @@ +#include <dirent.h> #include <errno.h> #include <unistd.h> #include "dirstream.h" diff --git a/libc/misc/dirent/scandir.c b/libc/misc/dirent/scandir.c index 31ebce549..a460e161f 100644 --- a/libc/misc/dirent/scandir.c +++ b/libc/misc/dirent/scandir.c @@ -23,6 +23,7 @@ SOFTWARE. */ +#include <dirent.h> #include <stdio.h> #include <string.h> #include <stdlib.h> diff --git a/libc/misc/dirent/scandir64.c b/libc/misc/dirent/scandir64.c index 6b0892191..6c6697b42 100644 --- a/libc/misc/dirent/scandir64.c +++ b/libc/misc/dirent/scandir64.c @@ -24,16 +24,17 @@ */ #include <features.h> +#ifdef __UCLIBC_HAVE_LFS__ #define _FILE_OFFSET_BITS 64 #define __USE_LARGEFILE64 #define __USE_FILE_OFFSET64 +#include <dirent.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <sys/types.h> #include "dirstream.h" -#ifdef __UCLIBC_HAVE_LFS__ /* * FIXME: This is a simple hack version which doesn't sort the data, and diff --git a/libc/misc/dirent/seekdir.c b/libc/misc/dirent/seekdir.c index 3ff9f5da9..a1649c9b3 100644 --- a/libc/misc/dirent/seekdir.c +++ b/libc/misc/dirent/seekdir.c @@ -1,9 +1,10 @@ +#include <dirent.h> #include <errno.h> #include <unistd.h> #include "dirstream.h" -void seekdir(DIR * dir, off_t offset) +void seekdir(DIR * dir, long int offset) { if (!dir) { __set_errno(EBADF); diff --git a/libc/misc/dirent/telldir.c b/libc/misc/dirent/telldir.c index 872cddbf1..8c13a9c23 100644 --- a/libc/misc/dirent/telldir.c +++ b/libc/misc/dirent/telldir.c @@ -1,9 +1,10 @@ +#include <dirent.h> #include <errno.h> #include <unistd.h> #include "dirstream.h" -off_t telldir(DIR * dir) +long int telldir(DIR * dir) { off_t offset; |