public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v5 0/5] Fix opendir regression on some FS
@ 2023-01-27 17:28 Adhemerval Zanella
  2023-01-27 17:28 ` [PATCH v5 1/5] linux: Use getdents64 on non-LFS readdir Adhemerval Zanella
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Adhemerval Zanella @ 2023-01-27 17:28 UTC (permalink / raw)
  To: libc-alpha, Andreas K . Huettel, Paul Eggert, Florian Weimer

Some filesystem might return a non-representable d_off on getdents
call, even if there are few entries in the directories (for instance
ext4, which returns a hash).  This trigger issues with non-LFS readdir
when it finds the first non representable entry, and also for LFS
interface when used along with telldir (which return a 'long int',
while d_off is potentially off64_t).

This patch changes non-LFS readdir so it ignore non representable
entries.  The opendir now uses getdents64, even for non-LFS and uses
a translation buffer to return the getdents entry from the getdents64
buffer.

The second part fixes the broken telldir on non LP64 ABIs, where
returning d_off as stream position might overflow.  For these ABIs,
readdir updates an internal list that maps the DIR object off64_t
offsets to the returned long int (the function return value).  The
seekdir will then set the correct offset from the internal list using
the telldir as the list key.

I have checked on x86_64-linux-gnu, i686-linux-gnu, and
arm-linux-gnueabihf.

Changes from v4:
  * Allocate the telldir map an readdir, thus avoid telldir failure.
  * The translation buffer now uses a fixed size struct.
  * Fixed the condition to use the long to off64_t map.

Changes from v3:
  * Rebase against master.
  * Fixed a missing lock unlock on telldir.
  * Renamed tst-seekdir2 to tst-opendir-nolfs and check the opendir
    result against getdents64.


Adhemerval Zanella (5):
  linux: Use getdents64 on non-LFS readdir
  linux: Set internal DIR filepos as off64_t (BZ #23960, BZ #24050)
  linux: Add __readdir64_unlocked
  linux: Add __old_readdir64_unlocked
  linux: Use getdents64 on readdir64 compat implementation

 dirent/tst-scandir.c                        |   6 +-
 dirent/tst-seekdir.c                        |   8 +
 include/dirent.h                            |   3 +-
 sysdeps/unix/sysv/linux/Makefile            |   1 +
 sysdeps/unix/sysv/linux/alpha/bits/dirent.h |   3 +
 sysdeps/unix/sysv/linux/bits/dirent.h       |   4 +
 sysdeps/unix/sysv/linux/closedir.c          |   4 +
 sysdeps/unix/sysv/linux/dirstream.h         |  22 ++-
 sysdeps/unix/sysv/linux/getdents64.c        |  93 ------------
 sysdeps/unix/sysv/linux/olddirent.h         |   4 +-
 sysdeps/unix/sysv/linux/opendir.c           |   3 +
 sysdeps/unix/sysv/linux/readdir.c           |  88 ++++++++---
 sysdeps/unix/sysv/linux/readdir64.c         |  92 ++++++++---
 sysdeps/unix/sysv/linux/readdir64_r.c       | 159 +++++---------------
 sysdeps/unix/sysv/linux/rewinddir.c         |   5 +
 sysdeps/unix/sysv/linux/seekdir.c           |  35 ++++-
 sysdeps/unix/sysv/linux/telldir.c           |  35 +++++
 sysdeps/unix/sysv/linux/telldir.h           |  65 ++++++++
 sysdeps/unix/sysv/linux/tst-opendir-nolfs.c | 146 ++++++++++++++++++
 19 files changed, 499 insertions(+), 277 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/telldir.h
 create mode 100644 sysdeps/unix/sysv/linux/tst-opendir-nolfs.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-03-01 17:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27 17:28 [PATCH v5 0/5] Fix opendir regression on some FS Adhemerval Zanella
2023-01-27 17:28 ` [PATCH v5 1/5] linux: Use getdents64 on non-LFS readdir Adhemerval Zanella
2023-01-27 17:38   ` Andreas Schwab
2023-02-20 13:31   ` Florian Weimer
2023-02-20 17:55     ` Florian Weimer
2023-03-01 16:34       ` Adhemerval Zanella Netto
2023-01-27 17:28 ` [PATCH v5 2/5] linux: Set internal DIR filepos as off64_t (BZ #23960, BZ #24050) Adhemerval Zanella
2023-02-20 18:39   ` Florian Weimer
2023-03-01 17:40     ` Adhemerval Zanella Netto
2023-01-27 17:28 ` [PATCH v5 3/5] linux: Add __readdir64_unlocked Adhemerval Zanella
2023-01-27 17:28 ` [PATCH v5 4/5] linux: Add __old_readdir64_unlocked Adhemerval Zanella
2023-01-27 17:28 ` [PATCH v5 5/5] linux: Use getdents64 on readdir64 compat implementation Adhemerval Zanella
2023-02-09 20:14 ` [PATCH v5 0/5] Fix opendir regression on some FS Andreas K. Huettel
2023-02-09 20:14 ` Andreas K. Huettel

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).