commit:     82af9273c46fe3f6227d0bf0e9198a11f8a82156
Author:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  1 18:29:39 2023 +0000
Commit:     Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
CommitDate: Sun Jan  1 18:29:39 2023 +0000
URL:        
https://gitweb.gentoo.org/proj/toolchain/glibc-patches.git/commit/?id=82af9273

Update dirent-related patchset from azanella/bz23960-dirent git branch

Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>

 9999/0001-Disable-ldconfig-during-install.patch    |  10 +-
 ...Adapt-to-Gentoo-specific-etc-mail-aliases.patch |   7 +-
 ...O0-in-conform-tests-to-survive-CC-changes.patch |   6 +-
 .../0004-Fix-miscompilation-on-ia64-s-gcc-10.patch |   6 +-
 ...t-skip-entries-with-zero-d_ino-values-BZ-.patch | 182 ---------------------
 ...-linux-Use-getdents64-on-non-LFS-readdir.patch} |  61 ++++---
 ...ternal-DIR-filepos-as-off64_t-BZ-23960-B.patch} |  10 +-
 ...h => 0007-linux-Add-__readdir64_unlocked.patch} |  17 +-
 ... 0008-linux-Add-__old_readdir64_unlocked.patch} |  34 ++--
 ...tdents64-on-readdir64-compat-implementat.patch} |  95 ++++-------
 ...h => 0010-dirent-Deprecate-getdirentries.patch} |  29 ++--
 11 files changed, 126 insertions(+), 331 deletions(-)

diff --git a/9999/0001-Disable-ldconfig-during-install.patch 
b/9999/0001-Disable-ldconfig-during-install.patch
index 7bc6628..4a8c771 100644
--- a/9999/0001-Disable-ldconfig-during-install.patch
+++ b/9999/0001-Disable-ldconfig-during-install.patch
@@ -1,7 +1,10 @@
-From 4917be423cb1a70a66e90e39a73e986b011d7687 Mon Sep 17 00:00:00 2001
+From 5349895a928bff28939b228824c8265d20d9fa60 Mon Sep 17 00:00:00 2001
 From: Mike Frysinger <vap...@gentoo.org>
 Date: Tue, 3 Aug 2021 00:34:59 +0200
-Subject: [PATCH 01/12] Disable ldconfig during install
+Subject: [PATCH 01/10] Disable ldconfig during install
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
 
 Do not bother running ldconfig on DESTDIR.  It's a waste of time as we
 won't use the result (portage will rebuild the cache after install).
@@ -10,6 +13,7 @@ we end up (incorrectly) flagging it as a violation as a write 
to /etc.
 
 http://sourceware.org/ml/libc-alpha/2012-08/msg00118.html
 https://bugs.gentoo.org/431038
+Signed-off-by: Andreas K. Hüttel <dilfri...@gentoo.org>
 ---
  Makefile | 1 +
  1 file changed, 1 insertion(+)
@@ -27,5 +31,5 @@ index 179dd478ff..763d6a084a 100644
          $(elf-objpfx)ldconfig $(addprefix -r ,$(install_root)) \
                                $(slibdir) $(libdir)
 -- 
-2.35.1
+2.38.2
 

diff --git a/9999/0002-Adapt-to-Gentoo-specific-etc-mail-aliases.patch 
b/9999/0002-Adapt-to-Gentoo-specific-etc-mail-aliases.patch
index 56b9db3..559e736 100644
--- a/9999/0002-Adapt-to-Gentoo-specific-etc-mail-aliases.patch
+++ b/9999/0002-Adapt-to-Gentoo-specific-etc-mail-aliases.patch
@@ -1,7 +1,7 @@
-From a66ccda34dd319ce19255a029b746362d5773d31 Mon Sep 17 00:00:00 2001
+From ab1ca71990a972e375709711f5fa268010505324 Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Andreas=20K=2E=20H=C3=BCttel?= <dilfri...@gentoo.org>
 Date: Mon, 22 Oct 2018 22:34:13 +0200
-Subject: [PATCH 02/12] Adapt to Gentoo-specific /etc/mail/aliases
+Subject: [PATCH 02/10] Adapt to Gentoo-specific /etc/mail/aliases
 MIME-Version: 1.0
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 8bit
@@ -10,6 +10,7 @@ Patch by pacho2
 
 Signed-off-by: Andreas K. Hüttel <dilfri...@gentoo.org>
 (cherry picked from commit 4e616cda056f471b799beba2b1cedc787ad4ecc0)
+Signed-off-by: Andreas K. Hüttel <dilfri...@gentoo.org>
 ---
  nss/nss_files/files-alias.c    |  2 +-
  nss/tst-nss-files-alias-leak.c | 18 +++++++++---------
