[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] ioemu: cope with partial reads/writes when using the read()/write()
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1202741226 0 # Node ID a1b83b3b04491868d7e5aac594ed8ce0070d8c38 # Parent 209512f6d89c0650d065fad4f70a8a39a46b8460 ioemu: cope with partial reads/writes when using the read()/write() syscall interfaces. Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx> --- tools/ioemu/block-raw.c | 27 ++++++++++++++++++++------- 1 files changed, 20 insertions(+), 7 deletions(-) diff -r 209512f6d89c -r a1b83b3b0449 tools/ioemu/block-raw.c --- a/tools/ioemu/block-raw.c Mon Feb 11 14:45:29 2008 +0000 +++ b/tools/ioemu/block-raw.c Mon Feb 11 14:47:06 2008 +0000 @@ -169,10 +169,16 @@ static int raw_pread(BlockDriverState *b } s->lseek_err_cnt=0; - ret = read(s->fd, buf, count); - if (ret == count) - goto label__raw_read__success; - + uint64_t done; + for (done = 0; done < count; done += ret) { + ret = read(s->fd, buf + done, count - done); + if (ret == -1) + goto label__raw_read__error; + } + ret = count; + goto label__raw_read__success; + +label__raw_read__error: DEBUG_BLOCK_PRINT("raw_read(%d:%s, %" PRId64 ", %p, %d) [%" PRId64 "] read failed %d : %d = %s\n", s->fd, bs->filename, @@ -234,9 +240,16 @@ static int raw_pwrite(BlockDriverState * } s->lseek_err_cnt = 0; - ret = write(s->fd, buf, count); - if (ret == count) - goto label__raw_write__success; + uint64_t done; + for (done = 0; done < count; done += ret) { + ret = write(s->fd, buf + done, count - done); + if (ret == -1) + goto label__raw_write__error; + } + ret = count; + goto label__raw_write__success; + +label__raw_write__error: DEBUG_BLOCK_PRINT("raw_write(%d:%s, %" PRId64 ", %p, %d) [%" PRId64 "] write failed %d : %d = %s\n", s->fd, _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |