+#include <dirent.h>
#include <string.h>
#include "dirstream.h"
#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)
{
+#include <dirent.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
+#include <dirent.h>
#include <errno.h>
#include "dirstream.h"
#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
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;
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;
}
#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>
#include <dirent.h>
#include "dirstream.h"
-#ifdef __UCLIBC_HAVE_LFS__
-
extern int getdents64 __P ((unsigned int fd, struct dirent64 *dirp, unsigned int count));
/* 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;
return de;
}
-#endif /* __UCLIBC_HAVE_LFS__ */
-
+#endif /* __UCLIBC_HAVE_LFS__ */
+#include <dirent.h>
#include <errno.h>
#include <unistd.h>
#include "dirstream.h"
SOFTWARE.
*/
+#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
*/
#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
+#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);
+#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;
__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! */
};
__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
__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! */
};
__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
__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! */
};
__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
__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! */
};
__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
__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! */
};
__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
__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! */
};
__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! */
};
__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
__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! */
};