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
16 #include <sys/types.h>
18 #include "../misc/nls-enable.h"
20 static void usage(char *progname)
22 fprintf(stderr, _("%s: %s filename nblocks blocksize\n"),
28 int main(int argc, char **argv)
31 int nblocks, blocksize;
41 nblocks = strtoul(argv[2], 0, 0) - 1;
42 blocksize = strtoul(argv[3], 0, 0);
45 fprintf(stderr, _("Illegal number of blocks!\n"));
49 retval = ext2fs_get_memzero(blocksize, &block);
51 fprintf(stderr, _("Couldn't allocate block buffer (size=%d)\n"),
56 fd = open(filename, O_RDWR);
61 ret = lseek(fd, nblocks*blocksize, SEEK_SET);
66 ret = read(fd, block, blocksize);
71 ret = lseek(fd, nblocks*blocksize, SEEK_SET);
76 ret = write(fd, block, blocksize);
81 ext2fs_free_mem(&block);