Created
May 9, 2020 13:40
-
-
Save nmmmnu/0225562bd1bead91dfc5f74845e4bf64 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
#define _GNU_SOURCE | |
#include <fcntl.h> // open | |
#include <stdlib.h> // fallocate | |
#include <stdio.h> | |
inline void err(const char *msg){ | |
perror(msg); | |
exit(1); | |
} | |
off_t const size = 1024 * 1024 * 1024; | |
int main(void){ | |
int fd = open("testfile", O_RDWR | O_TRUNC | O_CREAT, 0644); | |
if (fd < 0) | |
err("open"); | |
if (fallocate(fd, FALLOC_FL_ZERO_RANGE, 0, 8 * size) < 0) | |
err("fallocate"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment