public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: [PATCH 3/4] Use LFS readdir in generic POSIX getcwd [BZ# 22899]
Date: Wed, 26 Aug 2020 18:02:45 -0300	[thread overview]
Message-ID: <20200826210246.2830973-3-adhemerval.zanella@linaro.org> (raw)
In-Reply-To: <20200826210246.2830973-1-adhemerval.zanella@linaro.org>

Checked on x86_64-linux-gnu and i686-linux-gnu.
---
 sysdeps/posix/getcwd.c              | 9 +++++----
 sysdeps/unix/sysv/linux/readdir64.c | 4 ++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c
index 3876e1a641..1e6fc9b845 100644
--- a/sysdeps/posix/getcwd.c
+++ b/sysdeps/posix/getcwd.c
@@ -96,11 +96,12 @@
 # define __lstat64 lstat
 # define __closedir closedir
 # define __opendir opendir
-# define __readdir readdir
+# define __readdir64 readdir
 # define __fdopendir fdopendir
 # define __openat openat
 # define __rewinddir rewinddir
 # define __openat64 openat
+# define dirent64 dirent
 #else
 # include <not-cancel.h>
 #endif
@@ -259,7 +260,7 @@ __getcwd (char *buf, size_t size)
 
   while (!(thisdev == rootdev && thisino == rootino))
     {
-      struct dirent *d;
+      struct dirent64 *d;
       dev_t dotdev;
       ino_t dotino;
       bool mount_point;
@@ -312,7 +313,7 @@ __getcwd (char *buf, size_t size)
           /* Clear errno to distinguish EOF from error if readdir returns
              NULL.  */
           __set_errno (0);
-          d = __readdir (dirstream);
+          d = __readdir64 (dirstream);
 
           /* When we've iterated through all directory entries without finding
              one with a matching d_ino, rewind the stream and consider each
@@ -325,7 +326,7 @@ __getcwd (char *buf, size_t size)
             {
               use_d_ino = false;
               __rewinddir (dirstream);
-              d = __readdir (dirstream);
+              d = __readdir64 (dirstream);
             }
 
           if (d == NULL)
diff --git a/sysdeps/unix/sysv/linux/readdir64.c b/sysdeps/unix/sysv/linux/readdir64.c
index 7d4b0001b3..170a889c51 100644
--- a/sysdeps/unix/sysv/linux/readdir64.c
+++ b/sysdeps/unix/sysv/linux/readdir64.c
@@ -42,7 +42,11 @@ weak_alias (__readdir64, readdir)
 /* The compat code expects the 'struct direct' with d_ino being a __ino_t
    instead of __ino64_t.  */
 # include <shlib-compat.h>
+# if IS_IN(rtld)
+weak_alias (__readdir64, readdir64)
+# else
 versioned_symbol (libc, __readdir64, readdir64, GLIBC_2_2);
+# endif
 # if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
 #  include <olddirent.h>
 #  define __READDIR   attribute_compat_text_section __old_readdir64
-- 
2.25.1


  parent reply	other threads:[~2020-08-26 21:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-26 21:02 [PATCH 1/4] Sync getcwd with gnulib Adhemerval Zanella
2020-08-26 21:02 ` [PATCH 2/4] linux: Remove __ASSUME_ATFCTS Adhemerval Zanella
2020-08-26 21:02 ` Adhemerval Zanella [this message]
2020-08-27  9:58   ` [PATCH 3/4] Use LFS readdir in generic POSIX getcwd [BZ# 22899] Florian Weimer
2020-08-26 21:02 ` [PATCH 4/4] io: Reorganize the getcwd implementation Adhemerval Zanella
2020-08-26 22:39   ` Paul Eggert
2020-08-27 12:35   ` Adhemerval Zanella
2020-08-27 13:21     ` Florian Weimer
2020-08-27 13:40       ` Adhemerval Zanella
2020-08-27 17:29     ` Adhemerval Zanella
2020-08-27 19:20   ` [PATCH v2] " Adhemerval Zanella
2020-08-27 23:44     ` Paul Eggert
2020-08-31 18:27       ` Adhemerval Zanella
2020-08-26 22:39 ` [PATCH 1/4] Sync getcwd with gnulib Paul Eggert
2020-08-27 11:07   ` Adhemerval Zanella
2020-08-27  8:14 ` Florian Weimer
2020-08-27 10:53   ` Adhemerval Zanella
2020-08-27 10:58     ` Florian Weimer
2020-08-27 11:06       ` Adhemerval Zanella
2020-08-27 11:10         ` Florian Weimer
2020-08-27 11:33           ` Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200826210246.2830973-3-adhemerval.zanella@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).