Quoth Aurelien Jarno <aurel...@aurel32.net>, on 2010-02-20 11:38:22 +0100: > On Fri, Feb 19, 2010 at 08:35:59PM -0600, Drake Wilson wrote: > > Two C source files are attached. One of them uses Linux fallocate() > > They are not.
D'oh. Sorry! *brown paper bag* Let's try that again, then. *attach* > Your filesystem does not support fallocate, so the glibc is emulating it > with a pwrite. That makes a certain amount of sense in this context; I originally assumed I couldn't trust the return value of the syscall due to the strange parameters (and didn't think ext2 might not have fallocate). > Reassigning. Thank you for the attention, and sorry for the initial incorrectness. ---> Drake Wilson
#define _GNU_SOURCE #include <unistd.h> #include <fcntl.h> int main(int argc, char *argv[]) { int const fd = open("file", O_WRONLY | O_CREAT | O_TRUNC, 0666); if (fd == -1) return 1; int const err = fallocate(fd, 0, 0, (off_t)(1 << 20)); if (err == -1) return 1; return 0; }
#define _XOPEN_SOURCE 600 #include <unistd.h> #include <fcntl.h> int main(int argc, char *argv[]) { int const fd = open("file", O_WRONLY | O_CREAT | O_TRUNC, 0666); if (fd == -1) return 1; int const err = posix_fallocate(fd, 0, (off_t)(1 << 20)); if (err == -1) return 1; return 0; }