diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2018-03-01 18:22:16 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2018-04-25 17:55:33 -0300 |
commit | 7d80f48e93508476d0d17d368b34b28cd5dda2a5 (patch) | |
tree | d8672dcbc6ae05b783855ba4d4f18b09dd388627 /sysdeps/unix/sysv/linux/getdirentries64.c | |
parent | 42a2bf58ffadf26ebfdfdeb96e2878eb19a1d922 (diff) | |
download | glibc-7d80f48e93508476d0d17d368b34b28cd5dda2a5.zip glibc-7d80f48e93508476d0d17d368b34b28cd5dda2a5.tar.gz glibc-7d80f48e93508476d0d17d368b34b28cd5dda2a5.tar.bz2 |
Consolidate getdirentries{64} implementation
This patch consolidates Linux getdirentries{64} implementation on just
the default sysdeps/unix/sysv/linux/getdirentries{64} ones. The default
implementation handles the Linux requirements:
* getdirentries is only built for _DIRENT_MATCHES_DIRENT64 being 0.
* getdirentries64 is always built and aliased to getdents for ABIs
that define _DIRENT_MATCHES_DIRENT64 to 1.
Checked on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
sparcv9-linux-gnu, sparc64-linux-gnu, powerpc-linux-gnu, and
powerpc64le-linux-gnu.
* sysdeps/unix/sysv/linux/getdirentries.c (getdirentries): Build iff
_DIRENT_MATCHES_DIRENT64 is not defined.
* sysdeps/unix/sysv/linux/getdirentries64.c (getdirentries64): Open
implementation and alias to getdirentries if _DIRENT_MATCHES_DIRENT64
is defined.
* sysdeps/unix/sysv/linux/wordsize-64/getdirentries.c: Remove file.
* sysdeps/unix/sysv/linux/wordsize-64/getdirentries64.c: Remove file.
Diffstat (limited to 'sysdeps/unix/sysv/linux/getdirentries64.c')
-rw-r--r-- | sysdeps/unix/sysv/linux/getdirentries64.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/sysdeps/unix/sysv/linux/getdirentries64.c b/sysdeps/unix/sysv/linux/getdirentries64.c index e486a36..532f2fc 100644 --- a/sysdeps/unix/sysv/linux/getdirentries64.c +++ b/sysdeps/unix/sysv/linux/getdirentries64.c @@ -1,3 +1,39 @@ -#define GETDIRENTRIES getdirentries64 -#define __GETDENTS __getdents64 -#include "getdirentries.c" +/* Get directory entries in a filesystem-independent format. LFS version. + Copyright (C) 1993-2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#define getdirentries __no_getdirentries_decl +#include <dirent.h> +#undef getdirentries +#include <unistd.h> + +ssize_t +getdirentries64 (int fd, char *buf, size_t nbytes, off64_t *basep) +{ + off64_t base = __lseek64 (fd, (off_t) 0, SEEK_CUR); + + ssize_t result = __getdents64 (fd, buf, nbytes); + + if (result != -1) + *basep = base; + + return result; +} + +#if _DIRENT_MATCHES_DIRENT64 +weak_alias (getdirentries64, getdirentries) +#endif |