[Ocfs2-tools-devel] [PATCH v3] o2image: return error if pread64 failed in ocfs2_image_load_bitmap()

piaojun piaojun at huawei.com
Wed Dec 28 19:30:56 PST 2016


In ocfs2_image_load_bitmap(), if pread64 failed, we need catch the
errno and return errno to upper callers. otherwise we may get the
incorrect 'arr_map' but 'o2image -I' execute successfully.

Signed-off-by: Jun Piao <piaojun at huawei.com>
---
 libocfs2/image.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libocfs2/image.c b/libocfs2/image.c
index fe95530..4d4cce2 100644
--- a/libocfs2/image.c
+++ b/libocfs2/image.c
@@ -163,7 +163,8 @@ errcode_t ocfs2_image_load_bitmap(ocfs2_filesys *ofs)
 	struct ocfs2_image_state *ost;
 	struct ocfs2_image_hdr *hdr;
 	uint64_t blk_off, bits_set;
-	int count, i, j, fd;
+	int i, j, fd;
+	ssize_t count;
 	errcode_t ret;
 	char *blk;
 
@@ -218,8 +219,10 @@ errcode_t ocfs2_image_load_bitmap(ocfs2_filesys *ofs)
 		 */
 		count = pread64(fd, ost->ost_bmparr[i].arr_map,
 				ost->ost_bmpblksz, blk_off);
-		if (count < ost->ost_bmpblksz)
+		if (count < 0) {
+			ret = OCFS2_ET_IO;
 			goto out;
+		}
 
 		/* add bits set in this bitmap */
 		for (j = 0; j < (ost->ost_bmpblksz * 8); j++)
-- 
1.9.5.msysgit.1




More information about the Ocfs2-tools-devel mailing list