WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] ioemu: cope with partial reads/writes whe

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] ioemu: cope with partial reads/writes when using the read()/write()
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 11 Feb 2008 11:00:10 -0800
Delivery-date: Mon, 11 Feb 2008 11:00:12 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] ioemu: cope with partial reads/writes when using the read()/write(), Xen patchbot-unstable <=