6 int main(int argc
, char** argv
)
13 memset(zeros
, 0, sizeof zeros
);
14 memset(ones
, 1, sizeof ones
);
17 fd
= open("test1.data", O_RDWR
|O_CREAT
, 0666);
19 err(1, "creating file");
20 if (write(fd
, zeros
, sizeof zeros
) < 0)
21 err(1, "writing zeros");
25 fd
= open("test1.data", O_RDWR
);
27 err(1, "opening file");
28 if (lseek(fd
, 600, SEEK_SET
) < 0)
31 if (write(fd
, ones
, sizeof ones
) < 0)
32 err(1, "writing ones");
36 addr
= mmap(0, 4096, PROT_READ
|PROT_WRITE
, MAP_PRIVATE
, fd
, 0);
37 if (addr
== MAP_FAILED
)
39 unlink("test1.scratch");
40 fd2
= open("test1.scratch", O_RDWR
|O_CREAT
, 0666);
42 err(1, "creating scratch");
44 if (write(fd2
, addr
, 4096) < 0)
45 err(1, "writing scratch");