From patchwork Mon Oct 11 11:21:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1539230 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=ly40tBTN; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13d; helo=mail-lf1-x13d.google.com; envelope-from=swupdate+bncbcxploxj6ikrb2f4scfqmgqesrny5qq@googlegroups.com; receiver=) Received: from mail-lf1-x13d.google.com (mail-lf1-x13d.google.com [IPv6:2a00:1450:4864:20::13d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HSbx81PP9z9sXS for ; Mon, 11 Oct 2021 22:22:20 +1100 (AEDT) Received: by mail-lf1-x13d.google.com with SMTP id x33-20020a0565123fa100b003fcfd99073dsf12543292lfa.6 for ; Mon, 11 Oct 2021 04:22:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1633951336; cv=pass; d=google.com; s=arc-20160816; b=qg6oJpLEJ3kaSVAayCM2IH8Tjb+RdV5+RDIFdF5myNQ76kNuMHKAdkg4K0Sk7DXkch tjuEkKIFgA6fpaZmTZ3bXSwnWlHeOGoDG/IsISiyvRnsAW4rXd1mVvKoDWjTWqBeTxmW Fb6gJlaLHIWTAH9fHDmK6PPEhW+6DGtPmtB9rufNRxM9tcBLLAjT4832guZhqAjTIzhq ima2sbo6YgP8rEiUfg2fDFH5unzKdakh1WdNFf6utJohs3UWIIqclObqLak0IHcRHxbM bZcnr2liH013DtjLRlvqrOtXBtbI+VGZG6iFUXNDrEJPfyEcq1Ha8GGnznWJFAJSZGco AKNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=Tkxr3dlwhdl50wiRMWSQ7iFl7TMB2JpcAFGnpjoaLik=; b=GOK5fB/BmNwG8GWW4SuIb+7tctp8i1y5VGHwc/RU6ZCGsJtQIKm7uFjWGwD6NMkR9k Tix7azhMJhOYV56GBlfJyEztHwzToh8i8li0mNDrRl1oFocMHftclrLERnot8VZ0TprY cVR8deHerhcBukEB5pD/Tr+1ge+L1l+x+Dcx6Xe30QOwEyVM9rvkmA4SRlAA92hx+VbP DdTGoYxx2SnUTk5bR+lqiyyJUW2j9GIVtmrV4pptrY7zy65Nc5Q4rXINAgNqZ0KGUVm2 HrzH+X417dLI7jwqhxHtmwcX3Dn7g1KDyBwxfSha/L4MOGK0rXXr42YC3wcSN7mSXpVR dW0g== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Tkxr3dlwhdl50wiRMWSQ7iFl7TMB2JpcAFGnpjoaLik=; b=ly40tBTNzkGKsZgorzlyRAwsCO0AsqFVYeSJAV4PmOC67XzNEpPYatO0af9bryh/Nh Kxz+gLUXxqdv0op/72gkwGE/rCLefp0COi3tgW4EbNwx4W7sY/BWbXp5yqa7ikbOn2hr YfFGGRnh2c8yq87acRJTxzs/xc8RsBWPYWs2EhBsWaYZMil4gGMjxGtJrLrRbxbt0sqS If49ndPOfx6eiU//SE9cQs6a3FOHcfOO5NUInmiLoUGI4nHhlUTV/yWS6cJY87yGZ1kc Cz3ImESUGteryaXiV4rezHeNra87wYdm8RW8VjUvbplXbvcJDlEU6xB9j32B6DjmRFbu 6rkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Tkxr3dlwhdl50wiRMWSQ7iFl7TMB2JpcAFGnpjoaLik=; b=ce62tcaPcLs0L5AtPvBWz+75jGlYko3M1iUmAOHNRRLwJpt/+NN7l1colcEcpodIxg d0FoN2k6HZEeOgnyFoAL58blyUEex2pj0z9B3X4MyRrbwfL1GbzFWo7Vb3nQIBhTGI/l ruFEY6r2Km6trp+bsLQPeqQ1+MvPxNcc3tbng7lW1HpXsyWCAcEn56X+Dpk3YJe8x6Wn 8lh8kHhYAl2q5oHPbyOBmr2wAe7BB7hYhuubsH9KCpYAsuB8750ZMl2ES4p7sD1eWojo U8t67fknOkzZP2HJnLgGGPI/DT+d4zogpUxQDudEA07WgE6ABKiEVHScKTUpRgSMv3vF MI2Q== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532NjpA5nwR6tpq7I7rfmANyJCuGErTXN6A9sI7EC0PPSa/NLs4G kpo0hcpRpZGYdWM6PMvfFv8= X-Google-Smtp-Source: ABdhPJx532ZxmyAN559up9iF7mCmwIdt9/63GHRfC+F9KmepxnK5tjn53RdvGxXH8EizbA6QCS/jjA== X-Received: by 2002:a2e:9c8:: with SMTP id 191mr22005579ljj.190.1633951336736; Mon, 11 Oct 2021 04:22:16 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:651c:1795:: with SMTP id bn21ls1669573ljb.10.gmail; Mon, 11 Oct 2021 04:22:15 -0700 (PDT) X-Received: by 2002:a05:651c:988:: with SMTP id b8mr21792923ljq.187.1633951335840; Mon, 11 Oct 2021 04:22:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633951335; cv=none; d=google.com; s=arc-20160816; b=yrJtlnMfwvhDBJALNdDEsoa/XJEwLoFy/tyxv8Up8Ssi1i1IfdVEdSxOrz7YweSTEC EbEooUCeoJ3caXrE2jm2SAgbpCQulv3wJSZg6GzhDuKkNGoZV/aFQBhK/J3GAarW5291 VbyjmAXqBjaGKymtvvOfyAzBYKfB1SNVRwf0V6LRv94C1QyE0vte11SnElT7rVL7uW08 nnuhL7o9AR/35eGy9eWMktc55kPGQgliUXgZf9IHfjVYcdQDo9S3T9zuP6vVUW8C6EXf pqAx/h2qSI8P99oNt2etKtA0TQtDuZJZxbuRxjIEnXtTDOrwHczeCTa0sai67b963HPb C4kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=HNcVgtBxrajDZ63HySGxgvJzOfRrd+o/2gampVos5U8=; b=wmE1M47ET8bR4qwfFDWI1tZoo/TVjMS7c7PJrbraf/twkmkEl6qPph2z7sTCzVbRkb VYWt8cBBoftTSYjDQk2eVvbggtG9aWiD7kCsqXv7d0LEKr34x1+3NU+L6Z6CvO+Dd6L8 YwoNqhS7Cwg0kmLMwUAWBZOnpjT/di6MwjMzTYweQ1saIcLJqfmt3HshwI+xI1e1mHVE jaSq4xcgMsCRl1NourS9cX4jtWNEZf2PngI/cbLVsk5nf5hw/ILyy21rB/v1wSkx0csj n6FR78qbcdH7P6YxMzCZakTar2PLKeCB5z8e/nMyplRDhuj71QJFWQn3zMBn4cZT/Os8 RTDQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id w6si338149lfa.7.2021.10.11.04.22.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Oct 2021 04:22:15 -0700 (PDT) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HSbx32dJtz1sByw; Mon, 11 Oct 2021 13:22:15 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HSbx32QpFz1qqkC; Mon, 11 Oct 2021 13:22:15 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id jQojhKoLRzXj; Mon, 11 Oct 2021 13:22:14 +0200 (CEST) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Mon, 11 Oct 2021 13:22:14 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 1F27F4540BF1; Mon, 11 Oct 2021 13:22:14 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xa9bhQTdUgxv; Mon, 11 Oct 2021 13:22:11 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 9CBC945414D7; Mon, 11 Oct 2021 13:22:04 +0200 (CEST) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 05/29] Hide copyfile() implementation to add more input Date: Mon, 11 Oct 2021 13:21:32 +0200 Message-Id: <20211011112156.44192-6-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211011112156.44192-1-sbabic@denx.de> References: <20211011112156.44192-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Add copyfile implementation with a wrapper function to allow to change internals without modifying the API. Signed-off-by: Stefano Babic --- core/cpio_utils.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/core/cpio_utils.c b/core/cpio_utils.c index 2e4aca3..e06bf5f 100644 --- a/core/cpio_utils.c +++ b/core/cpio_utils.c @@ -380,7 +380,7 @@ static int zstd_step(void* state, void* buffer, size_t size) #endif -int copyfile(int fdin, void *out, unsigned int nbytes, unsigned long *offs, unsigned long long seek, +static int __swupdate_copy(int fdin, void *out, unsigned int nbytes, unsigned long *offs, unsigned long long seek, int skip_file, int __attribute__ ((__unused__)) compressed, uint32_t *checksum, unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback) { @@ -633,6 +633,24 @@ copyfile_exit: return ret; } +int copyfile(int fdin, void *out, unsigned int nbytes, unsigned long *offs, unsigned long long seek, + int skip_file, int __attribute__ ((__unused__)) compressed, + uint32_t *checksum, unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback) +{ + return __swupdate_copy(fdin, + out, + nbytes, + offs, + seek, + skip_file, + compressed, + checksum, + hash, + encrypted, + imgivt, + callback); +} + int copyimage(void *out, struct img_type *img, writeimage callback) { return copyfile(img->fdin,