Mercurial > hg > toybox
annotate toys/other/fallocate.c @ 1353:2102af52be68 draft
Enable fallocate in defconfig.
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 11 Jun 2014 22:18:35 -0500 |
parents | d5a1174ff88a |
children | 5ec6582aac50 |
rev | line source |
---|---|
993 | 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#|", TOYFLAG_USR|TOYFLAG_BIN)) | |
8 | |
9 config FALLOCATE | |
10 bool "fallocate" | |
1353
2102af52be68
Enable fallocate in defconfig.
Rob Landley <rob@landley.net>
parents:
993
diff
changeset
|
11 default y |
993 | 12 help |
13 usage: fallocate [-l size] file | |
14 | |
15 Tell the filesystem to allocate space for a file. | |
16 */ | |
17 | |
18 #define FOR_fallocate | |
19 #include "toys.h" | |
20 | |
21 GLOBALS( | |
22 long size; | |
23 ) | |
24 | |
25 void fallocate_main(void) | |
26 { | |
27 int fd = xcreate(*toys.optargs, O_RDWR | O_CREAT, 0644); | |
28 if (posix_fallocate(fd, 0, TT.size)) error_exit("Not enough space"); | |
29 if (CFG_TOYBOX_FREE) close(fd); | |
30 } |