#include #include #include #include #include #include #include int main(){ int fd = open("holes.txt",O_RDWR); size_t seek_point = ((size_t)1024)*1024*1024*1024*64; void *loc = mmap(0, seek_point + 40, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if ((ssize_t)loc == -1){ perror("Mapping File"); goto out; } printf("File contents from the beginning: %s\n", loc); strcpy(loc + 10000, "A squirrel snuck under my bed. I can tell, because it smells like rotten fish!\n"); printf("File contents 10000 characters in: %s\n", loc + 10000); printf("File contents after the hole: %s\n", loc + seek_point); strcpy(loc + strlen(loc)-1, loc + seek_point); ftruncate(fd, strlen(loc)); munmap(loc, seek_point + 40); out: close(fd); return 0; }