Debian Codegraph @

testsuite/systemtap.syscall/pwrite.c

raw
1 /* COVERAGE: pwrite pwrite64 */
2 #define _BSD_SOURCE
3 #define _DEFAULT_SOURCE
4 #define _LARGEFILE64_SOURCE
5 #define _ISOC99_SOURCE /* Needed for LLONG_MAX on RHEL5 */
6 #define _FILE_OFFSET_BITS 64
7 #define _XOPEN_SOURCE 500
8 #include <sys/types.h>
9 #include <sys/stat.h>
10 #include <fcntl.h>
11 #include <stdlib.h>
12 #include <unistd.h>
13 #include <limits.h>
14 #include <linux/unistd.h>
15 #include <sys/uio.h>
16 #include <sys/syscall.h>
17 #include <sys/mman.h>
18
19 #define STRING1 "red"
20 #define STRING2 "green"
21 #define STRING3 "blue"
22 int main()
23 {
24 int fd;
25 loff_t res;
26 char buf[64], buf1[32], buf2[32], buf3[32];
27
28 mlockall(MCL_CURRENT);
29
30 fd = open("foobar1", O_WRONLY|O_CREAT, 0666);
31 //staptest// [[[[open (!!!!openat (AT_FDCWD, ]]]]"foobar1", O_WRONLY|O_CREAT[[[[.O_LARGEFILE]]]]?, 0666) = NNNN
32
33 pwrite(fd, "Hello Again", 11, 12);
34 //staptest// pwrite (NNNN, "Hello Again", 11, 12) = 11
35
36 pwrite(-1, "Hello Again", 11, 12);
37 //staptest// pwrite (-1, "Hello Again", 11, 12) = NNNN
38
39 pwrite(fd, (void *)-1, 11, 12);
40 #ifdef __s390__
41 //staptest// pwrite (NNNN, 0x[7]?[f]+, 11, 12) = NNNN
42 #else
43 //staptest// pwrite (NNNN, 0x[f]+, 11, 12) = NNNN
44 #endif
45
46 /* We need to be careful when writing -1 bytes. */
47 pwrite(-1, NULL, -1, 12);
48 #if __WORDSIZE == 64
49 //staptest// pwrite (-1, *0x0, 18446744073709551615, 12) = NNNN
50 #else
51 //staptest// pwrite (-1, *0x0, 4294967295, 12) = NNNN
52 #endif
53
54 pwrite(fd, "Hello Again", 11, -1);
55 //staptest// pwrite (NNNN, "Hello Again", 11, -1) = NNNN
56
57 pwrite(-1, "Hello Again", 11, 0x12345678deadbeefLL);
58 //staptest// pwrite (-1, "Hello Again", 11, 1311768468603649775) = NNNN
59
60 pwrite(-1, "Hello Again", 11, LLONG_MAX);
61 //staptest// pwrite (-1, "Hello Again", 11, 9223372036854775807) = NNNN
62
63 close (fd);
64 //staptest// close (NNNN) = 0
65
66 return 0;
67 }