blob: c9185212c313715b5aa919c7cfdc36c803e60e41 (
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
|
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
int
main(int argc, char **argv)
{
int pfd;
pfd = open(argv[1], O_RDWR);
if (pfd == (-1)) {
perror("open");
return EXIT_FAILURE;
}
if (ftruncate(pfd, 0) == (-1)) {
perror("ftruncate");
return EXIT_FAILURE;
}
if (write(pfd, "hello", 5) == (-1)) {
perror("write");
return EXIT_FAILURE;
}
if (fsync(pfd) == (-1)) {
perror("fsync");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
|