/* * Exemplo de arquivo mapeado em memória */ #include #include #include #include #include #include #include #include int main() { int fd; char* map, *str = "Map\n"; if ((fd = open("teste.txt", O_RDWR | O_CREAT, 0644)) == -1) { perror("open"); exit(-1); } if ((map = mmap (NULL, 100, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0)) == (void*) -1) { perror("mmap"); exit(-1); } strcpy(map, str); munmap(map, 100); close(fd); return 0; }