aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2024-01-21 19:51:54 +0100
committerCorinna Vinschen <corinna@vinschen.de>2024-01-31 20:11:57 +0100
commit7e40e0169a75ebdf3f3861dab47abdfeb0ad9c58 (patch)
treecce21032416cde1d4b7f262d5d3840cd2c954201
parentcd260e4daa53eae7166aac3a6efbe7ebcf05683f (diff)
downloadnewlib-7e40e0169a75ebdf3f3861dab47abdfeb0ad9c58.zip
newlib-7e40e0169a75ebdf3f3861dab47abdfeb0ad9c58.tar.gz
newlib-7e40e0169a75ebdf3f3861dab47abdfeb0ad9c58.tar.bz2
Cygwin: implement dirent.d_reclen
This change is in preparation of adding posix_getdents() from the upcoming POSIX Base Specification Issue 8. - Add d_reclen - Add GLibC compatible test macros for dirent members - Bump dirent version - Set d_reclen to the fixed size of the dirent struct We can do that because the size is a multiple of 8, so it fits snugly in the buffer filled by posix_getdents and keep the alignement. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r--winsup/cygwin/dir.cc1
-rw-r--r--winsup/cygwin/include/cygwin/version.h3
-rw-r--r--winsup/cygwin/include/sys/dirent.h27
3 files changed, 23 insertions, 8 deletions
diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc
index d67ac02..2e0f03b 100644
--- a/winsup/cygwin/dir.cc
+++ b/winsup/cygwin/dir.cc
@@ -103,6 +103,7 @@ readdir_worker (DIR *dir, dirent *de)
de->d_ino = 0;
de->d_type = DT_UNKNOWN;
+ de->d_reclen = sizeof *de;
memset (&de->__d_unused1, 0, sizeof (de->__d_unused1));
res = ((fhandler_base *) dir->__fh)->readdir (dir, de);
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index e11ad90..ceff101 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -486,12 +486,13 @@ details. */
349: Add fallocate.
350: Add close_range.
351: Add getlocalename_l.
+ 352: Implement dirent.d_reclen.
Note that we forgot to bump the api for ualarm, strtoll, strtoull,
sigaltstack, sethostname. */
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 351
+#define CYGWIN_VERSION_API_MINOR 352
/* There is also a compatibity version number associated with the shared memory
regions. It is incremented when incompatible changes are made to the shared
diff --git a/winsup/cygwin/include/sys/dirent.h b/winsup/cygwin/include/sys/dirent.h
index 40e5e77..668c870 100644
--- a/winsup/cygwin/include/sys/dirent.h
+++ b/winsup/cygwin/include/sys/dirent.h
@@ -13,17 +13,30 @@
#include <sys/types.h>
#include <limits.h>
-#define __DIRENT_VERSION 2
+#define __DIRENT_VERSION 3
+/* Testing macros as per GLibC:
+ _DIRENT_HAVE_D_NAMLEN == dirent has a d_namlen member
+ _DIRENT_HAVE_D_OFF == dirent has a d_off member
+ _DIRENT_HAVE_D_RECLEN == dirent has a d_reclen member
+ _DIRENT_HAVE_D_TYPE == dirent has a d_type member
+*/
+#undef _DIRENT_HAVE_D_NAMLEN
+#undef _DIRENT_HAVE_D_OFF
+#define _DIRENT_HAVE_D_RECLEN
#define _DIRENT_HAVE_D_TYPE
+
struct dirent
{
- uint32_t __d_version; /* Used internally */
- ino_t d_ino;
- unsigned char d_type;
- unsigned char __d_unused1[3];
- __uint32_t __d_internal1;
- char d_name[NAME_MAX + 1];
+ __uint32_t __d_version; /* Used internally */
+ ino_t d_ino;
+ unsigned char d_type;
+ unsigned char __d_unused1[1];
+ __uint16_t d_reclen;
+ __uint32_t __d_internal1;
+ char d_name[NAME_MAX + 1];
+};
+
};
#define d_fileno d_ino /* BSD compatible definition */