From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 8326F3858C3A; Thu, 1 Feb 2024 11:39:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8326F3858C3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1706787548; bh=kIpu6WEl9LNGO95Q4iOzuOUUuoWL7gG9uLIzLAoOuHY=; h=From:To:Subject:Date:From; b=XriubKKcTdpVE9dUrGKdP20hcFwujR31V/JF33hkpaJOGRZ71FXUsFufbyftUs6QK TFLE/Paif3NAzY1lhAtlqTdZBch//sSnBlOH9lieu5OjJoERS315K5Tf+bKs2fCChW 4aZnl+79+PB+78+zMqiqAonXHWtO21fqKvxn/Bqk= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: implement dirent.d_reclen X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: cd260e4daa53eae7166aac3a6efbe7ebcf05683f X-Git-Newrev: 7e40e0169a75ebdf3f3861dab47abdfeb0ad9c58 Message-Id: <20240201113908.8326F3858C3A@sourceware.org> Date: Thu, 1 Feb 2024 11:39:06 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D7e40e0169a7= 5ebdf3f3861dab47abdfeb0ad9c58 commit 7e40e0169a75ebdf3f3861dab47abdfeb0ad9c58 Author: Corinna Vinschen AuthorDate: Sun Jan 21 19:51:54 2024 +0100 Commit: Corinna Vinschen CommitDate: Wed Jan 31 20:11:57 2024 +0100 Cygwin: implement dirent.d_reclen =20 This change is in preparation of adding posix_getdents() from the upcoming POSIX Base Specification Issue 8. =20 - 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. =20 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/dir.cc | 1 + winsup/cygwin/include/cygwin/version.h | 3 ++- winsup/cygwin/include/sys/dirent.h | 27 ++++++++++++++++++++------- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index d67ac02d9159..2e0f03b902c0 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -103,6 +103,7 @@ readdir_worker (DIR *dir, dirent *de) =20 de->d_ino =3D 0; de->d_type =3D DT_UNKNOWN; + de->d_reclen =3D sizeof *de; memset (&de->__d_unused1, 0, sizeof (de->__d_unused1)); =20 res =3D ((fhandler_base *) dir->__fh)->readdir (dir, de); diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include= /cygwin/version.h index e11ad90d6c46..ceff10115aad 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. =20 Note that we forgot to bump the api for ualarm, strtoll, strtoull, sigaltstack, sethostname. */ =20 #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 351 +#define CYGWIN_VERSION_API_MINOR 352 =20 /* There is also a compatibity version number associated with the shared m= emory regions. It is incremented when incompatible changes are made to the s= hared diff --git a/winsup/cygwin/include/sys/dirent.h b/winsup/cygwin/include/sys= /dirent.h index 40e5e7729b2e..668c870295b4 100644 --- a/winsup/cygwin/include/sys/dirent.h +++ b/winsup/cygwin/include/sys/dirent.h @@ -13,17 +13,30 @@ #include #include =20 -#define __DIRENT_VERSION 2 +#define __DIRENT_VERSION 3 =20 +/* Testing macros as per GLibC: + _DIRENT_HAVE_D_NAMLEN =3D=3D dirent has a d_namlen member + _DIRENT_HAVE_D_OFF =3D=3D dirent has a d_off member + _DIRENT_HAVE_D_RECLEN =3D=3D dirent has a d_reclen member + _DIRENT_HAVE_D_TYPE =3D=3D 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]; +}; + }; =20 #define d_fileno d_ino /* BSD compatible definition */