From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y7CDM-0005Ta-0w for qemu-devel@nongnu.org; Fri, 02 Jan 2015 19:05:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y7CDG-0001RD-Hm for qemu-devel@nongnu.org; Fri, 02 Jan 2015 19:05:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y7CDG-0001QY-9P for qemu-devel@nongnu.org; Fri, 02 Jan 2015 19:05:02 -0500 Message-ID: <54A7322A.2070604@redhat.com> Date: Fri, 02 Jan 2015 19:04:58 -0500 From: John Snow MIME-Version: 1.0 References: <1419692504-29373-1-git-send-email-peter@lekensteyn.nl> <1419692504-29373-8-git-send-email-peter@lekensteyn.nl> In-Reply-To: <1419692504-29373-8-git-send-email-peter@lekensteyn.nl> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 07/10] block/dmg: set virtual size to a non-zero value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Wu , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi On 12/27/2014 10:01 AM, Peter Wu wrote: > 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. > Do you mean to say from the 'koly' header? http://en.wikipedia.org/wiki/Apple_Disk_Image#UDIF_data_format > 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 > --- > 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); >