From nobody Wed Nov 5 13:00:25 2025 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534428093331487.69232438711447; Thu, 16 Aug 2018 07:01:33 -0700 (PDT) Received: from localhost ([::1]:55803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqIq4-00019Z-GL for importer@patchew.org; Thu, 16 Aug 2018 10:01:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqInj-0006AQ-QH for qemu-devel@nongnu.org; Thu, 16 Aug 2018 09:59:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqIng-0000E0-5q for qemu-devel@nongnu.org; Thu, 16 Aug 2018 09:58:58 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:35188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fqInc-0000B1-MX; Thu, 16 Aug 2018 09:58:53 -0400 Received: by mail-qk0-x242.google.com with SMTP id u21-v6so3775525qku.2; Thu, 16 Aug 2018 06:58:51 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 06:58:50 -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=/TxzpofLgoIWk2lknsUfRFFhqk6o962sSnFN6K2b+cY=; b=rCChTum8C8rjBoZd2WkmrDfkGKB9ANIR22cUzlyCCDBfXrpMGzb4gcb+ZTgc/JymVp CLWHU10bDDdDD7n9ZKl8grTtGiDeLee0i7KjJG725ccDLlzkiSLf89Fs1wYrg18LSqCZ a6Ii+sRzy+yjIJRQj1H70Ug2teerMxDMCyuoDNXRHATu1h+rk/lXlxf8zrQ+nQyYz3sj OJcNVAm12+9KFKG14aNJ8ovC4zx+Snn6ea/PVNiFgBtiHOJBrYzN7ABYVgQMDA3wvEBG 1NsJyMt9mT2rICh3szXMIvkwm909pFtQ4xDhKIBYITZTMvqaYQeMe3yU35U1jHRStj+x 1fIQ== 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=VWEo6i0NolgIaffpJRvSAkkyCha/2WpixZJhemUWJLhmM639NzF45tJzc1vYGQm8MZ Lqcq+aEQJQaToHmlf3vlFEbivM/tXMJ6zu8EM78G081nzefcfoX0wDJceTuW12zMGkhB riuYia0AQVDiVwgzcCZjMoTRiJOE7CieX3+kpa5DdL+iq/jgKVhqPmvItX0vLwXDR0Uk 9XrHrM/aPlRupS4u5siIKS0kR1kapg2kifhfDEcHLN0WOGokuAJiePGFCxbYVUiKd0lU NECETV67t4KtxfMiso9MKlRcs3qOVAVBE4zL8JhXFEVnCdC8UNmpLeyWhU1H1RuVnlYp fGMw== X-Gm-Message-State: AOUpUlGDubK9C5apEi/GyhUY7zBiuJzABCkXLB76piq+3fPafO5lqAKz 00JlX4okEWnMcUWH0cyEC9T3WM0O X-Google-Smtp-Source: AA+uWPxBhcwLDsbFpkihWP/xqYSKYBcPbeYRsHn5SZ6Rox3yYRl2HxrgjLdv8ruvS1mYrwDh4++vvA== X-Received: by 2002:a37:9d54:: with SMTP id g81-v6mr27016185qke.186.1534427931231; Thu, 16 Aug 2018 06:58:51 -0700 (PDT) From: Julio Faracco To: qemu-devel@nongnu.org Date: Thu, 16 Aug 2018 10:58:34 -0300 Message-Id: <20180816135837.13149-2-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:c09::242 Subject: [Qemu-devel] [PATCH v2 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: 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" 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