Implement -o support for fallocate(1)
This commit is contained in:
parent
c4315c880a
commit
2ca69a77fb
@ -9,19 +9,22 @@
|
|||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
eprintf("usage: %s -l length file\n", argv0);
|
eprintf("usage: %s [-o offset] -l length file\n", argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
long size;
|
off_t size = 0, offset = 0;
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'l':
|
case 'l':
|
||||||
size = estrtol(EARGF(usage()), 10);
|
size = estrtol(EARGF(usage()), 10);
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
offset = estrtol(EARGF(usage()), 10);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
@ -33,7 +36,7 @@ main(int argc, char *argv[])
|
|||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
eprintf("open %s:", argv[0]);
|
eprintf("open %s:", argv[0]);
|
||||||
|
|
||||||
if (posix_fallocate(fd, 0, size) < 0)
|
if (posix_fallocate(fd, offset, size) < 0)
|
||||||
eprintf("posix_fallocate:");
|
eprintf("posix_fallocate:");
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
Loading…
Reference in New Issue
Block a user