diff --git a/include/dirstream.h b/include/dirstream.h index f648b96c..797fd0ae 100644 --- a/include/dirstream.h +++ b/include/dirstream.h @@ -36,6 +36,7 @@ // Taken from GNU C Library 2.2.5 /* Directory stream type. */ +#if __SIZEOF_LONG_LONG__ != 8 struct __dirstream { int fd; /* File descriptor. */ @@ -47,6 +48,17 @@ struct __dirstream off_t filepos; /* Position of next entry to read. */ }; +#else // __SIZEOF_LONG_LONG__ == 8 +struct __dirstream +{ + off_t tell; + int fd; + int buf_pos; + int buf_end; + int lock[1]; + char buf[2048]; +}; +#endif // __SIZEOF_LONG_LONG__ == 8 typedef struct __dirstream DIR; diff --git a/include/fcntl.h b/include/fcntl.h index c5bc6951..59dad43c 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -42,9 +42,17 @@ #ifdef __arm__ #define O_DIRECTORY 0x4000 /*#define O_DIRECT 0x10000*/ +#define O_LARGEFILE 0x20000 #else #define O_DIRECTORY 0x10000 +#if __i386__ +//#define O_LARGEFILE 0x8000 +#define O_LARGEFILE 0100000 +#else +#define O_LARGEFILE 0 #endif +#endif + #elif __GNU__ #define O_RDONLY 1 diff --git a/include/sys/types.h b/include/sys/types.h index d8ab86e4..24767ed6 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -71,10 +71,10 @@ typedef unsigned gid_t; #ifndef __MES_INO_T #define __MES_INO_T #undef ino_t -#if __M2__ +#if __M2__ || __SIZEOF_LONG_LONG__ != 8 typedef unsigned ino_t; #else -typedef unsigned long ino_t; +typedef unsigned long long ino_t; #endif #endif diff --git a/lib/dirent/opendir.c b/lib/dirent/opendir.c index f0916056..c5ffdf3d 100644 --- a/lib/dirent/opendir.c +++ b/lib/dirent/opendir.c @@ -53,7 +53,11 @@ opendir (char const *name) return 0; } - fd = open (name, O_RDONLY | O_DIRECTORY); + int flags = O_RDONLY | O_DIRECTORY; +#if __SIZEOF_LONG_LONG__ == 8 + flags |= O_LARGEFILE; +#endif + fd = open (name, flags); if (fd < 0) return 0; @@ -74,8 +78,10 @@ opendir (char const *name) errno = save_errno; return 0; } +#if __SIZEOF_LONG_LONG__ != 8 dirp->data = (char *) (dirp + 1); dirp->allocation = allocation; +#endif dirp->fd = fd; return dirp; diff --git a/lib/linux/open.c b/lib/linux/open.c index 1806dfa6..0927b9a3 100644 --- a/lib/linux/open.c +++ b/lib/linux/open.c @@ -40,6 +40,9 @@ open (char const *file_name, int flags, ...) va_list ap; va_start (ap, flags); int mask = va_arg (ap, int); +#if __SIZEOF_LONG_LONG__ == 8 + flags |= O_LARGEFILE; +#endif int r = _sys_call3 (SYS_open, (long) file_name, flags, mask); va_end (ap); if (r > 2)