qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 15/21] dmg: fix reading of uncompressed chunks


From: Kevin Wolf
Subject: [Qemu-devel] [PATCH 15/21] dmg: fix reading of uncompressed chunks
Date: Fri, 14 May 2010 19:10:49 +0200

From: Christoph Hellwig <address@hidden>

When dmg_read_chunk encounters an uncompressed chunk it currently
calls read without any previous adjustment of the file postion.

This seems very wrong, and the "reference" implementation in
dmg2img does a search to the same offset as done in the various
compression cases, so do the same here.

Signed-off-by: Christoph Hellwig <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
 block/dmg.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/block/dmg.c b/block/dmg.c
index d5c1a68..02a3d67 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -239,7 +239,8 @@ static inline int dmg_read_chunk(BDRVDMGState *s,int 
sector_num)
                return -1;
            break; }
        case 1: /* copy */
-           ret = read(s->fd, s->uncompressed_chunk, s->lengths[chunk]);
+           ret = pread(s->fd, s->uncompressed_chunk, s->lengths[chunk],
+                        s->offsets[chunk]);
            if (ret != s->lengths[chunk])
                return -1;
            break;
-- 
1.6.6.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]