overlay/020: make sure the system supports the required namespaces
[xfstests-dev.git] / src / iopat.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2000-2003 Silicon Graphics, Inc.
4  * All Rights Reserved.
5  */
6
7 #include <stdlib.h>
8 #include <string.h>
9 #include <unistd.h>
10 #include <fcntl.h>
11 #include <sys/ioctl.h>
12 #include <xfs/xfs.h>
13 struct xfs_flock64 f;
14
15 int main(int argc, char **argv)
16 {
17    int fd, i;
18
19    int64_t x[131072];
20
21    for (i = 0; i < 131072; i++) {
22       x[i] = -1;
23    }
24    fd = open(argv[1], O_RDWR | O_CREAT, 0644);
25
26 #ifdef WRITE
27    f.l_whence = 0;
28    f.l_start = 0;
29    f.l_len = 1048576;
30    xfsctl (argv[1], fd, XFS_IOC_RESVSP, &f);
31    for (i = 0; i < 131072; i++) {
32       x[i] = i;
33    }
34    write(fd, &x, 1048576);
35 #endif
36
37 #ifdef READ
38    read(fd, &x, 1048576);
39    for (i = 0; i < 131072; i++) {
40       if (x[i] != i) {
41          printf("error: %d %d %lld\n", i ,8 * i, (long long)x[i]);
42          exit(1);
43       }
44    }
45 #endif
46
47    close(fd);
48    exit(0);
49 }
50