WIP getdents/opendir LARGEFILE

This commit is contained in:
Jan (janneke) Nieuwenhuizen 2022-10-30 21:31:07 +01:00
parent 9c72c28a06
commit 00096e6c9a
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
5 changed files with 32 additions and 3 deletions

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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)