Debian Codegraph @

testsuite/systemtap.syscall/readdir.c

raw
1 /* COVERAGE: readdir old_readdir */
2 /* 'old_readdir' isn't a separate syscall from 'readdir'. On some
3 * platforms (like i386), readdir is implemented via old_readdir. */
4
5 #define _GNU_SOURCE
6 #include <fcntl.h>
7 #include <unistd.h>
8 #include <stdlib.h>
9 #include <sys/syscall.h>
10
11 #define BUFSIZE 512
12
13
14 #ifdef __NR_readdir
15
16 long __readdir(unsigned int fd, void *dirent,
17 unsigned int count) {
18 return syscall(__NR_readdir, fd, dirent, count);
19 }
20
21
22 int main() {
23 int fd;
24 void *buf;
25
26 fd = open(".", O_RDONLY);
27 buf = malloc(BUFSIZE);
28
29 // test normal operation
30
31 __readdir(fd, buf, 0);
32 //staptest// [[[[readdir (NNNN, XXXX, 0)!!!!ni_syscall ()]]]] = NNNN
33
34
35 // test nasty calls
36
37 __readdir(-1, buf, 0);
38 //staptest// [[[[readdir (4294967295, XXXX, 0)!!!!ni_syscall ()]]]] = -NNNN
39
40 __readdir(fd, (void *)-1, 0);
41 #ifdef __s390__
42 //staptest// [[[[readdir (NNNN, 0x[7]?[f]+, 0)!!!!ni_syscall ()]]]] = NNNN
43 #else
44 //staptest// [[[[readdir (NNNN, 0x[f]+, 0)!!!!ni_syscall ()]]]] = NNNN
45 #endif
46
47 __readdir(fd, buf, -1);
48 //staptest// [[[[readdir (NNNN, XXXX, 4294967295)!!!!ni_syscall ()]]]] = NNNN
49
50 free(buf);
51 close(fd);
52
53 return 0;
54 }
55 #else /* __NR_readdir */
56 int main() {
57 return 0;
58 }
59 #endif
60