]>
git.ipfire.org Git - thirdparty/e2fsprogs.git/blob - e2fsck/extend.c
bdb62c3e2860d5724dc9d3fe1c0f3b4697b39d78
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
;
40 nblocks
= strtoul(argv
[2], 0, 0) - 1;
41 blocksize
= strtoul(argv
[3], 0, 0);
44 fprintf(stderr
, _("Illegal number of blocks!\n"));
48 block
= malloc(blocksize
);
50 fprintf(stderr
, _("Couldn't allocate block buffer (size=%d)\n"),
54 memset(block
, 0, blocksize
);
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
);