summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/misc/dirent/alphasort.c1
-rw-r--r--libc/misc/dirent/alphasort64.c3
-rw-r--r--libc/misc/dirent/closedir.c1
-rw-r--r--libc/misc/dirent/dirfd.c1
-rw-r--r--libc/misc/dirent/dirstream.h21
-rw-r--r--libc/misc/dirent/opendir.c9
-rw-r--r--libc/misc/dirent/readdir64.c9
-rw-r--r--libc/misc/dirent/rewinddir.c1
-rw-r--r--libc/misc/dirent/scandir.c1
-rw-r--r--libc/misc/dirent/scandir64.c3
-rw-r--r--libc/misc/dirent/seekdir.c3
-rw-r--r--libc/misc/dirent/telldir.c3
-rw-r--r--libc/sysdeps/linux/arm/bits/dirent.h6
-rw-r--r--libc/sysdeps/linux/i386/bits/dirent.h6
-rw-r--r--libc/sysdeps/linux/m68k/bits/dirent.h6
-rw-r--r--libc/sysdeps/linux/mips/bits/dirent.h6
-rw-r--r--libc/sysdeps/linux/powerpc/bits/dirent.h6
-rw-r--r--libc/sysdeps/linux/sh/bits/dirent.h3
-rw-r--r--libc/sysdeps/linux/sparc/bits/dirent.h6
-rw-r--r--libc/sysdeps/linux/v850/bits/dirent.h3
20 files changed, 68 insertions, 30 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;
diff --git a/libc/sysdeps/linux/arm/bits/dirent.h b/libc/sysdeps/linux/arm/bits/dirent.h
index 01fbf54dd..7e3769a48 100644
--- a/libc/sysdeps/linux/arm/bits/dirent.h
+++ b/libc/sysdeps/linux/arm/bits/dirent.h
@@ -30,7 +30,9 @@ struct dirent
__off64_t d_off;
#endif
unsigned short int d_reclen;
- //unsigned char d_type;
+#ifdef __USE_FILE_OFFSET64
+ unsigned char d_type;
+#endif
char d_name[256]; /* We must not include limits.h! */
};
@@ -40,7 +42,7 @@ struct dirent64
__ino64_t d_ino;
__off64_t d_off;
unsigned short int d_reclen;
- //unsigned char d_type;
+ unsigned char d_type;
char d_name[256]; /* We must not include limits.h! */
};
#endif
diff --git a/libc/sysdeps/linux/i386/bits/dirent.h b/libc/sysdeps/linux/i386/bits/dirent.h
index e299c7784..82d8663f2 100644
--- a/libc/sysdeps/linux/i386/bits/dirent.h
+++ b/libc/sysdeps/linux/i386/bits/dirent.h
@@ -30,7 +30,9 @@ struct dirent
__off64_t d_off;
#endif
unsigned short int d_reclen;
- //unsigned char d_type;
+#ifdef __USE_FILE_OFFSET64
+ unsigned char d_type;
+#endif
char d_name[256]; /* We must not include limits.h! */
};
@@ -40,7 +42,7 @@ struct dirent64
__ino64_t d_ino;
__off64_t d_off;
unsigned short int d_reclen;
- //unsigned char d_type;
+ unsigned char d_type;
char d_name[256]; /* We must not include limits.h! */
};
#endif
diff --git a/libc/sysdeps/linux/m68k/bits/dirent.h b/libc/sysdeps/linux/m68k/bits/dirent.h
index bde9fa744..82d8663f2 100644
--- a/libc/sysdeps/linux/m68k/bits/dirent.h
+++ b/libc/sysdeps/linux/m68k/bits/dirent.h
@@ -30,7 +30,9 @@ struct dirent
__off64_t d_off;
#endif
unsigned short int d_reclen;
- /*unsigned char d_type; */
+#ifdef __USE_FILE_OFFSET64
+ unsigned char d_type;
+#endif
char d_name[256]; /* We must not include limits.h! */
};
@@ -40,7 +42,7 @@ struct dirent64
__ino64_t d_ino;
__off64_t d_off;
unsigned short int d_reclen;
- /*unsigned char d_type; */
+ unsigned char d_type;
char d_name[256]; /* We must not include limits.h! */
};
#endif
diff --git a/libc/sysdeps/linux/mips/bits/dirent.h b/libc/sysdeps/linux/mips/bits/dirent.h
index 88b718672..82d8663f2 100644
--- a/libc/sysdeps/linux/mips/bits/dirent.h
+++ b/libc/sysdeps/linux/mips/bits/dirent.h
@@ -30,7 +30,9 @@ struct dirent
__off64_t d_off;
#endif
unsigned short int d_reclen;
- /*unsigned char d_type;*/
+#ifdef __USE_FILE_OFFSET64
+ unsigned char d_type;
+#endif
char d_name[256]; /* We must not include limits.h! */
};
@@ -40,7 +42,7 @@ struct dirent64
__ino64_t d_ino;
__off64_t d_off;
unsigned short int d_reclen;
- /*unsigned char d_type;*/
+ unsigned char d_type;
char d_name[256]; /* We must not include limits.h! */
};
#endif
diff --git a/libc/sysdeps/linux/powerpc/bits/dirent.h b/libc/sysdeps/linux/powerpc/bits/dirent.h
index a2936a7c5..1d41f4dd3 100644
--- a/libc/sysdeps/linux/powerpc/bits/dirent.h
+++ b/libc/sysdeps/linux/powerpc/bits/dirent.h
@@ -40,7 +40,9 @@ struct dirent
__off64_t d_off;
#endif
unsigned short int d_reclen;
- //unsigned char d_type;
+#ifdef __USE_FILE_OFFSET64
+ unsigned char d_type;
+#endif
char d_name[256]; /* We must not include limits.h! */
};
@@ -50,7 +52,7 @@ struct dirent64
__ino64_t d_ino;
__off64_t d_off;
unsigned short int d_reclen;
- //unsigned char d_type;
+ unsigned char d_type;
char d_name[256]; /* We must not include limits.h! */
};
#endif
diff --git a/libc/sysdeps/linux/sh/bits/dirent.h b/libc/sysdeps/linux/sh/bits/dirent.h
index 1754c7cbe..472ae1a04 100644
--- a/libc/sysdeps/linux/sh/bits/dirent.h
+++ b/libc/sysdeps/linux/sh/bits/dirent.h
@@ -40,6 +40,9 @@ struct dirent
__off64_t d_off;
#endif
unsigned short int d_reclen;
+#ifdef __USE_FILE_OFFSET64
+ unsigned char d_type;
+#endif
char d_name[256]; /* We must not include limits.h! */
};
diff --git a/libc/sysdeps/linux/sparc/bits/dirent.h b/libc/sysdeps/linux/sparc/bits/dirent.h
index 88b718672..82d8663f2 100644
--- a/libc/sysdeps/linux/sparc/bits/dirent.h
+++ b/libc/sysdeps/linux/sparc/bits/dirent.h
@@ -30,7 +30,9 @@ struct dirent
__off64_t d_off;
#endif
unsigned short int d_reclen;
- /*unsigned char d_type;*/
+#ifdef __USE_FILE_OFFSET64
+ unsigned char d_type;
+#endif
char d_name[256]; /* We must not include limits.h! */
};
@@ -40,7 +42,7 @@ struct dirent64
__ino64_t d_ino;
__off64_t d_off;
unsigned short int d_reclen;
- /*unsigned char d_type;*/
+ unsigned char d_type;
char d_name[256]; /* We must not include limits.h! */
};
#endif
diff --git a/libc/sysdeps/linux/v850/bits/dirent.h b/libc/sysdeps/linux/v850/bits/dirent.h
index 1754c7cbe..472ae1a04 100644
--- a/libc/sysdeps/linux/v850/bits/dirent.h
+++ b/libc/sysdeps/linux/v850/bits/dirent.h
@@ -40,6 +40,9 @@ struct dirent
__off64_t d_off;
#endif
unsigned short int d_reclen;
+#ifdef __USE_FILE_OFFSET64
+ unsigned char d_type;
+#endif
char d_name[256]; /* We must not include limits.h! */
};