]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/test_cfuse_cache_invalidate.cc
import ceph quincy 17.2.4
[ceph.git] / ceph / src / test / test_cfuse_cache_invalidate.cc
1
2 #include <stdio.h>
3 #include <errno.h>
4 #include <string.h>
5 #include <sys/types.h>
6 #include <sys/wait.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9 #include <unistd.h>
10
11 #include "include/ceph_assert.h"
12
13 #define REGION 1048576
14 int main(int argc, char *argv[]) {
15
16 pid_t p = fork();
17 char buf[REGION];
18 memset(buf, 0, sizeof(buf));
19
20 if (p != 0) {
21 int done = 0;
22 int fd = open(argv[1], O_RDWR|O_CREAT, 0644);
23 if (fd < 0) {
24 perror(argv[1]);
25 return 1;
26 }
27
28 int i = 0;
29 while(!done) {
30 printf("writing %d\n", i++);
31 ceph_assert(pwrite(fd, buf, REGION, 0) == REGION);
32 int status;
33 int ret = waitpid(p, &status, WNOHANG);
34 ceph_assert(ret >= 0);
35 if (ret > 0) {
36 done = 1;
37 }
38 }
39 close(fd);
40 } else {
41 sleep(1);
42 int fd = open(argv[2], O_RDONLY, 0644);
43 if (fd < 0) {
44 perror(argv[2]);
45 return 1;
46 }
47
48 printf("reading\n");
49 ceph_assert(pread(fd, buf, REGION, 0) == REGION);
50 close(fd);
51 }
52
53 return 0;
54 }