Mercurial > hg > toybox
annotate toys/other/fallocate.c @ 1539:3e85af1f7e22 draft
First batch of sed tests.
Only good for TEST_HOST=1 at the moment because the test infrastructure itself
depends on sed, so if an unfinished sed is in the $PATH it goes boing. But
hey, corner cases!
I have... more.
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 29 Oct 2014 18:44:33 -0500 |
parents | 5ec6582aac50 |
children |
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" | |
1369
5ec6582aac50
Make fallocate depend on probe for libc support.
Rob Landley <rob@landley.net>
parents:
1353
diff
changeset
|
11 depends on TOYBOX_FALLOCATE |
1353
2102af52be68
Enable fallocate in defconfig.
Rob Landley <rob@landley.net>
parents:
993
diff
changeset
|
12 default y |
993 | 13 help |
14 usage: fallocate [-l size] file | |
15 | |
16 Tell the filesystem to allocate space for a file. | |
17 */ | |
18 | |
19 #define FOR_fallocate | |
20 #include "toys.h" | |
21 | |
22 GLOBALS( | |
23 long size; | |
24 ) | |
25 | |
26 void fallocate_main(void) | |
27 { | |
28 int fd = xcreate(*toys.optargs, O_RDWR | O_CREAT, 0644); | |
29 if (posix_fallocate(fd, 0, TT.size)) error_exit("Not enough space"); | |
30 if (CFG_TOYBOX_FREE) close(fd); | |
31 } |