#include #include #include #include #include #include #include #define TESTSIZE (64*1024*1024) #define FILENAME "my_tmp_file" int main() { int fd = open(FILENAME, O_RDWR | O_CREAT | O_TRUNC, 0600); if(fd>0) { unlink(FILENAME); /* The file is gone */ if(lseek(fd, TESTSIZE, SEEK_SET)==TESTSIZE && write(fd, "x", 1)==1) { int prot = PROT_READ|PROT_WRITE; int flag = MAP_SHARED; char *ptr = (char*) mmap(0, TESTSIZE, prot, flag, fd, 0); if(ptr!=(char*)-1) { int idx, lcnt; close(fd); /* Dirty the pages */ for(lcnt=0; lcnt<3; lcnt++) { for(idx=0; idx