public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Cc: Dave Flogeras <dflogeras2@gmail.com>,
	James Clarke <jrtc27@debian.org>,
	John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Subject: [PATCH v2 9/9] dirent: Deprecate getdirentries
Date: Fri,  2 Oct 2020 14:06:20 -0300	[thread overview]
Message-ID: <20201002170620.1611673-10-adhemerval.zanella@linaro.org> (raw)
In-Reply-To: <20201002170620.1611673-1-adhemerval.zanella@linaro.org>

The interface has some issues:

  1. It is build on top getdents on Linux and requires handling
     non-LFS call using LFS getdents.

  2. It is not wildly used and the non-LFS support is as problematic
     as non-LFS readdir.  glibc only exports the LFS getdents.

  3. It is not a direct replacement over BSD since on some plataform
     its signature has changed (FreeBSD 11, for instance, used to
     set the offset as a 'long' and changed to 'off_t' on version 12).

The idea is to eventually move the symbols to compat ones.
---
 NEWS                             |  3 +++
 dirent/dirent.h                  | 11 +++++++----
 sysdeps/unix/sysv/linux/Makefile |  3 +++
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/NEWS b/NEWS
index ce05d05b16..43dab4d519 100644
--- a/NEWS
+++ b/NEWS
@@ -33,6 +33,9 @@ Deprecated and removed features, and other changes affecting compatibility:
 * The mallinfo function is marked deprecated.  Callers should call
   mallinfo2 instead.
 
+* The function getdirentries is now deprecated, applications should use
+  either getdents64, readdir64 or readdir.
+
 Changes to build and runtime requirements:
 
   [Add changes to build and runtime requirements here]
diff --git a/dirent/dirent.h b/dirent/dirent.h
index 92d0925047..1e93f2fbcf 100644
--- a/dirent/dirent.h
+++ b/dirent/dirent.h
@@ -348,29 +348,32 @@ extern int alphasort64 (const struct dirent64 **__e1,
 /* Read directory entries from FD into BUF, reading at most NBYTES.
    Reading starts at offset *BASEP, and *BASEP is updated with the new
    position after reading.  Returns the number of bytes read; zero when at
-   end of directory; or -1 for errors.  */
+   end of directory; or -1 for errors.
+   This is deprecated and getdents64 or readdir should be used instead.  */
 # ifndef __USE_FILE_OFFSET64
 extern __ssize_t getdirentries (int __fd, char *__restrict __buf,
 				size_t __nbytes,
 				__off_t *__restrict __basep)
-     __THROW __nonnull ((2, 4));
+     __THROW __nonnull ((2, 4)) __attribute_deprecated__;
 # else
 #  ifdef __REDIRECT
 extern __ssize_t __REDIRECT_NTH (getdirentries,
 				 (int __fd, char *__restrict __buf,
 				  size_t __nbytes,
 				  __off64_t *__restrict __basep),
-				 getdirentries64) __nonnull ((2, 4));
+				 getdirentries64)
+     __THROW __nonnull ((2, 4)) __attribute_deprecated__;
 #  else
 #   define getdirentries getdirentries64
 #  endif
 # endif
 
 # ifdef __USE_LARGEFILE64
+/* This is deprecated and getdents64 or readdir64 should be used instead.  */
 extern __ssize_t getdirentries64 (int __fd, char *__restrict __buf,
 				  size_t __nbytes,
 				  __off64_t *__restrict __basep)
-     __THROW __nonnull ((2, 4));
+     __THROW __nonnull ((2, 4)) __attribute_deprecated__;
 # endif
 #endif /* Use misc.  */
 
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 3bd3106ef9..55b8df59c5 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -260,6 +260,9 @@ ifeq ($(subdir),dirent)
 sysdep_routines += getdirentries getdirentries64
 tests += tst-getdents64
 tests-internal += tst-readdir64-compat
+
+# Avoid the warning for the weak_alias for _DIRENT_MATCHES_DIRENT64
+CFLAGS-getdirentries64.c = -Wno-deprecated-declarations
 endif
 
 ifeq ($(subdir),nis)
-- 
2.25.1


  parent reply	other threads:[~2020-10-02 17:06 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-02 17:06 [PATCH v2 0/9] Fix getdents{64} regression on some FS Adhemerval Zanella
2020-10-02 17:06 ` [PATCH v2 1/9] linux: Move posix dir implementations to Linux Adhemerval Zanella
2020-10-13 15:33   ` Florian Weimer
2020-10-15 14:08     ` Adhemerval Zanella
2020-10-02 17:06 ` [PATCH v2 2/9] linux: Simplify opendir buffer allocation Adhemerval Zanella
2020-10-13 15:34   ` Florian Weimer
2020-10-02 17:06 ` [PATCH v2 3/9] linux: Add __readdir_unlocked Adhemerval Zanella
2020-10-13 15:43   ` Florian Weimer
2020-10-15 14:10     ` Adhemerval Zanella
2020-10-02 17:06 ` [PATCH v2 4/9] linux: Use getdents64 on non-LFS readdir Adhemerval Zanella
2020-10-13 15:59   ` Florian Weimer
2020-10-15 14:25     ` Adhemerval Zanella
2020-10-19  8:18       ` Florian Weimer
2020-10-19 20:00         ` Adhemerval Zanella
2020-10-19 20:50           ` Florian Weimer
2020-10-19 21:09             ` Adhemerval Zanella
2020-10-20  7:38               ` Florian Weimer
2020-10-20 12:05                 ` Adhemerval Zanella
2020-10-20 12:35                   ` Florian Weimer
2020-10-20 14:09                     ` Adhemerval Zanella
2020-10-20 17:42                     ` Adhemerval Zanella
2020-10-02 17:06 ` [PATCH v2 5/9] linux: Set internal DIR filepos as off64_t [BZ #23960, BZ #24050] Adhemerval Zanella
2020-10-13 16:00   ` Florian Weimer
2020-10-15 14:26     ` Adhemerval Zanella
2020-10-02 17:06 ` [PATCH v2 6/9] linux: Add __readdir64_unlocked Adhemerval Zanella
2020-10-02 17:06 ` [PATCH v2 7/9] linux: Add __old_readdir64_unlocked Adhemerval Zanella
2020-10-02 17:06 ` [PATCH v2 8/9] linux: Use getdents64 on readdir64 compat implementation Adhemerval Zanella
2020-10-02 17:06 ` Adhemerval Zanella [this message]
2020-10-04 13:08 ` [PATCH v2 0/9] Fix getdents{64} regression on some FS Dave Flogeras

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=20201002170620.1611673-10-adhemerval.zanella@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=dflogeras2@gmail.com \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=jrtc27@debian.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).