From nobody Tue Feb 10 02:46:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534428293627882.1948087170772; Thu, 16 Aug 2018 07:04:53 -0700 (PDT) Received: from localhost ([::1]:55826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqItQ-0003aK-7N for importer@patchew.org; Thu, 16 Aug 2018 10:04:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqInl-0006Br-Aw for qemu-devel@nongnu.org; Thu, 16 Aug 2018 09:59:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqInj-0000Gl-Pf for qemu-devel@nongnu.org; Thu, 16 Aug 2018 09:59:00 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:34202) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fqIng-0000Dk-PB; Thu, 16 Aug 2018 09:58:58 -0400 Received: by mail-qt0-x242.google.com with SMTP id m13-v6so4751517qth.1; Thu, 16 Aug 2018 06:58:56 -0700 (PDT) Received: from localhost.localdomain ([177.83.75.169]) by smtp.gmail.com with ESMTPSA id p13-v6sm16454824qki.12.2018.08.16.06.58.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 06:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NM/TVz2txh2dTUWoK7dh7L5SubuA3O4s/CJVw731UUM=; b=JKfWeo4hciUde0+/prIhYjbqP7rpk38RjOa7vgAyXFbNk588cPsHRaY+6HQk8fGRqZ mdJpxnTgX0UTWmJMtoWGZ64qe3GlS4PBQIZet4r3ohTwnl3Uy7rP9gg2jtKpRJajeBgs J0t6q54mSgO6NVw4zzbZpli76f5L0Jxg+o2frRH7VWJofidb+XcjJg3mmEUYnksir5Xd B4i4yzk8mdCrbYTBtf84LvTU4UR6v3bQlUg6yNQjOx3I4kcC1ykfiQoMvo4f/UUVQx3q 1otecyftXSf3AVPRRl7d3coJqNBaxLQeUOIHAA+Js5PybVuaNdN5OGdOCiJ98XfCsN4n Lqyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NM/TVz2txh2dTUWoK7dh7L5SubuA3O4s/CJVw731UUM=; b=MFPniWBVcAi/P7oeDWjLWm7sVI0FC9VDLNm///4+7kNCTPrNovM6YxggIBPwGAN9v6 sXJi0gJfEJpqeXE62OaCUFzZkerB1x9Sr36azqn76oRT2uiNFxdlPYOq2Y/bJaaTSkhh sGVgPEdMYYfyt0x8EXS/zzbLgDO1BA65gLhFvGeN885OEvxmzg0rqQRvPE7JoTz4fBSe eirS4lyQWqk9LiffNg02hfjcvZ+ndEtH3UtIfrfz8S4ay8g6iGWDBEeeKRo7TNktN2CH w8G1MKv1arxfrqa+c0Y5VdbTflrYisWJdSdfHqPJCDYsatAEOqCpzgEeYvirwHlNynxI aC/w== X-Gm-Message-State: AOUpUlGsbSctlYqkgXIoYkjk8S/vGO2/dUYVgfF5O4ljl20ZvUavYAYl cyHyc+nylV/VeMMBB6tA3YEZRfF4 X-Google-Smtp-Source: AA+uWPwBiBSr0qUyczbDcW/aXQ7HD8S3koDSEv+fVu2klV2kyEhDx6vYnoobod38HPqOzHk3+Yw3Bg== X-Received: by 2002:ac8:13c3:: with SMTP id i3-v6mr30057248qtj.54.1534427935449; Thu, 16 Aug 2018 06:58:55 -0700 (PDT) From: Julio Faracco To: qemu-devel@nongnu.org Date: Thu, 16 Aug 2018 10:58:36 -0300 Message-Id: <20180816135837.13149-4-jcfaracco@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180816135837.13149-1-jcfaracco@gmail.com> References: <20180816135837.13149-1-jcfaracco@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PATCH v2 3/4] dmg: including dmg-lzfse module inside dmg block driver. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-block@nongnu.org, stefanha@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This commit includes the support to new module dmg-lzfse into dmg block driver. It includes the support for block type ULFO (0x80000007). Signed-off-by: Julio Faracco --- block/dmg.c | 28 ++++++++++++++++++++++++++++ block/dmg.h | 3 +++ 2 files changed, 31 insertions(+) diff --git a/block/dmg.c b/block/dmg.c index c9b3c519c4..615f818c5a 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -33,6 +33,9 @@ int (*dmg_uncompress_bz2)(char *next_in, unsigned int avail_in, char *next_out, unsigned int avail_out); =20 +int (*dmg_uncompress_lzfse)(char *next_in, unsigned int avail_in, + char *next_out, unsigned int avail_out); + enum { /* Limit chunk sizes to prevent unreasonable amounts of memory being u= sed * or truncating when converting to 32-bit types @@ -107,6 +110,7 @@ static void update_max_chunk_size(BDRVDMGState *s, uint= 32_t chunk, switch (s->types[chunk]) { case 0x80000005: /* zlib compressed */ case 0x80000006: /* bzip2 compressed */ + case 0x80000007: /* lzfse compressed */ compressed_size =3D s->lengths[chunk]; uncompressed_sectors =3D s->sectorcounts[chunk]; break; @@ -188,6 +192,8 @@ static bool dmg_is_known_block_type(uint32_t entry_type) return true; case 0x80000006: /* bzip2 */ return !!dmg_uncompress_bz2; + case 0x80000007: /* lzfse */ + return !!dmg_uncompress_lzfse; default: return false; } @@ -431,6 +437,7 @@ static int dmg_open(BlockDriverState *bs, QDict *option= s, int flags, } =20 block_module_load_one("dmg-bz2"); + block_module_load_one("dmg-lzfse"); =20 s->n_chunks =3D 0; s->offsets =3D s->lengths =3D s->sectors =3D s->sectorcounts =3D NULL; @@ -629,6 +636,27 @@ static inline int dmg_read_chunk(BlockDriverState *bs,= uint64_t sector_num) return ret; } break; + case 0x80000007: + if (!dmg_uncompress_lzfse) { + break; + } + /* we need to buffer, because only the chunk as whole can be + * inflated. */ + ret =3D bdrv_pread(bs->file, s->offsets[chunk], + s->compressed_chunk, s->lengths[chunk]); + if (ret !=3D s->lengths[chunk]) { + return -1; + } + + ret =3D dmg_uncompress_lzfse((char *)s->compressed_chunk, + (unsigned int) s->lengths[chunk], + (char *)s->uncompressed_chunk, + (unsigned int) + (512 * s->sectorcounts[chunk])); + if (ret < 0) { + return ret; + } + break; case 1: /* copy */ ret =3D bdrv_pread(bs->file, s->offsets[chunk], s->uncompressed_chunk, s->lengths[chunk]); diff --git a/block/dmg.h b/block/dmg.h index 2ecf239ba5..f28929998f 100644 --- a/block/dmg.h +++ b/block/dmg.h @@ -55,4 +55,7 @@ typedef struct BDRVDMGState { extern int (*dmg_uncompress_bz2)(char *next_in, unsigned int avail_in, char *next_out, unsigned int avail_out); =20 +extern int (*dmg_uncompress_lzfse)(char *next_in, unsigned int avail_in, + char *next_out, unsigned int avail_out); + #endif --=20 2.17.1