[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 07/10] block/dmg: set virtual size to a non-zero val
From: |
Peter Wu |
Subject: |
[Qemu-devel] [PATCH 07/10] block/dmg: set virtual size to a non-zero value |
Date: |
Sat, 27 Dec 2014 16:01:41 +0100 |
Right now the virtual size is always reported as zero which makes it
impossible to convert between formats.
After this patch, the number of sectors will be read from the BLXX
("mish") header.
To verify the behavior, the output of `dmg2img foo.dmg foo.img` was
compared against `qemu-img convert -f dmg -O raw foo.dmg foo.raw`. The
tests showed that the file contents are exactly the same, except that
QEMU creates a slightly larger file (it matches the total sectors
count).
Signed-off-by: Peter Wu <address@hidden>
---
block/dmg.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/block/dmg.c b/block/dmg.c
index c03ea01..984997f 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -430,6 +430,14 @@ static int dmg_open(BlockDriverState *bs, QDict *options,
int flags,
if (ret < 0) {
goto fail;
}
+ ret = read_uint64(bs, offset + 0x1ec, (uint64_t *)&bs->total_sectors);
+ if (ret < 0) {
+ goto fail;
+ }
+ if (bs->total_sectors < 0) {
+ ret = -EINVAL;
+ goto fail;
+ }
if (rsrc_fork_offset != 0 && rsrc_fork_length != 0) {
ret = dmg_read_resource_fork(bs, &ds,
rsrc_fork_offset, rsrc_fork_length);
--
2.2.1
- [Qemu-devel] [PATCH 00/10] block/dmg: (compatibility) fixes and bzip2 support, Peter Wu, 2014/12/27
- [Qemu-devel] [PATCH 05/10] block/dmg: validate chunk size to avoid overflow, Peter Wu, 2014/12/27
- [Qemu-devel] [PATCH 01/10] block/dmg: properly detect the UDIF trailer, Peter Wu, 2014/12/27
- [Qemu-devel] [PATCH 08/10] block/dmg: fix sector data offset calculation, Peter Wu, 2014/12/27
- [Qemu-devel] [PATCH 06/10] block/dmg: process XML plists, Peter Wu, 2014/12/27
- [Qemu-devel] [PATCH 07/10] block/dmg: set virtual size to a non-zero value,
Peter Wu <=
- [Qemu-devel] [PATCH 04/10] block/dmg: process a buffer instead of reading ints, Peter Wu, 2014/12/27
- [Qemu-devel] [PATCH 02/10] block/dmg: extract mish block decoding functionality, Peter Wu, 2014/12/27
- [Qemu-devel] [PATCH 09/10] block/dmg: support bzip2 block entry types, Peter Wu, 2014/12/27
- [Qemu-devel] [PATCH 03/10] block/dmg: extract processing of resource forks, Peter Wu, 2014/12/27
- [Qemu-devel] [PATCH 10/10] block/dmg: improve zeroes handling, Peter Wu, 2014/12/27