]> git.proxmox.com Git - ceph.git/blame - ceph/src/test/test_cfuse_cache_invalidate.cc
update ceph source to reef 18.2.0
[ceph.git] / ceph / src / test / test_cfuse_cache_invalidate.cc
CommitLineData
7c673cae
FG
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>
11fdf7f2
TL
10
11#include "include/ceph_assert.h"
7c673cae
FG
12
13#define REGION 1048576
14int 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++);
11fdf7f2 31 ceph_assert(pwrite(fd, buf, REGION, 0) == REGION);
7c673cae
FG
32 int status;
33 int ret = waitpid(p, &status, WNOHANG);
11fdf7f2 34 ceph_assert(ret >= 0);
7c673cae
FG
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");
11fdf7f2 49 ceph_assert(pread(fd, buf, REGION, 0) == REGION);
7c673cae
FG
50 close(fd);
51 }
52
53 return 0;
54}