blob: a6b234e0980a32bc4a6d5a5f623063556a1967e4 [file] [log] [blame]
Theodore Ts'o93d5c382003-05-21 17:28:29 -04001/*
2 * tst_getsize.c --- this function tests the getsize function
Theodore Ts'oefc6f622008-08-27 23:07:54 -04003 *
Theodore Ts'o93d5c382003-05-21 17:28:29 -04004 * Copyright (C) 1997 by Theodore Ts'o.
Theodore Ts'oefc6f622008-08-27 23:07:54 -04005 *
Theodore Ts'o93d5c382003-05-21 17:28:29 -04006 * %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'o93d5c382003-05-21 17:28:29 -04009 * %End-Header%
10 */
11
Theodore Ts'od1154eb2011-09-18 17:34:37 -040012#include "config.h"
Theodore Ts'o93d5c382003-05-21 17:28:29 -040013#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
29int main(int argc, char **argv)
30{
Theodore Ts'obb1158b2010-05-17 22:31:45 -040031 int lsectsize, psectsize;
Theodore Ts'o93d5c382003-05-21 17:28:29 -040032 int retval;
Theodore Ts'oefc6f622008-08-27 23:07:54 -040033
Theodore Ts'o93d5c382003-05-21 17:28:29 -040034 if (argc < 2) {
35 fprintf(stderr, "Usage: %s device\n", argv[0]);
36 exit(1);
37 }
38
Theodore Ts'obb1158b2010-05-17 22:31:45 -040039 retval = ext2fs_get_device_sectsize(argv[1], &lsectsize);
Theodore Ts'o93d5c382003-05-21 17:28:29 -040040 if (retval) {
41 com_err(argv[0], retval,
42 "while calling ext2fs_get_device_sectsize");
43 exit(1);
44 }
Theodore Ts'obb1158b2010-05-17 22:31:45 -040045 retval = ext2fs_get_device_phys_sectsize(argv[1], &psectsize);
46 if (retval) {
47 com_err(argv[0], retval,
48 "while calling ext2fs_get_device_phys_sectsize");
49 exit(1);
50 }
51 printf("Device %s has logical/physical sector size of %d/%d.\n",
52 argv[1], lsectsize, psectsize);
Theodore Ts'o93d5c382003-05-21 17:28:29 -040053 exit(0);
54}