From nobody Wed Nov 5 10:33:18 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1541430616390758.0147778809145; Mon, 5 Nov 2018 07:10:16 -0800 (PST) Received: from localhost ([::1]:35709 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJgW7-0006ZD-0s for importer@patchew.org; Mon, 05 Nov 2018 10:10:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJgUb-0005lL-DK for qemu-devel@nongnu.org; Mon, 05 Nov 2018 10:08:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJgUZ-00025v-1C for qemu-devel@nongnu.org; Mon, 05 Nov 2018 10:08:41 -0500 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]:42140) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gJgUY-0001j5-Qa; Mon, 05 Nov 2018 10:08:38 -0500 Received: by mail-qk1-x742.google.com with SMTP id u68so15155241qkg.9; Mon, 05 Nov 2018 07:08:37 -0800 (PST) Received: from localhost.localdomain ([177.45.6.151]) by smtp.gmail.com with ESMTPSA id v57sm5720501qtv.80.2018.11.05.07.08.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 07:08:35 -0800 (PST) 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=/TxzpofLgoIWk2lknsUfRFFhqk6o962sSnFN6K2b+cY=; b=SqKit7nXHCF4tgHp76BQxnJ17cknxLvLFv6lk0pDjMVJNb9BITZAFqZazX+rJO4Cib 9n1zWdOtXGGaj9w79aUGbRJ+X7yebQf+3x1//WtAD5MOyqOVV1Z2DAAUmnIt4xRxP7zL F7egosWFstq/ASai3r6G8bWTjl7DK1HEC9GWnPlIZmCkq6fiOPgdmxSeNNAZmTUHODSB RtLy3+3DQNqh0Wtes2qUYpgWLqe/HE2Q9BiJolHGeewu+eWkhy5HMxpOXIhXiB3NPHG8 cTikoz4Sf+cHaSF75ALOJHPSx4GPcxklgEeXFkBEctbOy29Aq6ZJONMo2mmq2EF3yQNB etmg== 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=/TxzpofLgoIWk2lknsUfRFFhqk6o962sSnFN6K2b+cY=; b=gAdVhdh0593gUt5UaqIVoxx9P0FL8ANIuvK1SL4jwB7KHcuvFh6+8MR9hQQ/yb0w4+ K8cA2HkIdeMVaopwKmAMcSKAsOY04NbYaIVd9Bi4mlSitoSAj4MEik23Y/MSgcBa/mrc 4NAQoXTEEpq/hGjC6IaCxckr27SKTs8ed2KyBAfAu+HXjBZ4NnghxcQAMuhyilMMyzug nyaRff+HL5cpsR4wwuFWjK0CmPlIKj43TcQqBtDNz5YhwujWcOcbkf1QviY0Z03tQ1w6 ckM8IKa5nYcLNvIHClXh24pKIxesIA5aJlaCPGxjjiqcmQZ/aTBOPitRhg4SH9cml44E I21A== X-Gm-Message-State: AGRZ1gLIsVFzs4ZKnOrWXqLCmnBKEzLBtUpoIA/opJW7G3D829WME61B hbKXI9siGhpJxDTZfa0wLIqEPZl0 X-Google-Smtp-Source: AJdET5d8ab1uy1QeaNz7pP1ylGZGqRYBOIoj2IBZDY+bTacPA0d3ZDpZyMNq/EmxrwQLX/hPYXTtJg== X-Received: by 2002:a0c:aff9:: with SMTP id t54mr21567009qvc.93.1541430516474; Mon, 05 Nov 2018 07:08:36 -0800 (PST) From: Julio Faracco To: qemu-devel@nongnu.org Date: Mon, 5 Nov 2018 13:08:03 -0200 Message-Id: <20181105150806.13649-2-jcfaracco@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181105150806.13649-1-jcfaracco@gmail.com> References: <20181105150806.13649-1-jcfaracco@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::742 Subject: [Qemu-devel] [PATCH v3 1/4] block: adding lzfse decompressing support as a module. 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: Kevin Wolf , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" QEMU dmg support includes zlib and bzip2, but it does not contains lzfse support. This commit adds the source file to extend compression support for new DMGs. Signed-off-by: Julio Faracco --- block/dmg-lzfse.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 block/dmg-lzfse.c diff --git a/block/dmg-lzfse.c b/block/dmg-lzfse.c new file mode 100644 index 0000000000..19d25bc646 --- /dev/null +++ b/block/dmg-lzfse.c @@ -0,0 +1,49 @@ +/* + * DMG lzfse uncompression + * + * Copyright (c) 2018 Julio Cesar Faracco + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "dmg.h" +#include + +static int dmg_uncompress_lzfse_do(char *next_in, unsigned int avail_in, + char *next_out, unsigned int avail_out) +{ + size_t out_size =3D lzfse_decode_buffer((uint8_t *) next_out, avail_ou= t, + (uint8_t *) next_in, avail_in, + NULL); + + /* We need to decode the single chunk only. */ + /* So, out_size =3D=3D avail_out is not an error here. */ + if (out_size > 0) { + return out_size; + } + return -1; +} + +__attribute__((constructor)) +static void dmg_lzfse_init(void) +{ + assert(!dmg_uncompress_lzfse); + dmg_uncompress_lzfse =3D dmg_uncompress_lzfse_do; +} --=20 2.17.1