Created
April 18, 2016 08:00
-
-
Save josephok/bf6936f52d5d84d32276f2f10cc659ef to your computer and use it in GitHub Desktop.
Add hole to a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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