1 /*
2 * Copyright (c) International Business Machines Corp., 2001
3 * Copyright (c) 2013 Cyril Hrubis <chrubis@suse.cz>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #ifndef GETDENTS_H
21 #define GETDENTS_H
22
23 #include <stdint.h>
24 #include "test.h"
25 #include "lapi/syscalls.h"
26 #include "config.h"
27 /*
28 * See fs/compat.c struct compat_linux_dirent
29 */
30 struct linux_dirent {
31 unsigned long d_ino;
32 unsigned long d_off;
33 unsigned short d_reclen;
34 char d_name[];
35 };
36
37 #if HAVE_GETDENTS
38 #include <unistd.h>
39 #else
40 static inline int
getdents(unsigned int fd,struct linux_dirent * dirp,unsigned int size)41 getdents(unsigned int fd, struct linux_dirent *dirp, unsigned int size)
42 {
43 return ltp_syscall(__NR_getdents, fd, dirp, size);
44 }
45
46 #endif /* HAVE_GETDENTS */
47
48 struct linux_dirent64 {
49 uint64_t d_ino;
50 int64_t d_off;
51 unsigned short d_reclen;
52 unsigned char d_type;
53 char d_name[];
54 };
55
56 #if HAVE_GETDENTS64
57 #include <dirent.h>
58 #include <unistd.h>
59 #else
60 static inline int
getdents64(unsigned int fd,struct linux_dirent64 * dirp64,unsigned int size)61 getdents64(unsigned int fd, struct linux_dirent64 *dirp64, unsigned int size)
62 {
63 return ltp_syscall(__NR_getdents64, fd, dirp64, size);
64 }
65 #endif /* HAVE_GETDENTS64 */
66 #endif /* GETDENTS_H */
67