@@ -104,5 +105,5 @@ index 4bf6fe0834..1548eba2ad 100644
    /* valgrind needs a temporary directory in the chroot.  */
    {
 -- 
-2.35.1
+2.38.2
 

diff --git a/9999/0003-Force-O0-in-conform-tests-to-survive-CC-changes.patch 
b/9999/0003-Force-O0-in-conform-tests-to-survive-CC-changes.patch
index 95fc2c5..f662cda 100644
--- a/9999/0003-Force-O0-in-conform-tests-to-survive-CC-changes.patch
+++ b/9999/0003-Force-O0-in-conform-tests-to-survive-CC-changes.patch
@@ -1,7 +1,7 @@
-From 68476d32783ea64c21bbd6d166a69fa881a3f22b Mon Sep 17 00:00:00 2001
+From f44c6c3768c2a3ef274782a2e308fb6b8fe84499 Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Andreas=20K=2E=20H=C3=BCttel?= <dilfri...@gentoo.org>
 Date: Fri, 14 Dec 2018 20:43:04 +0100
-Subject: [PATCH 03/12] Force -O0 in conform tests to survive $CC changes
+Subject: [PATCH 03/10] Force -O0 in conform tests to survive $CC changes
 MIME-Version: 1.0
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 8bit
@@ -61,5 +61,5 @@ index f7fe3a7a0a..ad87fd2a6d 100644
                                                    args.header)
      with tempfile.TemporaryDirectory() as temp_dir:
 -- 
-2.35.1
+2.38.2
 

diff --git a/9999/0004-Fix-miscompilation-on-ia64-s-gcc-10.patch 
b/9999/0004-Fix-miscompilation-on-ia64-s-gcc-10.patch
index b742135..2d9c8f7 100644
--- a/9999/0004-Fix-miscompilation-on-ia64-s-gcc-10.patch
+++ b/9999/0004-Fix-miscompilation-on-ia64-s-gcc-10.patch
@@ -1,7 +1,7 @@
-From 88e7fe55212b0110dca46b5d3a4b7be8db404598 Mon Sep 17 00:00:00 2001
+From 4aafe3fae7777fec09e2dd3915a8fd33642bba94 Mon Sep 17 00:00:00 2001
 From: Sergei Trofimovich <sly...@gentoo.org>
 Date: Sat, 11 Jul 2020 20:06:51 +0300
