aboutsummaryrefslogtreecommitdiff
path: root/toys/other
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2016-10-25 15:51:05 -0700
committerRob Landley <rob@landley.net>2016-10-25 23:10:58 -0500
commit31c519dcd7fba4291adfdb9f0d273929cdab7eb4 (patch)
tree79d973c57120e3a8b1463fd7ff1d8a23e6d27dce /toys/other
parent4a17bdf4a7b4db001e9602410587be83be8bce3b (diff)
downloadtoybox-31c519dcd7fba4291adfdb9f0d273929cdab7eb4.tar.gz
Add fallocate -o.
Also improve error reporting.
Diffstat (limited to 'toys/other')
-rw-r--r--toys/other/fallocate.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/toys/other/fallocate.c b/toys/other/fallocate.c
index 7a226343..a7308972 100644
--- a/toys/other/fallocate.c
+++ b/toys/other/fallocate.c
@@ -4,14 +4,14 @@
*
* No standard
-USE_FALLOCATE(NEWTOY(fallocate, ">1l#|", TOYFLAG_USR|TOYFLAG_BIN))
+USE_FALLOCATE(NEWTOY(fallocate, ">1l#|o#", TOYFLAG_USR|TOYFLAG_BIN))
config FALLOCATE
bool "fallocate"
depends on TOYBOX_FALLOCATE
default y
help
- usage: fallocate [-l size] file
+ usage: fallocate [-l size] [-o offset] file
Tell the filesystem to allocate space for a file.
*/
@@ -20,12 +20,14 @@ config FALLOCATE
#include "toys.h"
GLOBALS(
+ long offset;
long size;
)
void fallocate_main(void)
{
int fd = xcreate(*toys.optargs, O_RDWR | O_CREAT, 0644);
- if (posix_fallocate(fd, 0, TT.size)) error_exit("Not enough space");
+ if ((errno = posix_fallocate(fd, TT.offset, TT.size)))
+ perror_exit("fallocate");
if (CFG_TOYBOX_FREE) close(fd);
}