Blob Blame History Raw
From 6392be68c4d481148e20dbc2a8380cc246f27ad1 Mon Sep 17 00:00:00 2001
From: Ondrej Kozina <okozina@redhat.com>
Date: Tue, 19 Jun 2018 14:45:45 +0200
Subject: [PATCH 2/4] Fix write_lseek_blockwise for in the middle of sector
 case.

See unit test write_lseek_blockwise(bsize=512, offset=1, length=1).

The test tries to modify single byte at offset 1 of device with
bsize=512.
---
 lib/utils_io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/utils_io.c b/lib/utils_io.c
index 94c4ef6..8336b18 100644
--- a/lib/utils_io.c
+++ b/lib/utils_io.c
@@ -216,8 +216,8 @@ ssize_t write_lseek_blockwise(int fd, size_t bsize, size_t alignment,
 		if (lseek(fd, offset - frontHang, SEEK_SET) < 0)
 			goto out;
 
-		r = write_buffer(fd, frontPadBuf, frontHang + innerCount);
-		if (r < 0 || r != (ssize_t)(frontHang + innerCount))
+		r = write_buffer(fd, frontPadBuf, bsize);
+		if (r < 0 || r != (ssize_t)bsize)
 			goto out;
 
 		buf = (char*)buf + innerCount;
-- 
1.8.3.1