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