blob: 4ac2ea1f131a7c26fd7c133acfa93e69b7fdd134 [file] [log] [blame]
Theodore Ts'od36d8351997-11-12 03:48:07 +00001/*
2 * tst_getsize.c --- this function tests the getsize function
Theodore Ts'oefc6f622008-08-27 23:07:54 -04003 *
Theodore Ts'od36d8351997-11-12 03:48:07 +00004 * Copyright (C) 1997 by Theodore Ts'o.
Theodore Ts'oefc6f622008-08-27 23:07:54 -04005 *
Theodore Ts'od36d8351997-11-12 03:48:07 +00006 * %Begin-Header%
Theodore Ts'o543547a2010-05-17 21:31:56 -04007 * This file may be redistributed under the terms of the GNU Library
8 * General Public License, version 2.
Theodore Ts'od36d8351997-11-12 03:48:07 +00009 * %End-Header%
10 */
11
Theodore Ts'od1154eb2011-09-18 17:34:37 -040012#include "config.h"
Theodore Ts'od36d8351997-11-12 03:48:07 +000013#include <stdio.h>
14#include <string.h>
15#if HAVE_UNISTD_H
16#include <unistd.h>
17#endif
Theodore Ts'od36d8351997-11-12 03:48:07 +000018#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
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +000026#include "ext2_fs.h"
Theodore Ts'od36d8351997-11-12 03:48:07 +000027#include "ext2fs.h"
28
29int 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 }
Theodore Ts'o04f13d62009-09-08 21:33:03 -040038 add_error_table(&et_ext2_error_table);
Theodore Ts'od36d8351997-11-12 03:48:07 +000039 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 }
Eric Sandeend0ff90d2006-09-12 14:56:15 -040044 printf("%s is device has %u blocks.\n", argv[1], blocks);
Theodore Ts'od36d8351997-11-12 03:48:07 +000045 return 0;
46}