Debian Codegraph @

testsuite/systemtap.syscall/trunc.c

raw
1 /* COVERAGE: ftruncate ftruncate64 truncate truncate64 */
2
3 #define _LARGEFILE64_SOURCE
4 #include <unistd.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <fcntl.h>
8
9 int main()
10 {
11 int fd;
12
13 fd = creat("foobar", S_IREAD|S_IWRITE);
14
15 ftruncate(fd, 1024);
16 //staptest// ftruncate (NNNN, 1024) = 0
17
18 ftruncate(-1, 1024);
19 //staptest// ftruncate (-1, 1024) = -NNNN (EBADF)
20
21 ftruncate(fd, -1);
22 //staptest// ftruncate (NNNN, -1) = NNNN
23
24 /* Force a 64-bit number here. */
25 ftruncate64(fd, (off64_t)0x1FFFFFFF2LL);
26 //staptest// ftruncate (NNNN, 8589934578) = 0
27
28 ftruncate64(-1, (off64_t)0x7FFFFFFFFFFFFFFFLL);
29 //staptest// ftruncate (-1, 9223372036854775807) = NNNN
30
31 ftruncate64(fd, (off64_t)-1LL);
32 //staptest// ftruncate (NNNN, -1) = NNNN
33
34 close(fd);
35
36 truncate("foobar", 2048);
37 //staptest// truncate ("foobar", 2048) = 0
38
39 truncate((char *)-1, 2048);
40 #ifdef __s390__
41 //staptest// truncate (0x[7]?[f]+, 2048) = -NNNN (EFAULT)
42 #else
43 //staptest// truncate (0x[f]+, 2048) = -NNNN (EFAULT)
44 #endif
45
46 truncate("foobar", -1);
47 //staptest// truncate ("foobar", -1) = NNNN
48
49 /* Force a 64-bit number here. */
50 truncate64("foobar", (off64_t)0x1FFFFFFF2LL);
51 //staptest// truncate ("foobar", 8589934578) = 0
52
53 truncate64((char *)-1, (off64_t)0x7FFFFFFFFFFFFFFFLL);
54 #ifdef __s390__
55 //staptest// truncate (0x[7]?[f]+, 9223372036854775807) = NNNN
56 #else
57 //staptest// truncate (0x[f]+, 9223372036854775807) = NNNN
58 #endif
59
60 truncate64("foobar", (off64_t)-1LL);
61 //staptest// truncate ("foobar", -1) = NNNN
62
63 return 0;
64 }