-Subject: [PATCH 04/12] Fix miscompilation on ia64's gcc-10
+Subject: [PATCH 04/10] Fix miscompilation on ia64's gcc-10
 MIME-Version: 1.0
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 8bit
@@ -28,5 +28,5 @@ index aa1de6b361..f6472f1942 100644
  # define DL_SYSINFO_IMPLEMENTATION            \
    asm (".text\n\t"                            \
 -- 
-2.35.1
+2.38.2
 

diff --git 
a/9999/0005-linux-Do-not-skip-entries-with-zero-d_ino-values-BZ-.patch 
b/9999/0005-linux-Do-not-skip-entries-with-zero-d_ino-values-BZ-.patch
deleted file mode 100644
index 33f9869..0000000
--- a/9999/0005-linux-Do-not-skip-entries-with-zero-d_ino-values-BZ-.patch
+++ /dev/null
@@ -1,182 +0,0 @@
-From ad50ce9ae10cdd50bd620ae6ef67fe3b11896913 Mon Sep 17 00:00:00 2001
-From: Adhemerval Zanella <adhemerval.zane...@linaro.org>
-Date: Tue, 20 Oct 2020 12:18:56 -0300
-Subject: [PATCH 05/12] linux: Do not skip entries with zero d_ino values [BZ
- #12165]
-
-According to Linux commit 2adc376c55194 (vfs: avoid creation of inode
-number 0 in get_next_ino) Linux did not treat d_ino == 0 as a special
-case (it is a valid inode number).
-
-This patch fixes readdir{64} by not ignoring entried with d_ino being
-0.
-
-Checked on x86_64-linux-gnu and i686-linux-gnu.
----
- sysdeps/unix/sysv/linux/readdir.c   | 59 +++++++++++------------------
- sysdeps/unix/sysv/linux/readdir64.c | 59 +++++++++++------------------
- 2 files changed, 44 insertions(+), 74 deletions(-)
-
-diff --git a/sysdeps/unix/sysv/linux/readdir.c 
b/sysdeps/unix/sysv/linux/readdir.c
-index c31f349639..7743f50071 100644
---- a/sysdeps/unix/sysv/linux/readdir.c
-+++ b/sysdeps/unix/sysv/linux/readdir.c
-@@ -25,51 +25,36 @@
- struct dirent *
- __readdir_unlocked (DIR *dirp)
- {
--  struct dirent *dp;
--  int saved_errno = errno;
-+  const int saved_errno = errno;
- 
--  do
-+  if (dirp->offset >= dirp->size)
-     {
--      size_t reclen;
--
--      if (dirp->offset >= dirp->size)
-+      /* We've emptied out our buffer.  Refill it.  */
-+      ssize_t bytes = __getdents (dirp->fd, dirp->data, dirp->allocation);
-+      if (bytes <= 0)
-       {
--        /* We've emptied out our buffer.  Refill it.  */
--
--        size_t maxread = dirp->allocation;
--        ssize_t bytes;
--
--        bytes = __getdents (dirp->fd, dirp->data, maxread);
--        if (bytes <= 0)
--          {
--            /* On some systems getdents fails with ENOENT when the
--               open directory has been rmdir'd already.  POSIX.1
--               requires that we treat this condition like normal EOF.  */
--            if (bytes < 0 && errno == ENOENT)
--              bytes = 0;
--
--            /* Don't modifiy errno when reaching EOF.  */
--            if (bytes == 0)
--              __set_errno (saved_errno);
--            dp = NULL;
--            break;
--          }
--        dirp->size = (size_t) bytes;
--
--        /* Reset the offset into the buffer.  */
--        dirp->offset = 0;
-+        /* On some systems getdents fails with ENOENT when the
-+           open directory has been rmdir'd already.  POSIX.1
-+           requires that we treat this condition like normal EOF.  */
-+        if (bytes < 0 && errno == ENOENT)
-+          bytes = 0;
-+
-+        /* Don't modifiy errno when reaching EOF.  */
-+        if (bytes == 0)
-+          __set_errno (saved_errno);
-+        return NULL;
-       }
-+      dirp->size = bytes;
- 
--      dp = (struct dirent *) &dirp->data[dirp->offset];
--
--      reclen = dp->d_reclen;
-+      /* Reset the offset into the buffer.  */
-+      dirp->offset = 0;
-+    }
- 
--      dirp->offset += reclen;
-+  struct dirent *dp = (struct dirent *) &dirp->data[dirp->offset];
- 
--      dirp->filepos = dp->d_off;
-+  dirp->offset += dp->d_reclen;
- 
--      /* Skip deleted files.  */
--    } while (dp->d_ino == 0);
-+  dirp->filepos = dp->d_off;
- 
-   return dp;
- }
-diff --git a/sysdeps/unix/sysv/linux/readdir64.c 
b/sysdeps/unix/sysv/linux/readdir64.c
-index e876d84b02..d990a36e4e 100644
---- a/sysdeps/unix/sysv/linux/readdir64.c
-+++ b/sysdeps/unix/sysv/linux/readdir64.c
-@@ -30,55 +30,40 @@
- struct dirent64 *
- __readdir64 (DIR *dirp)
- {
--  struct dirent64 *dp;
--  int saved_errno = errno;
-+  const int saved_errno = errno;
- 
- #if IS_IN (libc)
-   __libc_lock_lock (dirp->lock);
- #endif
- 
--  do
-+  if (dirp->offset >= dirp->size)
-     {
--      size_t reclen;
--
--      if (dirp->offset >= dirp->size)
-+      /* We've emptied out our buffer.  Refill it.  */
-+      ssize_t bytes = __getdents64 (dirp->fd, dirp->data, dirp->allocation);
-+      if (bytes <= 0)
-       {
--        /* We've emptied out our buffer.  Refill it.  */
--
--        size_t maxread = dirp->allocation;
--        ssize_t bytes;
--
--        bytes = __getdents64 (dirp->fd, dirp->data, maxread);
--        if (bytes <= 0)
--          {
--            /* On some systems getdents fails with ENOENT when the
--               open directory has been rmdir'd already.  POSIX.1
--               requires that we treat this condition like normal EOF.  */
--            if (bytes < 0 && errno == ENOENT)
--              bytes = 0;
--
--            /* Don't modifiy errno when reaching EOF.  */
--            if (bytes == 0)
--              __set_errno (saved_errno);
--            dp = NULL;
--            break;
--          }
--        dirp->size = (size_t) bytes;
--
--        /* Reset the offset into the buffer.  */
--        dirp->offset = 0;
-+        /* On some systems getdents fails with ENOENT when the
-+           open directory has been rmdir'd already.  POSIX.1
-+           requires that we treat this condition like normal EOF.  */
-+        if (bytes < 0 && errno == ENOENT)
-+          bytes = 0;
-+
-+        /* Don't modifiy errno when reaching EOF.  */
-+        if (bytes == 0)
-+          __set_errno (saved_errno);
-+        return NULL;
-       }
-+      dirp->size = bytes;
- 
--      dp = (struct dirent64 *) &dirp->data[dirp->offset];
--
--      reclen = dp->d_reclen;
-+      /* Reset the offset into the buffer.  */
-+      dirp->offset = 0;
-+   }
- 
--      dirp->offset += reclen;
-+  struct dirent64 *dp = (struct dirent64 *) &dirp->data[dirp->offset];
- 
--      dirp->filepos = dp->d_off;
-+  dirp->offset += dp->d_reclen;
- 
--      /* Skip deleted files.  */
--    } while (dp->d_ino == 0);
-+  dirp->filepos = dp->d_off;
- 
- #if IS_IN (libc)
-   __libc_lock_unlock (dirp->lock);
--- 
-2.35.1
-

diff --git a/9999/0006-linux-Use-getdents64-on-non-LFS-readdir.patch 
b/9999/0005-linux-Use-getdents64-on-non-LFS-readdir.patch
similarity index 82%
rename from 9999/0006-linux-Use-getdents64-on-non-LFS-readdir.patch
rename to 9999/0005-linux-Use-getdents64-on-non-LFS-readdir.patch
index b588195..4e1dc0d 100644
--- a/9999/0006-linux-Use-getdents64-on-non-LFS-readdir.patch
+++ b/9999/0005-linux-Use-getdents64-on-non-LFS-readdir.patch
@@ -1,7 +1,7 @@
-From 5e92232132d809ca1a4dde473e3b9d061754db90 Mon Sep 17 00:00:00 2001
+From 0718c1ca37fe6407bd4bad15dfae873719eabb6e Mon Sep 17 00:00:00 2001
 From: Adhemerval Zanella <adhemerval.zane...@linaro.org>
 Date: Tue, 20 Oct 2020 13:37:15 -0300
-Subject: [PATCH 06/12] linux: Use getdents64 on non-LFS readdir
+Subject: [PATCH 05/10] linux: Use getdents64 on non-LFS readdir
 
 The opendir allocates a translation buffer to be used to return the
 non-LFS readdir entry.  The obtained dirent64 struct is translated
@@ -15,8 +15,8 @@ Checked on x86_64-linux-gnu and i686-linux-gnu.
  sysdeps/unix/sysv/linux/closedir.c  |  4 ++
  sysdeps/unix/sysv/linux/dirstream.h |  5 ++
  sysdeps/unix/sysv/linux/opendir.c   | 21 +++++++
- sysdeps/unix/sysv/linux/readdir.c   | 97 +++++++++++++++++++++--------
- 4 files changed, 101 insertions(+), 26 deletions(-)
+ sysdeps/unix/sysv/linux/readdir.c   | 94 +++++++++++++++++++++--------
+ 4 files changed, 98 insertions(+), 26 deletions(-)
 
 diff --git a/sysdeps/unix/sysv/linux/closedir.c 
b/sysdeps/unix/sysv/linux/closedir.c
 index eee0193fc4..d876d49d78 100644
@@ -82,10 +82,10 @@ index 9e81d00630..bfd2f382a6 100644
  #if IS_IN (libc)
    __libc_lock_init (dirp->lock);
 diff --git a/sysdeps/unix/sysv/linux/readdir.c 
b/sysdeps/unix/sysv/linux/readdir.c
-index 7743f50071..7b4571839e 100644
+index c9a04dc160..c078146d7d 100644
 --- a/sysdeps/unix/sysv/linux/readdir.c
 +++ b/sysdeps/unix/sysv/linux/readdir.c
-@@ -21,42 +21,87 @@
+@@ -21,42 +21,84 @@
  #if !_DIRENT_MATCHES_DIRENT64
  #include <dirstream.h>
  
@@ -131,39 +131,31 @@ index 7743f50071..7b4571839e 100644
  struct dirent *
  __readdir_unlocked (DIR *dirp)
  {
-   const int saved_errno = errno;
+-  struct dirent *dp;
+   int saved_errno = errno;
  
 -  if (dirp->offset >= dirp->size)
 +  while (1)
      {
 -      /* We've emptied out our buffer.  Refill it.  */
--      ssize_t bytes = __getdents (dirp->fd, dirp->data, dirp->allocation);
+-
+-      size_t maxread = dirp->allocation;
+-      ssize_t bytes;
+-
+-      bytes = __getdents (dirp->fd, dirp->data, maxread);
 -      if (bytes <= 0)
 +      if (dirp->offset >= dirp->size)
-       {
--        /* On some systems getdents fails with ENOENT when the
--           open directory has been rmdir'd already.  POSIX.1
--           requires that we treat this condition like normal EOF.  */
--        if (bytes < 0 && errno == ENOENT)
--          bytes = 0;
--
--        /* Don't modifiy errno when reaching EOF.  */
--        if (bytes == 0)
--          __set_errno (saved_errno);
--        return NULL;
++      {
 +        /* We've emptied out our buffer.  Refill it.  */
 +        ssize_t bytes = __getdents64 (dirp->fd, dirp->data,
 +                                      dirp->allocation);
 +        if (bytes <= 0)
 +          {
-+            /* On some systems getdents fails with ENOENT when the
-+               open directory has been rmdir'd already.  POSIX.1
-+               requires that we treat this condition like normal EOF.  */
++            /* Linux may fail with ENOENT on some file systems if the
++               directory inode is marked as dead (deleted).  POSIX
++               treats this as a regular end-of-directory condition, so
++               do not set errno in that case, to indicate success.  */
 +            if (bytes < 0 && errno == ENOENT)
-+              bytes = 0;
-+
-+            /* Don't modifiy errno when reaching EOF.  */
-+            if (bytes == 0)
 +              __set_errno (saved_errno);
 +            return NULL;
 +          }
@@ -179,20 +171,25 @@ index 7743f50071..7b4571839e 100644
 +      /* Skip entries which might overflow d_off/d_ino or if the translation
 +       buffer can't be resized.  */
 +      if (dirstream_entry (dirp, dp64))
-+      {
+       {
+-        /* Linux may fail with ENOENT on some file systems if the
+-           directory inode is marked as dead (deleted).  POSIX
+-           treats this as a regular end-of-directory condition, so
+-           do not set errno in that case, to indicate success.  */
+-        if (bytes == 0 || errno == ENOENT)
+-          __set_errno (saved_errno);
+-        return NULL;
 +          dirp->filepos = dp64->d_off;
 +        return (struct dirent *) dirp->tbuffer;
        }
--      dirp->size = bytes;
+-      dirp->size = (size_t) bytes;
 -
 -      /* Reset the offset into the buffer.  */
 -      dirp->offset = 0;
      }
 -
--  struct dirent *dp = (struct dirent *) &dirp->data[dirp->offset];
--
+-  dp = (struct dirent *) &dirp->data[dirp->offset];
 -  dirp->offset += dp->d_reclen;
--
 -  dirp->filepos = dp->d_off;
 -
 -  return dp;
@@ -200,5 +197,5 @@ index 7743f50071..7b4571839e 100644
  
  struct dirent *
 -- 
-2.35.1
+2.38.2
 

diff --git 
a/9999/0007-linux-Set-internal-DIR-filepos-as-off64_t-BZ-23960-B.patch 
b/9999/0006-linux-Set-internal-DIR-filepos-as-off64_t-BZ-23960-B.patch
similarity index 98%
rename from 9999/0007-linux-Set-internal-DIR-filepos-as-off64_t-BZ-23960-B.patch
rename to 9999/0006-linux-Set-internal-DIR-filepos-as-off64_t-BZ-23960-B.patch
index a239bbc..38acaf8 100644
--- a/9999/0007-linux-Set-internal-DIR-filepos-as-off64_t-BZ-23960-B.patch
+++ b/9999/0006-linux-Set-internal-DIR-filepos-as-off64_t-BZ-23960-B.patch
@@ -1,7 +1,7 @@
-From a9813305234d6163d86aa78c062017f05b7a79d6 Mon Sep 17 00:00:00 2001
+From 36f553f67b8268341b7879640637fac5ea806017 Mon Sep 17 00:00:00 2001
 From: Adhemerval Zanella <adhemerval.zane...@linaro.org>
 Date: Mon, 13 Apr 2020 18:09:20 -0300
-Subject: [PATCH 07/12] linux: Set internal DIR filepos as off64_t [BZ #23960,
+Subject: [PATCH 06/10] linux: Set internal DIR filepos as off64_t [BZ #23960,
  BZ #24050]
 
 It allows to obtain the expected entry offset on telldir and set
@@ -39,7 +39,7 @@ and arm-linux-gnueabihf.
  create mode 100644 sysdeps/unix/sysv/linux/telldir.h
 
 diff --git a/dirent/Makefile b/dirent/Makefile
-index b80f6a73ea..65119db578 100644
+index cfa61826ed..9a9d91b8a5 100644
 --- a/dirent/Makefile
 +++ b/dirent/Makefile
 @@ -31,7 +31,7 @@ routines     := opendir closedir readdir readdir_r rewinddir 
\
@@ -276,7 +276,7 @@ index bfd2f382a6..9a0b7ab4c4 100644
    return dirp;
  }
 diff --git a/sysdeps/unix/sysv/linux/readdir.c 
b/sysdeps/unix/sysv/linux/readdir.c
-index 7b4571839e..94ac4cbae7 100644
+index c078146d7d..f377e5f268 100644
 --- a/sysdeps/unix/sysv/linux/readdir.c
 +++ b/sysdeps/unix/sysv/linux/readdir.c
 @@ -17,6 +17,7 @@
@@ -490,5 +490,5 @@ index 0000000000..7c45886341
 +
 +#endif /* _TELLDIR_H  */
 -- 
-2.35.1
+2.38.2
 

diff --git a/9999/0008-linux-Add-__readdir64_unlocked.patch 
b/9999/0007-linux-Add-__readdir64_unlocked.patch
similarity index 93%
rename from 9999/0008-linux-Add-__readdir64_unlocked.patch
rename to 9999/0007-linux-Add-__readdir64_unlocked.patch
index 540ddf7..631550c 100644
--- a/9999/0008-linux-Add-__readdir64_unlocked.patch
+++ b/9999/0007-linux-Add-__readdir64_unlocked.patch
@@ -1,7 +1,7 @@
-From 81cdcf158a683bb9c999967de2e332e5c5881bc9 Mon Sep 17 00:00:00 2001
+From 4cca67d0d2d615918e05db864c236e33c0fda8f3 Mon Sep 17 00:00:00 2001
 From: Adhemerval Zanella <adhemerval.zane...@linaro.org>
 Date: Mon, 13 Apr 2020 08:35:40 -0300
-Subject: [PATCH 08/12] linux: Add __readdir64_unlocked
+Subject: [PATCH 07/10] linux: Add __readdir64_unlocked
 
 And use it on readdir_r implementation.
 
@@ -25,17 +25,18 @@ index d7567f5e86..0c6715d0e4 100644
  libc_hidden_proto (__readdir64)
  extern int __readdir_r (DIR *__dirp, struct dirent *__entry,
 diff --git a/sysdeps/unix/sysv/linux/readdir64.c 
b/sysdeps/unix/sysv/linux/readdir64.c
-index d990a36e4e..c4539f6d96 100644
+index 7952da5c27..9d82054182 100644
 --- a/sysdeps/unix/sysv/linux/readdir64.c
 +++ b/sysdeps/unix/sysv/linux/readdir64.c
-@@ -28,14 +28,10 @@
+@@ -28,15 +28,11 @@
  
  /* Read a directory entry from DIRP.  */
  struct dirent64 *
 -__readdir64 (DIR *dirp)
 +__readdir64_unlocked (DIR *dirp)
  {
-   const int saved_errno = errno;
+   struct dirent64 *dp;
+   int saved_errno = errno;
  
 -#if IS_IN (libc)
 -  __libc_lock_lock (dirp->lock);
@@ -44,8 +45,8 @@ index d990a36e4e..c4539f6d96 100644
    if (dirp->offset >= dirp->size)
      {
        /* We've emptied out our buffer.  Refill it.  */
-@@ -65,6 +61,20 @@ __readdir64 (DIR *dirp)
- 
+@@ -68,6 +64,20 @@ __readdir64 (DIR *dirp)
+   dirp->offset += dp->d_reclen;
    dirp->filepos = dp->d_off;
  
 +  return dp;
@@ -177,5 +178,5 @@ index afd7f9af0f..32962a176a 100644
  
  
 -- 
-2.35.1
+2.38.2
 

diff --git a/9999/0009-linux-Add-__old_readdir64_unlocked.patch 
b/9999/0008-linux-Add-__old_readdir64_unlocked.patch
similarity index 84%
rename from 9999/0009-linux-Add-__old_readdir64_unlocked.patch
rename to 9999/0008-linux-Add-__old_readdir64_unlocked.patch
index 52af81a..3cd2923 100644
--- a/9999/0009-linux-Add-__old_readdir64_unlocked.patch
+++ b/9999/0008-linux-Add-__old_readdir64_unlocked.patch
@@ -1,16 +1,16 @@
-From 82605e1450880ac7d40f1b5d12eecbf2f0815535 Mon Sep 17 00:00:00 2001
+From cd6d96ae0a09c1bff40f19d54e2910d7d4e74864 Mon Sep 17 00:00:00 2001
 From: Adhemerval Zanella <adhemerval.zane...@linaro.org>
 Date: Tue, 14 Apr 2020 11:14:22 -0300
-Subject: [PATCH 09/12] linux: Add __old_readdir64_unlocked
+Subject: [PATCH 08/10] linux: Add __old_readdir64_unlocked
 
 And use it __old_readdir64_r.
 
 Checked on i686-linux-gnu.
 ---
  sysdeps/unix/sysv/linux/olddirent.h   |  2 +
- sysdeps/unix/sysv/linux/readdir64.c   | 21 +++++--
+ sysdeps/unix/sysv/linux/readdir64.c   | 24 +++++---
  sysdeps/unix/sysv/linux/readdir64_r.c | 79 ++++++---------------------
- 3 files changed, 35 insertions(+), 67 deletions(-)
+ 3 files changed, 35 insertions(+), 70 deletions(-)
 
 diff --git a/sysdeps/unix/sysv/linux/olddirent.h 
b/sysdeps/unix/sysv/linux/olddirent.h
 index 9a22609177..00c84b9521 100644
@@ -26,10 +26,10 @@ index 9a22609177..00c84b9521 100644
                          struct __old_dirent64 **__result);
  extern __ssize_t __old_getdents64 (int __fd, char *__buf, size_t __nbytes)
 diff --git a/sysdeps/unix/sysv/linux/readdir64.c 
b/sysdeps/unix/sysv/linux/readdir64.c
-index c4539f6d96..dbf6a8c54d 100644
+index 9d82054182..bbe247f95d 100644
 --- a/sysdeps/unix/sysv/linux/readdir64.c
 +++ b/sysdeps/unix/sysv/linux/readdir64.c
-@@ -101,15 +101,11 @@ versioned_symbol (libc, __readdir64, readdir64, 
GLIBC_2_2);
+@@ -104,15 +104,11 @@ versioned_symbol (libc, __readdir64, readdir64, 
GLIBC_2_2);
  
  attribute_compat_text_section
  struct __old_dirent64 *
@@ -43,12 +43,22 @@ index c4539f6d96..dbf6a8c54d 100644
 -  __libc_lock_lock (dirp->lock);
 -#endif
 -
-   do
+   if (dirp->offset >= dirp->size)
      {
-       size_t reclen;
-@@ -153,6 +149,21 @@ __old_readdir64 (DIR *dirp)
-       /* Skip deleted files.  */
-     } while (dp->d_ino == 0);
+       /* We've emptied out our buffer.  Refill it.  */
+@@ -129,9 +125,6 @@ __old_readdir64 (DIR *dirp)
+            do not set errno in that case, to indicate success.  */
+         if (bytes == 0 || errno == ENOENT)
+           __set_errno (saved_errno);
+-#if IS_IN (libc)
+-        __libc_lock_unlock (dirp->lock);
+-#endif
+         return NULL;
+       }
+       dirp->size = (size_t) bytes;
+@@ -144,6 +137,21 @@ __old_readdir64 (DIR *dirp)
+   dirp->offset += dp->d_reclen;
+   dirp->filepos = dp->d_off;
  
 +  return dp;
 +}
@@ -180,5 +190,5 @@ index 32962a176a..699d120b76 100644
  
  compat_symbol (libc, __old_readdir64_r, readdir64_r, GLIBC_2_1);
 -- 
-2.35.1
+2.38.2
 

diff --git 
a/9999/0010-linux-Use-getdents64-on-readdir64-compat-implementat.patch 
b/9999/0009-linux-Use-getdents64-on-readdir64-compat-implementat.patch
similarity index 78%
rename from 9999/0010-linux-Use-getdents64-on-readdir64-compat-implementat.patch
rename to 9999/0009-linux-Use-getdents64-on-readdir64-compat-implementat.patch
index 5bbea04..7a9c5a3 100644
--- a/9999/0010-linux-Use-getdents64-on-readdir64-compat-implementat.patch
+++ b/9999/0009-linux-Use-getdents64-on-readdir64-compat-implementat.patch
@@ -1,7 +1,7 @@
-From 7a72e18a7b710feea5375578450e11a106336102 Mon Sep 17 00:00:00 2001
+From c71a60022adc7c9b7e37a813e2abad0d0724245a Mon Sep 17 00:00:00 2001
 From: Adhemerval Zanella <adhemerval.zane...@linaro.org>
 Date: Tue, 20 Oct 2020 16:00:43 -0300
-Subject: [PATCH 10/12] linux: Use getdents64 on readdir64 compat
+Subject: [PATCH 09/10] linux: Use getdents64 on readdir64 compat
  implementation
 
 It uses a similar strategy from the non-LFS readdir that also
@@ -12,11 +12,11 @@ It allows to remove __old_getdents64.
 
 Checked on i686-linux-gnu.
 ---
- sysdeps/unix/sysv/linux/getdents64.c |  93 ------------------------
- sysdeps/unix/sysv/linux/olddirent.h  |   2 -
- sysdeps/unix/sysv/linux/opendir.c    |  15 +++-
- sysdeps/unix/sysv/linux/readdir64.c  | 104 +++++++++++++++++----------
- 4 files changed, 79 insertions(+), 135 deletions(-)
+ sysdeps/unix/sysv/linux/getdents64.c | 93 ----------------------------
+ sysdeps/unix/sysv/linux/olddirent.h  |  2 -
+ sysdeps/unix/sysv/linux/opendir.c    | 15 ++++-
+ sysdeps/unix/sysv/linux/readdir64.c  | 62 +++++++++++++++----
+ 4 files changed, 64 insertions(+), 108 deletions(-)
 
 diff --git a/sysdeps/unix/sysv/linux/getdents64.c 
b/sysdeps/unix/sysv/linux/getdents64.c
 index 510a586859..92481526c5 100644
@@ -167,10 +167,10 @@ index 9a0b7ab4c4..df40b0a64e 100644
    dirp->tbuffer = malloc (tbuffer_size);
    if (dirp->tbuffer == NULL)
 diff --git a/sysdeps/unix/sysv/linux/readdir64.c 
b/sysdeps/unix/sysv/linux/readdir64.c
-index dbf6a8c54d..4b41299c6c 100644
+index bbe247f95d..01e834e238 100644
 --- a/sysdeps/unix/sysv/linux/readdir64.c
 +++ b/sysdeps/unix/sysv/linux/readdir64.c
-@@ -99,57 +99,83 @@ versioned_symbol (libc, __readdir64, readdir64, GLIBC_2_2);
+@@ -102,21 +102,52 @@ versioned_symbol (libc, __readdir64, readdir64, 
GLIBC_2_2);
  # if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
  #  include <olddirent.h>
  
@@ -218,68 +218,36 @@ index dbf6a8c54d..4b41299c6c 100644
 -  int saved_errno = errno;
 +  const int saved_errno = errno;
  
--  do
-+  if (dirp->offset >= dirp->size)
+   if (dirp->offset >= dirp->size)
      {
--      size_t reclen;
+       /* We've emptied out our buffer.  Refill it.  */
 -
--      if (dirp->offset >= dirp->size)
-+      /* We've emptied out our buffer.  Refill it.  */
+-      size_t maxread = dirp->allocation;
+-      ssize_t bytes;
+-
+-      bytes = __old_getdents64 (dirp->fd, dirp->data, maxread);
 +      ssize_t bytes = __getdents64 (dirp->fd, dirp->data, dirp->allocation);
-+      if (bytes <= 0)
+       if (bytes <= 0)
        {
--        /* We've emptied out our buffer.  Refill it.  */
--
--        size_t maxread = dirp->allocation;
--        ssize_t bytes;
--
--        bytes = __old_getdents64 (dirp->fd, dirp->data, maxread);
--        if (bytes <= 0)
--          {
--            /* On some systems getdents fails with ENOENT when the
--               open directory has been rmdir'd already.  POSIX.1
--               requires that we treat this condition like normal EOF.  */
--            if (bytes < 0 && errno == ENOENT)
--              bytes = 0;
--
--            /* Don't modifiy errno when reaching EOF.  */
--            if (bytes == 0)
--              __set_errno (saved_errno);
--            dp = NULL;
--            break;
--          }
--        dirp->size = (size_t) bytes;
--
--        /* Reset the offset into the buffer.  */
--        dirp->offset = 0;
--      }
--
--      dp = (struct __old_dirent64 *) &dirp->data[dirp->offset];
-+        /* On some systems getdents fails with ENOENT when the
-+           open directory has been rmdir'd already.  POSIX.1
-+           requires that we treat this condition like normal EOF.  */
-+        if (bytes < 0 && errno == ENOENT)
-+          bytes = 0;
- 
--      reclen = dp->d_reclen;
-+        /* Don't modifiy errno when reaching EOF.  */
-+        if (bytes == 0)
-+          __set_errno (saved_errno);
-+        return NULL;
-+      }
+         /* Linux may fail with ENOENT on some file systems if the
+@@ -127,17 +158,24 @@ __old_readdir64_unlocked (DIR *dirp)
+           __set_errno (saved_errno);
+         return NULL;
+       }
+-      dirp->size = (size_t) bytes;
 +      dirp->size = bytes;
  
--      dirp->offset += reclen;
-+      /* Reset the offset into the buffer.  */
-+      dirp->offset = 0;
-+    }
+       /* Reset the offset into the buffer.  */
+       dirp->offset = 0;
+     }
  
--      dirp->filepos = dp->d_off;
+-  dp = (struct __old_dirent64 *) &dirp->data[dirp->offset];
+-  dirp->offset += dp->d_reclen;
+-  dirp->filepos = dp->d_off;
 +  struct dirent64 *dp64 = (struct dirent64 *) &dirp->data[dirp->offset];
 +  dirp->offset += dp64->d_reclen;
  
--      /* Skip deleted files.  */
--    } while (dp->d_ino == 0);
+-  return dp;
 +  /* Skip entries which might overflow d_ino or for memory allocation failure
 +     in case of large file names.  */
 +  if (dirstream_old_entry (dirp, dp64))
@@ -287,12 +255,11 @@ index dbf6a8c54d..4b41299c6c 100644
 +      dirp->filepos = dp64->d_off;
 +      return (struct __old_dirent64 *) dirp->tbuffer;
 +    }
- 
--  return dp;
++
 +  return NULL;
  }
  
  attribute_compat_text_section
 -- 
-2.35.1
+2.38.2
 

diff --git a/9999/0011-dirent-Deprecate-getdirentries.patch 
b/9999/0010-dirent-Deprecate-getdirentries.patch
similarity index 82%
rename from 9999/0011-dirent-Deprecate-getdirentries.patch
rename to 9999/0010-dirent-Deprecate-getdirentries.patch
index c7abd61..28f744a 100644
--- a/9999/0011-dirent-Deprecate-getdirentries.patch
+++ b/9999/0010-dirent-Deprecate-getdirentries.patch
@@ -1,7 +1,7 @@
-From fe14184069e952f57e74f1e599816d0403205ac0 Mon Sep 17 00:00:00 2001
+From 2f0668caf22acf6493dce8dcfd670e4b35fb6892 Mon Sep 17 00:00:00 2001
 From: Adhemerval Zanella <adhemerval.zane...@linaro.org>
 Date: Fri, 17 Apr 2020 09:59:51 -0300
-Subject: [PATCH 11/12] dirent: Deprecate getdirentries
+Subject: [PATCH 10/10] dirent: Deprecate getdirentries
 
 The interface has some issues:
 
@@ -17,28 +17,25 @@ The interface has some issues:
 
 The idea is to eventually move the symbols to compat ones.
 ---
- NEWS                             |  6 ++++++
+ NEWS                             |  3 +++
  dirent/dirent.h                  | 14 ++++++++++----
  sysdeps/unix/sysv/linux/Makefile |  4 ++++
- 3 files changed, 20 insertions(+), 4 deletions(-)
+ 3 files changed, 17 insertions(+), 4 deletions(-)
 
 diff --git a/NEWS b/NEWS
-index bc1aac1270..56c4d3ed7e 100644
+index a10bb08fb0..2b4ed6bbc1 100644
 --- a/NEWS
 +++ b/NEWS
-@@ -93,6 +93,12 @@ Security related changes:
+@@ -21,6 +21,9 @@ Deprecated and removed features, and other changes affecting 
compatibility:
+   corresponds to the AT_PLATFORM system name, or employs the legacy AT_HWCAP
+   search mechanism, which was deprecated in version 2.33.
  
-   [Add security related changes here]
- 
-+Deprecated and removed features, and other changes affecting compatibility:
-+
 +* The function getdirentries is now deprecated, applications should use
 +  either getdents64, readdir64 or readdir.
 +
-+
- The following bugs are resolved with this release:
+ Changes to build and runtime requirements:
  
-   [The release manager will add the list generated by
+   [Add changes to build and runtime requirements here]
 diff --git a/dirent/dirent.h b/dirent/dirent.h
 index c47d3273b2..1c299e5be8 100644
 --- a/dirent/dirent.h
@@ -84,10 +81,10 @@ index c47d3273b2..1c299e5be8 100644
  #endif /* Use misc.  */
  
 diff --git a/sysdeps/unix/sysv/linux/Makefile 
b/sysdeps/unix/sysv/linux/Makefile
-index a139a16532..237b8ca80a 100644
+index f298878e8f..41e5341450 100644
 --- a/sysdeps/unix/sysv/linux/Makefile
 +++ b/sysdeps/unix/sysv/linux/Makefile
-@@ -365,6 +365,10 @@ tests += \
+@@ -467,6 +467,10 @@ tests += \
    tst-getdents64 \
    tst-readdir64-compat \
    # tests
@@ -99,5 +96,5 @@ index a139a16532..237b8ca80a 100644
  
  ifeq ($(subdir),nis)
 -- 
-2.35.1
+2.38.2
 

Reply via email to