Whamcloud - gitweb
mke2fs: account for physical as well as logical sector size
[tools/e2fsprogs.git] / lib / ext2fs / tst_getsectsize.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 Library
8  * General Public License, version 2.
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, char **argv)
29 {
30         int     lsectsize, psectsize;
31         int     retval;
32
33         if (argc < 2) {
34                 fprintf(stderr, "Usage: %s device\n", argv[0]);
35                 exit(1);
36         }
37
38         retval = ext2fs_get_device_sectsize(argv[1], &lsectsize);
39         if (retval) {
40                 com_err(argv[0], retval,
41                         "while calling ext2fs_get_device_sectsize");
42                 exit(1);
43         }
44         retval = ext2fs_get_device_phys_sectsize(argv[1], &psectsize);
45         if (retval) {
46                 com_err(argv[0], retval,
47                         "while calling ext2fs_get_device_phys_sectsize");
48                 exit(1);
49         }
50         printf("Device %s has logical/physical sector size of %d/%d.\n",
51                argv[1], lsectsize, psectsize);
52         exit(0);
53 }