#include #include #include #include int main(int argc, char **argv) { char *mapping; int fd; fd = open("mapfile", O_RDWR | O_TRUNC | O_CREAT, 0666); if (fd < 0) return -1; if (ftruncate(fd, 10) < 0) return -1; mapping = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (-1 == (int)(long)mapping) return -1; memset(mapping, 0x55, 10); if (ftruncate(fd, 100) < 0) return -1; memset(mapping, 0xaa, 200); if (ftruncate(fd, 200) < 0) return -1; return 0; }