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>
18 static void usage(char *progname)
20 fprintf(stderr, "%s: %s filename nblocks blocksize\n",
26 int main(int argc, char **argv)
29 int nblocks, blocksize;
38 nblocks = strtoul(argv[2], 0, 0) - 1;
39 blocksize = strtoul(argv[3], 0, 0);
42 fprintf(stderr, "Illegal number of blocks!\n");
46 block = malloc(blocksize);
48 fprintf(stderr, "Couldn't allocate block buffer(size=%d)\n",
52 memset(block, 0, blocksize);
54 fd = open(filename, O_RDWR);
59 ret = lseek(fd, nblocks*blocksize, SEEK_SET);
64 ret = read(fd, block, blocksize);
69 ret = lseek(fd, nblocks*blocksize, SEEK_SET);
74 ret = write(fd, block, blocksize);