Commit 14c83787 authored by Fedor Uporov's avatar Fedor Uporov Committed by Tomasz Zawadzki
Browse files

util: Fix FreeBSD block len ioctl



The DKIOCGETBLOCKSIZE ioctl does not present in FreeBSD, looks it
came from OSX. Add FreeBSD specified DIOCGSECTORSIZE ioctl to avoid
zero block length returning in case of block devices.

Change-Id: I162070ffd911e542630fad3d2c0de67e8160c629
Signed-off-by: default avatarFedor Uporov <fuporov.vstack@gmail.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/18497


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Community-CI: Mellanox Build Bot
parent 74e12a15
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -11,6 +11,10 @@
#include <linux/fs.h>
#endif

#ifdef __FreeBSD__
#include <sys/disk.h>
#endif

static uint64_t
dev_get_size(int fd)
{
@@ -34,7 +38,13 @@ dev_get_size(int fd)
uint32_t
spdk_fd_get_blocklen(int fd)
{
#if defined(DKIOCGETBLOCKSIZE) /* FreeBSD */
#if defined(DIOCGSECTORSIZE) /* FreeBSD */
	uint32_t blocklen;

	if (ioctl(fd, DIOCGSECTORSIZE, &blocklen) == 0) {
		return blocklen;
	}
#elif defined(DKIOCGETBLOCKSIZE)
	uint32_t blocklen;

	if (ioctl(fd, DKIOCGETBLOCKSIZE, &blocklen) == 0) {