From patchwork Fri Aug 10 04:07:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julio Faracco X-Patchwork-Id: 955928 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PBMYGi2t"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ms7V4B6Jz9s5b for ; Fri, 10 Aug 2018 14:08:53 +1000 (AEST) Received: from localhost ([::1]:54170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnyjL-0000p7-HT for incoming@patchwork.ozlabs.org; Fri, 10 Aug 2018 00:08:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55718) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnyij-0000nZ-Rm for qemu-devel@nongnu.org; Fri, 10 Aug 2018 00:08:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnyii-0002bA-Sy for qemu-devel@nongnu.org; Fri, 10 Aug 2018 00:08:13 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:38463) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnyii-0002aG-Mq; Fri, 10 Aug 2018 00:08:12 -0400 Received: by mail-qt0-x241.google.com with SMTP id w26-v6so9016349qto.5; Thu, 09 Aug 2018 21:08:12 -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=aLrs+E6+diswMUSxliQaa8sQ5JemVMgzp57ZKMgnaeY=; b=PBMYGi2tozDmCP6oKlIE1NOn9OD6y/surhww1v+VSkZFoXWUHgD0JuKOyMgj5Tt0Gr LceraVhqyV4Sk0PJB8kyXg7ATh9Hir8VDL9pOZu6jce+FeKOPUDiqs0d7tyaFNkSv9vm AGKyRxJQtATB80qUNeja7vKwRH9VKB9n/HlRaMSSplLATlJkUFfqWN638rSlrrAr8Oh4 HvKO633O1MuOCFk7FyyyjoAh2GRd9CjLMppCsIP7gCF9Tgif74AAHpi3J3RV0EDlNZ9c IwozV3mvFBUk+mZBhtN2CKK+IPbHHPpuxl5BxLmsWExOB4Z97XQPp18NW/XWJwr4JGu4 yKFA== 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=aLrs+E6+diswMUSxliQaa8sQ5JemVMgzp57ZKMgnaeY=; b=cAd1a1fW2LidKfGh+JtfbNS6EP0SIL5nFlsggXEoIF//sJ798wusSjfBwyh8p9GzXt X74qtjGhN+L6PDFOqv1zz/aY+cZ4lA3LoUIh/MkfEoUA+op80akxbe30yg88SUdHbVL2 c77CfCKLuRexkktyLr3U+Ez04NZANcys1ncTT1wIo3OmoUtx9568IPTSoeEdFeSRlu54 RU7j4EuT5lGPb8YOmrs0dgwzTrH93P4GTLTxVVOiy5oLxO+Wv7abVw3BPM7t9/l84C+c TaOnDOPW/ibzbKA8OpVTv7w+FjNjA1+4LjlBULVtLVRABh6hLsP3pG7K6W22jnWKFykX 0p6Q== X-Gm-Message-State: AOUpUlFTaJY1vbjNZXPMoutC3Onsc6Ke3pbxioujjlUc6Y2SWFN8QQ6t 1V99pf3AkTXL6C41kSofa3pEU0u2 X-Google-Smtp-Source: AA+uWPyNgVCOfrlKXQM0/Ivy4d3sU9xYJZo7ZHRVytZZL5m5WkTPwNOP8gLj7nsCqi7FdyqueVGj7A== X-Received: by 2002:a0c:e505:: with SMTP id l5-v6mr4348375qvm.128.1533874091700; Thu, 09 Aug 2018 21:08:11 -0700 (PDT) Received: from localhost.localdomain ([186.223.91.15]) by smtp.gmail.com with ESMTPSA id s53-v6sm6561555qts.5.2018.08.09.21.08.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 21:08:11 -0700 (PDT) From: Julio Faracco To: qemu-devel@nongnu.org Date: Fri, 10 Aug 2018 01:07:40 -0300 Message-Id: <20180810040743.25424-2-jcfaracco@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180810040743.25424-1-jcfaracco@gmail.com> References: <20180810040743.25424-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::241 Subject: [Qemu-devel] [PATCH 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 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..d09b544a0a --- /dev/null +++ b/block/dmg-lzfse.c @@ -0,0 +1,54 @@ +/* + * 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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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) +{ + void *aux; + size_t aux_allocated; + size_t out_size; + + aux_allocated = lzfse_decode_scratch_size(); + aux = g_malloc(aux_allocated); + + if (aux_allocated != 0 && aux == 0) { + return -1; + } + + out_size = lzfse_decode_buffer((uint8_t *) next_out, avail_out, + (uint8_t *) next_in, avail_in, aux); + + return out_size; +} + +__attribute__((constructor)) +static void dmg_lzfse_init(void) +{ + assert(!dmg_uncompress_lzfse); + dmg_uncompress_lzfse = dmg_uncompress_lzfse_do; +}