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-3.2-testing] ioemu: cope with partial reads/writes

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-3.2-testing] ioemu: cope with partial reads/writes when using the read()/write()
From: "Xen patchbot-3.2-testing" <patchbot-3.2-testing@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 21 Feb 2008 07:12:03 -0800
Delivery-date: Fri, 22 Feb 2008 07:36:49 -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 1203343943 0
# Node ID 408acef82ffb5451bca9bd18fb5b3bf151eefc43
# Parent  f2811c8c09f000b2a5724397492401dde4553da4
ioemu: cope with partial reads/writes when using the read()/write()
syscall interfaces.
Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
xen-unstable changeset:   17018:a1b83b3b04491868d7e5aac594ed8ce0070d8c38
xen-unstable date:        Mon Feb 11 14:47:06 2008 +0000
---
 tools/ioemu/block-raw.c |   27 ++++++++++++++++++++-------
 1 files changed, 20 insertions(+), 7 deletions(-)

diff -r f2811c8c09f0 -r 408acef82ffb tools/ioemu/block-raw.c
--- a/tools/ioemu/block-raw.c   Mon Feb 18 14:09:56 2008 +0000
+++ b/tools/ioemu/block-raw.c   Mon Feb 18 14:12:23 2008 +0000
@@ -167,10 +167,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, 
@@ -232,9 +238,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-3.2-testing] ioemu: cope with partial reads/writes when using the read()/write(), Xen patchbot-3.2-testing <=