From 464df1d5e5ab1322e2dd0a7796939fff1aeefa9a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 17:49:25 +0200 Subject: Adding upstream version 1.47.0. Signed-off-by: Daniel Baumann --- lib/ext2fs/tst_getsectsize.c | 63 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 lib/ext2fs/tst_getsectsize.c (limited to 'lib/ext2fs/tst_getsectsize.c') diff --git a/lib/ext2fs/tst_getsectsize.c b/lib/ext2fs/tst_getsectsize.c new file mode 100644 index 0000000..d616965 --- /dev/null +++ b/lib/ext2fs/tst_getsectsize.c @@ -0,0 +1,63 @@ +/* + * tst_getsize.c --- this function tests the getsize function + * + * Copyright (C) 1997 by Theodore Ts'o. + * + * %Begin-Header% + * This file may be redistributed under the terms of the GNU Library + * General Public License, version 2. + * %End-Header% + */ + +#include "config.h" +#include +#include +#if HAVE_UNISTD_H +#include +#endif +#include +#include +#include +#include +#if HAVE_ERRNO_H +#include +#endif + +#include "ext2_fs.h" +#include "ext2fs.h" + +int main(int argc, char **argv) +{ + int lsectsize, psectsize; + int retval; + int fd; + + if (argc < 2) { + fprintf(stderr, "Usage: %s device\n", argv[0]); + exit(1); + } + + retval = ext2fs_get_device_sectsize(argv[1], &lsectsize); + if (retval) { + com_err(argv[0], retval, + "while calling ext2fs_get_device_sectsize"); + exit(1); + } + retval = ext2fs_get_device_phys_sectsize(argv[1], &psectsize); + if (retval) { + com_err(argv[0], retval, + "while calling ext2fs_get_device_phys_sectsize"); + exit(1); + } + printf("Device %s has logical/physical sector size of %d/%d.\n", + argv[1], lsectsize, psectsize); + fd = open(argv[1], O_RDONLY); + if (fd < 0) { + perror("open"); + exit(1); + } + printf("The device's DIO alignment is %d\n", + ext2fs_get_dio_alignment(fd)); + close(fd); + exit(0); +} -- cgit v1.2.3