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 #include "ext2_fs.h" 26 #include "ext2fs.h" 27 28 int main(int argc, const char *argv[]) 29 { 30 errcode_t retval; 31 blk_t blocks; 32 33 if (argc < 2) { 34 fprintf(stderr, "%s device\n", argv[0]); 35 exit(1); 36 } 37 retval = ext2fs_get_device_size(argv[1], 1024, &blocks); 38 if (retval) { 39 com_err(argv[0], retval, "while getting device size"); 40 exit(1); 41 } 42 printf("%s is device has %u blocks.\n", argv[1], blocks); 43 return 0; 44 } 45