1 /* fallocate.c - Preallocate space to a file 2 * 3 * Copyright 2013 Felix Janda <[email protected]> 4 * 5 * No standard 6 7 USE_FALLOCATE(NEWTOY(fallocate, ">1l#|o#", TOYFLAG_USR|TOYFLAG_BIN)) 8 9 config FALLOCATE 10 bool "fallocate" 11 default y 12 help 13 usage: fallocate [-o OFFSET] -l SIZE FILE 14 15 Tell the filesystem to allocate space for a range in a file. 16 17 -l Number of bytes in range 18 -o Start offset of range (default 0) 19 */ 20 21 #define FOR_fallocate 22 #include "toys.h" 23 GLOBALS(long o,l;)24GLOBALS( 25 long o, l; 26 ) 27 28 void fallocate_main(void) 29 { 30 int fd = xcreate(*toys.optargs, O_RDWR | O_CREAT, 0644); 31 if ((errno = posix_fallocate(fd, TT.o, TT.l))) perror_exit("fallocate"); 32 if (CFG_TOYBOX_FREE) close(fd); 33 } 34