• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * tst_getsize.c --- this function tests the getsize function
3  *
4  * Copyright (C) 1997 by Theodore Ts'o.
5  *
6  * %Begin-Header%
7  * This file may be redistributed under the terms of the GNU Library
8  * General Public License, version 2.
9  * %End-Header%
10  */
11 
12 #include "config.h"
13 #include <stdio.h>
14 #include <string.h>
15 #if HAVE_UNISTD_H
16 #include <unistd.h>
17 #endif
18 #include <fcntl.h>
19 #include <time.h>
20 #include <sys/stat.h>
21 #include <sys/types.h>
22 #if HAVE_ERRNO_H
23 #include <errno.h>
24 #endif
25 
26 #include "ext2_fs.h"
27 #include "ext2fs.h"
28 
main(int argc,const char * argv[])29 int main(int argc, const char *argv[])
30 {
31 	errcode_t	retval;
32 	blk_t		blocks;
33 
34 	if (argc < 2) {
35 		fprintf(stderr, "%s device\n", argv[0]);
36 		exit(1);
37 	}
38 	add_error_table(&et_ext2_error_table);
39 	retval = ext2fs_get_device_size(argv[1], 1024, &blocks);
40 	if (retval) {
41 		com_err(argv[0], retval, "while getting device size");
42 		exit(1);
43 	}
44 	printf("%s is device has %u blocks.\n", argv[1], blocks);
45 	return 0;
46 }
47