Skip to content

Commit

Permalink
syscalls/getdents: Add autotools check for getdents/getdents64
Browse files Browse the repository at this point in the history
glibc 2.30 has added wrapper for getdents64, this will help in detecting
right condition to use fallback.

Check for getdents API as well while here.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
  • Loading branch information
kraj authored and pevik committed Jul 29, 2019
1 parent 1010e92 commit 6d9de5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ AC_CHECK_FUNCS([ \
fallocate \
fchownat \
fstatat \
getdents \
getdents64 \
kcmp \
mkdirat \
mknodat \
Expand Down
12 changes: 10 additions & 2 deletions testcases/kernel/syscalls/getdents/getdents.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <stdint.h>
#include "test.h"
#include "lapi/syscalls.h"

#include "config.h"
/*
* See fs/compat.c struct compat_linux_dirent
*/
Expand All @@ -34,12 +34,17 @@ struct linux_dirent {
char d_name[];
};

#if HAVE_GETDENTS
#include <unistd.h>
#else
static inline int
getdents(unsigned int fd, struct linux_dirent *dirp, unsigned int size)
{
return ltp_syscall(__NR_getdents, fd, dirp, size);
}

#endif /* HAVE_GETDENTS */

struct linux_dirent64 {
uint64_t d_ino;
int64_t d_off;
Expand All @@ -48,10 +53,13 @@ struct linux_dirent64 {
char d_name[];
};

#if HAVE_GETDENTS64
#include <unistd.h>
#else
static inline int
getdents64(unsigned int fd, struct linux_dirent64 *dirp64, unsigned int size)
{
return ltp_syscall(__NR_getdents64, fd, dirp64, size);
}

#endif /* HAVE_GETDENTS64 */
#endif /* GETDENTS_H */

0 comments on commit 6d9de5f

Please sign in to comment.