xfs: test that reflink forces the log if mounted with wsync
[xfstests-dev.git] / src / append_writer.c
1 /* Simple test program for O_APPEND writes (checked by append_reader.c)
2  * 
3  * Contributed by hatakeyama@bsd.tnes.nec.co.jp
4  */
5 #include <stdio.h>
6 #include <unistd.h>
7 #include <fcntl.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <errno.h>
11 #include <sys/param.h>
12
13 int main(int argc, char **argv)
14 {
15         char file[MAXPATHLEN];
16         int fd, i, iterations;
17
18         if (argc < 2)
19                 exit(1);
20
21         iterations = atoi(argv[1]);
22
23         sprintf(file, "testfile.%d", getpid());
24
25         if ((fd = open(file, O_CREAT | O_RDWR | O_APPEND, 0600)) == -1) {
26                 perror("couldn't open");
27                 exit(1);
28         }
29
30         for (i = 0; i < iterations;i++) {
31                 if (write(fd, &i, sizeof(i)) != sizeof(i)) {
32                         perror("couldn't write");
33                         exit(1);
34                 }
35         }
36
37         exit(0);
38 }
39