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 "config.h" 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 { 31 int lsectsize, psectsize; 32 int retval; 33 int fd; 34 35 if (argc < 2) { 36 fprintf(stderr, "Usage: %s device\n", argv[0]); 37 exit(1); 38 } 39 40 retval = ext2fs_get_device_sectsize(argv[1], &lsectsize); 41 if (retval) { 42 com_err(argv[0], retval, 43 "while calling ext2fs_get_device_sectsize"); 44 exit(1); 45 } 46 retval = ext2fs_get_device_phys_sectsize(argv[1], &psectsize); 47 if (retval) { 48 com_err(argv[0], retval, 49 "while calling ext2fs_get_device_phys_sectsize"); 50 exit(1); 51 } 52 printf("Device %s has logical/physical sector size of %d/%d.\n", 53 argv[1], lsectsize, psectsize); 54 fd = open(argv[1], O_RDONLY); 55 if (fd < 0) { 56 perror("open"); 57 exit(1); 58 } 59 printf("The device's DIO alignment is %d\n", 60 ext2fs_get_dio_alignment(fd)); 61 close(fd); 62 exit(0); 63 } 64