turns printfs back on
[freebsd-src/fkvm-freebsd.git] / tools / regression / nfsmmap / test1 / test1.c
blob7a7e69f5694bf3676ff0b5d2fff760745bbb23da
1 #include <sys/types.h>
2 #include <sys/fcntl.h>
3 #include <sys/mman.h>
4 #include <unistd.h>
6 int main(int argc, char** argv)
8 int fd, fd2;
9 caddr_t addr;
10 char zeros[4096];
11 char ones[200];
13 memset(zeros, 0, sizeof zeros);
14 memset(ones, 1, sizeof ones);
15 #if 0
16 unlink("test1.data");
17 fd = open("test1.data", O_RDWR|O_CREAT, 0666);
18 if (fd < 0)
19 err(1, "creating file");
20 if (write(fd, zeros, sizeof zeros) < 0)
21 err(1, "writing zeros");
22 close(fd);
23 #endif
25 fd = open("test1.data", O_RDWR);
26 if (fd < 0)
27 err(1, "opening file");
28 if (lseek(fd, 600, SEEK_SET) < 0)
29 err(1, "seeking");
31 if (write(fd, ones, sizeof ones) < 0)
32 err(1, "writing ones");
34 fsync(fd);
36 addr = mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
37 if (addr == MAP_FAILED)
38 err(1, "mapping");
39 unlink("test1.scratch");
40 fd2 = open("test1.scratch", O_RDWR|O_CREAT, 0666);
41 if (fd2 < 0)
42 err(1, "creating scratch");
44 if (write(fd2, addr, 4096) < 0)
45 err(1, "writing scratch");