Skip to content

Instantly share code, notes, and snippets.

@josephok
Created April 18, 2016 08:00
Show Gist options
  • Save josephok/bf6936f52d5d84d32276f2f10cc659ef to your computer and use it in GitHub Desktop.
Save josephok/bf6936f52d5d84d32276f2f10cc659ef to your computer and use it in GitHub Desktop.
Add hole to a file
// Removed all error hanlder for simplicity
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
int main(int argc, char const *argv[]) {
int flags = O_RDWR;
char *strs = "memmmmmmmm\n";
int fd = open(argv[1], flags);
off_t nseek = lseek(fd, 10000, SEEK_END);
for (size_t i = 0; i < 100; i++) {
write(fd, strs, sizeof(strs));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment