ubase

suckless linux base utils
git clone git://git.2f30.org/ubase
Log | Files | Refs | README | LICENSE

commit 2ca69a77fb92c7fdcbc93784e201362b1f9c3744
parent c4315c880a1ef0b85677d8ae2fd9e4fe3f3af4f9
Author: sin <sin@2f30.org>
Date:   Sun,  1 Sep 2013 17:57:59 +0100

Implement -o support for fallocate(1)

Diffstat:
Mfallocate.c | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fallocate.c b/fallocate.c @@ -9,19 +9,22 @@ static void usage(void) { - eprintf("usage: %s -l length file\n", argv0); + eprintf("usage: %s [-o offset] -l length file\n", argv0); } int main(int argc, char *argv[]) { int fd; - long size; + off_t size = 0, offset = 0; ARGBEGIN { case 'l': size = estrtol(EARGF(usage()), 10); break; + case 'o': + offset = estrtol(EARGF(usage()), 10); + break; default: usage(); } ARGEND; @@ -33,7 +36,7 @@ main(int argc, char *argv[]) if (fd < 0) eprintf("open %s:", argv[0]); - if (posix_fallocate(fd, 0, size) < 0) + if (posix_fallocate(fd, offset, size) < 0) eprintf("posix_fallocate:"); close(fd);