From 075dc184a04e10106de8c2a6e9a0a6e249d815c6 Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Mon, 21 Aug 2017 01:19:27 +0200 Subject: [PATCH] jehanne: introduce libposix_getdents machinery --- newlib/libc/sys/jehanne/sys/dirent.h | 11 +++-------- newlib/libc/sys/jehanne/syscalls.c | 7 +++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/newlib/libc/sys/jehanne/sys/dirent.h b/newlib/libc/sys/jehanne/sys/dirent.h index 4ebf340fc..36e9e94bc 100644 --- a/newlib/libc/sys/jehanne/sys/dirent.h +++ b/newlib/libc/sys/jehanne/sys/dirent.h @@ -22,14 +22,9 @@ #define MAXNAMLEN 127 /* sizeof(struct dirent.d_name)-1 */ -struct dirent -{ - ino_t d_ino; - char d_name[MAXNAMLEN+1]; - unsigned int d_reclen; -}; - -#define _DIRENT_HAVE_D_RECLEN +#define _LIBPOSIX_H +#include /* get dirent structure from posix.h */ +#undef _LIBPOSIX_H typedef struct { int dd_fd; /* Directory file. */ diff --git a/newlib/libc/sys/jehanne/syscalls.c b/newlib/libc/sys/jehanne/syscalls.c index 680ba4b72..5d6c5f9a0 100644 --- a/newlib/libc/sys/jehanne/syscalls.c +++ b/newlib/libc/sys/jehanne/syscalls.c @@ -250,6 +250,13 @@ getpass(const char *prompt) return POSIX_getpass(errnop, prompt); } +int +getdents (int fd, void *buf, int buf_size) +{ + int *errnop = &_REENT->_errno; + return libposix_getdents(errnop, fd, buf, buf_size); +} + #undef pread ssize_t pread(int fd, void *buf, size_t count, off_t offset)