[Ocfs2-tools-devel] [PATCH v2] o2image: return error if pread64 failed in ocfs2_image_load_bitmap()
Joseph Qi
jiangqi903 at gmail.com
Mon Dec 26 16:59:05 PST 2016
On 16/12/26 21:25, piaojun wrote:
> 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;
> + }
Thanks, Jun.
We'd better also define count as type ssize_t to avoid type conversion
warning.
Thanks,
Joseph
>
> /* add bits set in this bitmap */
> for (j = 0; j < (ost->ost_bmpblksz * 8); j++)
More information about the Ocfs2-tools-devel
mailing list