Whamcloud - gitweb
Many files:
[tools/e2fsprogs.git] / lib / ext2fs / tst_getsize.c
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 Public
8  * License.
9  * %End-Header%
10  */
11
12 #include <stdio.h>
13 #include <string.h>
14 #if HAVE_UNISTD_H
15 #include <unistd.h>
16 #endif
17 #include <fcntl.h>
18 #include <time.h>
19 #include <sys/stat.h>
20 #include <sys/types.h>
21 #if HAVE_ERRNO_H
22 #include <errno.h>
23 #endif
24
25 #if EXT2_FLAT_INCLUDES
26 #include "ext2_fs.h"
27 #else
28 #include <linux/ext2_fs.h>
29 #endif
30
31 #include "ext2fs.h"
32
33 int main(int argc, const char *argv[])
34 {
35         errcode_t       retval;
36         blk_t           blocks;
37
38         if (argc < 2) {
39                 fprintf(stderr, "%s device\n", argv[0]);
40                 exit(1);
41         }
42         retval = ext2fs_get_device_size(argv[1], 1024, &blocks);
43         if (retval) {
44                 com_err(argv[0], retval, "while getting device size");
45                 exit(1);
46         }
47         printf("%s is device has %d blocks.\n", argv[1], blocks);
48         return 0;
49 }