mirror of
https://sourceware.org/git/glibc.git
synced 2025-12-24 17:51:17 +03:00
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.
This commit is contained in:
@@ -16,26 +16,21 @@
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef GETDIRENTRIES
|
||||
# define GETDIRENTRIES getdirentries
|
||||
# define __GETDENTS __getdents
|
||||
#else
|
||||
# define off_t off64_t
|
||||
# define __lseek __lseek64
|
||||
#endif
|
||||
#if !_DIRENT_MATCHES_DIRENT64
|
||||
# include <unistd.h>
|
||||
|
||||
ssize_t
|
||||
GETDIRENTRIES (int fd, char *buf, size_t nbytes, off_t *basep)
|
||||
getdirentries (int fd, char *buf, size_t nbytes, off_t *basep)
|
||||
{
|
||||
off_t base = __lseek (fd, (off_t) 0, SEEK_CUR);
|
||||
ssize_t result;
|
||||
off_t base = __lseek (fd, 0, SEEK_CUR);
|
||||
|
||||
result = __GETDENTS (fd, buf, nbytes);
|
||||
ssize_t result = __getdents (fd, buf, nbytes);
|
||||
|
||||
if (result != -1)
|
||||
*basep = base;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user