2 * extend.c --- extend a file so that it has at least a specified
5 * Copyright (C) 1993, 1994, 1995 Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Public
15 #include <sys/types.h>
17 #include "../misc/nls-enable.h"
19 static void usage(char *progname)
21 fprintf(stderr, _("%s: %s filename nblocks blocksize\n"),
27 int main(int argc, char **argv)
30 int nblocks, blocksize;
39 nblocks = strtoul(argv[2], 0, 0) - 1;
40 blocksize = strtoul(argv[3], 0, 0);
43 fprintf(stderr, _("Illegal number of blocks!\n"));
47 block = malloc(blocksize);
49 fprintf(stderr, _("Couldn't allocate block buffer (size=%d)\n"),
53 memset(block, 0, blocksize);
55 fd = open(filename, O_RDWR);
60 ret = lseek(fd, nblocks*blocksize, SEEK_SET);
65 ret = read(fd, block, blocksize);
70 ret = lseek(fd, nblocks*blocksize, SEEK_SET);
75 ret = write(fd, block, blocksize);