Theodore Ts'o | 93d5c38 | 2003-05-21 17:28:29 -0400 | [diff] [blame] | 1 | /* |
| 2 | * tst_getsize.c --- this function tests the getsize function |
Theodore Ts'o | efc6f62 | 2008-08-27 23:07:54 -0400 | [diff] [blame] | 3 | * |
Theodore Ts'o | 93d5c38 | 2003-05-21 17:28:29 -0400 | [diff] [blame] | 4 | * Copyright (C) 1997 by Theodore Ts'o. |
Theodore Ts'o | efc6f62 | 2008-08-27 23:07:54 -0400 | [diff] [blame] | 5 | * |
Theodore Ts'o | 93d5c38 | 2003-05-21 17:28:29 -0400 | [diff] [blame] | 6 | * %Begin-Header% |
Theodore Ts'o | 543547a | 2010-05-17 21:31:56 -0400 | [diff] [blame] | 7 | * This file may be redistributed under the terms of the GNU Library |
| 8 | * General Public License, version 2. |
Theodore Ts'o | 93d5c38 | 2003-05-21 17:28:29 -0400 | [diff] [blame] | 9 | * %End-Header% |
| 10 | */ |
| 11 | |
Theodore Ts'o | d1154eb | 2011-09-18 17:34:37 -0400 | [diff] [blame] | 12 | #include "config.h" |
Theodore Ts'o | 93d5c38 | 2003-05-21 17:28:29 -0400 | [diff] [blame] | 13 | #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 | |
| 29 | int main(int argc, char **argv) |
| 30 | { |
Theodore Ts'o | bb1158b | 2010-05-17 22:31:45 -0400 | [diff] [blame] | 31 | int lsectsize, psectsize; |
Theodore Ts'o | 93d5c38 | 2003-05-21 17:28:29 -0400 | [diff] [blame] | 32 | int retval; |
Theodore Ts'o | efc6f62 | 2008-08-27 23:07:54 -0400 | [diff] [blame] | 33 | |
Theodore Ts'o | 93d5c38 | 2003-05-21 17:28:29 -0400 | [diff] [blame] | 34 | if (argc < 2) { |
| 35 | fprintf(stderr, "Usage: %s device\n", argv[0]); |
| 36 | exit(1); |
| 37 | } |
| 38 | |
Theodore Ts'o | bb1158b | 2010-05-17 22:31:45 -0400 | [diff] [blame] | 39 | retval = ext2fs_get_device_sectsize(argv[1], &lsectsize); |
Theodore Ts'o | 93d5c38 | 2003-05-21 17:28:29 -0400 | [diff] [blame] | 40 | if (retval) { |
| 41 | com_err(argv[0], retval, |
| 42 | "while calling ext2fs_get_device_sectsize"); |
| 43 | exit(1); |
| 44 | } |
Theodore Ts'o | bb1158b | 2010-05-17 22:31:45 -0400 | [diff] [blame] | 45 | 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'o | 93d5c38 | 2003-05-21 17:28:29 -0400 | [diff] [blame] | 53 | exit(0); |
| 54 | } |