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

piaojun piaojun at huawei.com
Mon Dec 26 05:25:33 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 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libocfs2/image.c b/libocfs2/image.c
index fe95530..1af7fa8 100644
--- a/libocfs2/image.c
+++ b/libocfs2/image.c
@@ -218,8 +218,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