summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/ltp/ltp/0001-Add-configure-time-check-for-getdents-getdents64-API.patch
blob: bfceadb190d2e324c94d62f0784595bb76e52aef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
From 404dfeb4faef213b0450f173b60cd7080edec349 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 26 Jul 2019 10:32:29 -0700
Subject: [PATCH 1/2] Add configure time check for getdents/getdents64 APIs

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

Upstream-Status: Submitted [http://lists.linux.it/pipermail/ltp/2019-July/012954.html]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 configure.ac                                  | 2 ++
 testcases/kernel/syscalls/getdents/getdents.h | 8 ++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

--- a/configure.ac
+++ b/configure.ac
@@ -65,6 +65,8 @@ AC_CHECK_FUNCS([ \
     fallocate \
     fchownat \
     fstatat \
+    getdents \
+    getdents64 \
     kcmp \
     mkdirat \
     mknodat \
--- a/testcases/kernel/syscalls/getdents/getdents.h
+++ b/testcases/kernel/syscalls/getdents/getdents.h
@@ -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
  */
@@ -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;
@@ -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 */