From ae80d88bcb8fb6b76dba3ef816a0ae1644aa9504 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 2 Nov 2015 08:48:58 -0700 Subject: [PATCH] util: fix return code checks in dev_get_blocklen The ioctl() calls in dev_get_blocklen() were checking for != 0 instead of == 0, so the default path (512) was always being taken. Change-Id: Ib0b016b1d453fb94d408063417b7485ff24ed220 Signed-off-by: Daniel Verkamp --- lib/util/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/util/file.c b/lib/util/file.c index b6b0b68e8..e736da5ce 100644 --- a/lib/util/file.c +++ b/lib/util/file.c @@ -67,13 +67,13 @@ dev_get_blocklen(int fd) #if defined(DKIOCGETBLOCKSIZE) /* FreeBSD */ uint32_t blocklen; - if (ioctl(fd, DKIOCGETBLOCKSIZE, &blocklen) != 0) { + if (ioctl(fd, DKIOCGETBLOCKSIZE, &blocklen) == 0) { return blocklen; } #elif defined(__linux__) && defined(BLKSSZGET) uint32_t blocklen; - if (ioctl(fd, BLKSSZGET, &blocklen) != 0) { + if (ioctl(fd, BLKSSZGET, &blocklen) == 0) { return blocklen; } #endif