xfs/{019, 031}: make sure we don't set rtinherit=1 on mkfs
[xfstests-dev.git] / src / append_reader.c
1 /* Simple test program for checking O_APPEND writes (see append_writer.c)
2  *
3  * Contributed by hatakeyama@bsd.tnes.nec.co.jp
4  */
5 #include <unistd.h>
6 #include <fcntl.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <errno.h>
10 #include <sys/param.h>
11 #include <stdio.h>
12
13 int main(int argc, char **argv)
14 {
15         char *file;
16         int fd, i, rc, d;
17
18         if (argc < 2)
19                 exit(1);
20
21         file = argv[1];
22
23         if ((fd = open(file, O_RDONLY, 0600)) == -1) {
24                 perror("couldn't open");
25                 exit(1);
26         }
27
28         for (i = 0; ;i ++) {
29                 if ((rc = read(fd, &d, sizeof(d))) != sizeof(i)) {
30                         if (rc == 0)
31                                 exit(0);
32                         perror("couldn't read");
33                         exit(1);
34                 }
35
36                 if (d != i) {
37                         fprintf(stderr, "bad data, offset = %u", i * 4);
38                         exit(1);
39                 }
40         }
41
42         exit(0);
43 }
44