From 6486babb14cb89daafc9e1c6796aa2ef699c3b17 Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Mon, 24 Jan 2011 13:48:20 +0000 Subject: [PATCH] add d_type to dirent --- dkarm-eabi/patches/newlib-1.19.0.patch | 19 ++++-- dkppc/patches/newlib-1.19.0.patch | 90 +++++++++++--------------- 2 files changed, 52 insertions(+), 57 deletions(-) diff --git a/dkarm-eabi/patches/newlib-1.19.0.patch b/dkarm-eabi/patches/newlib-1.19.0.patch index 666038e..db596d3 100644 --- a/dkarm-eabi/patches/newlib-1.19.0.patch +++ b/dkarm-eabi/patches/newlib-1.19.0.patch @@ -4725,8 +4725,8 @@ diff -Nbaur newlib-1.19.0/libgloss/libsysbase/configure.in newlib-1.19.0-arm/lib + diff -Nbaur newlib-1.19.0/libgloss/libsysbase/dirent.c newlib-1.19.0-arm/libgloss/libsysbase/dirent.c --- newlib-1.19.0/libgloss/libsysbase/dirent.c 1970-01-01 01:00:00.000000000 +0100 -+++ newlib-1.19.0-arm/libgloss/libsysbase/dirent.c 2011-01-19 22:13:21.000000000 +0000 -@@ -0,0 +1,246 @@ ++++ newlib-1.19.0-arm/libgloss/libsysbase/dirent.c 2011-01-21 21:53:22.000000000 +0000 +@@ -0,0 +1,247 @@ +#include +#include +#include @@ -4890,6 +4890,7 @@ diff -Nbaur newlib-1.19.0/libgloss/libsysbase/dirent.c newlib-1.19.0-arm/libglos + + strncpy (dirp->fileData.d_name, filename, sizeof(dirp->fileData.d_name)); + dirp->fileData.d_ino = st.st_ino; ++ dirp->fileData.d_type = S_ISDIR(st.st_mode)?DT_DIR:DT_REG; + + return &(dirp->fileData); +} @@ -6649,8 +6650,8 @@ diff -Nbaur newlib-1.19.0/newlib/libc/include/sys/_types.h newlib-1.19.0-arm/new diff -Nbaur newlib-1.19.0/newlib/libc/include/sys/dirent.h newlib-1.19.0-arm/newlib/libc/include/sys/dirent.h --- newlib-1.19.0/newlib/libc/include/sys/dirent.h 2005-10-04 21:47:39.000000000 +0100 -+++ newlib-1.19.0-arm/newlib/libc/include/sys/dirent.h 2010-12-18 16:49:59.000000000 +0000 -@@ -4,10 +4,39 @@ ++++ newlib-1.19.0-arm/newlib/libc/include/sys/dirent.h 2011-01-21 21:52:14.000000000 +0000 +@@ -4,10 +4,49 @@ not support , we will get this file which uses #error to force an error. */ @@ -6661,6 +6662,15 @@ diff -Nbaur newlib-1.19.0/newlib/libc/include/sys/dirent.h newlib-1.19.0-arm/new +#include +#include + ++#define DT_UNKNOWN 0 ++#define DT_FIFO 1 ++#define DT_CHR 2 ++#define DT_DIR 4 ++#define DT_BLK 6 ++#define DT_REG 8 ++#define DT_LNK 10 ++#define DT_SOCK 12 ++#define DT_WHT 14 + #ifdef __cplusplus extern "C" { @@ -6669,6 +6679,7 @@ diff -Nbaur newlib-1.19.0/newlib/libc/include/sys/dirent.h newlib-1.19.0-arm/new + + struct dirent { + ino_t d_ino; ++ unsigned char d_type; + char d_name[NAME_MAX+1]; + }; + diff --git a/dkppc/patches/newlib-1.19.0.patch b/dkppc/patches/newlib-1.19.0.patch index 919fef9..3fbf0d2 100644 --- a/dkppc/patches/newlib-1.19.0.patch +++ b/dkppc/patches/newlib-1.19.0.patch @@ -4713,8 +4713,8 @@ diff -Nbaur newlib-1.19.0/libgloss/libsysbase/configure.in newlib-1.19.0-ppc/lib + diff -Nbaur newlib-1.19.0/libgloss/libsysbase/dirent.c newlib-1.19.0-ppc/libgloss/libsysbase/dirent.c --- newlib-1.19.0/libgloss/libsysbase/dirent.c 1970-01-01 01:00:00.000000000 +0100 -+++ newlib-1.19.0-ppc/libgloss/libsysbase/dirent.c 2011-01-19 22:14:23.000000000 +0000 -@@ -0,0 +1,246 @@ ++++ newlib-1.19.0-ppc/libgloss/libsysbase/dirent.c 2011-01-21 21:50:08.000000000 +0000 +@@ -0,0 +1,200 @@ +#include +#include +#include @@ -4808,9 +4808,6 @@ diff -Nbaur newlib-1.19.0/libgloss/libsysbase/dirent.c newlib-1.19.0-ppc/libglos + return ret; +} + -+ -+ -+ +DIR* opendir (const char *dirname) { + DIR* dirp = malloc (sizeof(DIR)); + if (!dirp) { @@ -4831,7 +4828,6 @@ diff -Nbaur newlib-1.19.0/libgloss/libsysbase/dirent.c newlib-1.19.0-ppc/libglos + return dirp; +} + -+ +int closedir (DIR *dirp) { + int res; + @@ -4845,7 +4841,6 @@ diff -Nbaur newlib-1.19.0/libgloss/libsysbase/dirent.c newlib-1.19.0-ppc/libglos + return res; +} + -+ +struct dirent* readdir (DIR *dirp) { + struct stat st; + char filename[MAXPATHLEN]; @@ -4878,49 +4873,10 @@ diff -Nbaur newlib-1.19.0/libgloss/libsysbase/dirent.c newlib-1.19.0-ppc/libglos + + strncpy (dirp->fileData.d_name, filename, sizeof(dirp->fileData.d_name)); + dirp->fileData.d_ino = st.st_ino; -+ ++ dirp->fileData.d_type = S_ISDIR(st.st_mode)?DT_DIR:DT_REG; + return &(dirp->fileData); +} + -+ -+int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) { -+ struct stat st; -+ char filename[MAXPATHLEN]; -+ int res; -+ -+ if (!dirp) { -+ return EBADF; -+ } -+ -+ res = __dirnext (dirp->dirData, filename, &st); -+ -+ if (res < 0) { -+ res = errno; -+ *result = NULL; -+ if (errno == ENOENT) { -+ // errno == ENONENT set by dirnext means it's end of directory -+ // But readdir should not touch errno in case of dir end -+ res = 0; -+ } -+ return res; -+ } -+ -+ // We've moved forward in the directory -+ dirp->position += 1; -+ -+ if (strnlen(filename, MAXPATHLEN) >= sizeof(entry->d_name)) { -+ errno = EOVERFLOW; -+ return EOVERFLOW; -+ } -+ -+ strncpy (entry->d_name, filename, sizeof(entry->d_name)); -+ entry->d_ino = st.st_ino; -+ -+ *result = entry; -+ return 0; -+} -+ -+ +void rewinddir (DIR *dirp) { + if (!dirp) { + return; @@ -4930,7 +4886,6 @@ diff -Nbaur newlib-1.19.0/libgloss/libsysbase/dirent.c newlib-1.19.0-ppc/libglos + dirp->position = 0; +} + -+ +void seekdir(DIR *dirp, long int loc) { + char filename[MAXPATHLEN]; + @@ -4953,7 +4908,6 @@ diff -Nbaur newlib-1.19.0/libgloss/libsysbase/dirent.c newlib-1.19.0-ppc/libglos + } +} + -+ +long int telldir(DIR *dirp) { + if (!dirp) { + return -1; @@ -6311,6 +6265,18 @@ diff -Nbaur newlib-1.19.0/newlib/configure.host newlib-1.19.0-ppc/newlib/configu powerpc*-*-elf* | \ powerpc*-*-linux* | \ powerpc*-*-rtem* | \ +diff -Nbaur newlib-1.19.0/newlib/libc/include/dirent.h newlib-1.19.0-ppc/newlib/libc/include/dirent.h +--- newlib-1.19.0/newlib/libc/include/dirent.h 2001-11-30 17:26:47.000000000 +0000 ++++ newlib-1.19.0-ppc/newlib/libc/include/dirent.h 2011-01-21 19:10:18.000000000 +0000 +@@ -6,7 +6,7 @@ + #include + + #if !defined(MAXNAMLEN) && !defined(_POSIX_SOURCE) +-#define MAXNAMLEN 1024 ++#define MAXNAMLEN 4096 + #endif + + #ifdef __cplusplus diff -Nbaur newlib-1.19.0/newlib/libc/include/pthread.h newlib-1.19.0-ppc/newlib/libc/include/pthread.h --- newlib-1.19.0/newlib/libc/include/pthread.h 2010-12-08 14:44:06.000000000 +0000 +++ newlib-1.19.0-ppc/newlib/libc/include/pthread.h 1970-01-01 01:00:00.000000000 +0100 @@ -6720,8 +6686,8 @@ diff -Nbaur newlib-1.19.0/newlib/libc/include/stdio.h newlib-1.19.0-ppc/newlib/l _off_t _EXFUN(_ftello_r,(struct _reent *, FILE *)); diff -Nbaur newlib-1.19.0/newlib/libc/include/sys/dirent.h newlib-1.19.0-ppc/newlib/libc/include/sys/dirent.h --- newlib-1.19.0/newlib/libc/include/sys/dirent.h 2005-10-04 21:47:39.000000000 +0100 -+++ newlib-1.19.0-ppc/newlib/libc/include/sys/dirent.h 2011-01-13 14:15:14.000000000 +0000 -@@ -4,10 +4,39 @@ ++++ newlib-1.19.0-ppc/newlib/libc/include/sys/dirent.h 2011-01-23 12:38:06.000000000 +0000 +@@ -4,10 +4,51 @@ not support , we will get this file which uses #error to force an error. */ @@ -6732,6 +6698,17 @@ diff -Nbaur newlib-1.19.0/newlib/libc/include/sys/dirent.h newlib-1.19.0-ppc/new +#include +#include + ++#define _DIRENT_HAVE_D_TYPE ++ ++#define DT_UNKNOWN 0 ++#define DT_FIFO 1 ++#define DT_CHR 2 ++#define DT_DIR 4 ++#define DT_BLK 6 ++#define DT_REG 8 ++#define DT_LNK 10 ++#define DT_SOCK 12 ++#define DT_WHT 14 + #ifdef __cplusplus extern "C" { @@ -6740,6 +6717,7 @@ diff -Nbaur newlib-1.19.0/newlib/libc/include/sys/dirent.h newlib-1.19.0-ppc/new + + struct dirent { + ino_t d_ino; ++ unsigned char d_type; + char d_name[NAME_MAX+1]; + }; + @@ -6915,8 +6893,8 @@ diff -Nbaur newlib-1.19.0/newlib/libc/include/sys/statvfs.h newlib-1.19.0-ppc/ne \ No newline at end of file diff -Nbaur newlib-1.19.0/newlib/libc/include/sys/syslimits.h newlib-1.19.0-ppc/newlib/libc/include/sys/syslimits.h --- newlib-1.19.0/newlib/libc/include/sys/syslimits.h 2002-08-23 02:56:03.000000000 +0100 -+++ newlib-1.19.0-ppc/newlib/libc/include/sys/syslimits.h 2011-01-13 13:58:57.000000000 +0000 -@@ -44,7 +44,7 @@ ++++ newlib-1.19.0-ppc/newlib/libc/include/sys/syslimits.h 2011-01-20 16:30:43.000000000 +0000 +@@ -44,12 +44,12 @@ #define LINK_MAX 32767 /* max file link count */ #define MAX_CANON 255 /* max bytes in term canon input line */ #define MAX_INPUT 255 /* max bytes in terminal input */ @@ -6925,6 +6903,12 @@ diff -Nbaur newlib-1.19.0/newlib/libc/include/sys/syslimits.h newlib-1.19.0-ppc/ #define NGROUPS_MAX 16 /* max supplemental group id's */ #ifndef OPEN_MAX #define OPEN_MAX 64 /* max open files per process */ + #endif +-#define PATH_MAX 1024 /* max bytes in pathname */ ++#define PATH_MAX 4096 /* max bytes in pathname */ + #define PIPE_BUF 512 /* max bytes for atomic pipe writes */ + #define IOV_MAX 1024 /* max elements in i/o vector */ + diff -Nbaur newlib-1.19.0/newlib/libc/include/sys/types.h newlib-1.19.0-ppc/newlib/libc/include/sys/types.h --- newlib-1.19.0/newlib/libc/include/sys/types.h 2010-12-08 14:44:06.000000000 +0000 +++ newlib-1.19.0-ppc/newlib/libc/include/sys/types.h 2011-01-13 13:58:57.000000000 +0000