2 * getsectsize.c --- get the sector size of a device.
4 * Copyright (C) 1995, 1995 Theodore Ts'o.
5 * Copyright (C) 2003 VMware, Inc.
8 * This file may be redistributed under the terms of the GNU Public
13 #define _LARGEFILE_SOURCE
14 #define _LARGEFILE64_SOURCE
24 #ifdef HAVE_LINUX_FD_H
25 #include <sys/ioctl.h>
29 #if defined(__linux__) && defined(_IO) && !defined(BLKSSZGET)
30 #define BLKSSZGET _IO(0x12,104)/* get block device sector size */
37 * Returns the number of blocks in a partition
39 errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize)
44 fd = open64(file, O_RDONLY);
46 fd = open(file, O_RDONLY);
52 if (ioctl(fd, BLKSSZGET, sectsize) >= 0) {