(2013/10/14 23:11), WANG Chao wrote: > On 10/14/13 at 09:04pm, Jingbai Ma wrote: >> This patch Enhance bitmap writting function in reassemble_kdump_header(). >> Prevent bitmap writting failure if the size of bitmap is too large to fit a >> sigle write. > > This patch looks good to me. > > Acked-by: WANG Chao <chaowang at redhat.com> Thanks, I'll merge this patch into v1.5.5. Atsushi Kumagai >> >> Signed-off-by: Jingbai Ma <jingbai.ma at hp.com> >> --- >> makedumpfile.c | 45 +++++++++++++++++++++++++++++++-------------- >> 1 files changed, 31 insertions(+), 14 deletions(-) >> >> diff --git a/makedumpfile.c b/makedumpfile.c >> index 130cf9f..f43454a 100644 >> --- a/makedumpfile.c >> +++ b/makedumpfile.c >> @@ -7990,6 +7990,7 @@ reassemble_kdump_header(void) >> struct disk_dump_header dh; >> struct kdump_sub_header kh; >> char *buf_bitmap = NULL; >> + ssize_t status, read_size, written_size; >> >> /* >> * Write common header. >> @@ -8068,10 +8069,16 @@ reassemble_kdump_header(void) >> SPLITTING_DUMPFILE(0), strerror(errno)); >> goto out; >> } >> - if (read(fd, buf_bitmap, info->len_bitmap) != info->len_bitmap) { >> - ERRMSG("Can't read a file(%s). %s\n", >> - SPLITTING_DUMPFILE(0), strerror(errno)); >> - goto out; >> + read_size = 0; >> + while (read_size < info->len_bitmap) { >> + status = read(fd, buf_bitmap + read_size, info->len_bitmap >> + - read_size); >> + if (status < 0) { >> + ERRMSG("Can't read a file(%s). %s\n", >> + SPLITTING_DUMPFILE(0), strerror(errno)); >> + goto out; >> + } >> + read_size += status; >> } >> >> if (lseek(info->fd_dumpfile, offset, SEEK_SET) < 0) { >> @@ -8079,11 +8086,16 @@ reassemble_kdump_header(void) >> info->name_dumpfile, strerror(errno)); >> goto out; >> } >> - if (write(info->fd_dumpfile, buf_bitmap, info->len_bitmap) >> - != info->len_bitmap) { >> - ERRMSG("Can't write a file(%s). %s\n", >> - info->name_dumpfile, strerror(errno)); >> - goto out; >> + written_size = 0; >> + while (written_size < info->len_bitmap) { >> + status = write(info->fd_dumpfile, buf_bitmap + written_size, >> + info->len_bitmap - written_size); >> + if (status < 0) { >> + ERRMSG("Can't write a file(%s). %s\n", >> + info->name_dumpfile, strerror(errno)); >> + goto out; >> + } >> + written_size += status; >> } >> >> if (lseek(info->fd_bitmap, 0x0, SEEK_SET) < 0) { >> @@ -8091,11 +8103,16 @@ reassemble_kdump_header(void) >> info->name_bitmap, strerror(errno)); >> goto out; >> } >> - if (write(info->fd_bitmap, buf_bitmap, info->len_bitmap) >> - != info->len_bitmap) { >> - ERRMSG("Can't write a file(%s). %s\n", >> - info->name_bitmap, strerror(errno)); >> - goto out; >> + written_size = 0; >> + while (written_size < info->len_bitmap) { >> + status = write(info->fd_bitmap, buf_bitmap + written_size, >> + info->len_bitmap - written_size); >> + if (status < 0) { >> + ERRMSG("Can't write a file(%s). %s\n", >> + info->name_bitmap, strerror(errno)); >> + goto out; >> + } >> + written_size += status; >> } >> >> ret = TRUE; >> > >