Implement -o support for fallocate(1)
This commit is contained in:
parent
c4315c880a
commit
2ca69a77fb
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user