Created
August 26, 2015 04:54
-
-
Save h2onda/66c4cf9c54882518bf9d to your computer and use it in GitHub Desktop.
This file contains 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
#include <stdio.h> | |
#include <fcntl.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <string.h> | |
int main(void) | |
{ | |
int fd, ret; | |
char filename[] = "testfile"; | |
long size = 1024 * 1024 * 1024; | |
fd = open(filename, O_RDWR|O_CREAT); | |
if (fd==-1) { | |
printf("open testfile is failed!:%s\n", strerror(errno)); | |
exit(1); | |
} | |
ret = posix_fallocate(fd, (off_t)0, (off_t)size); | |
if (ret != 0) { | |
printf("posix_fallocate is failed!:%s\n", strerror(ret)); | |
exit(1); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment