1 From a739f92a588c7566a7f38d27f1ff87af5dc93f7f Mon Sep 17 00:00:00 2001
2 From: rofl0r <rofl0r@users.noreply.github.com>
3 Date: Wed, 16 Mar 2022 23:19:19 +0000
4 Subject: [PATCH] fix dirent struct
6 the struct wasnt quite like posix demands, and breaks the build with
9 newlib/libc/sys/psp/libcglue.c | 10 +++++----
10 newlib/libc/sys/psp/sys/dirent.h | 35 ++++++++++++++++++++++----------
11 2 files changed, 30 insertions(+), 15 deletions(-)
13 diff --git a/newlib/libc/sys/psp/libcglue.c b/newlib/libc/sys/psp/libcglue.c
14 index d64ba4f..9821ae9 100644
15 --- a/newlib/libc/sys/psp/libcglue.c
16 +++ b/newlib/libc/sys/psp/libcglue.c
17 @@ -414,11 +414,9 @@ DIR *opendir(const char *filename)
18 struct dirent *readdir(DIR *dirp)
21 + SceIoDirent scede = {0};
23 - /* Zero the dirent, to avoid possible problems with sceIoDread */
24 - memset(&dirp->de, 0, sizeof(struct dirent));
26 - ret = sceIoDread(dirp->uid, (SceIoDirent *)&dirp->de);
27 + ret = sceIoDread(dirp->uid, &scede);
31 @@ -428,6 +426,10 @@ struct dirent *readdir(DIR *dirp)
32 (void) __psp_set_errno(ret);
35 + memset(&dirp->de, 0, sizeof(struct dirent));
36 + dirp->de.d_reclen = strlen(scede.d_name);
37 + memcpy(dirp->de.d_name, scede.d_name, dirp->de.d_reclen);
38 + /* FIXME figure out the right values for rest of the dirent struct */
42 diff --git a/newlib/libc/sys/psp/sys/dirent.h b/newlib/libc/sys/psp/sys/dirent.h
43 index 26e2ccc..5007857 100644
44 --- a/newlib/libc/sys/psp/sys/dirent.h
45 +++ b/newlib/libc/sys/psp/sys/dirent.h
51 -#include <pspiofilemgr_dirent.h>
56 -/* Same as SceIoDirent, just with a different name. */
62 - /** Device-specific data. */
65 + ino_t d_fileno; /* file number of entry */
66 + off_t d_off; /* Not an offset; see below */
67 + unsigned short int d_reclen; /* Length of this record */
68 + unsigned char d_type; /* Type of file; not supported by all fs */
69 + char d_name[MAXNAMLEN+1];
82 +#include <pspiofilemgr_dirent.h>
87 + int dd_fd; /* directory file */
88 + int dd_loc; /* position in buffer */
90 + char *dd_buf; /* buffer */
91 + int dd_len; /* buffer length */
92 + int dd_size; /* amount of data in buffer */
95 DIR *opendir (const char *);