From patchwork Sun Nov 14 17:26:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554894 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=mwn5TthL; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::240; helo=mail-lj1-x240.google.com; envelope-from=swupdate+bncbcxploxj6ikrbgeoywgamgqe6prvp4i@googlegroups.com; receiver=) Received: from mail-lj1-x240.google.com (mail-lj1-x240.google.com [IPv6:2a00:1450:4864:20::240]) (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 4HsfRM70Vvz9sX3 for ; Mon, 15 Nov 2021 04:27:58 +1100 (AEDT) Received: by mail-lj1-x240.google.com with SMTP id z18-20020a2e8e92000000b00218e583aff1sf4262516ljk.1 for ; Sun, 14 Nov 2021 09:27:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910873; cv=pass; d=google.com; s=arc-20160816; b=QuVM6F5rX/ggKtkk8nFu+UuPlMxk7ojpKmzmJ2LSPFJEAAgIOxjzuNQ9be55ZAiJl6 /50dY5G8/zRpx++wRimWN15BOSSI7Pinvl28LzlcW+rvZQfWt/svi8soyraY8DFRGqFE twJ/e1vj60lGl3DFXsUHwZmlVTjVS8TdUh7lpgsnPFb2E6X+fzXQCtNKNwl+uuswMm3A 4g93YSq3cA9s98SYVtRzpal89d0FT+MRUBQE9XOZWIaL3nZ0jvSEvHf1MbaqXyZzqFj0 YT3hxQA6WAcdz2quOfRxplPmqYcFCXYP+y0jlinTtXd+tjcEGApuhLMZ5B40Kfi7EgwU LHCQ== 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=RqtaHeoNZZaF3zIgxEpTA2H6D/uDkao/DVb2yEcQTLk=; b=NlZJL/Exha0ink0luDQxDMheBs+YgQb1HQKhHz77dLdczgcywxc2tzdT8Nqu1RMBjx jJylhG8hzVyfrvkcp/d6Z79NMIhIdhhtt7wLiWzlf350KNCN0tMh+5SMyHja968N40Jy jpzwPXtzClff8kzh1BtYqjrB+Y+QzEHD+SRrqJAODZCRz/AcKmayKmlPckSAWrRE41Jl 0SzqPPeBvB8eeND+vlDtsPWqkQij0yvSDu1pgrbT+j7xg90cKa41KG9G+Zvj2WrPnYFl PonzUqzR/+rcYoEpfov1YZqrM4oizVEtYNZoryWscTjJi9DdorzIQPOMCH3LVA2rm3Sz 7jNQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 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=RqtaHeoNZZaF3zIgxEpTA2H6D/uDkao/DVb2yEcQTLk=; b=mwn5TthLYC4K+HPCQGoSNgntcfjlA8zVGz1UhLOP3pZ/8QQ6RQwOy/3hlaNdvbvITf rjPxQDyMzbZ0gSrx+ValVTqu/IiNgLfGnpEacgEvhZo3mCox5LzG+W3YI4zXB9O4Pt8s RoGEwlFNY+iyPq7SfRsxDJhc3XfvQIf+eITQ+3uI7vNR4ZXo9iBCImqSZ02Rp6wUhhR9 Dby3GZn0eXvhR+BTpv7aNB/S8vF6ljZ7Tnw1qjkmYpFHxG7u2VzoRdYGgGA2xKvJlw/0 XDN/Zm0khzkLaGGjUbtsAohsXO15QyeBCH7LqntgwsiVGfavmMa1fM12xHBZFGO6Qfn4 yOdw== 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=RqtaHeoNZZaF3zIgxEpTA2H6D/uDkao/DVb2yEcQTLk=; b=OOp3rEW0uNv33JbVQpUySyUw3PLqQhm+5GVvdLT7abzmGFaJBvcteY08pjFPp5Vjxh sysnsyfpt8CQnS6581IYMAANthoi7H65NCv12YcDzFEgFRVpnXWJiIb18eAfewPWzC3U 4Cw1CVv9EarwBrLSl7aQVtrsVZtGnhWcxT7RjVAInL56Lbb+lQykoRwNlwr7Cf4xUhI4 BO3OVbkG8ETcNoy3E6Kr5BerugMGFOBs/yza3ntSKM5ZlCd3UeDhnKfh2miLFfxPvo5h 7DIoSSBmMWPB8acbuNqX/XFB2ARgTYaPifWnq/3SP0PH89aMsHc/r3BFeTMZwS2jwyt+ J6pw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5323HCSA2L9rfgzP0p9ArYbibBCWRmvHGMixCqhCfSwfMpbVCQfn EeZK3GNkaC7kAhJzLmttknQ= X-Google-Smtp-Source: ABdhPJzym7MvTrFIV/bSLa0ct3jaFBrJIBZcdnFLPS4NZcLPwOTAY7iXi/qPsF3xTLNSC1ldhlDyMg== X-Received: by 2002:a05:6512:3d94:: with SMTP id k20mr30494785lfv.116.1636910873094; Sun, 14 Nov 2021 09:27:53 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:1314:: with SMTP id x20ls4679274lfu.1.gmail; Sun, 14 Nov 2021 09:27:52 -0800 (PST) X-Received: by 2002:a05:6512:12c8:: with SMTP id p8mr21373449lfg.69.1636910872154; Sun, 14 Nov 2021 09:27:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910872; cv=none; d=google.com; s=arc-20160816; b=uQ+y4f/S0U3+sKIyh7xZf0a05PYFpTUP0v+sx9P9jLz0dc9bWghyET+qg4tkZb0Q9H kk9CBKM7QtiPJV7vAYYt7oIw/KdC5dN9invjl6fsmlKR/1HnY8hIs0oOrmlsFiKMyy/5 91EU8c+9a6aC4aPb1e+eJpFRnTKRgx0e8kQ/qCP8t946RHLPjo2qtAf1oSsho2g5YOON DEymYzjqX7VOuK8D48QxHRLoqisnFvdw0At6alVnx2AMgp2EicA+84cWHywEUpsd6xTK guLOqrU4R6C5v1HfowBaKh0pI9KDv+Hr1IxETF24U57iO9zQWLOyvuzeHfsm6qfp1PyS lOfg== 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=gmN2bv9rR0hj6XMoATuG20Qec9fNq2KOLkpqca4kra0=; b=qQeTkqG4agzbD4l6oMvrkCE5K4KkiDblAOuFZES2GJ8lh6hCrgF4q/v8rwXXr/wVT+ N5jGc5CNRgKT4/9D+eTLeI7d/IJMSGgkbfZgSn6Uo6PZwDw5Bvrb7VkATO7bGleHE+AN Pq7AVvdyZUWXWFmFN6T9+LE7CZ+KDrorrQVHLgr0nerhov+Adl6TmtFz6YI8/2SBERsY wLPF9NjXI1W39h6bvGakLSLqTYurRdLp9VUwLJH7nTM1AqnWV0kKob31/iiqxU0dr1ND rezx/Zc968YLXbZGkJaocNVd8vK2KQarISO4+PmQLRa4crWjIIrb5M6xJ2aO7Va7m8hD O3pA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 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. [212.18.0.10]) by gmr-mx.google.com with ESMTPS id bn28si937834ljb.1.2021.11.14.09.27.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:27:52 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.10 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.10; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRC468Yz1rk5n; Sun, 14 Nov 2021 18:27:51 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRC3RN5z1qqkB; Sun, 14 Nov 2021 18:27:51 +0100 (CET) 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 JPiKfxnwKVuQ; Sun, 14 Nov 2021 18:27:49 +0100 (CET) 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; Sun, 14 Nov 2021 18:27:49 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id CDC414540853; Sun, 14 Nov 2021 18:27:48 +0100 (CET) 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 UH3-3tyqpGXG; Sun, 14 Nov 2021 18:27:44 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id CDC1145408E4; Sun, 14 Nov 2021 18:27:44 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 01/36] Doc for delta update Date: Sun, 14 Nov 2021 18:26:58 +0100 Message-Id: <20211114172733.71602-2-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.10 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: , Signed-off-by: Stefano Babic --- doc/source/delta-update.rst | 223 ++++++++++++++++++++++++++++++++++++ doc/source/index.rst | 1 + 2 files changed, 224 insertions(+) create mode 100644 doc/source/delta-update.rst diff --git a/doc/source/delta-update.rst b/doc/source/delta-update.rst new file mode 100644 index 0000000..5307dcd --- /dev/null +++ b/doc/source/delta-update.rst @@ -0,0 +1,223 @@ +.. + SPDX-FileCopyrightText: 2021 Stefano Babic + SPDX-License-Identifier: GPL-2.0-only + +========================== +Delta Update with SWUpdate +========================== + +Overview +-------- + +The size of update packages is steadily increasing. While once the whole software was just +a bunch of megabytes, it is not unusual now that OS and application on devices running +Linux as OS reach huge size of Gigabytes. + +Several mechanisms can be used to reduce the size of downloaded data. The resulting images +can be compressed. However, this is not enough when bandwidth is important and not cheap. +It is very common that a device will be upgraded to a version that is similar to the +running one but add new features and solves some bugs. Specially in case of just fixes, +the new version is pretty much equal as the original one. This asks to find methods to +download just the differences with the current software without downloading a full image. +In case an update is performed from a known base, we talk about *delta updates*. In the following +chapter some well known algorithms are considered and verified if they can be integrated +into SWUpdate. The following criteria are important to find a suitable algorithm: + + - license must be compatible with GPLv2 + - good performance for smaller downloads, but not necessarily the best one. + - SWUpdate remains with the concept to deliver one package (SWU), the same + independently from the source where the SWU is stored (USB, OTA, etc.) + - It must comply to SWUpdate's security requirements (signed images, privilege separation, etc.) + +Specific ad-hoc delta updates mechanisms can be realized when the nature of the updated files is +the same. It is always possible with SWUpdate to install single files, but coherency and compatibility +with the runningsoftware must be guaranteed by the integratot / manufacturer. This is not covered here: +the scope is to get an efficient and content unaware *delta* mechanism, that can upgrade in differential +mode two arbitrary images, without any previous knowledge about what they content. + +FOSS projects for delta encoding +-------------------------------- + +There are several algorithms for *delta encoding*, that is to find the difference between files, +generally in binary format. Only algorithms available under a compatible FOSS license (GPLv2) +are considered for SWUpdate. +One of the goals in SWUpdate is that it should work independently which is the format of the +artifacts. Very specialized algorithm and libraries like Google's Courgette used in Chromium will give +much better results, but it works on programs (ELF files) and take advantages of the structure of compiled +code. In case of OTA update, not only software, but any kind of artifact can be delivered, and this includes +configuration data, databases, videos, docs, etc. + +librsync_ +......... + +librsync_ is an independent implementation for rsync and does not use the rsync protocol. It is well +suited to generate offline differential update and it is already integrated into SWUpdate. +However, librsync takes the whole artifact and generates a differential image that is applied +on the whole image. It gives the best results in terms of reduced size when differences are +very small, but the differential output tends to be very large as soon as the differences +are meaningful. Differential images created for SWUpdate show that, as soon as the difference larger is, +the resulting delta image can even become larger as the original one. + +SWUpdate supports `librsync` as delta encoder via the rdiff handler. + +xdelta_ +....... + +xdelta_ uses the VCDIFF algorithm to compute differences between binaries. It is often used +to deliver smaller images for CD and DVD. The resulting images are created from an installed +image that should be loaded entirely in main memory. For this reason, it does not scale well +when the images are becoming larger and it is unsuitable for embedded systems and SWUpdate. + +casync_ +....... + +casync_ is, according to his author. a tool for distributing images. It has several interesting +aspects that can be helpful with OTA update. +Files itself are grouped together in chunks and casync creates a "Chunk storage" where each chunk +is stored on a separate file. The chunk storage is part of the delivery, and it must be stored on +a server. casync checks if the chunk is already present on the target, and if not +download it. If this seems to be what is required, there are some drawbacks if casync +should be integrated in SWUpdate: + + - because of the nature of casync, each chunk is a separate file. This cause a huge + number of new connections, because each file is a separate GET on the server. + The overhead caused to re-instantiate connection is high on small devices, + where SSL connections are also increasing CPU load. There are downloads of + hundreds or thousands of small files just to recreate the original metadata + file. + - casync has no authentication and verification and the index (.caidx or .caibx) + are not signed. This is known, but casync goals and scopes are outside the ones + on embedded devices. + - it is difficult to deliver a whole chunk storage. The common usage for OTA is to deliver + artifacts, and they should be just a few. Thousands of files to be delivered to let + casync to compute the new image is not practical for companies: they have a new "firmware" + or "software" and they need an easy way to deliver this file (the output from their build system) + to the devices. In some cases, they are even not responsible for that, and the firmware is given to + another authority that groups all packages from vendors and realizes a sort of OTA service. + - casync is quite a huge project - even if it was stated that it will be converted into + a library, this never happened. This makes difficult to interface to SWUpdate, + and using it as external process is a no way in SWUpdate for security reason. + It breaks privilege separation, and adds a lot of code that is difficult + to maintain. + +For all these reasons, even if the idea of a chunk storage is good for an OTA updater, casync +is not a candidate for SWUpdate. A out-of-the-box solution cannot be found, and it is required to +implement an own solution that better suits for SWUpdate. + +Zchunk_ - compression format +............................ + +zchunk_ seems to combine the usage of a chunk storage without having to deliver it on a server. +zchunk is a FOSS project released under BSD by its author_. The goal of this project is something else: +zchunk creates a new compression format that adds the ability to download the differences between +new and old file. This matches very well with SWUpdate. A zchunk file contains a header that +has metadata for all chunks, and according to the header, it is known which chunks must be +downloaded and which ones can be reused. zchunk has utilities to download itself the missing chunks, +but it could be just used to find which part of an artifact must be downloading, +and SWUpdate can go on with its own way to do this. + +One big advantage on this approach is that metadata and compressed chunks are still bound into a single file, +that can be built by the buildsystem and delivered as it is used to. The updater needs first the metadata, that is +the header in zchunk file, and processes it to detect which chunks need to be downloaded. Each chunk has +its own hash, and the chunks already available on the device are verified against the hash to be sure +they are not corrupted. + +Zchunk supports multiple sha algorithms - to be compatible with SWUpdate, zchunk should be informed +to generate sha256 hashes. + +Design Delta Update in SWUpdate +------------------------------- + +For all reasons stated before, `zchunk` is chosen as format to deliver delta update in SWUpdate. An artifact +can be generated in ZCK format and then the ZCK's header (as described in format_) can be extracted and +added to the SWU. In this way, a ZCK file is signed (and if requested compressed and/or encrypted) as +part of the SWU, and loading chunks from an external URL can be verified as well because the corresponding +hashes are already verified as part of the header. + + +.. _casync: http://0pointer.net/blog/casync-a-tool-for-distributing-file-system-images.html +.. _xdelta: http://xdelta.org/ +.. _zchunk: https://github.com/zchunk/zchunk +.. _author: https://www.jdieter.net/posts/2018/05/31/what-is-zchunk/ +.. _librsync: https://librsync.github.io/ +.. _format: https://github.com/zchunk/zchunk/blob/main/zchunk_format.txt + +Changes in ZCHUNK project +------------------------- + +Zchunk has an API that hides most of its internal, and provides a set of tools for creating +and downloading itself a file in ZCK format. Nevertheless, Zchunk relies on hashes for the compressed +(ZST) chunks, and it was missing for support for uncompressed data. To combine SWUpdate and zchunk, +it is required that a comparison can be done between uncompressed data, because it is unwanted that +a device is obliged to compress big amount of data just to perform a comparisons. +A short list of changes in the Zchunk project is: + + - create hashes for uncompressed data and extend format to support it. The header + must be extended to include both size and hash of uncompressed data. + - make the library embedded friendly, that means reports errors in case of failure + instead of exiting and find a suitable way to integrate the log output + for the caller. + - allow to use sha256 (already foreseen in zchunk) as this is the only hash type + used in SWUpdate. + - add API to allow an external caller to take itself the decision if a chunk must be + downloaded or reused. + +Some of these changes were merged into Zchunk project, some are still open. Zchunk working with +SWUpdate ist stored on a separate branch_. + +.. _branch: https://github.com/sbabic/zchunk/tree/devel + +Most of missing features in Zchunk listed in TODO for the project have no relevance here: +SWUpdate already verifies the downloaded data, and there is no need to add signatures to Zchunk itself. + +Integration in sw-description +----------------------------- + +The most important part in a Zchunk file is the header: this contains all metadata and hashes to perform +comparisons. The `zck` tool splits a file in chunks and creates the header. Size of the header are know, and the +header itself can be extracted from the ZCK file. +The header will be part of sw-description: this is the header for the file that must be installed. Because the header +is very small compared to the size of the whole file (quite 1 %), this header can be delivered into the SWU. + + +Integration in SWUpdate: the delta handler +------------------------------------------ + +The delta handler is responsible to compute the differences and to download the missing parts. It is not responsible +to install the artifact, because this breaks the module design in SWUpdate and will constrain to have +just one artifact type, for example installing as `raw` or `rawfile`. But what about if the artifact should be installed +by a different handler, for example UBI, or a custom handler ? +The best way is that the delta handler does not install, but it creates the stream itself so that this stream +can be passed to another (chained) handler, that is responsible for installing. All current SWUpdate's handlers +can be reused: each handler does not know that the artifact is coming with separate chunks and it sees just a stream +as before. +The delta handler has in short the following duties: + + - parse and understanf the ZCK header + - create a ZCK header from the file / partition used as source for the comparison + - detect which chunks are missing and which one must be copied. + - build a mixer that copies and downloads all chunks and generates a stream + for the following handler. + - detect any error coming form the chained handler. + +Because the delta handler requires to download more data, it must start a connection to the storage +where the original ZCK is stored. This can lead to security issues, because handlers run with high +priviliges because they write into the hardware. In fact, this breaks `privilege separation` that is +part of SWUpdate design. +To avoid this, the delta handler does not download itself. A separate process, that can runs with different +userid and groupid, is responsible for this. The handler sends a request to this process with a list of +ranges that should be downloaded (see HTTP Range request). The delta handler does not know how the chunks are +downlaoded, and even if using HTTP Range Request is the most frequent choice, it is open to further +implementations. +The downloader process prepares the connection and asks the server for ranges. If the server is not +able to provide ranges, the update aborts. It is in fact a requirement for delta update that the +server storing the ZCK file is able to answer to HTTP Range Request, and there is no fallback to download +the full file. +An easy IPC is implemented between the delta handler and the downloader process. This allows to exchange +messages, and the downloader can inform the handler if any error occurs so that the update can be stopped. +The downloader will send a termination message when all chunks will be downloaded. +Because the number of missing chunks can be very high, the delta handler must sends and organize +several requests to the downloader, and tracking each of them. +The downloader is thought as dummy servant: it starts the connection, retrieves HTTP headers and data, +and sends them back to the caller. The delta handler is then responsible to parse the answer, and to +retrieve the missing chunks from the multipart HTTP body. diff --git a/doc/source/index.rst b/doc/source/index.rst index c07b79c..8ed508e 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -49,6 +49,7 @@ SWUpdate Documentation bindings.rst building-with-yocto.rst swupdate-best-practise.rst + delta-update.rst ############################################ Utilities and tools From patchwork Sun Nov 14 17:26:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554891 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=ZujmlsDw; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::43a; helo=mail-wr1-x43a.google.com; envelope-from=swupdate+bncbcxploxj6ikrbguoywgamgqem5qddxy@googlegroups.com; receiver=) Received: from mail-wr1-x43a.google.com (mail-wr1-x43a.google.com [IPv6:2a00:1450:4864:20::43a]) (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 4HsfRM6ml9z9sWJ for ; Mon, 15 Nov 2021 04:27:58 +1100 (AEDT) Received: by mail-wr1-x43a.google.com with SMTP id y10-20020adffa4a000000b0017eea6cb05dsf2574750wrr.6 for ; Sun, 14 Nov 2021 09:27:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910875; cv=pass; d=google.com; s=arc-20160816; b=iXVqy5rTVLVPqeL+Q4zPNtBsLvQE/bZIgT9zcKfuYf300qWM4blC3C09KFLVx7mYdO v+hWdZns5AXMk8z6eJUiHrS8OyO4fEZiSt7Q/61OA8QNt0UughMsxPFLMi2CsaThSl1B 6DY3ucUm6GdFOmuyUvh/Ji0PznE8hPyUjiVBLk/5Sfa97+IOYhWaiC8mpcXO8zfdIALy YMs7S2X0RQe3G1TFFQjW85zAH9AA0jVbD2GSG5uc85p29GWFwOJsGDUrJ5vH2aLi37o+ sa7ARQ/3V+Kfw5lZQnx/eYUpfan0Q7EZsU1iIEELUTELGSCgSqLT86AI0xMNUf1/w6E4 DBsg== 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=q0CP5fv2RaQeen3BaUf6iMroea12JFo6QqwJhuI3ZL8=; b=u9zrVqv5nMLTPewUDbW2nUGe4rCOeLvFqx4DM5wbWUmFoFaNyRzgH+vAGTlSRNRbVq RAhRh2IGyxP6ZSt00w37j4uIOF4EwZReujQDu0dYdIWWI0J9/Nf5ciDG4zgyuyF6klew Ds6+1FdNida53Bxa5F0sG8Rhej3aZivyoDyncZPU5LmXp+BfL6KfrjphJ/a5uQRFyvyt AqZDaq8wawXLdLsuzW3I8AzvVmOrxASeBz25gO01VML23170h8eO8Mcvacm4NEIH5pFp fZjyVu617LmPQgvNxTgCGJsz9e4Cs0BpjDJrEkina5bgE6TO8UyzJWN+ChHBbFu6Bn6s EYrA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=q0CP5fv2RaQeen3BaUf6iMroea12JFo6QqwJhuI3ZL8=; b=ZujmlsDwUDHvMK2OMMeWmblzFMdxLSjXzl/t/hjmu7vfP6xqnY854i3KpBErOPCPxc cS+WBPJe2N4w8zwMA3oPbAAwJODztEr2SXcEpQ9osxJrFsLpbEk4N9zQ6SecNNGLY01+ tbuFsaCUM7GFpc5z6a7oCOZwWhlTzFhWxxKNAjtfGb0o8kpCxJl7Ydj6PAyIXHj6ZxkH 8qkr+/MDLt6N4tjxF83bz/9ZadWSROWJQTXDkn+dy5U86XpwVFATb1TrwgTh0eoVPLgU +r7sf7KhONeGLlQmxqriSO/MlwH/GOJUrxdHdZTnRx3pacHLjvVWVJ4HrpJzw/CJX4/M bdXQ== 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=q0CP5fv2RaQeen3BaUf6iMroea12JFo6QqwJhuI3ZL8=; b=AO/58JvvU8o1LgIVhmA6gdMbdZguSYgSRnE8UpDVsQmH1OtjbSmkRMbGwyIcMugofe oQUPVx4hdt4dswFmukKnQFCZjlZzIEEQh4B6UAdCtS70NigEx8EgQ8gNKQMY4hFxjDEo yhHjB+1hb4+3cmqrRJa8M5yWFcVIL3IDXGs12q1GkilpQt1Bxp5O19Ajb4OirpDWNj53 Cfn4YxeOslHpg9jUl3i25AYUcMv1jYtmypTYFowRQ36UigqVmPxgs14+0VttEPkT2aEO 7HhcbYH6Kytlohz8JK9DsI52IkYWGY6eYhc91wr8FeQY2PkRObBJE+6JwKBJMSH4h0lO ljNw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530T0nJiJbe2bxk0r7DHR/sCkBYDeEVt6sDkihS8DvIChvsx+C3X QbdNa8we0wZU3m+b3QKjo5A= X-Google-Smtp-Source: ABdhPJzXfODpqlLF7GQJXOHPlXdq0A33dgBK9m6e3oc++EnhaHrDqnOEEdgF2BUSU2U2Omzqb2Ikzg== X-Received: by 2002:a05:600c:24c:: with SMTP id 12mr51827979wmj.124.1636910874783; Sun, 14 Nov 2021 09:27:54 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:ad6:: with SMTP id c22ls9086194wmr.1.canary-gmail; Sun, 14 Nov 2021 09:27:54 -0800 (PST) X-Received: by 2002:a1c:540c:: with SMTP id i12mr1895246wmb.33.1636910873924; Sun, 14 Nov 2021 09:27:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910873; cv=none; d=google.com; s=arc-20160816; b=QwJa5ilpWDOnlfH2S1qEueOszME1d0lhLxYexAm5MFs+UUqasud1nbM9iZJpDMFXLA npfvzxirHQY5+HbYa2UXqDVGvkOX8KfCHS/1cxR0qLuVAHLRYbMFX4BfGz9fssZgbit6 PnfLlXf3ZiKTJAtmjtsyRCoADdqz8fHq8awyNxdNQGa7YeX5tdcDMPUMJMplhTwnsINX U0jje6pYDxwzmbmyVvAoxPZi4E4qTDb5jM9+xRyvIlmgvyq+o9HefjpPNGPSBopnnjXh SVpKBCvzDbK6NT+2pw7og4KC2G/PSir2AcRYHdbWt0MNIr2JDd+NzQNP41FhjvIUKpgh TDOg== 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=urfpxCEbElVpzhJI5j75sWOF5EDayvmT/OfVUSw4xl0=; b=tV96cLnxqNL/1MYvapxNVuTPTxhSlbMuYla+VX/C0CVpiQ8fuccRrcXR8zUj9G3FDj 4OjAwVoUKq5gRK8+Vo9qnqOcLdJ54gOWGBOgqkK2k8PX0JrtQ80eyfoqZEO8pWYTwpnq n6mfcZfBqkzF6H/LOJaalk9uK1a2z0wUwVQVst8F4E/Qa/MJOY2hlpngoB/mWnLW/Go1 bFxQkoLt+3VyMtYhnXLbwO8H43VxFiFsWT2jdFpfym+A+fKR2KNd4KCEDbiMudwATOZo iUnLv4coQS1chK+9kq0fLnrFUhpeet0EDIm4rQzyrZeMR4OI32Ztk6RV30a5b494P98S pyxQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id i7si983008wrc.4.2021.11.14.09.27.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:27:53 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRF4k0Nz1qwdP; Sun, 14 Nov 2021 18:27:53 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRF4YZHz1qqkB; Sun, 14 Nov 2021 18:27:53 +0100 (CET) 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 UOORfRdBsmoe; Sun, 14 Nov 2021 18:27:52 +0100 (CET) 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; Sun, 14 Nov 2021 18:27:52 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 901CE4540853; Sun, 14 Nov 2021 18:27:51 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id lCRKOdB03PwV; Sun, 14 Nov 2021 18:27:48 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id DC2F34541B5B; Sun, 14 Nov 2021 18:27:44 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 02/36] Handlers: sort list of handlers in menuconfig Date: Sun, 14 Nov 2021 18:26:59 +0100 Message-Id: <20211114172733.71602-3-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , Numbers of supplied handlers is raised, sort the list to find them easier during menuconfig. Signed-off-by: Stefano Babic --- handlers/Config.in | 256 ++++++++++++++++++++++----------------------- 1 file changed, 128 insertions(+), 128 deletions(-) diff --git a/handlers/Config.in b/handlers/Config.in index 0dd899a..01663db 100644 --- a/handlers/Config.in +++ b/handlers/Config.in @@ -9,67 +9,31 @@ menu "Image Handlers" -config UBIVOL - bool "ubivol" +config ARCHIVE + bool "archive" + depends on HAVE_LIBARCHIVE default n - depends on HAVE_LIBUBI - depends on MTD help - ubi is the default format for NAND device. - Say Y if you have NAND or you use UBI on - your system. + Handler using the libarchive to extract tarballs + into a filesystem. -comment "ubivol support needs libubi" - depends on !HAVE_LIBUBI +comment "archive support needs libarchive" + depends on !HAVE_LIBARCHIVE -config UBIATTACH - bool "Automatically attach UBI devices" +config LOCALE + bool "Locale support for filenames" + depends on ARCHIVE default y - depends on UBIVOL - help - If this option is enabled, swupdate will try to attach - UBI devices to all MTD devices. - - Make sure UBIBLACKLIST or UBIWHITELIST is set correctly, - since attaching a UBI device will write to it if it is - found to be empty, and that may destroy already existing - content on that device. - -config UBIBLACKLIST - string "List of MTD devices to be excluded for UBI" - depends on UBIATTACH - help - Define a list of MTD devices that are excluded - by scan_mtd_device. The devices are still available - as raw devices. - The list can be set as a string with the mtd numbers. - Examples: "0 1 2" - This excludes mtd0-mtd1-mtd2 to be searched for UBI volumes - -config UBIWHITELIST - string "List of MTD devices that must have UBI" - depends on UBIATTACH help - Define a list of MTD devices that are planned to have - always UBI. If first attach fails, the device is erased - and tried again. - The list can be set as a string with the mtd numbers. - Examples: "0 1 2" - This sets mtd0-mtd1-mtd2 to be used as UBI volumes. - UBIBLACKLIST has priority on UBIWHITELIST. + Option to remove attempts to use locale in systems + without locale support in toolchain. -config UBIVIDOFFSET - int "VID Header Offset" - depends on UBIATTACH - default 0 +config BOOTLOADERHANDLER + bool "bootloader" + default n help - Force UBI to set a VID header offset to be 2048 bytes - instead of the value reported by the kernel. - In other words, you may ask UBI to avoid using sub-pages. - This is not recommended since this will require - more storage overhead, but may be useful - if your NAND driver incorrectly reports that it can handle - sub-page accesses when it should not. + Enable it to change bootloader environment + during the installation process. config CFI bool "cfi" @@ -124,53 +88,6 @@ config DISKFORMAT_HANDLER source fs/Config.in -config UNIQUEUUID - bool "uniqueuuid" - depends on HAVE_LIBBLKID - default n - help - This handler checks that no filesystem on the device has - a UUID from a list (list is added as part of "properties" - in sw-description) for this handler. - This is useful for bootloader (like GRUB) that use UUID to - select the partition to be started, and in case two or - more filesystem have the same UUID, a wrong one is started. - This handler is a partition handler and it is guaranteed that - it runs before any image is installed on the device. - -comment "uniqueuuid support needs libblkid" - depends on !HAVE_LIBBLKID - -config RAW - bool "raw" - default n - help - This is a simple handler that simply copies - into the destination. - -config RDIFFHANDLER - bool "rdiff" - depends on HAVE_LIBRSYNC - default n - help - Add support for applying librsync's rdiff patches, - see http://librsync.sourcefrog.net/ - -comment "rdiff support needs librsync" - depends on !HAVE_LIBRSYNC - -config READBACKHANDLER - bool "readback" - depends on HASH_VERIFY - default n - help - To verify that an image was written properly, this readback handler - calculates the sha256 hash of a partition (or part of it) and compares - it against a given hash value. - - This is a post-install handler running at the same time as - post-install scripts. - config LUASCRIPTHANDLER bool "Lua Script" depends on LUA @@ -179,14 +96,6 @@ config LUASCRIPTHANDLER Handler to be called for pre- and post scripts written in Lua. -config SHELLSCRIPTHANDLER - bool "shellscript" - default n - help - Handler to be called for pre- and post scripts - written as shell scripts. The default shell /bin/sh - is called. - config HANDLER_IN_LUA bool "Handlers in Lua" depends on LUASCRIPTHANDLER @@ -219,24 +128,35 @@ config EMBEDDED_LUA_HANDLER_SOURCE Path to the Lua handler source code file to be embedded into the SWUpdate binary. -config ARCHIVE - bool "archive" - depends on HAVE_LIBARCHIVE +config RAW + bool "raw" default n help - Handler using the libarchive to extract tarballs - into a filesystem. + This is a simple handler that simply copies + into the destination. -comment "archive support needs libarchive" - depends on !HAVE_LIBARCHIVE +config RDIFFHANDLER + bool "rdiff" + depends on HAVE_LIBRSYNC + default n + help + Add support for applying librsync's rdiff patches, + see http://librsync.sourcefrog.net/ -config LOCALE - bool "Locale support for filenames" - depends on ARCHIVE - default y +comment "rdiff support needs librsync" + depends on !HAVE_LIBRSYNC + +config READBACKHANDLER + bool "readback" + depends on HASH_VERIFY + default n help - Option to remove attempts to use locale in systems - without locale support in toolchain. + To verify that an image was written properly, this readback handler + calculates the sha256 hash of a partition (or part of it) and compares + it against a given hash value. + + This is a post-install handler running at the same time as + post-install scripts. config REMOTE_HANDLER bool "Remote handler" @@ -253,6 +173,14 @@ config REMOTE_HANDLER comment "remote handler needs zeromq" depends on !HAVE_LIBZEROMQ +config SHELLSCRIPTHANDLER + bool "shellscript" + default n + help + Handler to be called for pre- and post scripts + written as shell scripts. The default shell /bin/sh + is called. + config SWUFORWARDER_HANDLER bool "SWU forwarder" depends on HAVE_LIBCURL @@ -275,13 +203,6 @@ comment "swuforward handler needs json-c and libcurl" comment "swuforward handler needs websockets and uriparser" depends on !HAVE_LIBWEBSOCKETS || !HAVE_URIPARSER -config BOOTLOADERHANDLER - bool "bootloader" - default n - help - Enable it to change bootloader environment - during the installation process. - config SSBLSWITCH bool "Second Stage Switcher" depends on MTD @@ -293,6 +214,68 @@ config SSBLSWITCH way between two software set. It can be used to reliable update a second stage bootloader. +config UBIVOL + bool "ubivol" + default n + depends on HAVE_LIBUBI + depends on MTD + help + ubi is the default format for NAND device. + Say Y if you have NAND or you use UBI on + your system. + +comment "ubivol support needs libubi" + depends on !HAVE_LIBUBI + +config UBIATTACH + bool "Automatically attach UBI devices" + default y + depends on UBIVOL + help + If this option is enabled, swupdate will try to attach + UBI devices to all MTD devices. + + Make sure UBIBLACKLIST or UBIWHITELIST is set correctly, + since attaching a UBI device will write to it if it is + found to be empty, and that may destroy already existing + content on that device. + +config UBIBLACKLIST + string "List of MTD devices to be excluded for UBI" + depends on UBIATTACH + help + Define a list of MTD devices that are excluded + by scan_mtd_device. The devices are still available + as raw devices. + The list can be set as a string with the mtd numbers. + Examples: "0 1 2" + This excludes mtd0-mtd1-mtd2 to be searched for UBI volumes + +config UBIWHITELIST + string "List of MTD devices that must have UBI" + depends on UBIATTACH + help + Define a list of MTD devices that are planned to have + always UBI. If first attach fails, the device is erased + and tried again. + The list can be set as a string with the mtd numbers. + Examples: "0 1 2" + This sets mtd0-mtd1-mtd2 to be used as UBI volumes. + UBIBLACKLIST has priority on UBIWHITELIST. + +config UBIVIDOFFSET + int "VID Header Offset" + depends on UBIATTACH + default 0 + help + Force UBI to set a VID header offset to be 2048 bytes + instead of the value reported by the kernel. + In other words, you may ask UBI to avoid using sub-pages. + This is not recommended since this will require + more storage overhead, but may be useful + if your NAND driver incorrectly reports that it can handle + sub-page accesses when it should not. + config UCFWHANDLER bool "microcontroller firmware update" depends on HAVE_LIBGPIOD @@ -304,4 +287,21 @@ config UCFWHANDLER comment "Microcontroller handler depends on libgpiod" depends on !HAVE_LIBGPIOD +config UNIQUEUUID + bool "uniqueuuid" + depends on HAVE_LIBBLKID + default n + help + This handler checks that no filesystem on the device has + a UUID from a list (list is added as part of "properties" + in sw-description) for this handler. + This is useful for bootloader (like GRUB) that use UUID to + select the partition to be started, and in case two or + more filesystem have the same UUID, a wrong one is started. + This handler is a partition handler and it is guaranteed that + it runs before any image is installed on the device. + +comment "uniqueuuid support needs libblkid" + depends on !HAVE_LIBBLKID + endmenu From patchwork Sun Nov 14 17:27:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554893 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=aO7R52Nd; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::43c; helo=mail-wr1-x43c.google.com; envelope-from=swupdate+bncbcxploxj6ikrbguoywgamgqem5qddxy@googlegroups.com; receiver=) Received: from mail-wr1-x43c.google.com (mail-wr1-x43c.google.com [IPv6:2a00:1450:4864:20::43c]) (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 4HsfRN0mLtz9ssD for ; Mon, 15 Nov 2021 04:27:58 +1100 (AEDT) Received: by mail-wr1-x43c.google.com with SMTP id y4-20020adfd084000000b00186b16950f3sf2576004wrh.14 for ; Sun, 14 Nov 2021 09:27:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910875; cv=pass; d=google.com; s=arc-20160816; b=VQYUO3Xs5I2gpD+UorvTeV7FgSSvVKAOpkYEnPKOMUS0oqK3GYovh9NU5l8vz52U+e bGm5qhI7zjnbDSXWMEWbpH+DPw30l5fB5FAdf9uivNK/wx9wTh23KtWYXuwCg5zJYPDF raKG919FqvQwkhqgqW+oHsb86E8mectBBw51GxR4dXNqVQ7fERD+BpRbxiFHpai7M2ij gwvlY/k3X+Lng3/UhucOG6p1f/oEsBTlVs6Y52YK5F/h5nb2D8mQMXbuRcT3FK1K1YfJ N7HsM5zNElFJNVpvxULtDXB/6U+23M17w5geyj1S6dD/gjEfeJXYuBWYVlropP1Nelvh RBmg== 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=Up/DUWe+LQf3OCfsWDg0/vxD9e7pfdC1wJhMAMXLB5s=; b=jfqvIr6gRpw514DLkQdTBht7EA1fBm/DbooWII4N5/LI7SlUGFNz/Cs1QlTuIOBzh2 skioFtL11w1whAq48bad/KcuyWPcpXkRw7ehFciWq1elUyZlCur2R4oqKbAfs3VLJeL9 II00GmABwWzCyI5cnZRgMTO04R7BNA/NOvqM5AM95SUBMI1RqXmCkseItwo40TXJLoaO nEFXhxnGFqJ7PV8SYbHXUyTtjsa0FVog647bMeYUUnKIU2L9MDUXtefZLkwkyYozGmMa tCz+Hj2vFeMfK+5e/ELOLZ1QqUiW5wB+Hs0l3OjwAN/FgY3bZ/yKwXpnRK0mCgsZdwTi RLWA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=Up/DUWe+LQf3OCfsWDg0/vxD9e7pfdC1wJhMAMXLB5s=; b=aO7R52Nd6Bm5WEFATTi2kcpMF8Db5P/lmEGfMayGAwHIHer+vo1J5rIVe0Tg5xXqPf P3eircGtg+cDakOlBMFzURZhmI2L0BPGukMtmKxS5kUV5evbQaVsF394XwNGGES4Sxca HgOiz/n7H+3/ApfJYKO5WZ2xxER3QQ4yKqc7fAS/pCjd0iK/yso5lABIBdC1omdOxkIG u3AnC1KaOV6iMzAls5H6BgYxntxmFny/UrBJ/GadzFALdvdZMnxAaNiO2jWcsvsM6f+/ Z0YdgsQ2S9mvtmmz+8ZUK8JrVugVRDhArODKP4oYgElYu3kEIfyFncnHeotSFd+Cy04p GU4Q== 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=Up/DUWe+LQf3OCfsWDg0/vxD9e7pfdC1wJhMAMXLB5s=; b=YUnoX5DcLt4t3Web5kmrKlaBvnTcTYQn9NDThs77diYA3x8fTDhs0v2ASBvWgM9nKj IEW8Nyzp72HWxccg79tn9wFHEFnKlK9MpgzONxWMIE4JtVHZhDmLFTfy1fgXgqdFPzw7 6rHJFxv+aiv1ImXUZYESeQyxanS3GO5wG7asWHofu5YHC4iTCO2iqZ1vCj2wQxrRiYdZ /XFq3cdezMsE/uT7UagkJ5Cz7ljkJUQmYreJa+rSMhgL2JbA8iRJHaujBtKpedEFHF2h A3V7odegkPANouNSWu6f0TzqqMZ/HvKcY1gUiXy6O+qxHNnsTrjzwZZs4tW4YP4eCXPJ kKcg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531b5ZBYiSkIphT5baBIcmT/CuY8Zj+zEuCd8WjiPzRwakftsyV4 /t2JzC4CdZKo/VVAswolWMk= X-Google-Smtp-Source: ABdhPJyzU00M2LcutXAgcIR0V+McDtYmkwiYvl3NyrteYLkSuGbEYWCynJMxNHvYQtqZI29JWLkWHA== X-Received: by 2002:a05:600c:22c7:: with SMTP id 7mr35132178wmg.58.1636910875025; Sun, 14 Nov 2021 09:27:55 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a5d:6a05:: with SMTP id m5ls7200138wru.3.gmail; Sun, 14 Nov 2021 09:27:54 -0800 (PST) X-Received: by 2002:a5d:58f9:: with SMTP id f25mr40387122wrd.206.1636910874323; Sun, 14 Nov 2021 09:27:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910874; cv=none; d=google.com; s=arc-20160816; b=udrhfcl0uvHpeCVCBcDZt45Mz2LcResjhR+dKuQJPxVadEP3lQ+gCKV+PC2qbBXU77 jC8ISp2p85X2HgDz2er5nn3lZDheiDJ4agNRRvoZ2gDPPtB/3vKIuQEeyd2xHcpz7d40 tnNxKGebuGBU/MLhejrEfs38gTmIS6vFEZeMHqj5XkWqmzbLLPBMwL3/2Pv+OchGcLnk brszaqcQttAY81wd2A8PXKc7uIA0gFs0XHD6CxpRXO8190oSXuDmC534a3GCbGpTFHpW MQNZn2xjOBF2kGxUy0yT3D2SReRiY0rC53pq1cNYFIjQy5EDSeCbO4ss/VtKVl0tbVyt DYyQ== 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=Va7yFAnmv10dXQ2s5THX6ohh3bimkD64AqcXr5z7TUM=; b=odXo88p8RmvESm1tHJzeRNn3lq8Ah3BEsdzW5uQY8+W/CraUPlQsH9H5fLSUngC+Kf 0JNdUt90jlWIH/HDP1fdNyPL99sA5aef/WpyzzIGIH81T/PXXobJ63tj3cDYHrgzK+T+ xtn0hvjro043zVPUiMQs2l5YHJuWHoitMBcbl1lbQk/jbmcW03hX/kriI6jeId3tt716 rYCpGByN5XAjITaK6kwQZPczAM10j63m9pzygokXGOmR2bglXuxr5wV/RWB3Q70olSNC pgjHLhUjzyGUfysMQHkzl4u5PH5QwKiLHXJKHWqtGDq6IOpLt2ahfUU20IwjaXFKuF4l hG/w== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id c2si1225322wmq.2.2021.11.14.09.27.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:27:54 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRG0pCMz1qwdZ; Sun, 14 Nov 2021 18:27:54 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRG0hs5z1qqkB; Sun, 14 Nov 2021 18:27:54 +0100 (CET) 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 r0NpPvMKja5j; Sun, 14 Nov 2021 18:27:53 +0100 (CET) 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; Sun, 14 Nov 2021 18:27:53 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id DDE0345408E4; Sun, 14 Nov 2021 18:27:52 +0100 (CET) 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 nWFXCUPCQIvz; Sun, 14 Nov 2021 18:27:48 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 0072C4541B62; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 03/36] Add utility function to detect filesystem Date: Sun, 14 Nov 2021 18:27:00 +0100 Message-Id: <20211114172733.71602-4-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , This can be used to detect a filesystem from a device instead of specify the expected filesystem. Signed-off-by: Stefano Babic --- fs/diskformat.c | 28 ++++++++++++++++++++-------- include/fs_interface.h | 1 + 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/fs/diskformat.c b/fs/diskformat.c index 0841f0b..8d58fc3 100644 --- a/fs/diskformat.c +++ b/fs/diskformat.c @@ -39,36 +39,48 @@ static struct supported_filesystems fs[] = { * Checks if file system fstype already exists on device. * return 0 if not exists, 1 if exists, negative values on failure */ -int diskformat_fs_exists(char *device, char *fstype) + +char *diskformat_fs_detect(char *device) { - char buf[10]; - const char *value = buf; + const char *value; + char *s = NULL; size_t len; blkid_probe pr; - int ret = 0; pr = blkid_new_probe_from_filename(device); if (!pr) { ERROR("%s: failed to create libblkid probe", device); - return -EFAULT; + return NULL; } while (blkid_do_probe(pr) == 0) { if (blkid_probe_lookup_value(pr, "TYPE", &value, &len)) { ERROR("blkid_probe_lookup_value failed"); - ret = -EFAULT; break; } - if (!strncmp(value, fstype, sizeof(buf))) { - ret = 1; + if (len > 0) { + s = strndup(value, len); break; } } blkid_free_probe(pr); + return s; +} + +int diskformat_fs_exists(char *device, char *fstype) +{ + int ret = 0; + char *filesystem = diskformat_fs_detect(device); + + if (filesystem) { + ret = !strcmp(fstype, filesystem); + } + + free(filesystem); return ret; } diff --git a/include/fs_interface.h b/include/fs_interface.h index 25c22e5..581f02a 100644 --- a/include/fs_interface.h +++ b/include/fs_interface.h @@ -7,6 +7,7 @@ #ifndef _FS_INTERFACE_H #define _FS_INTERFACE_H +char *diskformat_fs_detect(char *device); int diskformat_fs_exists(char *device, char *fstype); int diskformat_mkfs(char *device, char *fstype); From patchwork Sun Nov 14 17:27:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554895 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=PZjlUupp; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23d; helo=mail-lj1-x23d.google.com; envelope-from=swupdate+bncbcxploxj6ikrbhmoywgamgqe6x42kba@googlegroups.com; receiver=) Received: from mail-lj1-x23d.google.com (mail-lj1-x23d.google.com [IPv6:2a00:1450:4864:20::23d]) (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 4HsfRP1pvMz9t0k for ; Mon, 15 Nov 2021 04:28:00 +1100 (AEDT) Received: by mail-lj1-x23d.google.com with SMTP id y23-20020a2e3217000000b00218c6ede162sf4411625ljy.23 for ; Sun, 14 Nov 2021 09:28:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910877; cv=pass; d=google.com; s=arc-20160816; b=UWFRkP0VKj+sMryqbhS9jHR/aGIyOP5/0rMce7ceYlkJMkpn8iC73Ze4Y7IZ9qOsCv Al5pg+RpSlY9Jw9FxD+XRVwVMRnrLo6b10JfIv2yMib0XK7JMQbj6UXtOvBEB6D9TqEr j3HMqL/H+CbEg8PGupCaY1A+FqF+cCcRdEP2uIpInASpnns5Hk9WITsX5fBL5JyyVAXq MmWx/4UrRq6E3az4MZAj1/9kATFaTiMmiIpsQmxB4oASquuziWACystAb88cn8WzKynM KiThxf7qibZ/FHbeRkoX1MC5F8KvylphGUC1XSUfI97BlTgukvu0SH/QxIXBfAGktMyv +Drg== 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=NZDNybkCS6xuG/ra1ToX0UH4rCPtGEHaCWYUEDw+8gE=; b=PXl9Ce6BMmBZHPD10er+UGcdawA7LsqaYhdTje1E1grTp/ph4k25Yjf9yYUPUaf8M4 s7nm6IBw32AG+z0DiqxGljWY0+OTeanq6AJJYHmm6XrmS0ivtW2TaT4BcruoWKQc9Pbh YgJcuRh2vgi0sj2v31fgt5Auxtllu3305hsF9wRauxA5UzKwwPm3bJESL1fjFsjxAs5j jGIq2a9ZLr9DQxea4KEozclguvRCegfkh7RNbQ6da0OMJMJYCotMKhIwR011d7xHEwU4 7AZu9V2KiYDqxYcqaqDqWEYN+PKOf+j7rgpiTDNZbYfc/ZK+Dpj0Org/xCNDDh2scmgZ mBVQ== 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=NZDNybkCS6xuG/ra1ToX0UH4rCPtGEHaCWYUEDw+8gE=; b=PZjlUupprEkBzlgmHZOCJ2dM7V1NE7G/gTfEaa2nsSRHKuaQRdxaefKd+5hhdGcoRL ZXtg7ezpD8ExwZ+Huhxa8DGf2Ob2/Nbl1Rr+eBhKQGPJexXuaZM6JLI03GOf475oh5aT cx5P2L2ohn3tmGcT0OA9QJACsTYWntWeOPnlWgECfboYhFdGK8I3mPWRwZ5wUO8CT5eE tzpEBU0Madnk5jQLDNee989Dr1DKdJ7PzloEhYc22ssvLy5vUsLWcHLvJ6uhXF+HJUio FDtu7XBWs05Eh972Ze7mtKerwvZG3QIyzP7I/a5DluatlCSOANcp1dojzJl8g7gJqjnX 6E6w== 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=NZDNybkCS6xuG/ra1ToX0UH4rCPtGEHaCWYUEDw+8gE=; b=Rv2avTQVyqdDp0fLsvT5G1FjZHiL0xE2ioV+766XdlIvjffE5yg2R8C4OeyH4beUdF RjfZQ3ZFTabe7ZPg69xJPmvO0gtz/dv9lHGeSK2W/2OCx1FfENBR4dnHxCN4GVplGMCy IHLvkD84H8U153MKGssD8WXVTnLkLTk/fhZK+z2BiMPfk5kqF4Qlwcqar6+paB/vazbX +QVcG9ZoRnhtirkAQlRY2Hex17HhmuWIf/yH9VexKaBtROjO62qqDp+7CBSPuAUS3vZk 4ZbJuWvvzHcOA/W2rTqH6RlMcc2m58J8r3Ufwp771aSOTg6jV4e/LJCfuRGecSqI4yQY onYQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533DFvOfat6GE2z+NRt/4LNQv24EvgT/1ThCxPTrq6qQKcCv9vaJ ZvkyVSqb/OVv+sxO7kGIU/s= X-Google-Smtp-Source: ABdhPJzB4wj9jjwh+4Q0ktpZbsFxxv+NptrH4FIPY+2eRNIgvkGJ2zZC+xzZ0MLmz+noUk/zzWZ9+w== X-Received: by 2002:a05:6512:230e:: with SMTP id o14mr30424107lfu.490.1636910877441; Sun, 14 Nov 2021 09:27:57 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:898c:: with SMTP id c12ls1819086lji.11.gmail; Sun, 14 Nov 2021 09:27:56 -0800 (PST) X-Received: by 2002:a2e:3902:: with SMTP id g2mr32594824lja.321.1636910876586; Sun, 14 Nov 2021 09:27:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910876; cv=none; d=google.com; s=arc-20160816; b=QbsrEo8ljFi7wcNpqtUH/qS6sUmBHjLKy4PuTpv066bs2Sg3QCMAH9gUbdUHLrA1FQ 7XVmXdXpaXiqdT/4P3ct8UEtdZ5awC/iHQWpuXc4Hg3qPBEWDKXEYqnqbe7HAm0sOaEx 9LQCjhsqCnaLJB7IyWyyUjJ84SfGCohkVNTB5oXrRMhBh4XXsGVQbn+tVuvOhvmkvWtb OBcB9pmtQNFsQBa1d3xko324GXt1j8/SlqgtIwivetaLy4NmukhTHeXXs9/yFChzuGvu 2yKEACf+Pt0FRwtDNXQID0eKOoFxnI+dZMMNg7b03YdmAECd8Yl4U2XFVG6BbpKbU2nE y/DA== 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=HpaiGKAmCjXaxRUrYQp++iSsFUfrbJRzze6xnE126Pk=; b=nUyL3YWsOf/qPbREhnk09d8nayFq7ekoBl6IR+EEvjgrxBd8zRBHUA0NbsWw++siCR zD2BE8fzwa8l35u9e/bWrWatp8CwFepwKctbw8pCmVgh3oMFQYp6wX/MSGgvQHMqTlCj omb6SMr6KdmBgD2DUWlUhf+cjN9OyeNoL4PIigt5tUYDGlvEC+ur3qnwNOjwrW+bcz73 Ptk37B5b6G5V3Oj76jP4zTxw4nNMRrCu7zwqP17NUbdVtQ7CMpsbAW5ctccWNr8rvgcW encmDw6yqv00sLDhAETX3/YjWLi8iXYpS/UGRf6xnbKnVEr+XoNkU+SpPimGTJiVZ1pm EeCQ== 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 f25si359740lfj.4.2021.11.14.09.27.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:27:56 -0800 (PST) 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 4HsfRJ09lwz1rk5m; Sun, 14 Nov 2021 18:27:56 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRJ0395z1qqkB; Sun, 14 Nov 2021 18:27:56 +0100 (CET) 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 E1YjTLw66yNh; Sun, 14 Nov 2021 18:27:55 +0100 (CET) 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; Sun, 14 Nov 2021 18:27:55 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id C41074540853; Sun, 14 Nov 2021 18:27:54 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Ox2yZHcN1dmm; Sun, 14 Nov 2021 18:27:51 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 0B70F4541B6E; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 04/36] util: add safe version for realloc() Date: Sun, 14 Nov 2021 18:27:01 +0100 Message-Id: <20211114172733.71602-5-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: , Realloc does not touch the passed pointer, creates a wrap-around function to be sure that the memory on the heap is always freed. Signed-off-by: Stefano Babic --- core/util.c | 12 ++++++++++++ include/util.h | 1 + 2 files changed, 13 insertions(+) diff --git a/core/util.c b/core/util.c index da6bd10..f5d7c63 100644 --- a/core/util.c +++ b/core/util.c @@ -212,6 +212,18 @@ void freeargs (char **argv) } } +void *saferealloc(void *ptr, size_t size) { + void *ret = realloc(ptr, size); + /* + * Realloc does not touch the original block if fails. + * Policy is to free memory and returns with error (Null) + */ + if (!ret && ptr) + free(ptr); + return ret; +} + + /* * Concatente array of strings in a single string * The allocated string must be freed by the caller diff --git a/include/util.h b/include/util.h index 9c81e62..4f2995b 100644 --- a/include/util.h +++ b/include/util.h @@ -162,6 +162,7 @@ bool strtobool(const char *s); */ typedef int (*writeimage) (void *out, const void *buf, unsigned int len); +void *saferealloc(void *ptr, size_t size); int openfile(const char *filename); int copy_write(void *out, const void *buf, unsigned int len); #if defined(__FreeBSD__) From patchwork Sun Nov 14 17:27:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554896 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=pTwaBF9f; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23f; helo=mail-lj1-x23f.google.com; envelope-from=swupdate+bncbcxploxj6ikrbhmoywgamgqe6x42kba@googlegroups.com; receiver=) Received: from mail-lj1-x23f.google.com (mail-lj1-x23f.google.com [IPv6:2a00:1450:4864:20::23f]) (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 4HsfRP1kVXz9t0G for ; Mon, 15 Nov 2021 04:28:00 +1100 (AEDT) Received: by mail-lj1-x23f.google.com with SMTP id j11-20020a2ea90b000000b00218c174bb5dsf4414072ljq.22 for ; Sun, 14 Nov 2021 09:28:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910878; cv=pass; d=google.com; s=arc-20160816; b=RnKAQ4YjMHsqHm0zK3A+psvywx3Vh3GhpKay170m6NLu9HReCwUQGC+IE9KVkc+BnV ci+z6gjmiqE5iN2HloltsekkZtmVHGHTUexdw632BKwWwVlMAzQpsb6yQc7ug3Za0+3z XNT+83nzK39PwxGv0HCENm5yiDxRxkK0t8v5kvDhjGd7L2mEmHNWQSo19nXGpYd7pBRN gDe2qqBqb/sc6yCWYMjY0Rp4Ri5GOv790fSCodK7pkXYWCIEeU774ZRtGOYGEs6MRmng xlvR4jqOTO4XdfiK9H61y7VvvUPKfbfy/erVJEnbO+sqV2zyszGt+eXb05/ohaHYq2IG W52A== 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=4ZTlcnXchLVuH0jqgqXIjKyM9G5ln8LcUaA5oKLMx3I=; b=NdbAtKMU3NMyeFT83KSYEV0miuFdDK+CwuD7Iy5OI/x9DSu42/jlBQP0ET5Pyzbk6g mHQ/dICzH70l27Ub7eVOU+xrG+hCGnVjphipzwum31EeXxumExSrF+998mH7PQnGW9ki Tf9UYtZuYMPuANv19/ptTw2as1xvvGWDpT4SVq8nKxSU4hWOTDoWvA6xTSSGSnRL2BBf NPzujSS2BH6/QfiTxi4z4gnHZJ+LYw/dMZsUK7qUlfrEU1+2X0TIGULhXvWumMo+UQQ8 0GfimFz1nuPNumc5CyifscbnuZXRcjioOWl1Ck8Q09Eo23EikurnqK1doi7lxHevjXm3 /dLg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=4ZTlcnXchLVuH0jqgqXIjKyM9G5ln8LcUaA5oKLMx3I=; b=pTwaBF9fCcsJ2L29kGQHsAKxGsxxps/gO5CKcTgdjOfuz3NwHR7F5Ue9dAFwnSmB26 /N3GP6ieUyiV1+hVuO3RNSyTGYy2cvvc/34nCO/3uD66ojfczREGklkKeCh68ciyKWRY x2/1kIasfgS4CAi8IhlYcNjfl6TMNBdVB8ZzRlA7tMr5qbDKLdxjtdDVCKmvgehj4hdR S7f4SLRX5ZaD2154IECqhkvDVu540d8ucOeqdG1Px9cB1xmrJ1obP5eKFbRAmZQSymm8 38Ly7M+HMlsuX7t5VvBxTIJIuNPffZ/j3WcZmCXr8C1Q31uQQnEMIQqqpyhn8AEfOB9E MNeQ== 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=4ZTlcnXchLVuH0jqgqXIjKyM9G5ln8LcUaA5oKLMx3I=; b=4eXVqZgCGz8+eQ5XUeyxuqACOOlkxj5fQcgbqaDvMjstThpis/dTLQOxY/6IfKXniD K/URCGv9Ryhjs4k8KRMWEgLVFXTCsjWMxIyDypwhv+xrbtDEa8MKfptn9EuUYXol+QNl IUjtOVEVOK3y7auqZOweGtrea5RXroHCk4MIk/11mMXldRd38gdlzfdV7tjBH6tmoJXU nEE154ZgzomVNYgGzD1XCjf1w0q+HYqJEWaZ1XRAP6dasLSLndhHYl5ABPOX8JBQrirt jkS6climabKRJgnddzTEAGDT2Ke0vLq/VO3XzqyTpZLKZLlq5GBhLFt/vBoM1xAQkHkC N8Jw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533T42nSy/F4TtPSIuLAz2HW16zRzYHVXwpoA1qeTuy2Q4YP1Fr6 XbniguB1m21Cq3dAnaD6BSI= X-Google-Smtp-Source: ABdhPJz2zCizRcc2UVi/bmLBrjimRkXPOEDRjFYEeUXXf3W6VJ2eBdd8+r1uawk/K6qlhfDoKC5P4w== X-Received: by 2002:a2e:bd82:: with SMTP id o2mr32202235ljq.96.1636910878117; Sun, 14 Nov 2021 09:27:58 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:3499:: with SMTP id v25ls4675185lfr.0.gmail; Sun, 14 Nov 2021 09:27:57 -0800 (PST) X-Received: by 2002:a05:6512:21cf:: with SMTP id d15mr28554979lft.394.1636910877250; Sun, 14 Nov 2021 09:27:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910877; cv=none; d=google.com; s=arc-20160816; b=xPCuzh2RkmnYanQqDUgO1Pq5zbHo07Bw+hn9fhH/TwNdUL6FPvzBXb69VYgZJ0AOG2 z0qwNyhWHPDW/cIKBVtUI9UL3XgjZb0nN5jLJhZJZNxL3onKcInlJeV1LS2yMcM7xn9f Y3lBqW3GSCHNd+GuQvzRd7fxRq1xoFT++PM53Y6jCNBdzvARml918HfNBIB6JaPz7f/x 5Pc+cDboSiWYNpBgewRt0d+dajZRD2RHRfxY28NfqdcMoLJc0zD+7O3Gp98G3Ff6/x9+ YqPIiljUw1bX3l92ZTb03oGrT0OH4EvOfcPQ7w2P8KKMUh/9+IMR+ojZw0Jh0DpGm7T/ j/ig== 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=eT8tfYPwy2yygQ6WCDJqFP7DgA6okRyNAfHkKTTrOZI=; b=0K/SOjkSyfwvdU72xI4aM0A41o7nJaiqx6fT3ci6xmWmT3aiWw0AU77foPy+Js00el Z5kF1gZH/g+M1wO5Sn2XRKX8cTggwTT3nWkSGNaZENy/tytjn6Bmo4JdeYKOYa6TSNH/ lTsTcU4rL0vj1Kzd7P9GgdWve9uodujG11ECHp+vltA3IDQqaOa6n0mJndY5Mbd9ZPht egDMLIteN8fvtzZh1gWmiDJHlCJ0/84Lm0LM2V03O6D/HnjQvCns/pLLvFNOGkKoFLbK DbDBJZ4QxexddvNbc6IWDm/7E1LujN5uhPNFd6SXsFXVB3WVpjSH1ZkEtNPb24rEMnA7 aH5w== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id y7si654147ljp.7.2021.11.14.09.27.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:27:57 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRJ5c5Tz1qwdP; Sun, 14 Nov 2021 18:27:56 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRJ5ST2z1qqkB; Sun, 14 Nov 2021 18:27:56 +0100 (CET) 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 RrAw7b8KcpXw; Sun, 14 Nov 2021 18:27:56 +0100 (CET) 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; Sun, 14 Nov 2021 18:27:56 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id BE49545408E4; Sun, 14 Nov 2021 18:27:55 +0100 (CET) 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 kPs1_YFP1-vD; Sun, 14 Nov 2021 18:27:53 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 176284541BC4; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 05/36] util: add function to convert string to lowercase Date: Sun, 14 Nov 2021 18:27:02 +0100 Message-Id: <20211114172733.71602-6-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , No function available in libc, just add to utilities. Signed-off-by: Stefano Babic --- core/util.c | 12 ++++++++++++ include/util.h | 1 + 2 files changed, 13 insertions(+) diff --git a/core/util.c b/core/util.c index f5d7c63..3eeec41 100644 --- a/core/util.c +++ b/core/util.c @@ -281,6 +281,18 @@ char *substring(const char *src, int first, int len) { return s; } +/* + * Convert all chars of a string to lower, + * there is no ready to use function + */ + +char *string_tolower(char *s) +{ + char *p = s; + for ( ; *p; ++p) *p = tolower(*p); + return s; +} + int openfileoutput(const char *filename) { int fdout; diff --git a/include/util.h b/include/util.h index 4f2995b..091e41f 100644 --- a/include/util.h +++ b/include/util.h @@ -191,6 +191,7 @@ char **splitargs(char *args, int *argc); char *mstrcat(const char **nodes, const char *delim); char** string_split(const char* a_str, const char a_delim); char *substring(const char *src, int first, int len); +char *string_tolower(char *s); size_t snescape(char *dst, size_t n, const char *src); void freeargs (char **argv); int get_hw_revision(struct hw_type *hw); From patchwork Sun Nov 14 17:27:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554897 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=Rin0qx0R; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33d; helo=mail-wm1-x33d.google.com; envelope-from=swupdate+bncbcxploxj6ikrbh4oywgamgqe2abjn4i@googlegroups.com; receiver=) Received: from mail-wm1-x33d.google.com (mail-wm1-x33d.google.com [IPv6:2a00:1450:4864:20::33d]) (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 4HsfRR3nxXz9sWJ for ; Mon, 15 Nov 2021 04:28:03 +1100 (AEDT) Received: by mail-wm1-x33d.google.com with SMTP id c1-20020a05600c0ac100b00322fcaa2bc7sf6916362wmr.4 for ; Sun, 14 Nov 2021 09:28:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910879; cv=pass; d=google.com; s=arc-20160816; b=t1b4wQeYpGcL1Q4plUVZHMdN5fKfCVvGg/zS9+5SVDDsaNr2KRY933TYNwinBr9UaB 5VhqjlEWeifNRo17cW55MFWja0zDAkDVBuqAe5CXejBJVwO7RMkfXtdj4Yt0krf2kjPa fgzDw/lmHwQqGtcH6+UKqEfybXNoZBESV7jAqVOe3e5rTPU42iE9jVZZe9ag4yUSgg9R +zQUvZXHZlIIlH5RxNkUxIEwM0JxP/VYZiQwF6LKdsJEi/B9fiE/XKfZJqHUYOngdYp1 g2jQ8at+RB5RetUbyzVoEffHNUT2bfgDQXl6en2dMA3ovkDRVp7cr/0QQlDelosJVTax WHwg== 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=PG4F20IV+W7NCyvqP3YBj3KJCLL5L/ui8BA7k+QASvw=; b=YOvLeT3fU/MkxemEVSrPmyQa/jfiCRcswZy2+hpFmuFmcvgr7Y/baLWRQXwasJQwmL dC8KonVHKnU6/NpXU4pO7A6UZR1VwQGlalY8l/IZ36O+4W0NvfAVZMxaL3X2keG01N38 g5B462HcORx4F1da1qoBpNtAilxhZG+2MypSmKgEXXMl0iwAnEKtMrVt6GkV+lIKxBL3 uYc1yDYZ5v68TMc591exAgmVrKP2Iz6VQnky3Jv+jE7v+TZ51n5yeweP3838ph9fOims vVjeqLAp2gtblCBw4g4iNzG5BA1jxmASe6pyx4uAfjE90ptfpAz4EhJhtFMbOWUhrnrI wZbQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 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=PG4F20IV+W7NCyvqP3YBj3KJCLL5L/ui8BA7k+QASvw=; b=Rin0qx0ReryegD0Wd4UgF5+6GsChekefHMVMr/Z3w2tvfsFlUIiVyiOHAo/XU72Nzz J5aEzHCeN5CD5UmmeNakndKiZ2sj2PJmxM/GzEF6aQ4WHF/bDtFW2FDV6CbaTuleEMYu enqYlw9U9H0G5MDTWStAzPVBT3S7qzi3vUUhPDk4X8DjkQvW3YXJ3F6xw6Fh1hBVg1e+ B7VgA1iE5wKof+vBLRxRtj3bSqb2qzjm42KxGvHPBTO+Bkw0zibbXx7TMbOvC4J85sDT /c/tj5mPaAF+O8PJlGIPAQyLmyKFQ0Xnor7xAtmQ/saA7z1KEvNKt2gHuidwXSMBZ7ku pY3w== 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=PG4F20IV+W7NCyvqP3YBj3KJCLL5L/ui8BA7k+QASvw=; b=Rw4qoAZTt/c44w7GMxZUkakk8PKiF2y676wr5aTMZT3cI3efeK/KuYi3PfdHjwYvCx fgpdEO6ZHYXRtw6TmyehSlLc2z9XJSQQMvkFLyR5LL2xTtyz93ls0RpOaYTfq0s4c3bJ j16+nyfJUent/KxR7tssX7KmAoRZofqD7o5GyQkxKerM7x9nAwmernicsYau31Ov0cVE hZHibLKMzgE0IFDgrxwepOi6FHZgyCrG4XiaXoxzALbOukOEEPq2ezs01gk9vagdKwnT cYOgJRNqrv6FQ5wFhCiwpoH1mVtbxaKDkB5Ll3XJMD6Rn5L5jvfZvgWWc27nahbeX1Bp pPcg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533ZZ44EVaOUnFd8Dbz1XtNPt9Mj+KdF9fQcsrS9pDAeUV/N3WBJ I/WtSoE93lK6/a42niCmxbA= X-Google-Smtp-Source: ABdhPJyW5E/namVjNbtN9EZSZVnF13Zy0SBRpNT+K74M/UJGx/uJlWWmXK6LHkFXCjQ1BCI/NNfGxw== X-Received: by 2002:a5d:6501:: with SMTP id x1mr39101133wru.390.1636910879794; Sun, 14 Nov 2021 09:27:59 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:f1c2:: with SMTP id z2ls7196811wro.2.gmail; Sun, 14 Nov 2021 09:27:59 -0800 (PST) X-Received: by 2002:a5d:624f:: with SMTP id m15mr27465567wrv.13.1636910879039; Sun, 14 Nov 2021 09:27:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910879; cv=none; d=google.com; s=arc-20160816; b=iWyAy+aWfdZ+1zcFWIEh36njPa59U6zKzYawQW1MMQQk9Pk+ph5l7/5Mc72hwCr0DT jp/fsvK2JEB77mBiuxLUuuGaQHQoHhnPmS7s9pUYP4QqMiluKy7r5eFJbDhSI4J/Hv+g YExxSBVSc6bIDJxGar+KvjvbxTnHfUYKsk1uCZU43dpIRo2hxPjVvosaq9qmsgVpeOsq b0hgPNCmwguLBWZzTPESNW/AtlnLFmRmFp3YMaQZ5M1qPh+w3wXXQGbJQGlqjdEw7MSS A1zz7iaPiqIMIRhk9lqrGPYqhy/R9TPJCiK6xapDp/UU091DxoR7wiVgsaGCXMWqtYDU P+Nw== 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=CRillieQPsjlhgM/xRa3x8kpoLXrZXzU6rFn9xIVnn96ieRHjC+co4VSBo5QbGMTSl k8G3rHl1TaOpFuvPMri0U6bmPi0yBppcaHyPlDTlDHZwzdNZpwrxhAqiJsUSo4eV1fWt pnXrM75emksJaKpcthi6ofw8elD3ek4Fk/tH4k0kMsPhaMY0+/C2X6TfmysNv3qs5gi5 EIcrrD1o62Sg/QdyyWGfwnjHtDPAsyJGUwEvTATppbXvWW6+9QVoBCq4otGsY7nrlHgV Od7eLOdFvFdMd2BTc89KEfKSJGW6+kFfhHT1nB9GyBB99lMKx3NtrEU+Kb2fhiRrB34g CDkQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 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. [212.18.0.10]) by gmr-mx.google.com with ESMTPS id g130si1274469wmg.0.2021.11.14.09.27.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:27:59 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.10 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.10; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRL6HgQz1rk5m; Sun, 14 Nov 2021 18:27:58 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRL68y9z1qqkB; Sun, 14 Nov 2021 18:27:58 +0100 (CET) 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 LzZ2Zmp09MJc; Sun, 14 Nov 2021 18:27:58 +0100 (CET) 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; Sun, 14 Nov 2021 18:27:58 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id E455A4540853; Sun, 14 Nov 2021 18:27:57 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 1sunqUs1nrcI; Sun, 14 Nov 2021 18:27:54 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 2918E4542618; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 06/36] Hide copyfile() implementation to add more input Date: Sun, 14 Nov 2021 18:27:03 +0100 Message-Id: <20211114172733.71602-7-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.10 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, From patchwork Sun Nov 14 17:27:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554898 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=G9ECAU3N; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::440; helo=mail-wr1-x440.google.com; envelope-from=swupdate+bncbcxploxj6ikrbieoywgamgqeiat3gay@googlegroups.com; receiver=) Received: from mail-wr1-x440.google.com (mail-wr1-x440.google.com [IPv6:2a00:1450:4864:20::440]) (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 4HsfRR6hGLz9sX3 for ; Mon, 15 Nov 2021 04:28:03 +1100 (AEDT) Received: by mail-wr1-x440.google.com with SMTP id h7-20020adfaa87000000b001885269a937sf2586617wrc.17 for ; Sun, 14 Nov 2021 09:28:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910880; cv=pass; d=google.com; s=arc-20160816; b=iIFwmr/+nqs9HL7k2hLj/75OClWSbPC2hzPEn7NbL85CohYcDuF4KadIDIRPYZn1xt eD/qajQm6UjqFI1IL83g7z0SR2HcEs1gDRu8G/GQKIW2QQVtrPVJ97WLry5lc9cAwr51 5Zu0aZg0I37Pd9ngqSpDSkhOAs6tFhT5ds+U7FnyZ5BqSVIyd6UJGSM8V6R9zwziqEIY Q94+timPuVWLL01SDCkeavaZQOEMt7GWEKjxlhlgXeJeqdBtPVpiJx+r2vTJ+zCAGSRh waWEJbMmrcOWrRenjpA943Of0uEUZtFyQAoMojDLAaM7XaDNGfPz2tA4o0SYjQxqeYf9 eVZw== 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=XEUGQxU+c5lwZIXmDHggctO1deuMzfAVybEBVzH57Ds=; b=sCeNsmHord2shqa9sjmhAhm+/AkVervxjn4Iifw/H5G2WBfjbByTfOuueUCugqMAIz hNhcXSD5lJu+ut8b+ZvA1Fq9xb7kDhB6ugmenkF16yN46+936YFGMSA/TNQp6OlZD4Ks 3tblx5/4eg9TUcaNM+J110+yH3x4yhP61je3JtTCZLRE8IxcKG5vCwGiTtEa8z7I9MmH aaD5wRSRJ1yQlfdHdWo/cb6zOHqw8W3xjAbyjfLLoNWLrug6uYwaoNM3BKlWT6427Dxo 8vZPnuTRnJkRlzlj06IpsBtIVHFexo7CpTeEVmboy7rDfT0V3SikZM0AWp7nTr1RlbK3 13fA== 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=XEUGQxU+c5lwZIXmDHggctO1deuMzfAVybEBVzH57Ds=; b=G9ECAU3N8Sb2Q3YneouYJvETT9x5keUDJu4jFKoCiXwFVZ4oJvkSH95GsRRwCAmw1L /le4uI7uwrSnmyXIl50ALpMvjuXJVd/n/0CUgSoOiSGpXjNE4MB1R5NUVsRKsWfn64B2 W2lGac1jDoIfpWLBHGPGfJ5YadfsgQWocrKEyncB94swO3HQakuHqcGXoW9CHuZnxe3s 2BOP8Hllg6BezSN2YfJlE1hzGJFZv/yqhZP7Nh1C3ONiTUpwZpB+OC/xZVXhbtYlhLUt XuEvjBh2SRSJneqMeopw1YM2H7B8LngDfXnxOHLNxwzUKwt4ZcmQ6NOnmAm4N7gmRi7S QdVg== 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=XEUGQxU+c5lwZIXmDHggctO1deuMzfAVybEBVzH57Ds=; b=aC7T53ZX5E0+OWvRpyUTr2/ds2CQ6vjPqRooiQb2A8Hg/qhj22wdgHuztfTduUzBW3 FL72+B37bUGEzEStZW+XSM01G861dugSlWnfxeSFlMbdf+mb33wP3pwHbBnDEbTetVvI fOG69Ga63irUpoil7hdLoOwe00OBgfMPdXv/xCuvm2gdKhtWPukQgA+FgKHGfxSxd3GT QfwB2TnM1kNLxgJZTjPdGvbdsdlwJEblk9tqZ3K8VEM6vOH9Y4TrPyIQHbVM3Bs6QX1R P1nnrmcd1jDuHikSVru2t150gPTLK2ID2Tg1YDrmtYkBv462+GfK+4vpcAwZbgzIle3N 9Uvg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM53158oIjTu8lFUOmOJR2tODFi4nX9KtdE0F9yOlvsYGAAq2wycz1 yNWO4Kr73vbBpVRTsmtqV8Y= X-Google-Smtp-Source: ABdhPJwVJdX7UpiX+81ZxDIh0hAcomXw4FJ5OXGf1pphkoaecLvboH2S0FtF+fymNHxow/zYvWqxKQ== X-Received: by 2002:a5d:6da9:: with SMTP id u9mr41351123wrs.237.1636910880602; Sun, 14 Nov 2021 09:28:00 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:f1c2:: with SMTP id z2ls7196824wro.2.gmail; Sun, 14 Nov 2021 09:28:00 -0800 (PST) X-Received: by 2002:a05:6000:1c2:: with SMTP id t2mr38847143wrx.378.1636910879983; Sun, 14 Nov 2021 09:27:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910879; cv=none; d=google.com; s=arc-20160816; b=kciGhK243c0IPk3FSDzebiaBKA4xclcSaH6oJnVtKe7B6PxYa+GRL7kSnaAI+nF2/o 7ZMuQoSeSlGA4PkZF5YSbeaOCZTVj1znMnSjWRdaU9yyy8q0SS0+gFzkZNwbr54oXje8 JTCfUyRpcyQwxUi/EN38lcL11V0+WJPDqYW9YX6SdOO4Jjpo4Yq9yvwbq5koq0w4Ctb4 GFUInhDMrflS/sHLrZ3dUi1LO8xnnGnOyjJtkFW4fJkrnH9eICzskw6sFX/Ysv7ZjFgT 22yrffcceSIVEOSXe88tIOOZJATxGvPYBU8xS2YI2QQJE2CpDj76qI0EszbJ1o7hEkad 3Oag== 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=GkQyrY63jvQnzIbS6pteojHtDwTQce+XBTiTOekZNiA=; b=MTfn7oXtBMtYQ/O540+UIZh3Nv+d95uST1nC8+3ZZrkBqFKbXD2Hg7dQv013If1LFC 9zTcQNLyMePuAeJHlbJbbnh+vBhmgu7g7bq5bzbGmBot1njhjemqF+1SpBCt2rShUXwU w6BL6csxMyKefIHX5jlBAX8y92celDxwveaS2FNbOnHhy8apkJTXnMRylvPwQQENE77g 8YQt5gJ/YaGgzwsZdEB/lSRyU7iCAtEcu01YsflumHjl39zsxk2Wt0w5CLA/foZlnzDP lA1O15J23+QydcvOrILWm3iVgoxkHl+lMEninWjxR9WGnDSUgAUpM/gqK5i8906X8jWG ssYg== 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 c10si502449wmq.4.2021.11.14.09.27.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:27:59 -0800 (PST) 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 4HsfRM5nDXz1rk5m; Sun, 14 Nov 2021 18:27:59 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRM5ZsWz1qqkB; Sun, 14 Nov 2021 18:27:59 +0100 (CET) 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 QTCIRhVexrdQ; Sun, 14 Nov 2021 18:27:58 +0100 (CET) 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; Sun, 14 Nov 2021 18:27:58 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 8B31B45408E4; Sun, 14 Nov 2021 18:27:58 +0100 (CET) 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 NoCaaD4kaCV2; Sun, 14 Nov 2021 18:27:55 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 37CA14542646; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 07/36] Introduce copybuffer to copy from memory Date: Sun, 14 Nov 2021 18:27:04 +0100 Message-Id: <20211114172733.71602-8-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: , This adds a central function to copy a SWUpdate artifact. Functions are: copyfile() : copy artifact rwading from file descriptor copyimage() : copy artifact with a image definition NEW copybuffer() : copy an artifact from memory Signed-off-by: Stefano Babic --- core/cpio_utils.c | 70 +++++++++++++++++++++++++++++++++++++++++++---- include/util.h | 2 ++ 2 files changed, 66 insertions(+), 6 deletions(-) diff --git a/core/cpio_utils.c b/core/cpio_utils.c index e06bf5f..d3c115f 100644 --- a/core/cpio_utils.c +++ b/core/cpio_utils.c @@ -29,6 +29,11 @@ #define NPAD_BYTES(o) ((4 - (o % 4)) % 4) +typedef enum { + INPUT_FROM_FD, + INPUT_FROM_MEMORY +} input_type_t; + int get_cpiohdr(unsigned char *buf, struct filehdr *fhdr) { struct new_ascii_header *cpiohdr; @@ -120,8 +125,10 @@ int copy_write(void *out, const void *buf, unsigned int len) int ret; int fd; - if (!out) + if (!out) { + ERROR("Output file descriptor invalid !"); return -1; + } fd = *(int *)out; @@ -187,6 +194,9 @@ typedef int (*PipelineStep)(void *state, void *buffer, size_t size); struct InputState { int fdin; + input_type_t source; + unsigned char *inbuf; + size_t pos; unsigned int nbytes; unsigned long *offs; void *dgst; /* use a private context for HASH */ @@ -196,12 +206,26 @@ struct InputState static int input_step(void *state, void *buffer, size_t size) { struct InputState *s = (struct InputState *)state; + int ret = 0; if (size >= s->nbytes) { size = s->nbytes; } - int ret = fill_buffer(s->fdin, buffer, size, s->offs, &s->checksum, s->dgst); - if (ret < 0) { - return ret; + switch (s->source) { + case INPUT_FROM_FD: + ret = fill_buffer(s->fdin, buffer, size, s->offs, &s->checksum, s->dgst); + if (ret < 0) { + return ret; + } + break; + case INPUT_FROM_MEMORY: + memcpy(buffer, &s->inbuf[s->pos], size); + if (s->dgst) { + if (swupdate_HASH_update(s->dgst, &s->inbuf[s->pos], size) < 0) + return -EFAULT; + } + ret = size; + s->pos += size; + break; } s->nbytes -= ret; return ret; @@ -380,7 +404,7 @@ static int zstd_step(void* state, void* buffer, size_t size) #endif -static int __swupdate_copy(int fdin, void *out, unsigned int nbytes, unsigned long *offs, unsigned long long seek, +static int __swupdate_copy(int fdin, unsigned char *inbuf, 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) { @@ -398,6 +422,9 @@ static int __swupdate_copy(int fdin, void *out, unsigned int nbytes, unsigned lo struct InputState input_state = { .fdin = fdin, + .source = INPUT_FROM_FD, + .inbuf = NULL, + .pos = 0, .nbytes = nbytes, .offs = offs, .dgst = NULL, @@ -435,6 +462,14 @@ static int __swupdate_copy(int fdin, void *out, unsigned int nbytes, unsigned lo #endif #endif + /* + * If inbuf is set, read from buffer instead of from file + */ + if (inbuf) { + input_state.inbuf = inbuf; + input_state.source = INPUT_FROM_MEMORY; + } + PipelineStep step = NULL; void *state = NULL; uint8_t buffer[BUFF_SIZE]; @@ -604,7 +639,11 @@ static int __swupdate_copy(int fdin, void *out, unsigned int nbytes, unsigned lo } } - fill_buffer(fdin, buffer, NPAD_BYTES(*offs), offs, checksum, NULL); + if (!inbuf) { + ret = fill_buffer(fdin, buffer, NPAD_BYTES(*offs), offs, checksum, NULL); + if (ret < 0) + DEBUG("Padding bytes are not read, ignoring"); + } if (checksum != NULL) { *checksum = input_state.checksum; @@ -638,6 +677,7 @@ int copyfile(int fdin, void *out, unsigned int nbytes, unsigned long *offs, unsi uint32_t *checksum, unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback) { return __swupdate_copy(fdin, + NULL, out, nbytes, offs, @@ -651,6 +691,24 @@ int copyfile(int fdin, void *out, unsigned int nbytes, unsigned long *offs, unsi callback); } +int copybuffer(unsigned char *inbuf, void *out, unsigned int nbytes, int __attribute__ ((__unused__)) compressed, + unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback) +{ + return __swupdate_copy(-1, + inbuf, + out, + nbytes, + NULL, + 0, + 0, + compressed, + NULL, + hash, + encrypted, + imgivt, + callback); +} + int copyimage(void *out, struct img_type *img, writeimage callback) { return copyfile(img->fdin, diff --git a/include/util.h b/include/util.h index 091e41f..cfb6e79 100644 --- a/include/util.h +++ b/include/util.h @@ -178,6 +178,8 @@ int copyfile(int fdin, void *out, unsigned int nbytes, unsigned long *offs, int skip_file, int compressed, uint32_t *checksum, unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback); int copyimage(void *out, struct img_type *img, writeimage callback); +int copybuffer(unsigned char *inbuf, void *out, unsigned int nbytes, int compressed, + unsigned char *hash, bool encrypted, const char *imgivt, writeimage callback); off_t extract_next_file(int fd, int fdout, off_t start, int compressed, int encrypted, char *ivt, unsigned char *hash); int openfileoutput(const char *filename); From patchwork Sun Nov 14 17:27:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554899 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=jw4b+dLO; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::538; helo=mail-ed1-x538.google.com; envelope-from=swupdate+bncbcxploxj6ikrbjeoywgamgqet6m6rja@googlegroups.com; receiver=) Received: from mail-ed1-x538.google.com (mail-ed1-x538.google.com [IPv6:2a00:1450:4864:20::538]) (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 4HsfRX2FGvz9sWJ for ; Mon, 15 Nov 2021 04:28:08 +1100 (AEDT) Received: by mail-ed1-x538.google.com with SMTP id q17-20020aa7da91000000b003e7c0641b9csf446688eds.12 for ; Sun, 14 Nov 2021 09:28:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910885; cv=pass; d=google.com; s=arc-20160816; b=SaKKFYgarKZFkKSsO/nSOTmErnq/ocrDdK74sTxscCfZQxzh93gWFMHtho/nGYGOni 9KNBJkZkIjeJBGWm2LTu7ce2opkBk6dsAWqdq3aXti4o6S2wH80hsd6irqj5uVUOkOMd AjJ1Ik/LhB3UqvSBSG8TH3NHlYhUMt76cliEJy09orqyfxyOJyEkwiu018u0NyWKXxll l+HP41qmpzYEfQTa2eCFhP5ABEfY6zuP8BAX/RPGPPgcK5pia2KlDoSPEocyCnqE5zMK 1gOXWeWC7hH0ZMM8Os9NOJZN3iFshTWDucj/RCTjukLC5ee+C/ACUCPH9m0JL6JK8wSW nFww== 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=zFZkWfbdOdKRfzn492eg6qR2msEUcKC77Rds61kHGYA=; b=L8F7QnYlAqhIrwwPtbuQvmChAyT3cYR/0YWFDpYlQI38njObfuxh4i9gcatSz4sG0N U+nIHN0Ob1EpempWkvo1AGQDOsksNqLhrarUk0cCDhqXAnk8N2pPDwXwf7yGQEiXXc6R KRycQ+nQ9ujMXq1oZkHHGQAtAs1yRZGG+WSKMpI6SmFEobwhBDcAhl/bS8rQaUgQkPX7 I/90CxTm7vIGiryx5C9Ahrp8/aq2sZq3ftDU/35hGt0Slh6CXI1KAlDVMfd9SZ1zThsi TdeqUl4HUng0LyZHz9zlCj+SxZ56TK60gax1QqOsZXkwZvKGKIzGeJ+5cBmGESG3VDXo ZzMA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=zFZkWfbdOdKRfzn492eg6qR2msEUcKC77Rds61kHGYA=; b=jw4b+dLOF5gvk79CmiC/0/BzIwEbel/0AQQAglKZwuEJoV/K1ezvt3Pr70RKPVS9Nf tHRlilTr/VYoo1UwjdE6Qv5GsiSFfKepbppxI82sfbTF1AWDs6eF+VLhESvoNlbQ6dQQ u9Ebgnnx5pzJYytsOqn1QxoXH09NwTKdTb8DH2Mrr51EStYlu/KVqfn/6j3S8uPkXp4A XTBzyZicXDf1V2W51QJIvT9J+MmBvNm805W1p8P6P8kxy1i1FBlDvfOq1pFfCkx6N0hy xx7gd87jruafemkZEMD0cdcgREjAhHM9/RLtkmZDUzgU/Yhwz/+65TBVikdxlnrMik0W HCbA== 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=zFZkWfbdOdKRfzn492eg6qR2msEUcKC77Rds61kHGYA=; b=jrT8vWZBdE/1kHHoZ4L6+X70WvxKJ3gT3QDIzby2SXvbKwiQxUnNZ0bO3HtmDjCkSF NTEuSpFKhOG5r501MdAQzNjdSMXp2k7Gy9q6C+VnklVbDRDZyffsOZWEDBPXwi0SEqd9 Xl8cT8ld7OEN08NIn+WRPOKTkJM1JDH9qsyCb1TsMVVUmUM0U/N99lamOwgiDv2c7HqZ px6QmZEJhyE0PpXiXXyxuPQIHLm8xwZTFBXGfme+YLNcCTUZuH6wzjVfjsc1F5HBQ0iM 6rUOPDrxOQa1NWTb1gEHSv2YUW3rjLXavsTOTB4NMbd2NHTpqrdl5g1QsITRFU3FtkIa LA+A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532Ul96RF+bWcOSGdnymKKUeTjUPPqec5R3WQWuqkmETtcaBDGIh sTHoZR3cus7udvFs+iIDB5w= X-Google-Smtp-Source: ABdhPJxbkAQrQKNJDd1iI6s8AfQ8yc+OSsVUeS6BqLa+/7RMsi+6aDIBa9QDen6ytCmTKIbg5Mg98Q== X-Received: by 2002:a50:e183:: with SMTP id k3mr46033989edl.22.1636910884967; Sun, 14 Nov 2021 09:28:04 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:907:7e93:: with SMTP id qb19ls2572823ejc.4.gmail; Sun, 14 Nov 2021 09:28:04 -0800 (PST) X-Received: by 2002:a17:907:720d:: with SMTP id dr13mr42461024ejc.153.1636910884057; Sun, 14 Nov 2021 09:28:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910884; cv=none; d=google.com; s=arc-20160816; b=IvUuSxlx9H2Rqg0q6gLuwozBN5xhMQyQkp6K7IVstU3hakBiZ5E1MWcipi/cx2aflo a/kWPve6TBxyXqYy5IHOThiaysS2f0b9cmOXpAfU/vjVKbUP4JiZbXL9WCtPdTsrSwNr 2opfYOz9ZOwKn61gEiRI7MXtQebCe1KEfvD5SAIfnLjVADimCCWLmeDwkUcc5nUitcFY Xzqd3J/Zs+sawp+K3L9TI9uuBNFsUtaIR0++IgdhrAQf+e1AdvEMjZ99cDGb2mdwyBPk 5Fy8y8M/201WjX0YyiFSGv45ESTbU6F+MZP/FxKOwxMXckP50alEFUttBUecqdpCbvW+ n7Ag== 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=VcaUqUQvvrrvEpfiP7HlotMxwK7bwjjLz3T4SjNrvT8=; b=f5f7FAa5CMygDqTbJCdh6ffwsCjTAYtUjtbnsrPtGpRDwhqpWEnRDjeX24J3N/azP9 cBem/89WC8X61CDjCPMPfdkwbWOUWCBu65dZbpQqVAVUt0cxTbRhrEV6KO55IpOW3qty Ov0wgi31xelmMiKO6JE26nMFPK6VXb2iJq9Zi/1opmEVMglXEGq4Wqs+0dERScrzUKyI 0cEqKjK/z5oY2SbZIKzyhuc3DWjG17aRckcAWc7ypYWOLp01q3o+boYA6GPNYkuoDDzS cBF8OirO+bVVwfz5vvriEr1ObM2N+PUY+M75DziDi7amnXTURX8WzKjDr/2h2FBtelAI qVqA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id k2si665092edl.2.2021.11.14.09.28.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:04 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRR5kCPz1qwdP; Sun, 14 Nov 2021 18:28:03 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRR5ZL9z1qqkD; Sun, 14 Nov 2021 18:28:03 +0100 (CET) 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 13NBOtqUivSE; Sun, 14 Nov 2021 18:28:01 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:01 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 7FAE24540853; Sun, 14 Nov 2021 18:28:01 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id bMshKWitkMpU; Sun, 14 Nov 2021 18:27:58 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 46A55454269A; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 08/36] Import small multipart library Date: Sun, 14 Nov 2021 18:27:05 +0100 Message-Id: <20211114172733.71602-9-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , This is a lightweight parser for C licensed under MIT license. Sources are available at https://github.com/iafonov/multipart-parser-c. Fix a warning due to missing va_end() and set SPDX header. Signed-off-by: Stefano Babic --- corelib/Makefile | 1 + corelib/multipart_parser.c | 306 +++++++++++++++++++++++++++++++++++++ include/multipart_parser.h | 49 ++++++ 3 files changed, 356 insertions(+) create mode 100644 corelib/multipart_parser.c create mode 100644 include/multipart_parser.h diff --git a/corelib/Makefile b/corelib/Makefile index 037e72f..d6ea6a2 100644 --- a/corelib/Makefile +++ b/corelib/Makefile @@ -2,6 +2,7 @@ # # SPDX-License-Identifier: GPL-2.0-only +lib-y += multipart_parser.o lib-$(CONFIG_DOWNLOAD) += downloader.o lib-$(CONFIG_MTD) += mtd-interface.o lib-$(CONFIG_LUA) += lua_interface.o lua_compat.o diff --git a/corelib/multipart_parser.c b/corelib/multipart_parser.c new file mode 100644 index 0000000..5014dc8 --- /dev/null +++ b/corelib/multipart_parser.c @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2012 Igor Afonov afonov@gmail.com + * + * SPDX-License-Identifier: MIT + */ +#include "multipart_parser.h" +#include +#include +#include + +static void multipart_log(const char * format, ...) +{ +#ifdef DEBUG_MULTIPART + va_list args; + va_start(args, format); + + fprintf(stderr, "[HTTP_MULTIPART_PARSER] %s:%d: ", __FILE__, __LINE__); + vfprintf(stderr, format, args); + fprintf(stderr, "\n"); + va_end(args); +#endif +} + +#define NOTIFY_CB(FOR) \ +do { \ + if (p->settings->on_##FOR) { \ + if (p->settings->on_##FOR(p) != 0) { \ + return i; \ + } \ + } \ +} while (0) + +#define EMIT_DATA_CB(FOR, ptr, len) \ +do { \ + if (p->settings->on_##FOR) { \ + if (p->settings->on_##FOR(p, ptr, len) != 0) { \ + return i; \ + } \ + } \ +} while (0) + + +#define LF 10 +#define CR 13 + +struct multipart_parser { + void * data; + + size_t index; + size_t boundary_length; + + unsigned char state; + + const multipart_parser_settings* settings; + + char* lookbehind; + char multipart_boundary[1]; +}; + +enum state { + s_uninitialized = 1, + s_start, + s_start_boundary, + s_header_field_start, + s_header_field, + s_headers_almost_done, + s_header_value_start, + s_header_value, + s_header_value_almost_done, + s_part_data_start, + s_part_data, + s_part_data_almost_boundary, + s_part_data_boundary, + s_part_data_almost_end, + s_part_data_end, + s_part_data_final_hyphen, + s_end +}; + +multipart_parser* multipart_parser_init + (const char *boundary, const multipart_parser_settings* settings) { + + multipart_parser* p = malloc(sizeof(multipart_parser) + + strlen(boundary) + + strlen(boundary) + 9); + + strcpy(p->multipart_boundary, boundary); + p->boundary_length = strlen(boundary); + + p->lookbehind = (p->multipart_boundary + p->boundary_length + 1); + + p->index = 0; + p->state = s_start; + p->settings = settings; + + return p; +} + +void multipart_parser_free(multipart_parser* p) { + free(p); +} + +void multipart_parser_set_data(multipart_parser *p, void *data) { + p->data = data; +} + +void *multipart_parser_get_data(multipart_parser *p) { + return p->data; +} + +size_t multipart_parser_execute(multipart_parser* p, const char *buf, size_t len) { + size_t i = 0; + size_t mark = 0; + char c, cl; + int is_last = 0; + + while(i < len) { + c = buf[i]; + is_last = (i == (len - 1)); + switch (p->state) { + case s_start: + multipart_log("s_start"); + p->index = 0; + p->state = s_start_boundary; + + /* fallthrough */ + case s_start_boundary: + multipart_log("s_start_boundary"); + if (p->index == p->boundary_length) { + if (c != CR) { + return i; + } + p->index++; + break; + } else if (p->index == (p->boundary_length + 1)) { + if (c != LF) { + return i; + } + p->index = 0; + NOTIFY_CB(part_data_begin); + p->state = s_header_field_start; + break; + } + if (c != p->multipart_boundary[p->index]) { + return i; + } + p->index++; + break; + + case s_header_field_start: + multipart_log("s_header_field_start"); + mark = i; + p->state = s_header_field; + + /* fallthrough */ + case s_header_field: + multipart_log("s_header_field"); + if (c == CR) { + p->state = s_headers_almost_done; + break; + } + + if (c == ':') { + EMIT_DATA_CB(header_field, buf + mark, i - mark); + p->state = s_header_value_start; + break; + } + + cl = tolower(c); + if ((c != '-') && (cl < 'a' || cl > 'z')) { + multipart_log("invalid character in header name"); + return i; + } + if (is_last) + EMIT_DATA_CB(header_field, buf + mark, (i - mark) + 1); + break; + + case s_headers_almost_done: + multipart_log("s_headers_almost_done"); + if (c != LF) { + return i; + } + + p->state = s_part_data_start; + break; + + case s_header_value_start: + multipart_log("s_header_value_start"); + if (c == ' ') { + break; + } + + mark = i; + p->state = s_header_value; + + /* fallthrough */ + case s_header_value: + multipart_log("s_header_value"); + if (c == CR) { + EMIT_DATA_CB(header_value, buf + mark, i - mark); + p->state = s_header_value_almost_done; + break; + } + if (is_last) + EMIT_DATA_CB(header_value, buf + mark, (i - mark) + 1); + break; + + case s_header_value_almost_done: + multipart_log("s_header_value_almost_done"); + if (c != LF) { + return i; + } + p->state = s_header_field_start; + break; + + case s_part_data_start: + multipart_log("s_part_data_start"); + NOTIFY_CB(headers_complete); + mark = i; + p->state = s_part_data; + + /* fallthrough */ + case s_part_data: + multipart_log("s_part_data"); + if (c == CR) { + EMIT_DATA_CB(part_data, buf + mark, i - mark); + mark = i; + p->state = s_part_data_almost_boundary; + p->lookbehind[0] = CR; + break; + } + if (is_last) + EMIT_DATA_CB(part_data, buf + mark, (i - mark) + 1); + break; + + case s_part_data_almost_boundary: + multipart_log("s_part_data_almost_boundary"); + if (c == LF) { + p->state = s_part_data_boundary; + p->lookbehind[1] = LF; + p->index = 0; + break; + } + EMIT_DATA_CB(part_data, p->lookbehind, 1); + p->state = s_part_data; + mark = i --; + break; + + case s_part_data_boundary: + multipart_log("s_part_data_boundary"); + if (p->multipart_boundary[p->index] != c) { + EMIT_DATA_CB(part_data, p->lookbehind, 2 + p->index); + p->state = s_part_data; + mark = i --; + break; + } + p->lookbehind[2 + p->index] = c; + if ((++ p->index) == p->boundary_length) { + NOTIFY_CB(part_data_end); + p->state = s_part_data_almost_end; + } + break; + + case s_part_data_almost_end: + multipart_log("s_part_data_almost_end"); + if (c == '-') { + p->state = s_part_data_final_hyphen; + break; + } + if (c == CR) { + p->state = s_part_data_end; + break; + } + return i; + + case s_part_data_final_hyphen: + multipart_log("s_part_data_final_hyphen"); + if (c == '-') { + NOTIFY_CB(body_end); + p->state = s_end; + break; + } + return i; + + case s_part_data_end: + multipart_log("s_part_data_end"); + if (c == LF) { + p->state = s_header_field_start; + NOTIFY_CB(part_data_begin); + break; + } + return i; + + case s_end: + multipart_log("s_end: %02X", (int) c); + break; + + default: + multipart_log("Multipart parser unrecoverable error"); + return 0; + } + ++ i; + } + + return len; +} diff --git a/include/multipart_parser.h b/include/multipart_parser.h new file mode 100644 index 0000000..015e8ad --- /dev/null +++ b/include/multipart_parser.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2012 Igor Afonov afonov@gmail.com + * + * SPDX-License-Identifier: MIT + */ +#ifndef _multipart_parser_h +#define _multipart_parser_h + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +typedef struct multipart_parser multipart_parser; +typedef struct multipart_parser_settings multipart_parser_settings; +typedef struct multipart_parser_state multipart_parser_state; + +typedef int (*multipart_data_cb) (multipart_parser*, const char *at, size_t length); +typedef int (*multipart_notify_cb) (multipart_parser*); + +struct multipart_parser_settings { + multipart_data_cb on_header_field; + multipart_data_cb on_header_value; + multipart_data_cb on_part_data; + + multipart_notify_cb on_part_data_begin; + multipart_notify_cb on_headers_complete; + multipart_notify_cb on_part_data_end; + multipart_notify_cb on_body_end; +}; + +multipart_parser* multipart_parser_init + (const char *boundary, const multipart_parser_settings* settings); + +void multipart_parser_free(multipart_parser* p); + +size_t multipart_parser_execute(multipart_parser* p, const char *buf, size_t len); + +void multipart_parser_set_data(multipart_parser* p, void* data); +void * multipart_parser_get_data(multipart_parser* p); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif From patchwork Sun Nov 14 17:27:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554900 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=CpjiIVE8; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::337; helo=mail-wm1-x337.google.com; envelope-from=swupdate+bncbcxploxj6ikrbkmoywgamgqefebq3cq@googlegroups.com; receiver=) Received: from mail-wm1-x337.google.com (mail-wm1-x337.google.com [IPv6:2a00:1450:4864:20::337]) (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 4HsfRc67VQz9sWJ for ; Mon, 15 Nov 2021 04:28:12 +1100 (AEDT) Received: by mail-wm1-x337.google.com with SMTP id z126-20020a1c7e84000000b003335e5dc26bsf4809584wmc.8 for ; Sun, 14 Nov 2021 09:28:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910889; cv=pass; d=google.com; s=arc-20160816; b=vkI2u4I3Ne/12iXH6+LkHm96PibJCwKCrWKjxfCUwcen98lVd2R3NKtWW90pdKjPIZ HX8M1IbAO6GNNvv8mB76HsgCp08XIXc+b7xEtbwi2I1pWmHN4/qanYgOiFNdiJatn5x7 jyEm6Gwn79ifmqYaRkgn3S/SlrQ2Qn+Yi8mYzy9TJXHqvJaFOWqmNaFtZ0f/puwPZJuf 2nFh451Vod8gIrFduCRciyIfug7yNF2JAihXc9AvgZXSRaLYFH6cCtrkaPM312z19uYX zsv58WYI/EyDCqTBx6k5vhj/ZnJSeyH2/7vOPrEvhvjQvJo7/kb/3nG25hyxAu7qOgr9 iFHg== 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=/aA/+2HsCYMVDa2M1x6+QaQPJQtvZw6qj0r8nxRAdF4=; b=GX7ZdZnvmqe/QT2fEJstTY+uX9B9bmXpT5tahqvRtPhqcBGxb9hdWLw/dLfAsGsTwt hyzUwA2bG8Gwekf1xuPnefDyPBvVlcigxvZa4oixXDRHt3u9v1hdQXCkAHpJ4RKOeeMD P890pzPMcaSyhX28kX7iCDfSBzKAdgkEzggV/KEJhlPTBx3rLqesrmLQZuiPaQpb2Hiy s990f4qlNacMPbOKywsrCgmiCl+ayRKnnAa81NsWDAcQ7cbtr9eUkO1gaVS6+l/GcXH/ hxlN7DqZvlHZDWKAfFD7Vj77Tx9EiyDDJ4I77kCEwpWd6+wjIbNxCtMFlD92sM4RBxgM RUPA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=/aA/+2HsCYMVDa2M1x6+QaQPJQtvZw6qj0r8nxRAdF4=; b=CpjiIVE8IG6/If0gUZ3FZHYSGrHam37HEF/a9uoeJDVOHctlRyryGMEyqJ0cayq/an pnrAKZycepM/TKPXxCivhVV7mQu4oupYgeColMMQp89IvDDKe9x81fwQpxsZt8VH/9/1 5ZCTfkzIP1kDxCZHboNrZxCmBMBhHutG52MN9GUaOKuNXtrGTFIxUwYeuLuRLtilakVh c5HrK3oa0+V2h++yVSZxnbR8/t+XUT6WwWl1YFsJlBkKYXUEncsJtlCoxzH3tAdhZ6/r aS9DZZaU5z7bgs/Kiv3Oxg83zD/WNKAm1RSCm3+Ggg7R4UxN3pB581C7l1+SKD8NmRJj Px8g== 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=/aA/+2HsCYMVDa2M1x6+QaQPJQtvZw6qj0r8nxRAdF4=; b=4nX/899dADyo7W7g13SD8CAANJ2yECIJQoWYkkQdfB6C+95UUw37gv8h0sPWnpJ9wl CP3KlBOH9i2nozcUmImueoaP1WWysRaAo/4ll4zi9n5mj+zo7DRwQN0KVKHHRjj1W4ms IZ781uATLZYxE64FsTeZV+W24woxE6RChP+UHIEaD6ASWe5puaLgBWcv0Q4eZWfInd9W iCyvqUy04MytlT7lAKTPibK4ksOWk/0jVy1De7pvNDxmeoD9sd6bXc6PnY9VwRXc0oQ7 sjgLvn8IgmBHX/b0dM5GYFDO2qEVI+ED/mStzg3Xnlgrjqn1EsIJ9+pg+7PxZctWev2A XsRw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531aq0frbCjFLyJgNVkGieybdhD7V3nFBBMn0v6GgCXxcjyuRj17 ZPpuKl0wP4m6ZA5kNprxTdY= X-Google-Smtp-Source: ABdhPJykG7HDoYrUhs3Kh+Kx/b1PSDBZs3EvCzp8yyFbCfd+Q5G0C/EilZWRn8Mp8J9JS8hxShBKyA== X-Received: by 2002:a05:600c:2052:: with SMTP id p18mr5825583wmg.3.1636910889563; Sun, 14 Nov 2021 09:28:09 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a5d:6a05:: with SMTP id m5ls7200575wru.3.gmail; Sun, 14 Nov 2021 09:28:08 -0800 (PST) X-Received: by 2002:a5d:6c67:: with SMTP id r7mr39903151wrz.286.1636910888902; Sun, 14 Nov 2021 09:28:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910888; cv=none; d=google.com; s=arc-20160816; b=X+taOUJrVZuUERPPYbj605C89EAa72O7jqbQT5DbpeyvxCyQTAC4UFK9U9bdtPlaxR wklGGL+yH4yJwhvbSh9EDoZncOvT0yO3K6hCiHzYIX0NcJlmp8dFx50yASR/2XN9BUfB dQmsmr3V4yRkimO0RWwAIhTGVFOOacAPMdr2PqKHCh7ngRLaqVCuAGLnFj8mS7n8SAKA xaxAdU7OhyasUiiHAAHDr68ccF6h5Q997IVv8pZkGc4UxF+coLEfOBoaaIS8pEPqq9d4 RwpwE4WcmsysGQ9rZVAxzc01fT5AlFYK5zcalCZKSiNaPtsoKhSP8+fPgCXxYAtQ+QZg ab1Q== 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=NRkDjh9yG2vq5lBBKmAIIiwsryw0qVlfh+8IT9hVQJc=; b=nlSo/qhouE+CIol8u1RwHs1iVUvh5bZsq5AYOZLpPFEim/fHflFA1otw2JC2R4Vi8x OV2DqCaFaHSfEeKcwwuhfEZOtsglyZX+WOCQpmliL83Nyb4w/sKFQ7wUOJuC95CD2oQ4 RnyM9tv8UfCQvrU8RnX2lvNayAc3aQZrKUTtcD+16LmdSCrfSQBc35vAcmpFLj21068S js1jt2av9ssCf/B2LfnvSPRka2BOFDIz6YicXxXdMgL3iOhzY2to1CPEZCIKcgDL3NgZ i+BKYMYHaq+nDC8MHj8yL5HspTogyoS4xjkY7IB4uIKs2M/RqabO+TQfQ63bGkD7gNCC El0Q== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id q74si1192911wme.0.2021.11.14.09.28.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:08 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRX5Jj6z1qwdP; Sun, 14 Nov 2021 18:28:08 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRX5Cr6z1qqkB; Sun, 14 Nov 2021 18:28:08 +0100 (CET) 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 M4TrMzQU6K8X; Sun, 14 Nov 2021 18:28:08 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:08 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id AEEF745408E4; Sun, 14 Nov 2021 18:28:02 +0100 (CET) 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 fYS1zGVFR_3U; Sun, 14 Nov 2021 18:27:58 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 60FBA45426D8; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 09/36] Fix warning in multipart code Date: Sun, 14 Nov 2021 18:27:06 +0100 Message-Id: <20211114172733.71602-10-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , Fix warning due to unused parameter in log. Signed-off-by: Stefano Babic --- corelib/multipart_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/corelib/multipart_parser.c b/corelib/multipart_parser.c index 5014dc8..982e853 100644 --- a/corelib/multipart_parser.c +++ b/corelib/multipart_parser.c @@ -8,7 +8,7 @@ #include #include -static void multipart_log(const char * format, ...) +static void multipart_log(const char __attribute__ ((__unused__)) *format, ...) { #ifdef DEBUG_MULTIPART va_list args; From patchwork Sun Nov 14 17:27:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554901 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=Z7tdHkd7; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23d; helo=mail-lj1-x23d.google.com; envelope-from=swupdate+bncbcxploxj6ikrbkuoywgamgqeieklfbi@googlegroups.com; receiver=) Received: from mail-lj1-x23d.google.com (mail-lj1-x23d.google.com [IPv6:2a00:1450:4864:20::23d]) (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 4HsfRd1Dl5z9sX3 for ; Mon, 15 Nov 2021 04:28:13 +1100 (AEDT) Received: by mail-lj1-x23d.google.com with SMTP id k24-20020a2e9a58000000b00218c7914524sf4428740ljj.17 for ; Sun, 14 Nov 2021 09:28:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910890; cv=pass; d=google.com; s=arc-20160816; b=AeNNVMA5NxRgTMfD7hy9EdcwONH20i5KuWsBUt7FzxdCcT27JqIBbQj/ZySDJB29zN Tbo/IA6K2r3WsWRb+3iZ+d/R3E7Ft44KWrM9yjybXfVkYhADQPLJxIE1AY0aSxHvaQGe BEqApa02nnfb4RiuH/6/6EYjJZBuUz8EjJxfgVqTQZ9dT1P3eyhl4AcF1PbL153HPbZ3 zybdhhTlWN5yZ3luGQjohlJz5v+J9cs96Osc0W78gCGp3kRtsovU3RIJG41zlAXcLuXI KhUNlyQhBBMQ7sCLfpHY8Rbbwj4bFLNeb98AgTWtXuEnE9/nB/KRdewzabVlEUA9s8qm Etfg== 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=0HZ67yBoNeR1nmW01+pgQLgS21MfJW9+u/LkTInZr2A=; b=kpmZaz0F8zDaCXxGfrWpF16k65TVtinLAsZHuJ81LRl6eMEkVSPmD4xL89Tq2gm2li fd7/aM2Vg9GRcw0lBenZwZgtKR+wVepsYxdkkGZEBiWnHCUroRQqGoq+b6Kfis8NeNXg 99nVlTm4nNbZcDxjtN/3uNvgCjXSrqAO6JA8O/hBUh3FJmdsJB9y++2XQ+XqVgYwD86C T4tffTvM4SMLcECkrZdvEcuKFDOON0W9ph6RAutz8hEsFiACnImAnErWhhGskMBFaV8P vIEe2//BkghjMmmiRM0XdnCalfVBGlHl6ZsVy0810SR9/p/YqyXwOIzGlLFm2UE5PHsj uAEg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=0HZ67yBoNeR1nmW01+pgQLgS21MfJW9+u/LkTInZr2A=; b=Z7tdHkd7C/qVl3pyy3wuCqEtyr4+O4WZWFefwyoZZ3lYToq1dMYfYcF+Nu9qb30aWU rxHDhjwnaDY7WCh5tkPLJwfkC/D6TQl89r/cbmZWCvwQ6pWF1ZA8BwlhYkZEPR2Ui8T/ DhZtaNmoXM6NhUmOd+bsnEG7tQNfRbjg8xr4n5OlCH4acEnqtvcXj6jgAW3E4cmvPBuV U0gOGEZ8CyEfieEbeHauwIhOGTCmTU8GMMOxqR5+DyYomBpNYpvbwMczpW4CsvnwvIsr 88Tf28bT+uuqEsf9mesyVQVLVku7ZcS1FYjNbe0kxBjks6DNmSOyZ+gFdi9aTYdqWcY0 04uQ== 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=0HZ67yBoNeR1nmW01+pgQLgS21MfJW9+u/LkTInZr2A=; b=31hyragm3ajCLtM0dhIR4xYakuj2F0eGZw1PvyI2pzYcGV/3xmj3YXo4oqqfDtiIdt WF7olA8MC05GtY9Go1e4FLvrWWITO4SF2uT4//jg/mxwkUJD8ymWkoJqEw9wZ6LWQ+KD uVCeHoyUMyQYN10zIDVebryUjMNL09PxcFVsme+Gn1EeJXc2ugiTFwiREG+2k9S3OlJd cBKeEpO42kfXLE52dENbAZlPD3PFuZiEmTrsso7kFnPK9SOKVipJkfKrXpKbRE9V1SkV sBFUrwP8uZS525uJq0ljbLc/T6JYyP/c+WZjbgToDFlv3VKS0J+mf6wSDNYBOt/bRDY6 tBLA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532gmeQgDxtG122KjXf2yNxeFmkVVVFiUYwhWeiOna+KadgYsMGv IHYgV4aMHuP9JqSXp9/ste4= X-Google-Smtp-Source: ABdhPJyztadxXhcZfJ84tr+mypYxT0QLqjceCxrH51o7XcIUcuvGDBog88Yaj8/odQe163jiUBq81Q== X-Received: by 2002:a2e:3a18:: with SMTP id h24mr33239087lja.372.1636910890223; Sun, 14 Nov 2021 09:28:10 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:a7c4:: with SMTP id x4ls1493534ljp.8.gmail; Sun, 14 Nov 2021 09:28:09 -0800 (PST) X-Received: by 2002:a2e:86da:: with SMTP id n26mr32617070ljj.522.1636910889393; Sun, 14 Nov 2021 09:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910889; cv=none; d=google.com; s=arc-20160816; b=YGFpqXpF36GC5Ud+SLGuic/Q7n18M6R8QcsuyGdT0cYdmBvMDgnZeUC3UKmsOAQG2L P8rUZhHZZwCCsJib+rdEcGS85mQZujCaviSMsb6OVUHUBNToQGztEjCJrI1+Q2sn0K/S 8lDrWhiYCE5+SuwCnRpaNXK8l1TjtUC/SPYiR3fLxS5WdTaOrr9PfWcvnFCI9TtS0jTk G9VQGiMNrvWB/0gyaPSR2vW25cJYj7xJvtbVHFyMODWNaN0edLNpmGdcFu+RsF1HIVtG h6004OzfkFnrqV11vokbLeDKnpSOguuSwjCJ8DoyRihAfx4Y1HxMU0EL2IdMe5LhjTDy Vogw== 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=Gbqj71V4ncdH9gPEuDIpYlod4Kh4wCiMtkDv/9hChSU=; b=R9k3sdcBKGMH0IDzq4kfaC76NtUC+uixgiMPzLPLdLuUA198nxajON5xzqTvDZZKb6 RHWAcA6yl4rPfNnz1G7+PkwqW66JlQdsQZ98KRDHgFOAEcOR/OnhlFxHXMoK3eC5Zz68 7WWCeTWN6Ty8c3XLbZihBs0kLO+7Ub7Q79MJb+Ahcq7V7OwxPC76widj8VmtqErYT9Wg t+O+9BEyvfFsN5f4cnr7Y8iq68pjZS89GGilSlBc54tMtdl+OTZY9iWFVg9XkCAz37ZX rlOwQbKRBnnCM2FPODKHpPPEogq7Tmm7Q+VpvjgKe4G05jSMtcK4I7YIUAAwwtnSK7f0 wlyQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id t71si717309lff.6.2021.11.14.09.28.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:09 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRX6fDNz1qwdZ; Sun, 14 Nov 2021 18:28:08 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRX6Wcsz1qqkB; Sun, 14 Nov 2021 18:28:08 +0100 (CET) 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 UlTUpAp36XjS; Sun, 14 Nov 2021 18:28:08 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:08 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 6779E4540853; Sun, 14 Nov 2021 18:28:04 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Wjmx0I2UEkWe; Sun, 14 Nov 2021 18:28:01 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 6FC1345426D9; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 10/36] Check return from malloc in multiparser library Date: Sun, 14 Nov 2021 18:27:07 +0100 Message-Id: <20211114172733.71602-11-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , Multiparser staruc created in the initialization is not checked for error. Signed-off-by: Stefano Babic --- corelib/multipart_parser.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/corelib/multipart_parser.c b/corelib/multipart_parser.c index 982e853..c6e0530 100644 --- a/corelib/multipart_parser.c +++ b/corelib/multipart_parser.c @@ -84,6 +84,8 @@ multipart_parser* multipart_parser_init strlen(boundary) + strlen(boundary) + 9); + if (!p) + return NULL; strcpy(p->multipart_boundary, boundary); p->boundary_length = strlen(boundary); From patchwork Sun Nov 14 17:27:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554903 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=EuzdETSg; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::43d; helo=mail-wr1-x43d.google.com; envelope-from=swupdate+bncbcxploxj6ikrbkuoywgamgqeieklfbi@googlegroups.com; receiver=) Received: from mail-wr1-x43d.google.com (mail-wr1-x43d.google.com [IPv6:2a00:1450:4864:20::43d]) (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 4HsfRd4j9tz9sWJ for ; Mon, 15 Nov 2021 04:28:13 +1100 (AEDT) Received: by mail-wr1-x43d.google.com with SMTP id y4-20020adfd084000000b00186b16950f3sf2576161wrh.14 for ; Sun, 14 Nov 2021 09:28:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910890; cv=pass; d=google.com; s=arc-20160816; b=SSrCPPlWbbjwSb15RCLWh/SBfmTJ5W8I1Xk7exSZHw1+JQ6STahV4y2HWY3Y0WDIPW GCrtEDH6QR2+a3HOMK/3xfCkX63Zz8JbwnHp4AmxttylOjG0zXXvoRmcHV8V3vCO2484 mpsJU3ozBo4qElT0ZJQi0HHwJ9V1aVOYRwFjWMHFO59ceiXC9vcfppkdOuKCdd5NcAFy LGu9XQXas7O1tQgo+E0Dseu/i1UnwZBd4wNGlYoYMgHOFpNm9zGrgUesKgYJuNbe04sy rFALQkPakTdgQApK+CTEOaxbnbipEvFTaj2zdZZSw4LAGbccXE+uVLjFKh7mBLkivWZ9 dtGA== 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=BZBhiWfpOrd0wE9ON4d821DK+AoDUaXUg30hxZ9jceM=; b=E9fMEviyG5d85qm2pMj5pheIEiraqYowQQcY2XBohgziwYXjNbPnYyawm7uANVMMM3 BPbWHj8u2mjZUo24IVMy2B+04S1lX5bzQuJjFTEE4yoOMLzdgsXkwoK/TFtQJCxIJH91 kBYYtjpqb4B+JMBpNTod2W2Vvger02fFU24XtkJLJGhfKMmUDN2uWndMZoxfvZV206dP oMvPSLZWcq35OumbBdNLDIXvrbXcJ2KkWdP8svsfH6/JhRr3yupXk8PEu5stogJbBxZC C8jsz1GcIFxGuuflHylGhzsOHXoNOIIeXn2EfLgu87+qMPb2zER5UFKJ0hyu9q1OAI9o SdyQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=BZBhiWfpOrd0wE9ON4d821DK+AoDUaXUg30hxZ9jceM=; b=EuzdETSgpE1gfH8S73M6Agh9NUJDVHmBWxg667jtQjB5S7wmvbVtcJgem/dhIpIjBy 8duEtLtWESKU8Oen0nv0VnYK60A4k89usbqOayVBWpWXI6G/Cb309hVUUWgVmPx9E1a9 hBNKzKHrdVyGc0KeLhqmlOoSnrI3wRKWqdW9yCJcAu2jMI7o4U/iacx6lX3UvTx5Opq1 +oAUq+QLf7RTgxJNxsrpFrZ+eUb3jh1BKmg/zwxNlGgGu+nAHRRrkahWTCzBz/z54qET +EWsBsZsILXH3MLCdOMWB+i5AGkdxKTbT7k8t1VlQUy3PTwlNgYnB7FP4pZyp81bfLMD s4kw== 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=BZBhiWfpOrd0wE9ON4d821DK+AoDUaXUg30hxZ9jceM=; b=ebLsLnwUcUQkGYGiScGNO0wDAce3lDuxN3LZHzPffTMrfwlK94e2/FZqtjo6SK882r LwOxE7lX8hmqJyJfFnsUsqc8Cboy0AUOttVqsUqCxP2di72G2TG4kJcPGjNW0XmVnNrQ y9aiXI4smX1f+Io3PyrkR6H5aw+E+wJTJLSztD2bsgWvq0eyacBC+oLGfnivPElCPfig 90FRQOB3TzXwb++N9YtNL5o+lG0w3yXDnfmh+QqJOoqw0q790+szeFkz6kdUbLam6ChV yFygBdPrAlhp65Ms4L6JQaNvQwCaDb2lne1pxVoonoZa2mBxk9Py5/SoPnd+UDY5U8mq ftOw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530az1cdmlXtTbZ2yas7NfxrYWecLgiQxi96vVPDOAIys54XomlO w9Pg+mMHxGpeX51IGyOiSkA= X-Google-Smtp-Source: ABdhPJz1Xs+uz1Y3reJkl3DWSspQuTMW4KMehYD1xl8TQFj0J/YVEZt5Dnd7hM4hE/CHOo30DOpR+g== X-Received: by 2002:a5d:6151:: with SMTP id y17mr39831882wrt.275.1636910890472; Sun, 14 Nov 2021 09:28:10 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a5d:6a05:: with SMTP id m5ls7200592wru.3.gmail; Sun, 14 Nov 2021 09:28:09 -0800 (PST) X-Received: by 2002:adf:df0d:: with SMTP id y13mr39590332wrl.176.1636910889859; Sun, 14 Nov 2021 09:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910889; cv=none; d=google.com; s=arc-20160816; b=hploh7HpMbvZHpLi5yZAvu93iDiMVj6rKVG8VUZUlHjPgf3WG9x5806jgElxkfkv25 WagYnPC4FD0CcYuJ6GyEpdLQ7mUBzv5ayb8QFiyOBP71lm/pPElRTbU8lb2R4fPEgFFx cxxQFn8mL1Oq1Yz1j577eskA1EBySYipA0rl3MuYTMsuXAxoZhSJ8cLE2Nb3SBdg1cvN 1s3pJLPKckwsY3+2BBcxHe2FIbPW/za035qk3yXJkJ+44aIQqfrxuee8pvESVVj7Dr9Z zzoHLckpRjPcw/kc7kN9sGqcXPETuAbJiE18fsJrNIveNRwT7guFOp8vavlwZr89rWnJ YRqQ== 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=ijR/JXUzbqhg3kF4GAJ5BL+6zCION/qElek/8vWHfc0=; b=vTPODt7Wz5tCgFQLUfTq+nv9wrPfYcSxTgPkHu7fDVdnIf7vVUCw6jEMyyVPtFPTFS X6hthjMWfK1O7TH/XUp8e8EwqZ4B40hCdJuruX5jaKSgooY33f9tvET/ESc7/pnEiy+U nVIeK0nSa+76/Q9ZuEloXP2cXiRNOVQO9xm4wDwqAobyg0k3xFMfto5E1vJT1MlOWTGz UDhBLbxqIDG923rSq4OhXIwr/Lurd2gN7CaH3RDoZ+MBq+Mr5syjbcjSMyO9pfiqLOma y4SeSyQm1Kcr9ew8Wn5py2xcmkz0ESTY+uP5XCjrIvQWDb1DhY/MFMrSeac88kjZ1QIQ oKMQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id q74si1192913wme.0.2021.11.14.09.28.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:09 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRY4s5dz1qwdP; Sun, 14 Nov 2021 18:28:09 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRY4jpnz1qqkB; Sun, 14 Nov 2021 18:28:09 +0100 (CET) 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 eE1z8jGZJ83i; Sun, 14 Nov 2021 18:28:08 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:08 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 23FB24541B5B; Sun, 14 Nov 2021 18:28:06 +0100 (CET) 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 rMPOfOlgknK2; Sun, 14 Nov 2021 18:28:02 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 81E1545426DC; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 11/36] Convert multiparser to SWUpdate codestyle Date: Sun, 14 Nov 2021 18:27:08 +0100 Message-Id: <20211114172733.71602-12-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , ASWUpdate uses Linux codestyle, so convert it Signed-off-by: Stefano Babic --- corelib/multipart_parser.c | 504 +++++++++++++++++++------------------ include/multipart_parser.h | 40 +-- 2 files changed, 277 insertions(+), 267 deletions(-) diff --git a/corelib/multipart_parser.c b/corelib/multipart_parser.c index c6e0530..5653677 100644 --- a/corelib/multipart_parser.c +++ b/corelib/multipart_parser.c @@ -8,16 +8,16 @@ #include #include -static void multipart_log(const char __attribute__ ((__unused__)) *format, ...) +static void multipart_log(const char __attribute__((__unused__)) * format, ...) { #ifdef DEBUG_MULTIPART - va_list args; - va_start(args, format); + va_list args; + va_start(args, format); - fprintf(stderr, "[HTTP_MULTIPART_PARSER] %s:%d: ", __FILE__, __LINE__); - vfprintf(stderr, format, args); - fprintf(stderr, "\n"); - va_end(args); + fprintf(stderr, "[HTTP_MULTIPART_PARSER] %s:%d: ", __FILE__, __LINE__); + vfprintf(stderr, format, args); + fprintf(stderr, "\n"); + va_end(args); #endif } @@ -39,270 +39,280 @@ do { \ } \ } while (0) - #define LF 10 #define CR 13 struct multipart_parser { - void * data; + void *data; - size_t index; - size_t boundary_length; + size_t index; + size_t boundary_length; - unsigned char state; + unsigned char state; - const multipart_parser_settings* settings; + const multipart_parser_settings *settings; - char* lookbehind; - char multipart_boundary[1]; + char *lookbehind; + char multipart_boundary[1]; }; enum state { - s_uninitialized = 1, - s_start, - s_start_boundary, - s_header_field_start, - s_header_field, - s_headers_almost_done, - s_header_value_start, - s_header_value, - s_header_value_almost_done, - s_part_data_start, - s_part_data, - s_part_data_almost_boundary, - s_part_data_boundary, - s_part_data_almost_end, - s_part_data_end, - s_part_data_final_hyphen, - s_end + s_uninitialized = 1, + s_start, + s_start_boundary, + s_header_field_start, + s_header_field, + s_headers_almost_done, + s_header_value_start, + s_header_value, + s_header_value_almost_done, + s_part_data_start, + s_part_data, + s_part_data_almost_boundary, + s_part_data_boundary, + s_part_data_almost_end, + s_part_data_end, + s_part_data_final_hyphen, + s_end }; -multipart_parser* multipart_parser_init - (const char *boundary, const multipart_parser_settings* settings) { +multipart_parser *multipart_parser_init + (const char *boundary, const multipart_parser_settings * settings) { - multipart_parser* p = malloc(sizeof(multipart_parser) + - strlen(boundary) + - strlen(boundary) + 9); + multipart_parser *p = malloc(sizeof(multipart_parser) + + strlen(boundary) + strlen(boundary) + 9); - if (!p) - return NULL; - strcpy(p->multipart_boundary, boundary); - p->boundary_length = strlen(boundary); + if (!p) + return NULL; + strcpy(p->multipart_boundary, boundary); + p->boundary_length = strlen(boundary); - p->lookbehind = (p->multipart_boundary + p->boundary_length + 1); + p->lookbehind = (p->multipart_boundary + p->boundary_length + 1); - p->index = 0; - p->state = s_start; - p->settings = settings; + p->index = 0; + p->state = s_start; + p->settings = settings; - return p; + return p; } -void multipart_parser_free(multipart_parser* p) { - free(p); +void multipart_parser_free(multipart_parser * p) +{ + free(p); } -void multipart_parser_set_data(multipart_parser *p, void *data) { - p->data = data; +void multipart_parser_set_data(multipart_parser * p, void *data) +{ + p->data = data; } -void *multipart_parser_get_data(multipart_parser *p) { - return p->data; +void *multipart_parser_get_data(multipart_parser * p) +{ + return p->data; } -size_t multipart_parser_execute(multipart_parser* p, const char *buf, size_t len) { - size_t i = 0; - size_t mark = 0; - char c, cl; - int is_last = 0; - - while(i < len) { - c = buf[i]; - is_last = (i == (len - 1)); - switch (p->state) { - case s_start: - multipart_log("s_start"); - p->index = 0; - p->state = s_start_boundary; - - /* fallthrough */ - case s_start_boundary: - multipart_log("s_start_boundary"); - if (p->index == p->boundary_length) { - if (c != CR) { - return i; - } - p->index++; - break; - } else if (p->index == (p->boundary_length + 1)) { - if (c != LF) { - return i; - } - p->index = 0; - NOTIFY_CB(part_data_begin); - p->state = s_header_field_start; - break; - } - if (c != p->multipart_boundary[p->index]) { - return i; - } - p->index++; - break; - - case s_header_field_start: - multipart_log("s_header_field_start"); - mark = i; - p->state = s_header_field; - - /* fallthrough */ - case s_header_field: - multipart_log("s_header_field"); - if (c == CR) { - p->state = s_headers_almost_done; - break; - } - - if (c == ':') { - EMIT_DATA_CB(header_field, buf + mark, i - mark); - p->state = s_header_value_start; - break; - } - - cl = tolower(c); - if ((c != '-') && (cl < 'a' || cl > 'z')) { - multipart_log("invalid character in header name"); - return i; - } - if (is_last) - EMIT_DATA_CB(header_field, buf + mark, (i - mark) + 1); - break; - - case s_headers_almost_done: - multipart_log("s_headers_almost_done"); - if (c != LF) { - return i; - } - - p->state = s_part_data_start; - break; - - case s_header_value_start: - multipart_log("s_header_value_start"); - if (c == ' ') { - break; - } - - mark = i; - p->state = s_header_value; - - /* fallthrough */ - case s_header_value: - multipart_log("s_header_value"); - if (c == CR) { - EMIT_DATA_CB(header_value, buf + mark, i - mark); - p->state = s_header_value_almost_done; - break; - } - if (is_last) - EMIT_DATA_CB(header_value, buf + mark, (i - mark) + 1); - break; - - case s_header_value_almost_done: - multipart_log("s_header_value_almost_done"); - if (c != LF) { - return i; - } - p->state = s_header_field_start; - break; - - case s_part_data_start: - multipart_log("s_part_data_start"); - NOTIFY_CB(headers_complete); - mark = i; - p->state = s_part_data; - - /* fallthrough */ - case s_part_data: - multipart_log("s_part_data"); - if (c == CR) { - EMIT_DATA_CB(part_data, buf + mark, i - mark); - mark = i; - p->state = s_part_data_almost_boundary; - p->lookbehind[0] = CR; - break; - } - if (is_last) - EMIT_DATA_CB(part_data, buf + mark, (i - mark) + 1); - break; - - case s_part_data_almost_boundary: - multipart_log("s_part_data_almost_boundary"); - if (c == LF) { - p->state = s_part_data_boundary; - p->lookbehind[1] = LF; - p->index = 0; - break; - } - EMIT_DATA_CB(part_data, p->lookbehind, 1); - p->state = s_part_data; - mark = i --; - break; - - case s_part_data_boundary: - multipart_log("s_part_data_boundary"); - if (p->multipart_boundary[p->index] != c) { - EMIT_DATA_CB(part_data, p->lookbehind, 2 + p->index); - p->state = s_part_data; - mark = i --; - break; - } - p->lookbehind[2 + p->index] = c; - if ((++ p->index) == p->boundary_length) { - NOTIFY_CB(part_data_end); - p->state = s_part_data_almost_end; - } - break; - - case s_part_data_almost_end: - multipart_log("s_part_data_almost_end"); - if (c == '-') { - p->state = s_part_data_final_hyphen; - break; - } - if (c == CR) { - p->state = s_part_data_end; - break; - } - return i; - - case s_part_data_final_hyphen: - multipart_log("s_part_data_final_hyphen"); - if (c == '-') { - NOTIFY_CB(body_end); - p->state = s_end; - break; - } - return i; - - case s_part_data_end: - multipart_log("s_part_data_end"); - if (c == LF) { - p->state = s_header_field_start; - NOTIFY_CB(part_data_begin); - break; - } - return i; - - case s_end: - multipart_log("s_end: %02X", (int) c); - break; - - default: - multipart_log("Multipart parser unrecoverable error"); - return 0; - } - ++ i; - } - - return len; +size_t multipart_parser_execute(multipart_parser * p, const char *buf, + size_t len) +{ + size_t i = 0; + size_t mark = 0; + char c, cl; + int is_last = 0; + + while (i < len) { + c = buf[i]; + is_last = (i == (len - 1)); + switch (p->state) { + case s_start: + multipart_log("s_start"); + p->index = 0; + p->state = s_start_boundary; + + /* fallthrough */ + case s_start_boundary: + multipart_log("s_start_boundary"); + if (p->index == p->boundary_length) { + if (c != CR) { + return i; + } + p->index++; + break; + } else if (p->index == (p->boundary_length + 1)) { + if (c != LF) { + return i; + } + p->index = 0; + NOTIFY_CB(part_data_begin); + p->state = s_header_field_start; + break; + } + if (c != p->multipart_boundary[p->index]) { + return i; + } + p->index++; + break; + + case s_header_field_start: + multipart_log("s_header_field_start"); + mark = i; + p->state = s_header_field; + + /* fallthrough */ + case s_header_field: + multipart_log("s_header_field"); + if (c == CR) { + p->state = s_headers_almost_done; + break; + } + + if (c == ':') { + EMIT_DATA_CB(header_field, buf + mark, + i - mark); + p->state = s_header_value_start; + break; + } + + cl = tolower(c); + if ((c != '-') && (cl < 'a' || cl > 'z')) { + multipart_log + ("invalid character in header name"); + return i; + } + if (is_last) + EMIT_DATA_CB(header_field, buf + mark, + (i - mark) + 1); + break; + + case s_headers_almost_done: + multipart_log("s_headers_almost_done"); + if (c != LF) { + return i; + } + + p->state = s_part_data_start; + break; + + case s_header_value_start: + multipart_log("s_header_value_start"); + if (c == ' ') { + break; + } + + mark = i; + p->state = s_header_value; + + /* fallthrough */ + case s_header_value: + multipart_log("s_header_value"); + if (c == CR) { + EMIT_DATA_CB(header_value, buf + mark, + i - mark); + p->state = s_header_value_almost_done; + break; + } + if (is_last) + EMIT_DATA_CB(header_value, buf + mark, + (i - mark) + 1); + break; + + case s_header_value_almost_done: + multipart_log("s_header_value_almost_done"); + if (c != LF) { + return i; + } + p->state = s_header_field_start; + break; + + case s_part_data_start: + multipart_log("s_part_data_start"); + NOTIFY_CB(headers_complete); + mark = i; + p->state = s_part_data; + + /* fallthrough */ + case s_part_data: + multipart_log("s_part_data"); + if (c == CR) { + EMIT_DATA_CB(part_data, buf + mark, i - mark); + mark = i; + p->state = s_part_data_almost_boundary; + p->lookbehind[0] = CR; + break; + } + if (is_last) + EMIT_DATA_CB(part_data, buf + mark, + (i - mark) + 1); + break; + + case s_part_data_almost_boundary: + multipart_log("s_part_data_almost_boundary"); + if (c == LF) { + p->state = s_part_data_boundary; + p->lookbehind[1] = LF; + p->index = 0; + break; + } + EMIT_DATA_CB(part_data, p->lookbehind, 1); + p->state = s_part_data; + mark = i--; + break; + + case s_part_data_boundary: + multipart_log("s_part_data_boundary"); + if (p->multipart_boundary[p->index] != c) { + EMIT_DATA_CB(part_data, p->lookbehind, + 2 + p->index); + p->state = s_part_data; + mark = i--; + break; + } + p->lookbehind[2 + p->index] = c; + if ((++p->index) == p->boundary_length) { + NOTIFY_CB(part_data_end); + p->state = s_part_data_almost_end; + } + break; + + case s_part_data_almost_end: + multipart_log("s_part_data_almost_end"); + if (c == '-') { + p->state = s_part_data_final_hyphen; + break; + } + if (c == CR) { + p->state = s_part_data_end; + break; + } + return i; + + case s_part_data_final_hyphen: + multipart_log("s_part_data_final_hyphen"); + if (c == '-') { + NOTIFY_CB(body_end); + p->state = s_end; + break; + } + return i; + + case s_part_data_end: + multipart_log("s_part_data_end"); + if (c == LF) { + p->state = s_header_field_start; + NOTIFY_CB(part_data_begin); + break; + } + return i; + + case s_end: + multipart_log("s_end: %02X", (int)c); + break; + + default: + multipart_log("Multipart parser unrecoverable error"); + return 0; + } + ++i; + } + + return len; } diff --git a/include/multipart_parser.h b/include/multipart_parser.h index 015e8ad..0282e50 100644 --- a/include/multipart_parser.h +++ b/include/multipart_parser.h @@ -7,8 +7,7 @@ #define _multipart_parser_h #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif #include @@ -18,32 +17,33 @@ typedef struct multipart_parser multipart_parser; typedef struct multipart_parser_settings multipart_parser_settings; typedef struct multipart_parser_state multipart_parser_state; -typedef int (*multipart_data_cb) (multipart_parser*, const char *at, size_t length); -typedef int (*multipart_notify_cb) (multipart_parser*); +typedef int (*multipart_data_cb)(multipart_parser *, const char *at, + size_t length); +typedef int (*multipart_notify_cb)(multipart_parser *); struct multipart_parser_settings { - multipart_data_cb on_header_field; - multipart_data_cb on_header_value; - multipart_data_cb on_part_data; - - multipart_notify_cb on_part_data_begin; - multipart_notify_cb on_headers_complete; - multipart_notify_cb on_part_data_end; - multipart_notify_cb on_body_end; + multipart_data_cb on_header_field; + multipart_data_cb on_header_value; + multipart_data_cb on_part_data; + + multipart_notify_cb on_part_data_begin; + multipart_notify_cb on_headers_complete; + multipart_notify_cb on_part_data_end; + multipart_notify_cb on_body_end; }; -multipart_parser* multipart_parser_init - (const char *boundary, const multipart_parser_settings* settings); +multipart_parser *multipart_parser_init + (const char *boundary, const multipart_parser_settings * settings); -void multipart_parser_free(multipart_parser* p); +void multipart_parser_free(multipart_parser * p); -size_t multipart_parser_execute(multipart_parser* p, const char *buf, size_t len); +size_t multipart_parser_execute(multipart_parser * p, const char *buf, + size_t len); -void multipart_parser_set_data(multipart_parser* p, void* data); -void * multipart_parser_get_data(multipart_parser* p); +void multipart_parser_set_data(multipart_parser * p, void *data); +void *multipart_parser_get_data(multipart_parser * p); #ifdef __cplusplus -} /* extern "C" */ +} /* extern "C" */ #endif - #endif From patchwork Sun Nov 14 17:27:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554902 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=joVUl3fA; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::537; helo=mail-ed1-x537.google.com; envelope-from=swupdate+bncbcxploxj6ikrbkmoywgamgqefebq3cq@googlegroups.com; receiver=) Received: from mail-ed1-x537.google.com (mail-ed1-x537.google.com [IPv6:2a00:1450:4864:20::537]) (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 4HsfRd1vLWz9sfG for ; Mon, 15 Nov 2021 04:28:13 +1100 (AEDT) Received: by mail-ed1-x537.google.com with SMTP id f4-20020a50e084000000b003db585bc274sf12020375edl.17 for ; Sun, 14 Nov 2021 09:28:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910890; cv=pass; d=google.com; s=arc-20160816; b=zAriCMc47N1bmf6tU7iE51VFX+BbRany0p3BRlrHlBadbpZEzHJ+tLRfRCkfvdrj8I qiYKGJXQCTre3W79izr32qQz38ahIqQ8vA1dlYYy/apHanasWI196FUf98ShxvuICMRI alGDQxiveGxIrX6K0zkwRKunWAcvVWgeXYqIaXvmocmpkwft1eWNRrBZE+WBvmdUS+HG oqwtOWoBCMDtlB8k8g4MtWp302K5mIl28S15Yr8Bb/yhJDVR2bLGs5Os05wt1HOKGYxb lnVCBqdxglwRTS+HhzNY2XQVmOwhGtUwGGRaZ93WvcoBIIACcrssnyUcd/uj3fFDnWz6 +U7g== 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=xfpksh5CDPvtSlvfUKxNuF0LjaOwNGOsj5e7eZXacMk=; b=xAuAnPZupCb3wwKkbWZfJ6xajQBAxwa46loAOgNJvBbqVmU0vVfCZ6jStvvkw/9C0P +7/tdbkjhVhz38JSN1huY3EH26DIB/J9fFyFGwmtzQ3vsqKRlISrPKodBF3Jo1kRayOv B6OohE9wWfWnERxMYzpAaIF4pY+z5/LRPzCps8lZ9qrRc/2fIDdZzoByOyk7/Sfes0i1 EpS/BPT0II8aRv2Jf/0Qk8onbF//rkBYyiWKfN6RBsSL0o3fdFHmJ8DXvHqRd6NAhfoo goCoxm/ndP8dGLSOYfoFKVFcbTv4bik+vQOHNo4UUBB1fV4X6jWUvaCAyTAsmZDqyLoz nmMA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 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=xfpksh5CDPvtSlvfUKxNuF0LjaOwNGOsj5e7eZXacMk=; b=joVUl3fAZiNq4aGdmumo70USu1kegDiC9ps9EKd0Ff66M7yg/jf7Kez+414wYEjq1W 79pOizgA1qHVfyEZMk+VYPFV/VBsw0jeJTx/AQrXxSFfc6oDuPCy/CFg5zUZW0w8v/t7 F1T1NO5AqAny9/3ulHGors3K/miVtccgu+kWlesOJ1BNXX0h4zEwaABtmjuaPM8f+eOi bNuqvpKRqBBzDtPIfl/G9NwToO4nv8dC6h0nOyJGZC5mq96fhtIJKGvQgdPD6SFNKccT xVQc/RAvQK3A2aT0FcykjOjHCUfwziHvIxDCzEmdJnw4aitAVUrLdwg5c8xetoSu9GZo t/hA== 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=xfpksh5CDPvtSlvfUKxNuF0LjaOwNGOsj5e7eZXacMk=; b=LB8vHK0eQm8BxAFt5GmEhRKFfxFAl2Cj8oYImxUYjqvDLCygOIsINJynvlVPYOPoMZ BgPOQinG88XI+p8N7Zhv2vT+gVdH6w/u7fWeQRKPDaIl9vMWthfMfhwGemdE+YQ7hJdG b37OSuLkkLmR6osc+W9zD7TOaMRV6SHNglTLvK246UvZCKtqnOls95mDjKP9ipt4S1U+ k5PvPBbSHHwEvKL41q1QrGsjcrH2cZ1pm63SUJZVvo/ulUk+QXG3O/QsQ0Dx87ZtAg7o AUrjMpLypaGDwjXpMJbv0XX5YtoTIN8AV2RI++DzFIiFdZitVwvFRl+MGxZdbcgaVkw6 P/uw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5311xeemWFz9Nm7grSBxkAHegy+iw+H4zBu8JfgsMVSawJeuBl5M kXFgf62w/uRC4u20OwhQm+c= X-Google-Smtp-Source: ABdhPJx71VU7vft1+wYjKj+TSHtS0+He6Zr1WtDRS7Hr+huUbvFzQwYeUxBOzhwg/YzLFBFUesadIA== X-Received: by 2002:a17:907:6e91:: with SMTP id sh17mr41713953ejc.86.1636910890107; Sun, 14 Nov 2021 09:28:10 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6402:3587:: with SMTP id y7ls3824693edc.2.gmail; Sun, 14 Nov 2021 09:28:09 -0800 (PST) X-Received: by 2002:a05:6402:3596:: with SMTP id y22mr47782799edc.255.1636910889334; Sun, 14 Nov 2021 09:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910889; cv=none; d=google.com; s=arc-20160816; b=GKckJUsxzHceO9JWIGkrCcit/hw6/mKOklrdxszhZyarvU13OqsAjkgPfuWwefFenH C/Yy+h5Ehv3q7TQh96SCze8V3gS6LCPRAH1iLFuXjwyV9Nz5UQFIYMVbGHSCNUtBJ8T4 sxk6t+4dVN9Toe/Nv0YIBjQi0ihjKrbxoAFwwGx7aBtD6n6SpRaS+2pjlG8UiDb01+CA EzE2xoNsTaXkbvVq5dvOkLusCa1oT5hTpnbRtBhNyejd+iEZ/zD2H3vvlt5x0W8TAWIe N6/13Pbedi0WzBlAmw5SSI8CmUYYWSZLXd3CVGpxcwo93Gdx6czi2txHGMC3i0RL1QVU sVNQ== 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=/ysHlb1iJ7tuVkZfSjxGgsxHT0yJAQced5rg1LXG0Ks=; b=i4BtEu2MsJLkVQsbWnJKRJz2f3F0RN3sIS46bX8JiSN47Kst3HqcfL8Fhq/0ZEQjKi pVkqMeU1GtdgojIFxsi9A6iQx586OMEZRzsWqkKsXxx7Yg02WEBjVBDgeKWO9MO1vN05 zpxAcx9lr80FHc17UlXhydq4aoAi4FdinW0MrCTk/560x60CBnztTRjBCrEqcBGKBqHC V8CWnrmm0fTilYdGtX7gu27x1w3QKj3kL4AikkQiRgF5BJnMZGngqsw50FObWTE4+mJL 5Hj7EhxikTIDCiZgTfKC0pxzUibjmb81+JshMObMHam8PP08nkb01FuT9DYvqUW4gG+1 y7mQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 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. [212.18.0.10]) by gmr-mx.google.com with ESMTPS id bi21si922463edb.0.2021.11.14.09.28.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:09 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.10 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.10; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRY0qWfz1rk5m; Sun, 14 Nov 2021 18:28:09 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRY0jVsz1qqkB; Sun, 14 Nov 2021 18:28:09 +0100 (CET) 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 w8Cqz1c7rqRG; Sun, 14 Nov 2021 18:28:08 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:08 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id D4E854541B62; Sun, 14 Nov 2021 18:28:07 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id qaIV-bAq_f3P; Sun, 14 Nov 2021 18:28:04 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 9BF4745426EE; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 12/36] channel_curl: statify entry points functions Date: Sun, 14 Nov 2021 18:27:09 +0100 Message-Id: <20211114172733.71602-13-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.10 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: , Functions are defined as part of a generic channel and initialized via a channel_new() call. Scope can be set inside the module and not global. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index f64ca93..06a030f 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -75,12 +75,12 @@ char *channel_get_redirect_url(channel_t *this); static void channel_log_effective_url(channel_t *this); /* Prototypes for "public" functions */ +static channel_op_res_t channel_close(channel_t *this); +static channel_op_res_t channel_open(channel_t *this, void *cfg); +static channel_op_res_t channel_get(channel_t *this, void *data); +static channel_op_res_t channel_get_file(channel_t *this, void *data); +static channel_op_res_t channel_put(channel_t *this, void *data); channel_op_res_t channel_curl_init(void); -channel_op_res_t channel_close(channel_t *this); -channel_op_res_t channel_open(channel_t *this, void *cfg); -channel_op_res_t channel_get(channel_t *this, void *data); -channel_op_res_t channel_get_file(channel_t *this, void *data); -channel_op_res_t channel_put(channel_t *this, void *data); channel_t *channel_new(void); From patchwork Sun Nov 14 17:27:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554904 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=FbOGhc0m; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23c; helo=mail-lj1-x23c.google.com; envelope-from=swupdate+bncbcxploxj6ikrbk4oywgamgqetinpwnq@googlegroups.com; receiver=) Received: from mail-lj1-x23c.google.com (mail-lj1-x23c.google.com [IPv6:2a00:1450:4864:20::23c]) (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 4HsfRf5zKNz9sWJ for ; Mon, 15 Nov 2021 04:28:14 +1100 (AEDT) Received: by mail-lj1-x23c.google.com with SMTP id b16-20020a2ebc10000000b00218d00045c4sf4403067ljf.5 for ; Sun, 14 Nov 2021 09:28:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910891; cv=pass; d=google.com; s=arc-20160816; b=cnDFCuSdph/Yaqg5DlG+7P6Wu5X+QY1rTT8crJP3CXkHrlEv9kLvDHQNxWDbP5Zk5O iJRS5HWVE10wmhAY9RrU/yIO3S1LNl1yxbAjapX9XMPx6vvyHT3CkwXOSfxUhNlEdI8F bgl/Ssj6zepRy/cjbwSmun9rngUUOQEObIFSZ0rlpoe50Na2mxvfrfaoBa2AOJ9mfjgT XwdhECukSdalhnqiQUzQuyukl2bmrW6NHIQTfAJmUn11R+wECrjJOf6VIiM4AjE15Xia wZNXoHQ9MqYtV9GBOKMFYrrv+mSHsnmd4PydjQrJnn7JXoPv9EwdmPl/i/9O9nZOxYl5 XTNQ== 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=Yg23uk4ulRfMBro2v6Lso2lKymEXh79e48qQlBsxDzI=; b=YNLhY6G81zvMKBapuGeYgrFAzVCjyydkxI32EpOUVjrzKKnyRm6s/xyscuLHvXTxi/ qlYiRkwX7Mb4BFe7mXCocCl8P+DE/ygADULzEiuWUx3vuoGgccU5YrGMD2SXWZpFx10h Gq/fwEpQUsGHHbb3ulsYtxU8Fz6EYgqIaBbgccSeYwD22zhzq9WukPTMsp67OLtn3f22 Jhy3BzvSsrv4dSsoOk5pBxtrn9kWF1l3KspleLFJthZ+0r1luLtPhjEFOwKaHb66KEbA L3M3mAZJZAztgw5WaWpCtvlljWDaNPmj2yCvUyptbCGhjdv++4M389R4ORc8WrbQwzOJ Oowg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 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=Yg23uk4ulRfMBro2v6Lso2lKymEXh79e48qQlBsxDzI=; b=FbOGhc0m7048SxloBEqH/uSH5/KzqByNY611Czw70LKHrsuphl/br75B7ivkqma+Fq E9XGFrx/XVgay7XksjcOfOA7zAR/CbWFQNI9iOIwOdj3+4NYBR5LgZVeFO4wyE9K2N4I y6Mz5ELWuvZlKwc+H3XKlDd9pgi34jfBpWdEAhwmFaio+dx7+d1FRYFSJjBGeXzF8qT3 r2gsXvOPhb8yAcjGaGjORgkguKadAxp6L2s6a2Icm1gNBNWrztPWOJAcK134lRljZwg4 uL93A+NcPqOKPjore6jm2LMtBzJ/JpTVMdsp7W21rfJfbxzKRe6zdGJdDR6B2PTqAq9M yaiA== 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=Yg23uk4ulRfMBro2v6Lso2lKymEXh79e48qQlBsxDzI=; b=zngP3h9DhttZbICQIJ15DB7rswcRW73JTU0BJ7ZHWMADufip4zDkrmyXyyosGjtpzg Fb/k7/bL/CyjJMNpPqRwHTNh8fDSIP9FQ6xVe+yUMDI8ndsUxLl28DOLOPlF4NUjartR KG5pj/D0ZGSAcrmeHDjpZwDziPHwA7eW60HUVh5dwa48mS8AJpdf6WlPB5zLhSumYKsJ y6gMCOf6fRtM2JynzZlaqjclLfiV5ASC6dhRXBsT7kaTI1R8F1Gt0k36jUBStg6OHmuQ 2b6F6VtjpP1omNNofmRn9WsWG7XXV960ox3sQxNhtTaBEbWN7IIraeIztBAKi/+86Aq4 F1tw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM53144+HLx/fpl7rQYNdyy6OsKwW0yURJi2VULBwdWU1voc0fquO7 15MJfCUAE7SpNN3ZhEfOGGk= X-Google-Smtp-Source: ABdhPJxvl/OyciS617RSGu68F5dYDiZfXJmoWVzRpFp6wy0AyiRVI3hZn+t28EFJTMwWJ1TeAwe8EA== X-Received: by 2002:a05:6512:3a91:: with SMTP id q17mr16162510lfu.425.1636910891342; Sun, 14 Nov 2021 09:28:11 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:651c:b1f:: with SMTP id b31ls1834994ljr.0.gmail; Sun, 14 Nov 2021 09:28:10 -0800 (PST) X-Received: by 2002:a2e:3102:: with SMTP id x2mr31436768ljx.62.1636910890638; Sun, 14 Nov 2021 09:28:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910890; cv=none; d=google.com; s=arc-20160816; b=b2dtml73QJ4cTsHfuhByD/v1vQxP+vyc79wYh1Ube3Qea/eJtQJotCAiDAWWsZQnlo DPASmUFN9/S8orsGDGGo4D2nbiIQpyM+dk0YkKCVY4C4bpNwAcM+zn5cht0H5kjYCSWo Df7YQI3OwXPzjOJMoWRg8HKZaGzIoiBvFVxVu6tYzKqkryzyttelvQMLrIxXthkZCbig /yyC3gs2U2f9J5FWE5I9Q1CZVCSM0WVyWNQTUC6m+2eYunc247KLJDcxsw+G5OL0uXNg oQBU1k/ekCdSjd9JesAjvnkg0b0yXSj/NCTU8950dHWshRj6RB6qVXiJ0Nw2S5Mr8cbx wcjg== 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=MbMughcZzRQbreN6e9oiw7CuIwJv5BCva0wiLnCf3tE=; b=b+4lVecM7k1CfI775ShXwHvb8fSaexTrBlS9gKvsEdIruZmR4BZFeap4Jlxc2NU7sS xEq8T+ezrcAh7Q3MR3Wz5IoiXTVTvt01lsDvEk3Y2fBpkUXkD/G9sTH6Fw0dV7i4IArw elV/v1bBa/pFvOBi3ZzOS2upOxo84OVqAXLL06LvMSl8mkNZ8gPPccxse/lI6ywx5GOP vudrD1C69evgUk7ESfoCV5OmXU8PUN8Ms+Gp7S7N/6zzK/Y/CzZgfLOJPJ9VbkN4gBUT vJdKW/thdYA9JCOiBiQMa5T2TpL7Je2Qig4LAzJFrbdQFUtKgAY3WzZ3x4xzrc2lANcx 0d9w== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 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. [212.18.0.10]) by gmr-mx.google.com with ESMTPS id b9si1213650lji.2.2021.11.14.09.28.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:10 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.10 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.10; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRZ1Gl4z1rk5n; Sun, 14 Nov 2021 18:28:10 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRZ184Mz1qqkB; Sun, 14 Nov 2021 18:28:10 +0100 (CET) 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 gobUGLp--iTm; Sun, 14 Nov 2021 18:28:09 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:09 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 353294540853; Sun, 14 Nov 2021 18:28:09 +0100 (CET) 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 HUblIkCctI6x; Sun, 14 Nov 2021 18:28:06 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id AAEC245426F5; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 13/36] channel_curl: fix wrong usage of pointer in assert Date: Sun, 14 Nov 2021 18:27:10 +0100 Message-Id: <20211114172733.71602-14-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.10 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: , Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 06a030f..d1c2f5a 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -1315,7 +1315,7 @@ channel_op_res_t channel_get(channel_t *this, void *data) { channel_curl_t *channel_curl = this->priv; assert(data != NULL); - assert(channel_curl.handle != NULL); + assert(channel_curl->handle != NULL); channel_op_res_t result = CHANNEL_OK; channel_data_t *channel_data = (channel_data_t *)data; From patchwork Sun Nov 14 17:27:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554905 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=dok9YTKR; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::538; helo=mail-ed1-x538.google.com; envelope-from=swupdate+bncbcxploxj6ikrbleoywgamgqex4rn2qa@googlegroups.com; receiver=) Received: from mail-ed1-x538.google.com (mail-ed1-x538.google.com [IPv6:2a00:1450:4864:20::538]) (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 4HsfRg4RWzz9sWJ for ; Mon, 15 Nov 2021 04:28:15 +1100 (AEDT) Received: by mail-ed1-x538.google.com with SMTP id c1-20020aa7c741000000b003e7bf1da4bcsf794649eds.21 for ; Sun, 14 Nov 2021 09:28:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910893; cv=pass; d=google.com; s=arc-20160816; b=NqutO5HdjRDTmD+3uPBo/8B6/a1MWLVPjLWmu8NegGFpXrrrDE0slecAwzGhDLMqQC jEl+tzrPmAEPr5kHLNDPxn39SIBglvqVnpMsYs8C0OgJrdXSv4vEn3pH0cIEAXXwi8H6 dgcldT5HR4vcAlJ81oRCVzoKCMY9sr8fy69BDCyZ0PdzZuopgDk0W6eS1aQY5hVAdwi8 kHt49Z6GLzkaDVKU0SXbIKmtuTSoA6w13CTMIQTcYPefYD560nr5L8GXLqV8zbiLqo8E oo/7IV20FgwlCAFXzV7rEat2rL36MXxTG4rwsrb/egRSfBkI3S/ex4cNn2QBGW3CwEzG txsw== 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=dFPf+dHKq1zWsP7l1CksZnI4oSh+ktX+3LO+ZckdSpU=; b=HUcmVVh0EpFvqbFxZ182OfeCzAr2IUWtLG8Oh18D8/iXG2pOb2qPLm+A+x5G6+XUfS +QiD7b4Z47nXYW1IaqoDTjSq6BR50Lmf3N+HCUTdI6HcQDcjK5P/byErW1uYWS7N7NzD XqBHXFYxxZaTFjN8dW6417kcIxSXwkCbzgXaSiCTPuwGBdnTtTL0uJv9ks2NHhbuUuqX nmUbKgUZ6Tx+/O+0GW3LgTYxE9XW+8bV2Wi870vcAhL9wkcdT6Ilgx9Epl/lotierdRl B2rqMsvfYXi8uXQErFLfUfs+KxysaXuoU176BEF6aPjGCO4GT0a4AjWD0cA4cezAnFk2 f5cA== 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=dFPf+dHKq1zWsP7l1CksZnI4oSh+ktX+3LO+ZckdSpU=; b=dok9YTKRwnkY1Oem18ujsw/CqIemghHxUuBD0GOvMqbH8QKGwkmF4zwar6puqvSHpD Fb2H2tnOcvn0Opfru7hRS75o4qM2XXvi9PtbiKEI3IulMNfHtGTpVEAaycKJacAjH2WS lcUAtctQ214SGv/1pvxW3w16uWWsTOZ0pUku+JGBUk3G9FKExFktzck6ssVhEDiXLckK CqGR4NZglZHUV5TLY4VqUMhZSgDovLZGSSMw2eh81f6NwwCfnSPvhIuofqY+oRFyekjF 9nQxeScL68cNOtXhlab2cajV8rk5b6J9IpVTwtM3iP6M2t6ob48X0q6Obcv8Yu5W1ylL Td4g== 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=dFPf+dHKq1zWsP7l1CksZnI4oSh+ktX+3LO+ZckdSpU=; b=4SmyaMAvPoP6+F1VGwfAiGFp4IBq007zLnSVi2upOpCPJbcYeBYP22yPGh+RodWLS1 vJyXaZoUaZS5omHuj7tpmpeAEGvOk1kuq3oEE8PYx7JM3T2JegezVNZI/X0g431sUGqU LD5t+UXMMyMEQv1hznj3rhYDQlv1GScrgawQ64xKGugmImuhzBCPdX50cV7iF1NWpaBg gtbipCpBuSWl41Jfa7SznH8g2hQ/4wv5zdQfaUYVAGYTdgAdodGhHa5/58GlnmJIS0kr mIdlz1UROnkcA2gNyfAdWlK/IKFgF25k27lneuEIuEyUmI3In0aXdeXkmT8enO9gmADy 9y+w== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533GDk6Dc41CbD4CFU/zkUcx1CaREXUKAEaCNh31Z5HRHsYb0JsZ JPVSPngGk9hdvX0yz9AZQXg= X-Google-Smtp-Source: ABdhPJzJWsbr9X/vMER5rD+zcdMKQMih31NedBvOXeXVP1xHQPpPu6PQGDYp1ExZ/3vVsKe1Jkakmg== X-Received: by 2002:a05:6402:124e:: with SMTP id l14mr16209079edw.74.1636910892964; Sun, 14 Nov 2021 09:28:12 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:907:3e05:: with SMTP id hp5ls4632172ejc.6.gmail; Sun, 14 Nov 2021 09:28:12 -0800 (PST) X-Received: by 2002:a17:906:6b81:: with SMTP id l1mr41106126ejr.479.1636910892156; Sun, 14 Nov 2021 09:28:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910892; cv=none; d=google.com; s=arc-20160816; b=iRu1lJgQTjhVS0tbXJB+CkE/xxRDRErxRuB7vYNqlTe7e5twoC7/m5mKEuNQvQ8ueC EEL9n849U83+3+IomHnvZcIqUFVkm5j+zludljZDsUCLp/eVUFXOAis1f755r/FCX6aE z9+Yfi1bgX8ly++XiIaxta3LQLQQDaSXCcOKyfku2x6iR7nP2Z3lyoORcvUdJzgOGKRG xPoMiYdFhvFRnypOpZx0sdE6DRLWjlstYyOanEUfjf9Cz536Nprb9xX+Ym10iZj3umt8 xGPO77kMDjjVZjWVtdy3Xr06kR7hp/3YprlOICe9ZeLytDrV0KjW8/1EMqYr7aNNNmi5 rNhQ== 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=7FNxHvo5WrJ/lAfLMCrq9UHe6gCBHEfjFWS9IXZVeS8=; b=mU4lLpj+So1deAAvm8s6jp0asZapmtDp4D1981QG9fBOEqZiPOkYvyE92cI7TR0OSt gt92/GNjMfJSi+9o6R2umC9dZyrs+9XgyqpRfOONez8BEvyS0k9duCaikfg+MlayXdrJ oAmjlxMh55HtkjbTyFG2skf03zlPSTNkpxrCARF/9qU+MED1BT3LEAvXwznxip99kNMJ EEi9m7XJbyghEh6bLFvDQVi8FRg4emmWqybo2xPFcMMPgEX7NkpcecU0To6JYf0cpTQZ KzP9S1oQNaIuiOL7NapahppI6Xwo26Rm7a6OiiYtKQU3eCwQ6l9jGYuVmKrJEDsljNEJ 3QrA== 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 d2si675794edk.1.2021.11.14.09.28.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:12 -0800 (PST) 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 4HsfRb6n62z1rk5m; Sun, 14 Nov 2021 18:28:11 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRb6dVcz1qqkB; Sun, 14 Nov 2021 18:28:11 +0100 (CET) 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 tFVM_MzE8_2O; Sun, 14 Nov 2021 18:28:11 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:11 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id D61E04540853; Sun, 14 Nov 2021 18:28:10 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id jFM2CfKcEsVo; Sun, 14 Nov 2021 18:28:08 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id BCAE745426FF; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 14/36] channel_curl: do not automatically add charset header Date: Sun, 14 Nov 2021 18:27:11 +0100 Message-Id: <20211114172733.71602-15-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: , If Content-type is set to bytes / binaries, the charset has no meaning. Just add it automatically in case of application/json and application/text. It is still possible to add it in other case, but the caller should add it to the list of headers. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index d1c2f5a..287f827 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -524,6 +524,17 @@ static channel_op_res_t channel_set_content_type(channel_t *this, result = CHANNEL_EINIT; } } + /* + * Add default charset for application content + */ + if ((!strcmp(content, "application/json") || !strcmp(content, "application/text")) && + (result == CHANNEL_OK)) { + if ((channel_curl->header = curl_slist_append( + channel_curl->header, "charsets: utf-8")) == NULL) { + ERROR("Set channel charset header failed."); + result = CHANNEL_EINIT; + } + } return result; } From patchwork Sun Nov 14 17:27:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554906 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=Eqpew7TW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::538; helo=mail-ed1-x538.google.com; envelope-from=swupdate+bncbcxploxj6ikrbluoywgamgqevynapzy@googlegroups.com; receiver=) Received: from mail-ed1-x538.google.com (mail-ed1-x538.google.com [IPv6:2a00:1450:4864:20::538]) (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 4HsfRj3bkNz9sWJ for ; Mon, 15 Nov 2021 04:28:17 +1100 (AEDT) Received: by mail-ed1-x538.google.com with SMTP id v10-20020aa7d9ca000000b003e7bed57968sf828715eds.23 for ; Sun, 14 Nov 2021 09:28:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910894; cv=pass; d=google.com; s=arc-20160816; b=Up3xKbMsA1sc3bKjoCjpWZPsGG5XnflGVvZEHm6Jq1y3GmnaGNcSsGMGEdikqE2MBn sLuQVR/IJI7vaFbNhwHYnnBAoJtSa0oN6WQ+S2n1Kav0AF1znDr5r5SQu1UAPsiYv2Ln v4IIS/ixZ5DVs/NYBav64zN39VwZssXkXOuk+dK4QXlfxUKQx0heZR1KLAvf5U+CNRlb EOekauchhEKiuWzDvpdyrtM3iIJ3p/cm9kM5yM01vNyKa6jjDrPCi3OEv6kRSw0ajTB3 yHFhhrDD+Qd5YBPYzjmAEL/dxnzWmSf6KKMwEODOcUwEpUmuFyo8O1//1qMqrf39jGfC i40Q== 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=qvxCDjBazz+kxGRcjoX+IRej5zaGhCcO0zKBEVHXcvA=; b=UGbwtH9y+k8ypLr0KGDtz5TkvGIySJHzvNTrKh61mBRvRPYRcWJFOVJ4gq+H8mfETp jUOSz7btg+uVNTDzDh2yaboCt3Y0e/hjMl6jeklQb1z9Sw7/F3+1Np5sI6cp0d9edias 8Vs7+AqZ3+lXhr9dq4mSESJKvkTtZNNkZOTYY60jib6Cqo3KL2Bfy+qyrkDvGDCLYivU dtJPuwCQpvw3Q85UVHZp/ThvkzXaGnMahgZqXGXuI5vV8yBR9cCt7sIcaaSJBAPQmFT0 e1P9xFSod6PBpGg1dQJO46Nxs6d+NLvTmAEcdKfeAbf+gFUNJd4R2eLzzn2PmMXy+5pe /hPg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=qvxCDjBazz+kxGRcjoX+IRej5zaGhCcO0zKBEVHXcvA=; b=Eqpew7TWsvdJDl45O001QK0DT+O+nTB3H3GPFG67NQKeShq8ZO2f6p6Ay4rBBVsKzE dKkHRH/wyk3PFzi/RJUE+TnzWOwyJUa/ojeV/4KLwgOD3E11rlMzRiuYPataUWC6fYom yFekkh2VAD/zlcmADEQ6W7kTRShrya6F+yzxiGXyRiUql9TZAP/nbW+Oz+3Bu2sSMLon VhlC6yoeQTRSryU5JZXgSqxg613v7HOl1NnF7e94LRJDmb5bGnC7LbtlAIVSmnJILbT5 GFeWvQ8/ERHyFdPeIgYgaQvtFCJIZaNKXurbtZHDGIeOu1KOxussAIkN6urDqu/V+uyE mnBA== 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=qvxCDjBazz+kxGRcjoX+IRej5zaGhCcO0zKBEVHXcvA=; b=r98LOOOl8AqFPY5tAV19dypxEujkZp3Z22M3qzThLRO67uuVjcNhvtBq3vvnPWsgMy 80+f0+/TrkbEcNgasqbgcKcb9S2YoBBUWfLJCr+6tQOEbFh3eEWi87Hw6vOdNjJseouD 7LP+ubUTAXIGBFiMNgKFVWdhwoSIbeyKqcHDMrobjV1gSRAFSCTsHuUt/VnMqaA2/OYP JrvR4l0OrB4KYDEq20VC/qYZnw3ZAs1QH4dcnJ6BvMjrXN4utgjbwQNprFGtuW8ek2Va pwa5U7lwo1tpNGEOmi0uag9DjUHRo2aAXIQnvdJ1xzjQgfulT3+HiZihHhPTbkzPuDPz ulhA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530fLdlttQlG94IEB+nwqHBsBdw4675QiV0gSdCsyNQjdjy3ybI2 e95RKKPxjuRADj0uY7pY2XA= X-Google-Smtp-Source: ABdhPJzvoH4NtqaPuL/jrwQjvPlBd75qY6XKpS0if/rKSHTswceLtTHhDLiVX5feeZ3BFx+TuXoTjA== X-Received: by 2002:a17:907:6da2:: with SMTP id sb34mr41874619ejc.509.1636910894750; Sun, 14 Nov 2021 09:28:14 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:906:1484:: with SMTP id x4ls4641135ejc.1.gmail; Sun, 14 Nov 2021 09:28:13 -0800 (PST) X-Received: by 2002:a17:907:6291:: with SMTP id nd17mr41170374ejc.194.1636910893827; Sun, 14 Nov 2021 09:28:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910893; cv=none; d=google.com; s=arc-20160816; b=vKsXIGSdbv2JgyH78Ux1vjqjcX04F9gotgfowKM6/q/U+1lsR9hnRItPyQTsJAOqvW WKvcN5ZOBXcuXRiT51JnaPOadodE7Qv5JhQF6DRp3ybcMUgp5WGAmFJJ5ayRytAfiPxa DVCOkQmxMAUJLEChDLZRTqn7FKs7mbk1n9ZNzWM4qmj+v9dyzW1taMp1AZkMrSLYr+hg ZDul5TJRB9XudUn0ckdG8eRrzvxrUzJOPQ5GspY8BcxoA8vfTAIzWVP9LhsqKAFxxTbt rUC8OwrOJh+Z2P5HFeWmJmbuMN/XUZrHgw40CwtPakARFjGH+eGxyQlupjXur/n1H0hy zPoA== 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=Fw35yH7hIdcsDXzUM1dUpsrsHTcUX5KOT43Xod/EDP4=; b=xqw53cKoOMLl8IAxkNGGueVJy9YHrJzuzPftdDdPTWhuxxZKe0TdZ+oA2f9V5hJlk5 n6PzoPmkImSuhm3fJMA1HrA+7atEFPG0Po+tkmDT5S1TGup9SZGDMJIoKhrC1HBgFUUB 27VoiTb+eRE/HS5k15rcbVmaWxjD/t7j+SNUDQCqohLIDSGlzVKRkW0AaowYirSYdX0T CZOf36AJAxknnrQcpOPomWfayMxpz32uaDDKCjG/6IO3aW4VZxIMq3aSIw/GBlfE7IJG xwETvMmaW+E8bUblmAoz3Lzkjc9Be9RqxhuPCB4GqgwlkkhxLDJZiygTBqq0SLZg1ROR R6hg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id w5si817908ede.3.2021.11.14.09.28.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:13 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRd4FTgz1qwdP; Sun, 14 Nov 2021 18:28:13 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRd47wLz1qqkB; Sun, 14 Nov 2021 18:28:13 +0100 (CET) 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 nC_vittETvc9; Sun, 14 Nov 2021 18:28:12 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:12 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 5532E4540853; Sun, 14 Nov 2021 18:28:12 +0100 (CET) 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 3T2hCkHAR7_o; Sun, 14 Nov 2021 18:28:09 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id CB7EF4542727; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 15/36] curl: change signature of write data callback Date: Sun, 14 Nov 2021 18:27:12 +0100 Message-Id: <20211114172733.71602-16-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , The "checkdwl" callback is used up now only by the Hawkbit backend to check if there is a cancel request on the server. It is called by the curl WRITEFUNCTION callback, but the callback in channel_curl.c changes the signature and does not send parameters to checkdwl. Rename checkdwl in a more generic "dwlwrdata" and pass all parameters foreseen by Curl for the callback. This allows to get access to the incoming stream and the channel can be used in other cases without sending data to to installer. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 6 ++++-- include/channel_curl.h | 3 ++- suricatta/server_general.c | 2 +- suricatta/server_hawkbit.c | 17 ++++++++++------- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 287f827..74f9d48 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -191,8 +191,10 @@ size_t channel_callback_ipc(void *streamdata, size_t size, size_t nmemb, return 0; } - if (data->channel_data->checkdwl && data->channel_data->checkdwl()) - return 0; + if (data->channel_data->dwlwrdata) { + return data->channel_data->dwlwrdata(streamdata, size, nmemb, data->channel_data); + } + /* * Now check if there is a callback from the server * during the download diff --git a/include/channel_curl.h b/include/channel_curl.h index 8ecaf59..49d5242 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -68,7 +68,8 @@ typedef struct { bool nocheckanswer; long http_response_code; bool nofollow; - int (*checkdwl)(void); + size_t (*dwlwrdata)(char *streamdata, size_t size, size_t nmemb, + void *data); struct swupdate_digest *dgst; char sha1hash[SWUPDATE_SHA_DIGEST_LENGTH * 2 + 1]; sourcetype source; diff --git a/suricatta/server_general.c b/suricatta/server_general.c index d19a3e6..7da3c84 100644 --- a/suricatta/server_general.c +++ b/suricatta/server_general.c @@ -545,7 +545,7 @@ server_op_res_t server_install_update(void) channel_data.nofollow = false; channel_data.nocheckanswer = false; - channel_data.checkdwl = NULL; + channel_data.dwlwrdata = NULL; channel_data.url = strdup(url); diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c index dbce9a3..aa4d9a4 100644 --- a/suricatta/server_hawkbit.c +++ b/suricatta/server_hawkbit.c @@ -666,12 +666,15 @@ cleanup: return result; } -static int server_check_during_dwl(void) +static size_t server_check_during_dwl(char __attribute__ ((__unused__)) *streamdata, + size_t size, + size_t nmemb, + void __attribute__ ((__unused__)) *data) { struct timeval now; channel_data_t channel_data = channel_data_defaults; int action_id; - int ret = 0; + int ret = size * nmemb; const char *update_action; server_get_current_time(&now); @@ -683,7 +686,7 @@ static int server_check_during_dwl(void) * was requested */ if ((now.tv_sec - server_time.tv_sec) < ((int)server_get_polling_interval())) - return 0; + return ret; /* Update current server time */ server_time = now; @@ -700,7 +703,7 @@ static int server_check_during_dwl(void) * go on downloading */ free(channel); - return 0; + return ret; } /* @@ -711,13 +714,13 @@ static int server_check_during_dwl(void) if (result == SERVER_UPDATE_CANCELED) { /* Mark that an update was cancelled by the server */ server_hawkbit.cancelDuringUpdate = true; - ret = -1; + ret = 0; } update_action = json_get_deployment_update_action(channel_data.json_reply); /* if the deployment is skipped then stop downloading */ if (update_action == deployment_update_action.skip) - ret = -1; + ret = 0; check_action_changed(action_id, update_action); @@ -1161,7 +1164,7 @@ server_op_res_t server_process_update_artifact(int action_id, goto cleanup_loop; } - channel_data.checkdwl = server_check_during_dwl; + channel_data.dwlwrdata = server_check_during_dwl; /* * There is no authorizytion token when file is loaded, because SWU From patchwork Sun Nov 14 17:27:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554908 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=TmrgWuOA; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::240; helo=mail-lj1-x240.google.com; envelope-from=swupdate+bncbcxploxj6ikrbmeoywgamgqehiiuumi@googlegroups.com; receiver=) Received: from mail-lj1-x240.google.com (mail-lj1-x240.google.com [IPv6:2a00:1450:4864:20::240]) (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 4HsfRl5xW4z9sWJ for ; Mon, 15 Nov 2021 04:28:19 +1100 (AEDT) Received: by mail-lj1-x240.google.com with SMTP id i14-20020a2e864e000000b00218a2c57df8sf4383141ljj.20 for ; Sun, 14 Nov 2021 09:28:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910897; cv=pass; d=google.com; s=arc-20160816; b=FpVIzX1Id2o29DjKaD3xXE1Fr/TxY7neLLA00kLRZOAS3vXVAZt/VOgUr8p1JoGo0R 9I2C2NpD5iX10UGzUHqhn//MHJJV+zLNYx1Wpxahqi8e8RNeE80Gt2oX69ExwMhe/zA6 wXl/Cw/VufJzBNMs2+KfQdZjAjdkwX6WNDofpct6FiWp3tkytFwH/bwNcHpgQrq+JSA6 9l4wI3cho9/dxub5NclpWMgiVtIA39SNAYt+hJI/m4KErgETLTHQYFfowbYhjtEB/u9d lqe0JLKO9jd/XAus5j7YDfBWERyUgp7u9Pe5lVZZhaIFBIYu4C0ExA9+8/aDGrtiymHW xqeQ== 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=u4hAtFmKITloEnF/+kcWh8LPJzLB1JH7ZPVHD5r2G4A=; b=msqxCKe67C/GCSpyPLOFkNxsQARU3kMpWHdDo2HaCMrkn3Z1mPrphJDz1WBIXFpiYe cBIftetkE+IG+VJOExBrIv5b/h2uNGBHgNyh2ZBVqWQ1h3CtcKFwsWCZEqmZe2kNV8Oa fE4va73huzZFJ8UsQB4jSYEbPNLDOQkkZSofSCT6mQMFp5/FSYB/IkveDrDfSzn0VtjS BEqs7Nllsr4TjKlUSdDOiz7y4RcFdarsp17MVmoeqD26PdfEt332BfdBURhCtmdnhBJi +TzpJytnY2MXqbH3m2me5Iw5Qs5hLtjuqxsHRgaw8+41zMpYO2e0waVWK3KNPqFr2FOz TcPA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=u4hAtFmKITloEnF/+kcWh8LPJzLB1JH7ZPVHD5r2G4A=; b=TmrgWuOAuQx307Upe9+TOLOBF6UceoniUjFPJDiYY5Z49GVHv1jqONNHIePdp0/GxF XT1eEqVQOrynHXzynYBNi4iYTJaAhT6RLuRxm8xTMncepHSq3uVIhK63bIYlBnfM3De7 95hTcxh6pQhjeUk8GZZtDWaa7LQVeCZ2rXxj5FnUh2CNxgmfK8+tHSQn9EPYuah+xFjw X5ove57oIApATxMKHJJGs4qvYBQFy4Dpsnrt1CfAFCvur6yk8KbiHDm8vW1AAbgImoVC VLmgPEnKHuaX4yNkaFxt2a8ye0FwDPFRlsmfPuy4llakg0phDYg+gRpd2e0Dt0oGkPgf diUQ== 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=u4hAtFmKITloEnF/+kcWh8LPJzLB1JH7ZPVHD5r2G4A=; b=kcpOrGX7Mpo/burN4pklG2R8GtYT9kyjI9VcFO+4TH5pr3xUaG93XZQD5R8XB/GFTS CENOar4cS4d5v9yIPUHHHsoorff/0shconGmoDMvKTDJXq4a6prUkC3ALtJPV7IbDpnT h/NJzBLuBd3ioLhpQE9RePw61cWI4qL9tag18hL6SN7ifnNRKa3iehCmeA+/6Kt3ctYM QVdLyP5UW6sKFkhKuLhEoQjj3aRZXaReuvwWMFAFl081zKpIZuRFLTNT7HVKOWMIaw7T QbzJDOiq/9ObCBDm83944IpcZtQ+53/A0tc85wLCpOogNeQtRcDA0u0jT7nFRJAN4v1h u6lQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532peTRIdS5lmcMce8ZPyCqWqH3zviMKaAfcSAPOqc0dsFQyufl2 aNabeF0giNj5U9rPi3YhSiQ= X-Google-Smtp-Source: ABdhPJywPpScJc9oPzMSY8uiSROiDb/5HUmd/MIEburZtiKytMk75+K9QmuvLQhgSlK55DyPC+bvKw== X-Received: by 2002:a2e:9549:: with SMTP id t9mr31304942ljh.154.1636910896921; Sun, 14 Nov 2021 09:28:16 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:3499:: with SMTP id v25ls4675297lfr.0.gmail; Sun, 14 Nov 2021 09:28:16 -0800 (PST) X-Received: by 2002:ac2:5d4a:: with SMTP id w10mr29982897lfd.584.1636910896147; Sun, 14 Nov 2021 09:28:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910896; cv=none; d=google.com; s=arc-20160816; b=R52ssYezpwdtacun0iUZG6i9DOz85xj8EbUxvd4+TXBaCYsEFjPYMU1LsdzjYUariV uWd6pxyb27p/RXJJavhOVEiik9bRh+yH9l2fsGN+aOcUSQSNTsBN44QeSGBC6LkqA7HV 0YE5CXdVRESVmMQq3qdMAuCuR+UOxKs7wDKx8G2Qc48K1kz4NElrKYawC80LG85+FMQs ve3+XEHlAPE5B9Hs8x+e7wEzaHZB1HLYnvKIzlDZaapnX97gAem8XoPfvUIQWynzNYuo COc5NYkd7n8aJhYFIQnWHqFWa0zykPl5b9lKIEoj7vUe9ZqVWRLHpnKvJ/qrKQM45XFe FpgQ== 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=pj3oSsNyX/mnC67TfbQRB4XFngzFpE6Mf2gbCxDWyVw=; b=nS6qMonqqxpWf0RFYW6v1hBCtGiwP3sYAaSyFbUzisvfeN4Q7APxuMU/2iRNU8h4WP FwqxasvBWXzAxgE7JTPU60/y5PtKm0a9WkaBLBQDm0PfnMi0qI/p0Rc1JoW3wVWKrWIl 66/ZNC2bydTDb/oe8GXiCSt+ugLqVPD1BRMQZJiCJ2gx2ORrS88/1HmTILETGKDzhu5w 3rRYib7ij6Q1G58LK6LlGzpjp7Iusr9p+d3Sz6zqhMJf0QQKwPVRfsBOP9vT3CInQJT4 ulGKjCmEaC44WpTxbDXdBHiBng6JifCTJDCOhADNp6t4mi+ona9e9P96vWoKZaK3MmKA WtWQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id c11si701931ljr.8.2021.11.14.09.28.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:16 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRg4pj0z1qwdP; Sun, 14 Nov 2021 18:28:15 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRg4k8jz1qqkB; Sun, 14 Nov 2021 18:28:15 +0100 (CET) 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 CEnGyNplOmtw; Sun, 14 Nov 2021 18:28:14 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:14 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 6E4E34540853; Sun, 14 Nov 2021 18:28:14 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Xk_a9zYTf7Po; Sun, 14 Nov 2021 18:28:11 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id EBF014542750; Sun, 14 Nov 2021 18:27:45 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 16/36] curl: add a noipc parameter Date: Sun, 14 Nov 2021 18:27:13 +0100 Message-Id: <20211114172733.71602-17-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , The get_file() function sends data to IPC to install the SWU. To make channel() more generic, add a parameter to control if the incoming data must be forwarded to the IPC. This allows to use get_file() in other contexts, providing an own callback to handle the stream and the curl callback in channel_curl.c becomes a proxy that simply forwards the data to a supplied callback as "dwlwrdata" in the channel_data_t structure. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 50 +++++++++++++++++++++++------------------- include/channel_curl.h | 1 + 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 74f9d48..a44370b 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -184,7 +184,8 @@ size_t channel_callback_ipc(void *streamdata, size_t size, size_t nmemb, } } - if (ipc_send_data(data->output, streamdata, (int)(size * nmemb)) < + if (!data->channel_data->noipc && + ipc_send_data(data->output, streamdata, (int)(size * nmemb)) < 0) { ERROR("Writing into SWUpdate IPC stream failed."); result_channel_callback_ipc = CHANNEL_EIO; @@ -1079,7 +1080,8 @@ channel_op_res_t channel_put(channel_t *this, void *data) channel_op_res_t channel_get_file(channel_t *this, void *data) { channel_curl_t *channel_curl = this->priv; - int file_handle; + int file_handle = -1; + struct swupdate_request req; assert(data != NULL); assert(channel_curl->handle != NULL); @@ -1139,30 +1141,32 @@ channel_op_res_t channel_get_file(channel_t *this, void *data) goto cleanup_header; } - struct swupdate_request req; - swupdate_prepare_req(&req); - req.dry_run = channel_data->dry_run; - req.source = channel_data->source; - if (channel_data->info) { - strncpy(req.info, channel_data->info, - sizeof(req.info) - 1 ); - } - for (int retries = 3; retries >= 0; retries--) { - file_handle = ipc_inst_start_ext( &req, sizeof(struct swupdate_request)); - if (file_handle > 0) - break; - sleep(1); - } - if (file_handle < 0) { - ERROR("Cannot open SWUpdate IPC stream: %s", strerror(errno)); - result = CHANNEL_EIO; - goto cleanup_header; - } - write_callback_t wrdata; wrdata.channel_data = channel_data; + if (!channel_data->noipc) { + swupdate_prepare_req(&req); + req.dry_run = channel_data->dry_run; + req.source = channel_data->source; + if (channel_data->info) { + strncpy(req.info, channel_data->info, + sizeof(req.info) - 1 ); + } + for (int retries = 3; retries >= 0; retries--) { + file_handle = ipc_inst_start_ext( &req, sizeof(struct swupdate_request)); + if (file_handle > 0) + break; + sleep(1); + } + if (file_handle < 0) { + ERROR("Cannot open SWUpdate IPC stream: %s", strerror(errno)); + result = CHANNEL_EIO; + goto cleanup_header; + } + } + wrdata.output = file_handle; result_channel_callback_ipc = CHANNEL_OK; + if ((curl_easy_setopt(channel_curl->handle, CURLOPT_WRITEFUNCTION, channel_callback_ipc) != CURLE_OK) || (curl_easy_setopt(channel_curl->handle, CURLOPT_WRITEDATA, @@ -1308,7 +1312,7 @@ cleanup_file: * so use close() here directly to issue an error in case. * Also, for a given file handle, calling ipc_end() would make * no semantic sense. */ - if (close(file_handle) != 0) { + if (file_handle >= 0 && close(file_handle) != 0) { ERROR("Channel error while closing download target handle: '%s'", strerror(errno)); } diff --git a/include/channel_curl.h b/include/channel_curl.h index 49d5242..fe68a99 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -66,6 +66,7 @@ typedef struct { bool usessl; bool strictssl; bool nocheckanswer; + bool noipc; /* do not send to SWUpdate IPC if set */ long http_response_code; bool nofollow; size_t (*dwlwrdata)(char *streamdata, size_t size, size_t nmemb, From patchwork Sun Nov 14 17:27:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554907 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=tedMMFUb; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::338; helo=mail-wm1-x338.google.com; envelope-from=swupdate+bncbcxploxj6ikrbmeoywgamgqehiiuumi@googlegroups.com; receiver=) Received: from mail-wm1-x338.google.com (mail-wm1-x338.google.com [IPv6:2a00:1450:4864:20::338]) (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 4HsfRl6w7Nz9sX3 for ; Mon, 15 Nov 2021 04:28:19 +1100 (AEDT) Received: by mail-wm1-x338.google.com with SMTP id 144-20020a1c0496000000b003305ac0e03asf8879415wme.8 for ; Sun, 14 Nov 2021 09:28:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910896; cv=pass; d=google.com; s=arc-20160816; b=Zh8Ha3BgCQI2/XnFUvzW3er4BLwP7JWzIdkZOdQtIqjCacQu2HyaBvYNp6JxRy7vgT i78nJv69sjYrop/irRh14EAwzIc9gbl7KmDBjD4h3hh5SU8GQIreuBwK5AtmrGJ/ha60 b5/ZkX7brlxB2RydZEnbLBGKU/fNvvUFsa39an4zbICWDcHwsGQzGJJdkMN6DEq45qbD SA34evUOBZPysHMCfJ2Fyb3AJ4ID4DCvqAQU4p9/F8wdMjtkIrgCx/yjMiQIl7fW/zOA chYz4vyvpOCO8w9Cnmh+Y4dreUwX+SPhHDxB6geIoZlZrfwnBuVXcEeheHL71XH2K4Ab v1qw== 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=DJfYzLDnECsDb1Bd0/xZMRbHRx8E4BzLJDy7HrqJlsU=; b=U+DzIo14tYQJG2iyH1WrG00n3ypaDMOH38/LY+K4wTykVfjAJ9qRNE078wr/FN/qVV orTUzIwKa0bf7tj3weBsefg6VDr0EYR+mppiNgdtykNgJvmH2/Hr0TWFufQeZSoHqOsZ fECcfisc59doQWnIbngLQLclKfLsdcPaKvaupTOQUia6ot7n1K1l0LtduaFmJZelbgHF rCFpxHiN1xtTYNQ7owumXBjbiZhFhUMBJPPfBXLXPSVgR+PhcJ8xDpo0WA4mW6ra7+ir xa2doOHyg0tC7oMI514U+Wll5l7wtoPvB9ykk7vb0Iqv0xqjSWSf2HuhXx58YKTjJf6p 4abw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=DJfYzLDnECsDb1Bd0/xZMRbHRx8E4BzLJDy7HrqJlsU=; b=tedMMFUb3ZGslNyzpJKivfJlrn72cnzAmxIttvnFyTQXHWmS3+7gzfkkP8XOCBtYlR rrNzQ8XiVG73XyCgpeUJupeDiABDCpw4x9W9l9Z+X7ZrHvQzV8p8U+J5bwIPiCUs7ql1 eLvB92HXm2Lo7DLrqeiUYhZr5HQPI3TzEvLYO0ssCLjhXeyh1maCypkrKk48Pttlwlju KC/PPKlrQDcr+hujfBu0uCRlQn4KlmTokNQgnwhlpt4uieo3DcJzLFpSsVkaUdgGgViG FRqvPp2vv68Dq0cN++bOMrrcRcX9ZzDJkguf2B2BHnigMgPlIChywF0iWdgBaek+xdHQ UXng== 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=DJfYzLDnECsDb1Bd0/xZMRbHRx8E4BzLJDy7HrqJlsU=; b=WDjvV6CW2oEDxUCgSNV4D25/c5MR10Zd9v/u2TGiW6O5aVd4BWKwWAjE/pw0NieWxQ 8yFcKb4xypjWxR7ZAdGx2asIpH+YaoDA084TyWKJPxwTsRq9qHwNHsPmOxpdcStRD6+t 716+QbJouAByRFWLyL5IViUDcvml7xEEd6hAsTLfjC6FEoJuHYUAoVUNZ+VJpSBUr4BU ImILepJ2rX2+F+LXpFFs6u+hjyWrPTaqjbNrqA2EIMebG2MoEXJhTKz1VaA3OnqpQ28f F3N7ZCqgweYEcThVEFdMirK4Y+JCLKZPXzHpgXAgNgSAvrYpumu3u69KhxocYrqT55Qm CmcA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530YipXyyDIVkASISqXHKLY8NmVC83Xof53PkYW6vvUzd69rq1Wc FD88SSYXrkPJaXPgrXpftDM= X-Google-Smtp-Source: ABdhPJx2nKU6yxssovE80K7fuNY/MOA66nxjz404p9V0x8c+ZJTHuykFCXMANp/GzBY/r9KmvBBNVg== X-Received: by 2002:a1c:7715:: with SMTP id t21mr35320264wmi.183.1636910896823; Sun, 14 Nov 2021 09:28:16 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:ad6:: with SMTP id c22ls9086456wmr.1.canary-gmail; Sun, 14 Nov 2021 09:28:16 -0800 (PST) X-Received: by 2002:a05:600c:6016:: with SMTP id az22mr51943739wmb.11.1636910896163; Sun, 14 Nov 2021 09:28:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910896; cv=none; d=google.com; s=arc-20160816; b=W6qKV1cKHUaq2elblo2Ob8/FyKdYvm7gnXpDgjJ3wiueIxgvC7d2CSCejrJkJzJJze ZV9dSJP7USRGe4AGf/9X4LL+saUV7PRpcxsmu7iwqr0CAMLHuO2LDfDdfd0AXYFd6fCH MZDczckCTr84LByyv9h9hr08Mbsi0/0RWBBJ9v58Lf8mj0g08XaI3n0aZaFwgTtkqtws BV/H3WjZ6qjzfx4Dw/DSXmCiPWQ9bIDxlvWL8qXlOmsBG1KM370L4q1f/GhI1iA2oOvQ 1ll2y+DIuQdKu62uZNun0z8C7U4zvn584q82W+9Y55qSxIeTVsBJ2qVRwlD/cfXC9Af9 uf/w== 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=dHp+0yNnv0bcFNydsT7MzK9iqa3rFd/1HbMF+1yCPfY=; b=ZxzDUOkYWHjyYWX6p1xUJ//wfPMgmrTVGg45LX1wdARZ0AdeTdtb90k2CAByGtfqaA VXUpZYue2/eKw/Sv0K/AGpFGDVimSZ4aDZmzlT5J37T29+9QSHiYwvF+P9sOYbL7Kg/8 6tqbmyz2HpSNKOqZwaWX6O+o/O4F9u6xeYZP97YS0jcP9VpDZIHA5C8Bvp4H3AlNn/58 lLgjZosBOeyZnb5jUmsmOomd0AhPaR2DsmEFGmq47xhAEe+TniRYG/yihNDbjGsl/VDO x/lwODKUhZj5ck65ROnzWX982FR9rhisJUh4vnapz89g6WUNE450fug6jAx8Ddt1VFVY zXtQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id s138si1351860wme.1.2021.11.14.09.28.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:16 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRh05lmz1qwdZ; Sun, 14 Nov 2021 18:28:16 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRh00Dxz1qqkB; Sun, 14 Nov 2021 18:28:15 +0100 (CET) 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 wAK3BSQlCPWc; Sun, 14 Nov 2021 18:28:15 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:15 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id F257C45408E4; Sun, 14 Nov 2021 18:28:14 +0100 (CET) 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 Z_W9SaV18qzc; Sun, 14 Nov 2021 18:28:12 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 07775454275A; Sun, 14 Nov 2021 18:27:46 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 17/36] channel_curl: pass channel_data to headers callback Date: Sun, 14 Nov 2021 18:27:14 +0100 Message-Id: <20211114172733.71602-18-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , Headers callback collects the headers in a distionary and receive as parameter the pointer to it. The callback can require more information if the headers must be evaluated, then pass the curl's setup (channel_data_t) instead of just the dictionary. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index a44370b..4ae2bed 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -452,7 +452,8 @@ static int channel_callback_xferinfo_legacy(void *p, double dltotal, double dlno static size_t channel_callback_headers(char *buffer, size_t size, size_t nitems, void *userdata) { - struct dict *dict = (struct dict *)userdata; + channel_data_t *channel_data = (channel_data_t *)userdata; + struct dict *dict = channel_data->received_headers; char *info = malloc(size * nitems + 1); char *p, *key, *val; From patchwork Sun Nov 14 17:27:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554909 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=CYBgMneH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::53a; helo=mail-ed1-x53a.google.com; envelope-from=swupdate+bncbcxploxj6ikrbm4oywgamgqen26rsqi@googlegroups.com; receiver=) Received: from mail-ed1-x53a.google.com (mail-ed1-x53a.google.com [IPv6:2a00:1450:4864:20::53a]) (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 4HsfRq2Btzz9sWJ for ; Mon, 15 Nov 2021 04:28:23 +1100 (AEDT) Received: by mail-ed1-x53a.google.com with SMTP id r16-20020a056402019000b003e6cbb77ed2sf2176860edv.10 for ; Sun, 14 Nov 2021 09:28:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910900; cv=pass; d=google.com; s=arc-20160816; b=EaLWZ8Am+FhV3eBlS5vH9vEY2tsAVEQ8upuLH468usf+JuBjVysnizuYVFZmUwRUdY 6p31TbTCQpikNpAHBDU6EnFVwcrn/ftk61agapxmlBBNhzAxw72vgZK4lBy/oPC5ZEwA AwRWVm1xeYt/Vf0HyOHJiHHu7JqxN9BXbMdc/Lr1GLW9kox8fMaRJTqjeptnIjpKKgO7 ViM2khXW6z+bPT/6xO9L425r6JnX90Ob1fVq7uIvF+2nJ0/rqYDBFArBFK50zyZsqAe/ ERj7Qh0o8/BWnibnHuDSp8mGnXzu1ulaokbtFmmf7fbEw9tJhjx+rdSkTARMkFFm06pz o0XA== 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=Ilromw2X7yJ6fkMz9zp3yjudE4IS6t6k4q/qexDZevg=; b=gVMRwciMdbzYA2JUdQ15p5RQ88l+ymjytCyVM8XAmvE/CEJR8ybup+jbsjOKLAJ9P7 RtFt92XAMehjz/T7WJU3BpscFUDw9PSPHbi9t8zlGZk2Jy+s1wms7miz4apISkXpm08z 5grghb6IEo+4Xh5zxaW6KyWmldfiLviZV8KTiTqCpFwvtyq5vuDmPhAgwx0dgusJdWW7 yE2+lddZDD2rdElcTrfz7l0r+iX1Zy0iI8N/BwODQ5DcQJyqNYOZXoClsAdeQpFWidVZ HFlVL5EYpZo4TMB+3A7wK4D2EcjEcUlLPT4kJFO2FXXQAGjnhDe3NwekGZGI9uawKJCK 3qQQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=Ilromw2X7yJ6fkMz9zp3yjudE4IS6t6k4q/qexDZevg=; b=CYBgMneHVQBlNhdFSjdpeFtDfGKmbZlf+aCP5Pde45baq4hzVCeGLmp2h3qVQ55R+x H3dfn2O4t/71+Eg/fRSpvvrKlt5qlVLE3+kwsZV7p/MyzcHBw+Mq1mmGTv70M6ZLtm7r aMfZRWsAkIsDjUtoNG/pFneWL6BvbQCqTqDi7wtgMOxf57eEHzSyhuCgutmvwM1jozOF pCDqz10CFUaDiOy60pBfyTUBqlbj19zUblWeaEqTY3YRbHKOy2YuWE0justRKmggmsCp tScaUsqf5ZJd9GVs/z8ccvNtweCDOEfHS2ouoYjH4Cwg4fD05bWHvv+sF8CV9KHk4zvt DzMw== 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=Ilromw2X7yJ6fkMz9zp3yjudE4IS6t6k4q/qexDZevg=; b=z5AQn9HJPmMBhnbf6iR7g/YpjpmOL3sV0/5Gws7byJ3CkhUVqluzA9x9awO2Aj+Oya 8eiOsocJYAcgZMLCmtrwRZS5YHDYHiv8vmpRk0eL8Qv/6AmleDfAwj+Qid6HSDsO/0rv wohRCseeP5ePyi0dZpgl+QPFNHAcxBdYCh6Yl0c6Qvq769RcoQNXUDiPUeXoG+8EpFcw 7xox6/nZXa6endOUL41uZWpJI1M13AfHZJlBv5x9VrwJLC0Hv44SchV8/8ZzMNDjGSj7 TWtWOl0eGvnajsZhs+GHrxIbrKuo386b8jIHD2z6Abf6YjF/diWgDA3w+EN/SUzRoWSZ 1v1w== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533xUlu4wreyA2xVrWuPAkGda8if0IHIoHWPMX9bvTSDkSrzI+3d GqQku/xzrtRxSpWysdrmRk4= X-Google-Smtp-Source: ABdhPJxUSJI1JU8ZbO6dvo2xlBHLPaz7cfXUg8LHzxMK02zLl5HvAnlt3/G/DmE3aq20zb7+mZVbBw== X-Received: by 2002:a17:906:1c56:: with SMTP id l22mr16697548ejg.208.1636910900036; Sun, 14 Nov 2021 09:28:20 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:aa7:c944:: with SMTP id h4ls3824632edt.1.gmail; Sun, 14 Nov 2021 09:28:19 -0800 (PST) X-Received: by 2002:aa7:cb86:: with SMTP id r6mr45203158edt.236.1636910899264; Sun, 14 Nov 2021 09:28:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910899; cv=none; d=google.com; s=arc-20160816; b=WfvThibe3khM4BFw3GaHRfAF5jcgZJ9l19Q5S49A04MupSpURdMo1B/qvS7Gq9/J0B 4YD95yJyWqnSHfYydEDdLfp6thFIjjgOmZzNRT0ZOoOlapWkZcDrMonG7M2Nj5xAfFXG pQSjztC2XkGI0s9wZD+5GRNYEP3sXccZW26gyQcs4mXmnG94R6Klj5guG1doOQ+dXN8y cDztL6trskyu36LL1xQhcj76WA8kiBV/063ncaCCtwW7TS8qpo5ylu6BKI7nhJfBDcUu XwA4m1RhI9R+Btm1yVgyrmlh9nqHUSMD/H+MrbKo88TC20c7ccFyoi4oBd80IcfRrNhu 0oIQ== 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=uZ4XYBoErPW1Top5U6amX+UzF7uzJFLpN5mRtZOZ8fc=; b=jM+vl0FFD1ChKnfC4oB/A6VZepM42a8zfmIUxIj09702UkZHAVew3nPsIn/ee77U3J ixzGyATsZ739Lkrj/z1aFMtIUZmSnJ2CyK1P/c0mXS0tKCvbp6rY2WFjfv7NiAnojoRO ZgPMQDMq4biOIZJfft3eyKtSth8YhNwUqecdTHHucSd8G46C9tEBr0MhqUf4sAIeTi/V eTZiPX/FHJ1Ap6BfnGWEciNr+IxTO0GDo1shihVtRofpOb/OXkDp1nOl7+DMXpf6a8Qw f++bJhuc5NHLyf1EnMuM3l4as/Um00FqR3NQzlsAjYbuYEzIOvumZsmmGWkXNxWfXaJh LRfg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id bi21si922480edb.0.2021.11.14.09.28.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:19 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRl0GS5z1qwdP; Sun, 14 Nov 2021 18:28:19 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRl07zqz1qqkB; Sun, 14 Nov 2021 18:28:19 +0100 (CET) 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 uy9A8cdLLgRN; Sun, 14 Nov 2021 18:28:18 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:18 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id EDBD74540853; Sun, 14 Nov 2021 18:28:17 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 4GJK4RnO5Qon; Sun, 14 Nov 2021 18:28:14 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 2172D454275B; Sun, 14 Nov 2021 18:27:46 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 18/36] channel_curl: allow an external callback for headers Date: Sun, 14 Nov 2021 18:27:15 +0100 Message-Id: <20211114172733.71602-19-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , Headers are handled automatically by the channel. Add an optional callback that the channel can call to handle the headers. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 63 +++++++++++++++++++++++------------------- include/channel_curl.h | 2 ++ 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 4ae2bed..4894c06 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -454,36 +454,43 @@ static size_t channel_callback_headers(char *buffer, size_t size, size_t nitems, { channel_data_t *channel_data = (channel_data_t *)userdata; struct dict *dict = channel_data->received_headers; - char *info = malloc(size * nitems + 1); + char *info; char *p, *key, *val; - if (!info) { - ERROR("No memory allocated for headers, headers not collected !!"); - return nitems * size; - } - /* - * Work on a local copy because the buffer is not - * '\0' terminated - */ - memcpy(info, buffer, size * nitems); - info[size * nitems] = '\0'; - p = memchr(info, ':', size * nitems); - if (p) { - *p = '\0'; - key = info; - val = p + 1; /* Next char after ':' */ - while(isspace((unsigned char)*val)) val++; - /* Remove '\n', '\r', and '\r\n' from header's value. */ - *strchrnul(val, '\r') = '\0'; - *strchrnul(val, '\n') = '\0'; - /* For multiple same-key headers, only the last is saved. */ - dict_set_value(dict, key, val); - TRACE("Header processed: %s : %s", key, val); - } else { - TRACE("Header not processed: '%s'", info); + if (dict) { + info = malloc(size * nitems + 1); + if (!info) { + ERROR("No memory allocated for headers, headers not collected !!"); + return nitems * size; + } + /* + * Work on a local copy because the buffer is not + * '\0' terminated + */ + memcpy(info, buffer, size * nitems); + info[size * nitems] = '\0'; + p = memchr(info, ':', size * nitems); + if (p) { + *p = '\0'; + key = info; + val = p + 1; /* Next char after ':' */ + while(isspace((unsigned char)*val)) val++; + /* Remove '\n', '\r', and '\r\n' from header's value. */ + *strchrnul(val, '\r') = '\0'; + *strchrnul(val, '\n') = '\0'; + /* For multiple same-key headers, only the last is saved. */ + dict_set_value(dict, key, val); + TRACE("Header processed: %s : %s", key, val); + } else { + TRACE("Header not processed: '%s'", info); + } + + free(info); } - free(info); + if (channel_data->headers) + return channel_data->headers(buffer, size, nitems, userdata); + return nitems * size; } @@ -610,12 +617,12 @@ channel_op_res_t channel_set_options(channel_t *this, channel_data_t *channel_da goto cleanup; } - if (channel_data->received_headers) { + if (channel_data->received_headers || channel_data->headers) { if ((curl_easy_setopt(channel_curl->handle, CURLOPT_HEADERFUNCTION, channel_callback_headers) != CURLE_OK) || (curl_easy_setopt(channel_curl->handle, CURLOPT_HEADERDATA, - channel_data->received_headers) != CURLE_OK)) { + channel_data) != CURLE_OK)) { result = CHANNEL_EINIT; goto cleanup; } diff --git a/include/channel_curl.h b/include/channel_curl.h index fe68a99..456367d 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -71,6 +71,8 @@ typedef struct { bool nofollow; size_t (*dwlwrdata)(char *streamdata, size_t size, size_t nmemb, void *data); + size_t (*headers)(char *streamdata, size_t size, size_t nmemb, + void *data); struct swupdate_digest *dgst; char sha1hash[SWUPDATE_SHA_DIGEST_LENGTH * 2 + 1]; sourcetype source; From patchwork Sun Nov 14 17:27:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554910 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=o0bcax3C; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13f; helo=mail-lf1-x13f.google.com; envelope-from=swupdate+bncbcxploxj6ikrbneoywgamgqef6cu25q@googlegroups.com; receiver=) Received: from mail-lf1-x13f.google.com (mail-lf1-x13f.google.com [IPv6:2a00:1450:4864:20::13f]) (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 4HsfRr2GVdz9sWJ for ; Mon, 15 Nov 2021 04:28:24 +1100 (AEDT) Received: by mail-lf1-x13f.google.com with SMTP id d2-20020a0565123d0200b0040370d0d2fbsf5818000lfv.23 for ; Sun, 14 Nov 2021 09:28:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910901; cv=pass; d=google.com; s=arc-20160816; b=fD2FttuauutTe6kLZo7ksLS64y1FhcX3aTxSCVtQV0TpjTMGdg1wv35IXWhI65ALNG 7Kh9px9ZRakB02LKDzqypQ+IfKWcNQPfGgrPW1E19nuhow7C99AIHXU8PutzHLaYZUxJ THFPwJCT0RsCdqYaEScxn2787S6lohWvP15b/pOUAy2nWb0Gpix602geyHEMeonaoQqc jDr8/klaOd1yJeSjvAFQg9a+lNuM4NY6VSUnTFQYrDDM6zJkLM4D1AgzzVEXgRayzS1F CTqzC3ZPXQ5feT8Q7dFk59NT86UOdPbohGpLwpa4gjxCmAbDbEDK5qa5twEzjqXSx73w XJjg== 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=khx2IgDpcLpU3YCa4Q1oECj7+C1a9xzrbwZLTbjcLdk=; b=iSS0XaMtaq2rB2B2GeUssmQ3IUTOlPLi2Lfr8oQipyuB+yIMG4sUceYwg836f8HLrn tYABMh7KXRyI4bhGaRwOlxTFL9b7Ll/AlgRdfKFnxtWQdJ0sSdNpdAM9ypiNCpnKkuGM nvtybsXvNbbNgb9VRFnk8D6jawl7eF7osLo1fiC1g2ivSY7TQ9l0ewjPwgjdua5xHao6 xOLzuG7oWKqyYKj+3lUwB7knZiEKhUObayhFw4KdtHkihZBguQ+U3KD8FiewugOv9AwT 0smChtHZmSqDwyHFm6+TvDa1rQ1Uc9K+U176pQEjCzUlzDzLbvVZPRIl6yZYdrkcxvUZ rA9g== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=khx2IgDpcLpU3YCa4Q1oECj7+C1a9xzrbwZLTbjcLdk=; b=o0bcax3CMbJ01H33d7Dor+Z1OB2i65KPxcTGxKZwixNcEYwVPKMvZqRLHzX9oRJKdC XewNu5G5cJTwgIWIO7I+pPQKbE7KydCMJAqMQMYveUIGCZYfTlYnjz6kqSATpiEFKrxt d3DEor4Fth6UklmMcO00JGyx7uKlguB1nWa5nqP+CAGCAGmEc3j/yf9El7itfCVW4tR0 QA/6WrVsY2WKtNTZU4RjT1eqvHyVlFo/EO8XUy7HXsaR+ASmZis4cClnWltGEm2m2RIK FXo0K0EO4YUd4REsEMsVPQ3KVDYaarIdQiC7jsaws43D82URPd2gbSoSAMv0UZzXxicI Luvg== 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=khx2IgDpcLpU3YCa4Q1oECj7+C1a9xzrbwZLTbjcLdk=; b=gJFo/n0GQ/frmBLV1+RmafwKa6A8NTsFh1WXIhQNEdaXiKPACiGtWuMrLNV/oEibrR rJLd+Z672tUp/+qKBjpclNeMmZTiR0X3BqUWnlo1m8QVs7BKTeuTVlP6zV7N6fz6JSr5 +oIXyox1c+STEL6tif4o3O79rNEg2fFPnLIL9a998/VCNvsiHXqahtpK2U05lUnnPXCQ jY4NGkDMCa7pWmmfLvoUauXbjoHhjrNvO1ETgH87mxzN607V1sSSmmXMuBRvRhqhDhP1 OrSjHpLed4YeipIYWw1433LIPJ549c7uABsls3Kx4jQKVWuJFsyfJwGacy54L8ApL2ti iT4A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5329bN3Y3Bi20m3OPv9fzNYV1adKoCTZPQWjdRfqX/FmjScJLXSG fFia0Mz34ZfDBV2YSfyruVY= X-Google-Smtp-Source: ABdhPJyW7cr7xnSQlZhhB93I010kmCMUZU36/Mr25yzQruLjeSRWE9Qw6Gqs0GboN3IuJLYmNPu4Ew== X-Received: by 2002:a05:651c:1799:: with SMTP id bn25mr31554112ljb.514.1636910900805; Sun, 14 Nov 2021 09:28:20 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:651c:b1f:: with SMTP id b31ls1835015ljr.0.gmail; Sun, 14 Nov 2021 09:28:20 -0800 (PST) X-Received: by 2002:a05:651c:2123:: with SMTP id a35mr32688132ljq.285.1636910900076; Sun, 14 Nov 2021 09:28:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910900; cv=none; d=google.com; s=arc-20160816; b=Lrc32ClMe5faq0HgppPG2EElBBv8DgyRkKfdJMNBHtgw+VMlAnB2T5K9tZy75JYfWq eBR+DNxJhdOPH/BVOAnVjoVmLT6OiJznrM4goSYQ5xCgn70rXwB8crv6rQlfofUXfgWJ HcraZd5qfunoTT1eGu816Mj+tC5ht2hvybcvsRLHUkVn8KrMLDwyDevOYF9d4jm5vSa0 4QJsFw9gwtJp6FOzbfYmagpknGSRf5Xqho8ZuzMVzRKce1FuBFvnZ6+oYgPYXSFjjzkS 6qroMA+wbE/qBJRZTrvDA9oNFNby+knSY8w3PVIHrycPtnLR9yiY4sj5KYsUAkJpDKJo NDGQ== 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=g/Tv6HK/z0JagTkWPyHhOaFcr9ZhalgXU26WITZvq9w=; b=xbfC554ReaorNoPl947oNhZWSCF2gLbpKVJ6hc1U3f5KA8iu5aUvpWUATeSzEvA997 Hbap1Ow6RSL7TAwmfhQH/MlSNrkivMtDAfnslWttKBVio20WSeuB5t/knhO2zqU6GLPL ICMKhqpapml2KwZ6auHgs/LvriDJGNxSXLN8E0G8imFL96Aiz94NUKpbAAQyfQ/11FJX /h4/JgVGjQXsHuguv4Co8DZMf2vbyx0GuE9daVKwEzEHA3U8bmeQRh6O7ulwCeeyTpYF G1aU+Njx4E/oZym7CyfRRwkH3HaphqQBcJjxquyFqBsvtvmblrSNvEnA366rgNUdTV3I ltvw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id g21si474518lfv.11.2021.11.14.09.28.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:20 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRl4Pxtz1qwdP; Sun, 14 Nov 2021 18:28:19 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRl4Jp4z1qqkB; Sun, 14 Nov 2021 18:28:19 +0100 (CET) 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 ZNIQ6AnUrs88; Sun, 14 Nov 2021 18:28:19 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:19 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 79C6E45408E4; Sun, 14 Nov 2021 18:28:18 +0100 (CET) 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 nVb7MapbO5fi; Sun, 14 Nov 2021 18:28:15 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 305654542774; Sun, 14 Nov 2021 18:27:46 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 19/36] channel_curl: add optional pointer for callbacks Date: Sun, 14 Nov 2021 18:27:16 +0100 Message-Id: <20211114172733.71602-20-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , Channel callbacks pass as parameter the channel_data_t structure used to set up the transfer. Add to this structure an optional pointer that cna be used by the callbacks for own data. Signed-off-by: Stefano Babic --- include/channel_curl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/channel_curl.h b/include/channel_curl.h index 456367d..7d1e892 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -79,4 +79,5 @@ typedef struct { struct dict *headers_to_send; struct dict *received_headers; unsigned int max_download_speed; + void *user; } channel_data_t; From patchwork Sun Nov 14 17:27:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554911 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=MgWKusqy; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::53a; helo=mail-ed1-x53a.google.com; envelope-from=swupdate+bncbcxploxj6ikrbnuoywgamgqe4zwvqwi@googlegroups.com; receiver=) Received: from mail-ed1-x53a.google.com (mail-ed1-x53a.google.com [IPv6:2a00:1450:4864:20::53a]) (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 4HsfRs60P7z9sWJ for ; Mon, 15 Nov 2021 04:28:25 +1100 (AEDT) Received: by mail-ed1-x53a.google.com with SMTP id c1-20020aa7c741000000b003e7bf1da4bcsf794781eds.21 for ; Sun, 14 Nov 2021 09:28:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910903; cv=pass; d=google.com; s=arc-20160816; b=OIzJf+ZRLCPLwUiuGBn+VB0Tr+e0iwCDnpEsaRmLAEwqZKdcHuWVUYve7/TWSXu45w ByHOsMnK9SjqsS7AJDDGDS+ajTy6z6rFarpF7krgl1+gCiycwo0RhPdb72DjuI65TFrc kr8a0YuLdfg2AEcxQYZTOvs4W81hHfxWjVA4DOJosCaCVkP/VmTIUfkN2uJJdpXGLyX7 mZ8N0IV4Yv/Q6tfsaj9dLZvuIn7Fm6E9Jh/YvokijKeLydEmuitq01XH0717NNC0QGlj JFeivXlYjvlz8z7jIz/jqWmKref2kYV2hxeGA+bKLbHmGb6VJwjgoWIdV9/d6lGIemR/ lwMA== 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=qjdA0hIU5Ww1GMV722E0wSePdCrOLOoZtlJjQXw8geA=; b=HMOtDWtIPUzsh9Vy7qnIwzsqxB6NQO2DSQRS5S94Y2PZ2F5tz6sD0NJs9zSvuDlG62 q5Wy3wtEjnjmyLSJD9aFW3HE9o2JblGJddBdjqTUZcwG+jwDFGn8QzEgWjTtnjJyRf2C 6G4OdDuWADaJ8sncKMci35XN8iCyCkLYPcWIZ49zvLHBo47vsH1RMbHLfY28HQYqdGHj bpe5cqJvRFPFFTJpCkI5rCTguwmMRK3JX1FLbw8kELx1vAOTQC+V+e4Yk91IE3YGQUk4 YZPvGtj3j3Xqkx/JDboHMSVsvxkhH58LVzg+qg8A39jGTOgBfd8ouW8fjiFDkis0sicd 3B0A== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=qjdA0hIU5Ww1GMV722E0wSePdCrOLOoZtlJjQXw8geA=; b=MgWKusqyUlqK4juu9KY0HRjAFd3VfFWSkIkXq7SfziBF4d1cF62dYhTGk00XpYiFuz KDXcaQol4SVWTkcIEvwgDaEqSD2BPoPnAPmIk64QnJh3FFejjqQgFyLR7j/e3f7f3OWS Sfk2rUgbRVYseHr9L4RGB0C/bnXcUFUeLQEkzaOklN70U1guybq4PPr8JWFPvtykQ0ev 12R+XUPo6jDAPu/6cWRhRBZmnv8OZMBgnZP/783tbx4PG5LwwYGUE4p7QlMhtMGVNoA9 CFM4RzwUkActcRBrfNPehRlRCwNv8zBhmda1f0ZvHgH9+5wEoD4ToFb7zVpl4gFwGIm/ ZfFA== 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=qjdA0hIU5Ww1GMV722E0wSePdCrOLOoZtlJjQXw8geA=; b=UTWxYl9M+K9hxhfvWSdabHXx0s/CP1/5RK+GvWsc+iYSLcMpBd/0DJaxfIJoQI4IYz dpH7fbjYz9pkzKEXHrHPDWGpxbX0Xh0G5G6zOaPRj3A4tQFpTw8oJlvjZLIzdSRQ3qVu 8p3bYc+Skab7XwykUCo0CIQ4YYJxI2azKSzslp6bkwfc5uWj4Q9oG0282Vqg0mczkJV7 wkzsHETwXUqTXlhcYIMvPYubaZgytb+LgvW3DKo6tJrG+6PbuUrQgIC9pf6Iz/qVpXlR YuN8sc5pxjJ6HEP2u9UnLVOwgBarqy4e8WPqFq4XY9NjgM10+ACM73DuSHPgETJc7K+D BtWA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532F1xV3XSKCvH/GU+16c2F1YnkwP553ygmODtJhlpNSkUscxkL7 pvt36np/Ex1o5hmptTfecK8= X-Google-Smtp-Source: ABdhPJyPXeGUVorkk+uUMPsXTxBLJxdG3r3tZLjKbp9xuBdcMo3q3dvj5yOhaK38Vs5r13cP90Gtng== X-Received: by 2002:a50:8d47:: with SMTP id t7mr26505941edt.14.1636910903176; Sun, 14 Nov 2021 09:28:23 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a50:8e41:: with SMTP id 1ls3821629edx.0.gmail; Sun, 14 Nov 2021 09:28:22 -0800 (PST) X-Received: by 2002:a05:6402:34c1:: with SMTP id w1mr3351418edc.179.1636910902314; Sun, 14 Nov 2021 09:28:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910902; cv=none; d=google.com; s=arc-20160816; b=PrKpl3KCIqZjEfusdcoic74Y7F7cygKMQuco7EAhBjI07toFZfbnCoNxOWTDEU8Xke 8zFnwM2Os6cDiI5Z+UOqeFBB/jaXl5XQPpSuol8BBzfH8urIl9187uNfPsgE+AUq211A ZG44EGQ+USA2o+DVXaOdT6IyOJuS2PJB3N71YL1/HMlSSgqHSHTi4Qgdd4ypZkOXsXwC inpiQR5XWY7hDyErVxf6+s0nu6xNI6vtTOLFk+ZeyPBLrleIyCmnvuR/42EEyopq4QZR /eTgpWvBxpsFFC2Z0esnynHA0lIcm/iALkqqPleHqZspVz/v1O9PJQEItOEBAm6rQybS t6yg== 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=w7zFaIVVwHOZkxyLyTFcX+fmHTPJdNOqLruAOyRoz60=; b=ZYIBSaHOTDcK1ZSstEnthp+IsjNybWP6JiaQKJRIfwSq+HT9e1x5y/8WsYsAp4SnMo ESSpnfpdBDpeRpni4o7ZxWJWlJx+C5NRyqL58xiiYP4Uhojc55ri8lTFQ6s4ECGgZJX8 uwgp+zBV2nHxaZgKk7BKWaarvUT4itkNvF5QUyXQy8EZkxNi0lfScTNCsOHrHKS/dTwx VBc1kyAvYp+vzVd9f5mwQ07aKPPALg2I0PcHLV7rgtCXXMOK60+rLXMzPN6oPwT8xfzb plxOWptw/aqRBpeJ9g4eBkKjBMEh6fvZRB3oR7yxEzjMOZxFCKm71VW1PDKuL9xZ5Tnc Cdyw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id k2si665127edl.2.2021.11.14.09.28.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:22 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRp0kMLz1qwdP; Sun, 14 Nov 2021 18:28:22 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRp0bkkz1qqkB; Sun, 14 Nov 2021 18:28:22 +0100 (CET) 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 qG2uYGLPCclU; Sun, 14 Nov 2021 18:28:21 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:21 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 193034540853; Sun, 14 Nov 2021 18:28:21 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Qz8gfjV88Ebp; Sun, 14 Nov 2021 18:28:18 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 3EEF94542776; Sun, 14 Nov 2021 18:27:46 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 20/36] channel_curl: pass channel pointer to internal callbacks Date: Sun, 14 Nov 2021 18:27:17 +0100 Message-Id: <20211114172733.71602-21-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , Channel can be used by the callbacks to call curl functions that can be evaluated later. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 4894c06..a916186 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -53,6 +53,7 @@ typedef struct { channel_data_t *channel_data; int output; output_data_t *outdata; + channel_t *this; } write_callback_t; typedef struct { @@ -936,7 +937,7 @@ static channel_op_res_t channel_post_method(channel_t *this, void *data, int met channel_op_res_t result = CHANNEL_OK; channel_data_t *channel_data = (channel_data_t *)data; output_data_t outdata = {}; - write_callback_t wrdata = { .channel_data = channel_data, .outdata = &outdata }; + write_callback_t wrdata = { .this = this, .channel_data = channel_data, .outdata = &outdata }; if ((result = channel_set_content_type(this, channel_data)) != CHANNEL_OK) { @@ -1149,7 +1150,7 @@ channel_op_res_t channel_get_file(channel_t *this, void *data) goto cleanup_header; } - write_callback_t wrdata; + write_callback_t wrdata = { .this = this }; wrdata.channel_data = channel_data; if (!channel_data->noipc) { swupdate_prepare_req(&req); @@ -1346,7 +1347,7 @@ channel_op_res_t channel_get(channel_t *this, void *data) channel_data_t *channel_data = (channel_data_t *)data; channel_data->http_response_code = 0; output_data_t outdata = {}; - write_callback_t wrdata = { .channel_data = channel_data, .outdata = &outdata }; + write_callback_t wrdata = { .this = this, .channel_data = channel_data, .outdata = &outdata }; if ((result = channel_set_content_type(this, channel_data)) != CHANNEL_OK) { From patchwork Sun Nov 14 17:27:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554912 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=F9v55GLo; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::53d; helo=mail-ed1-x53d.google.com; envelope-from=swupdate+bncbcxploxj6ikrbn4oywgamgqejxgvwvy@googlegroups.com; receiver=) Received: from mail-ed1-x53d.google.com (mail-ed1-x53d.google.com [IPv6:2a00:1450:4864:20::53d]) (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 4HsfRt6C0pz9sWJ for ; Mon, 15 Nov 2021 04:28:26 +1100 (AEDT) Received: by mail-ed1-x53d.google.com with SMTP id m17-20020aa7d351000000b003e7c0bc8523sf383563edr.1 for ; Sun, 14 Nov 2021 09:28:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910903; cv=pass; d=google.com; s=arc-20160816; b=x1LM4PAUZ+2oJkCy8Suf7rVQ3SJAiBE0vReYMP7Y8vNi4NxKrh0rsFhINLEomK/j+x LZ8HUFh0vddv99GLlcqHqghnG6uM5hsp5jbDeQBufpjvn1RGL1fqOnWbrVCjitku1JaI qpxar2IS01FECC8W+kbfU45xyzrd5/1kzbT1b7Dxzm4mGsnQ852gEAh2foVI3sdXJ5bL hAIGdwTOxR9Ath9EiAHHybt8uXbuYle9qCgJ5h1KfgZCmcIGsVefCiXpI6erA0p0XKK2 lKOGJWriBmIU974ppazFFE4PnDU4GtRjtA5xGrnROt4IFghW4vnYtMQPt6KGyBIItrW2 4PGw== 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=xVI9LDF6KLuZ810x13faimRA2KIX7M+PvLkJ6yjruSI=; b=hV+L3cDHcziOabzgQQLFjKqSdD+FsUJHy5T9jHJptHR9VlwhFCD4RYC/DnewcsbDxv MgfzsG4Ec9uqRG5wIZ6aSzNrjTrLq0Y/ncThgCl8j4AKem/H4FmyroXereDN57yMEN46 YSsY5AU4ozHdsDWo44byJ+ArLrRLU0EiRsckjXtCUDyl5Mlxo3ekHgeYxEo7L2KvtAEZ 7vmyYhvWphNg2dvSIgWix28haud0rpluZxGjK5UVcUkI5twLsnXxctjK4o0Ni6aGa6+N 4FURVJwtSbIy86KtWshlzIVgt7SaJplSYkxx7lTWhju1ZYyvLS+q0MySCG+Ja6LPqIDA y6vw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=xVI9LDF6KLuZ810x13faimRA2KIX7M+PvLkJ6yjruSI=; b=F9v55GLomLaV8MHAn1SxIKx8CCr7caSLZKuMSgNTSwbnPbe43gP1v6MezF3rCeL8gh 00PwPFoppEdjkj/9a3RclXAN+rlTBAUGPlxUFACkYZU/QPTJWrtoN3r0yw3QFo+lOWYi btuneh21kTRTAKTxfXZTS05XDBA/hh3nYB1ipQKG9xMP6wzR8k/2z9U1HcTKx0aAQltp zA++YOuQc1d38Ki+YfOHNqI0oEST37UaNjX7y8KTOuKMeTLVTeg5zgMoVVgxLrZzz+y6 sS7elfHcnapGRIkSn2VAk9wWfDE3TwHJhMbvXJDocADdKZjPFD6EzSVAo3EoLp6+suf7 CKuA== 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=xVI9LDF6KLuZ810x13faimRA2KIX7M+PvLkJ6yjruSI=; b=ktZYYmQdeA1oRCaMeqw+RlSO9aDazKJrOXPKf8TzO76pVKKbA+nitzHxL5tYK5geh8 KCIpbR0ulZh/ytFmRUqo/3TxDslXKAG+EoJ08A7hYQeY3WTNEweMFiEch7G5cEAyZqZD OWPDW7FO9QZ30szT2FAil5/ETQLi5Vykt6HTABGQKCu8LXtWmRx9NJ5kOCQr2EWmvC7c 5EZDxtjld0A7Znqzz17Br+3fj1WRlRVlYun6dCP2HwO7pqcHqJ1/U9MjqCLDFtFDPE7Z Ich+q5xB27MIlHHaDCPD4DlxsiMvU/xqheCEvdZWZdZr5pq9no8wvWcNUHNRjFqCL2Si pDnA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533EypwrqvRBvL1cG/lXuEAvGkJ78NKUTGCTQbg4I/jLyU1IOhJF Rcej+2Nl/NH0EjoclpoZcWs= X-Google-Smtp-Source: ABdhPJxhVhUF+4O4I0xSUddpNbVs3pvTi0fSpOh7/hxxleGqB8pnIRPBsdDvX2Nd7Hn56iDPcFNj1A== X-Received: by 2002:a17:906:9501:: with SMTP id u1mr40740881ejx.496.1636910903576; Sun, 14 Nov 2021 09:28:23 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:907:7f8e:: with SMTP id qk14ls4641526ejc.3.gmail; Sun, 14 Nov 2021 09:28:22 -0800 (PST) X-Received: by 2002:a17:907:1c15:: with SMTP id nc21mr41806176ejc.510.1636910902770; Sun, 14 Nov 2021 09:28:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910902; cv=none; d=google.com; s=arc-20160816; b=J4Cpbni1c8/ApMCvBRPjGNnQG2y7H9nJ/WPrpQRpsu/hcJ40J7845miQr4/DrfA0lV 2oz4xLQvfKiZeP4X09vaTu/sMhQHgeVUfgYofTxtgl7BYkw7KsBV06fe11kGzTtuWjOz ftyXOw2LULnjVOhNE6g29ZsTjf3ZmzDvzejE/RS3a6PE7nPtdBfan7tBBOBYZRQiTGqD 23DvF50H+pKsxEZYhnAItqUDv/yXs0XCzb67/7XjpFCWXNEIh9AUiucaVZTZqEKhvtYX o7q+w/Wm0ViCYUf8lOcau51/6sGAwh9bAgsUBYDkH9RGmLqBv993BvSOZ5KtRobZv2J0 5xSg== 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=xGrsaxQ0z57Pf6QKsKD9VKfpk/48gKlurFmKeECH7mQ=; b=c+BEBnWJ9Z3zsVJTiGArO1LIBMJHYjy++54NJwOuMQd3XWUcw+DHnm5vAX6Ujjgbox ncnPIuZs1YP74XYByb8DQfCK5prOy9mAABSkwb2wz94NoskX+FCqzXmkrc6RaCZTt3ah GcYD/z6+Tcw036pC6ITTHp5E8KB+IkHHNFOFqgvaLQF+nnzTGF6ZYvkgUaRYzacMkteQ n5vK4+H8mZJzELJKFAzHsbvBkSdeNpuANPCjBSU/ao32JqiffGH4W3KtgurY1tgb13rB DAu36+/dQWL9Jsl360Gt1CZ8zmf+SrEif09kM56+Wbnjm+uMQoeopRHGxzSvj7AMbnPD X5/A== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id bi21si922495edb.0.2021.11.14.09.28.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:22 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRp3z4nz1qwdZ; Sun, 14 Nov 2021 18:28:22 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRp3tFdz1qqkB; Sun, 14 Nov 2021 18:28:22 +0100 (CET) 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 x6aDtEZOuC3d; Sun, 14 Nov 2021 18:28:21 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:21 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 8297545408E4; Sun, 14 Nov 2021 18:28:21 +0100 (CET) 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 HNM1J_l9y1o8; Sun, 14 Nov 2021 18:28:18 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 599F74542782; Sun, 14 Nov 2021 18:27:46 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 21/36] channel_curl: add the possibility to request a range Date: Sun, 14 Nov 2021 18:27:18 +0100 Message-Id: <20211114172733.71602-22-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , This allow to set a range request for a file to be downloaded. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 9 +++++++++ include/channel_curl.h | 1 + 2 files changed, 10 insertions(+) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index a916186..39c415d 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -753,6 +753,15 @@ channel_op_res_t channel_set_options(channel_t *this, channel_data_t *channel_da } } + if (channel_data->range) { + if (curl_easy_setopt(channel_curl->handle, CURLOPT_RANGE, + channel_data->range) != CURLE_OK) { + ERROR("Bytes Range could not be set."); + result = CHANNEL_EINIT; + goto cleanup; + } + } + cleanup: return result; } diff --git a/include/channel_curl.h b/include/channel_curl.h index 7d1e892..4409dca 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -79,5 +79,6 @@ typedef struct { struct dict *headers_to_send; struct dict *received_headers; unsigned int max_download_speed; + char *range; /* Range request for get_file in any */ void *user; } channel_data_t; From patchwork Sun Nov 14 17:27:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554913 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=m0nRD7i0; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::339; helo=mail-wm1-x339.google.com; envelope-from=swupdate+bncbcxploxj6ikrbouoywgamgqee25jjji@googlegroups.com; receiver=) Received: from mail-wm1-x339.google.com (mail-wm1-x339.google.com [IPv6:2a00:1450:4864:20::339]) (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 4HsfRx3dVtz9sWJ for ; Mon, 15 Nov 2021 04:28:29 +1100 (AEDT) Received: by mail-wm1-x339.google.com with SMTP id o18-20020a05600c511200b00332fa17a02esf6922621wms.5 for ; Sun, 14 Nov 2021 09:28:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910906; cv=pass; d=google.com; s=arc-20160816; b=kaNyZmiNuEYUYRzhmmd4nBRnYYK40RCAYcSUpsA+vgymwpBeWxiuwDCVJfLdOHv7l3 mZGFp+Fy8Z8EDQL1aF+Xqb1uqd0GqXPNTOHD0M/jW74XDvSwDe/UClohwTYDhnhwu8j+ cxNENNYAOIilXAMFx2d8VjFE12s0yFf3ZjeZLRFU6sfTXlV4unoIXUfFSBl6F9eg+bPd 1Fkf2nKPcj1OiPoBg1/ww7cHpTEAy2KGRrjJwHE5ooX828rVMYP+HOvD/2CHEDGwiSEa j0CXmSyd3dWrdrJ1YCNxzSyUCVaxDaB3I5iftriz+v+v2bHh9Va3P9raKcIGxluRNlRW 1d7w== 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=0VxCc2NsH5mn6bs4ps8q2I9WgwCkMnm3YX9IBbHwIlQ=; b=Z4ZsbsyvhQCGNhd9bXOYOg7xi6LESUzCVZTX8XRj0hxTz9vSyNvDiIOGecPzblRPOW uXAbKEOoVxDcYKEqNtbynf/hsWTeQvFOlPfas0NIUipQoukvs7Qiousc5TrbH5LEPiT1 s3SkeCn2Adi3aZwXPtDWPwhyNUxkpKAoC0G7UlqIuLmWew84RwXoXXY4knLZRFtQq64w q5Mooy6rn6eZlq+vFBwUKZ7dWNaHL9ENRWvhBM77F4gMpXGzWXSAwk44KPapoYN+g1Qj ruUS+bFWj0/OnBht/lQbGwvSbmmuL+nUBZ0fAGaGTa3ayFvU7kThWEcquqsSmisJHVb8 YfOA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=0VxCc2NsH5mn6bs4ps8q2I9WgwCkMnm3YX9IBbHwIlQ=; b=m0nRD7i0Ev1Wgl8A9TIcIC6BPScU7TX7nl6AZdQe46hBOmY7V0bphT6IzhPWKRLC+W P9sFrNBYVSDArzKA2JBV2MYXZp3bn27yqnpGDwhcj/IbYgNjTVxK04k9634ikjO4thUi AfjGlsgOvl7aaZVo99FE+sGO32RQB4h8nmTsf47NS7eijI2+UGCSbZxK6jdu23oqbHv4 +cpZ46d+8dSq5OHo/lTFYn2x0pmvbP0FAvFGi53I+GzRr2vbrhzrbD++Od4QVx1RfdU4 B5cFxnFtDrxMtGMuPcss29JLrqBLbkln1/gUhZCh2EVEjQPgPyFpVcBOOsl28UdXDONx HM/A== 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=0VxCc2NsH5mn6bs4ps8q2I9WgwCkMnm3YX9IBbHwIlQ=; b=T+a7IoaIijYudwD4GqLT0eEHg0SlwUkPO7oKEaLl3M+LXi3bgEXbTlxjCz9zW787XX kbUqihPtPImTW6HdO02SmZzGqrwkqljrW1wE81lltosRRG7G1o1C0irIVIzuOSc3F83f nwJfIHO9Zcz9gxf8yfpXK4KJca2Osfv9S8fGxoxbeRlnM1IJneuOsiCkQ2bjapixzFrI mfpy/6LvJu1KlGLlB9OZSm4O8b7+GPj+4NVymuG3Oof8YOiaRuc2l6Z/VNj41kGSIXF9 4N4nlgRXypKXNzI7zadzT42qkx4X5TcRlOXQnyIn+Dz+8lwIPWM+WwJTv/QaBYsoV7eD w0rA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5303l8hl733E5q7UgnVa/IBOrK5+e0oZ6O6SSxS4QeAR7S56Rl+z jyol9jKp8L8sizcsvEFIigA= X-Google-Smtp-Source: ABdhPJzzq/bf3nqN22Iofq6abBs3Wd70Pkb4FUnd/pEiCvlFWUBzp2uAFNklD0o1f1gZZFQz5QPgqg== X-Received: by 2002:a5d:46cb:: with SMTP id g11mr38851796wrs.26.1636910906222; Sun, 14 Nov 2021 09:28:26 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:fe0b:: with SMTP id n11ls7201656wrr.0.gmail; Sun, 14 Nov 2021 09:28:25 -0800 (PST) X-Received: by 2002:a5d:568c:: with SMTP id f12mr38353311wrv.240.1636910905420; Sun, 14 Nov 2021 09:28:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910905; cv=none; d=google.com; s=arc-20160816; b=bh3Sh38b+gdm+Q2R/gm8L6rCrtcG6ztKAJvZ/CvhbL27/in7o4vN3IZl4N6Yp/hKdh hP8KrPzbKp1/algWwByrHkHX8INaNml7fyCnn0mIBuGyHGfjGxGwdhvNO6fEYBdSke18 MjVskto33sufBfyT8jtaIQxgt0H7xuD4ebomWodvGgf/CypckZ1u9x4gWLkKi3Xzf2Fa /9GAA3sqUYJy5f7zHVkd/Ae7E9mbHxmAz0nLybd2VrZ4uH/eXfNUHnlvTbLrDomYXQiS 6dgd7JnZFM97n0Fgnb339q2tpSs2l0mCI4FqogIitfIpUJ9RNULJWmUfDD+qMFmMXLw/ moBQ== 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=JYZI3u2t+Smpa5Nwd3EsT5ZRsknAeep2zIeN4dCuJrI=; b=gr3rrsohRHQ2fkePcC+gUzXaCmHDzDWJsaxM1mpigEafy4bsmRj4Omz3l0EZK3w/KI gj/bHB+NatBSezzGFcMpi2yYvCahF36XGqZpVut7RvzYLMaUnBuQ/bI58A0SxTG3H5Mw 91zZ3wTxsQqB+CRf0cg8khUno25rpFWZEYZFnAinXoRfXwf02dJNO/8cZ7+Bds2Yzp5K 6zzTwBP3xsPVtpkO7/rpxpYVpkwWvlCY/04thF4ftVqcT6XXMgyR2PB6iVIVzxT3PBlt wNHSa/V25WR0RFnflJ8+Yt/cnH4DZ2KeFM59dgxAkLcd2tg8DrxDH1vgOTzyH3pvziLy O9AA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id w2si599131wrg.5.2021.11.14.09.28.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:25 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRs1xmVz1qwdP; Sun, 14 Nov 2021 18:28:25 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRs1qMFz1qqkB; Sun, 14 Nov 2021 18:28:25 +0100 (CET) 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 iX_2B8hjVwvd; Sun, 14 Nov 2021 18:28:24 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:24 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id D742D4540853; Sun, 14 Nov 2021 18:28:23 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id UaH4iVRim7Xs; Sun, 14 Nov 2021 18:28:21 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 6835345427E7; Sun, 14 Nov 2021 18:27:46 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 22/36] channel_curl: do not check download size if range requested Date: Sun, 14 Nov 2021 18:27:19 +0100 Message-Id: <20211114172733.71602-23-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , In case just a part of file via bytes-range is requested, do not ask the server for the size of the file to be downloaded. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 39c415d..2b9f178 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -1143,14 +1143,20 @@ channel_op_res_t channel_get_file(channel_t *this, void *data) } download_callback_data_t download_data; - if (channel_enable_download_progress_tracking(channel_curl, - channel_data->url, - &download_data) == CHANNEL_EINIT) { - WARN("Failed to get total download size for URL %s.", + /* + * In case of range do not ask the server for file size + */ + if (!channel_data->range) { + if (channel_enable_download_progress_tracking(channel_curl, + channel_data->url, + &download_data) == CHANNEL_EINIT) { + WARN("Failed to get total download size for URL %s.", channel_data->url); } else INFO("Total download size is %lu kB.", - download_data.total_download_size / 1024); + download_data.total_download_size / 1024); + + } if (curl_easy_setopt(channel_curl->handle, CURLOPT_CUSTOMREQUEST, "GET") != CURLE_OK) { From patchwork Sun Nov 14 17:27:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554914 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=kK16bNgq; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::539; helo=mail-ed1-x539.google.com; envelope-from=swupdate+bncbcxploxj6ikrbouoywgamgqee25jjji@googlegroups.com; receiver=) Received: from mail-ed1-x539.google.com (mail-ed1-x539.google.com [IPv6:2a00:1450:4864:20::539]) (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 4HsfRy1M7Dz9sWJ for ; Mon, 15 Nov 2021 04:28:30 +1100 (AEDT) Received: by mail-ed1-x539.google.com with SMTP id v10-20020aa7d9ca000000b003e7bed57968sf828888eds.23 for ; Sun, 14 Nov 2021 09:28:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910906; cv=pass; d=google.com; s=arc-20160816; b=smIqarhpGBh7drPOZZ8e+iPgzi/dlbNlIP4um+l98t2tHUusVOfLKQOH2utdRMrUa4 qdj2DDege7cn4abqiHvisVzH4FCa6h7LUa2L3dFeFKqH2xYwpp/dqDTOPzV/hRJ3dlVf r1/u1LjpGhA6lCvnk2cmhKHS8j4qUZ/feT61J+2RilVy2KCPWAz8N/K1EOIsdPvRA/Rl hgDhBk/Z+5IoNmx84nFFhldXwhdBqXkd4N1WVAq7TRnIYm6cSJxAJVbjaYaLZW8xtYgA MCgJk/T4PGwLbdltxzZJHcACMVa6AZ9P2ZU+nPpdEZnk65uqViCtmdPk4XkR9nM7neIe BisQ== 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=F1V2tHYbIrfXQULWCSXJBEnbookFQmxf2kmusYtyo9w=; b=KHEiO36vbn9VhiCcybjYWMyZ3rmGfzdQAoj31zIomyc8mRUB96W5sZGvFIekp7sErr r78IU226cGkfv415mydsQBoXPhPzT2lPLCqw1C9nRhJ8aws7lfXp7l4LRTPFb5StIB8x 3DWn7RSPi22yy3iDLzFYt0ZKKyB5Z/3MTUOqssS2MBBAy9a1Nll9nn4NS2IWEu2auqXk bbqifRci2ZDiDwRsxYqbO6HWu4ICeM8juRRhXfsuuDJrNOV4uR8r6wuQcuZO57gJEamw dexWwAriY86pUDZ5lPf0jhGslg8mxxP0GaHBV5iUQQZBy9pR0nlIDZi0qlhEcEfx64rW FUQg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=F1V2tHYbIrfXQULWCSXJBEnbookFQmxf2kmusYtyo9w=; b=kK16bNgqwnhUo3JdMbQfKSFNcyhjIx/bXKv+4k1b/1Wj/KIZayYJc4yfaNJ70ZcDk7 I6SooQCcqQfrBR7kZQTGwgMBVyqJufKpO8ezC+1WXRshBLVG/6CnaMI5yP0UDWs2801C DxIxIOP9RjeYsub4QqCs1Qb3b8AgnwxiRv0qIAGYDlgCRKXVOOu/p0VDSmNio109mJj3 q/Sf9oPxQJXcHA1O7TIzfQEvrMg0TqroD0dTW+CjY8uDn9027C7LWGKVWOM6dahvfWUF 00DGL7XEc4DjyZ+ITW8CLT53u2YC1VdHd9y8jmGvoI5SjQvx6gGYQ9OgJPKhd4aBTcPV aj1g== 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=F1V2tHYbIrfXQULWCSXJBEnbookFQmxf2kmusYtyo9w=; b=y0hjTK1g8X+szL67f589/BHVVRssAn2lNrDixuTU8eyoPDeIPyc+y1XNqMPkrVG4CV 7WN3VRQE+tZ2UxhS9IWcbw0UnGTV6bl+KNsZMPEK1ZV4BXjY1vACGV0pH+7FoDAGSSnb EB05RwpDs75fAEy9046Uu0c9sHwjuXF527BoAvZgs74+K5r+ZT2Tz0rZmbRADuY0nTS3 OU1TgA9PcG1EJqz0iGkkIq6j7q3h1bxkcwCwD1kmVCl+h9QCnDpfIZPEHsfuOaJlH1Uc fWDjOzZg3aIsr8q5bIP/v1eReJkotw7Z0/6a5ShHMnCUReKSOmvUprEuR/cKWeLyMb/6 xr+Q== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531WjuuiVpdiF5dvO6Z6Lyj9F7l6dWY+vVGucAYH53VXBhQ7yScE 5vIR0wJ4bdlYUYOkw0ZjSyU= X-Google-Smtp-Source: ABdhPJw9mXRNJVygEYvqF+O0JDPilIpymIIh1rVGocqr5i40Zjqy40fQC4MFBFvIrtCA3+lm319/nw== X-Received: by 2002:a17:906:dc8d:: with SMTP id cs13mr8232795ejc.276.1636910906734; Sun, 14 Nov 2021 09:28:26 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:907:3e05:: with SMTP id hp5ls4632254ejc.6.gmail; Sun, 14 Nov 2021 09:28:26 -0800 (PST) X-Received: by 2002:a17:907:3daa:: with SMTP id he42mr41689982ejc.160.1636910906012; Sun, 14 Nov 2021 09:28:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910906; cv=none; d=google.com; s=arc-20160816; b=0UNiEoOA64sw9ZeQQwVwrKrPp5n0TxexABv+c78dwImoCK2CPD3TruxlXgZBSTp4qw Qyd74jJ3Ez8AsqdzBDdJQ/JnsVB8+9Yiri395DndwNEBOsnMfjyvKi0YhHhcI/bNfAFm Gl4jybl0awXwTFF+9P9YT+NvaLackhpCurJVbe9VyKr714yvdKTcYAuoN3+7I2bLWb11 fqRVRcE1lQUKI74U4cTcUy+T4wjcjHa3t7Cl1DifexOrvx9JMQs3YYx7I2YM+WoQrBW7 zwbdYdCKiqBHpLMGQ5UFAVFARxaByR1BIVNcW7rVCixZpr1jq7NIN0w3w1+oSPPR2H/s ljPw== 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=kUBTfDCk6qFycXagoSioS3Y3n+8j3/rx6Cu70D1u91s=; b=0Xz/7Kv577oprtQ51thG44/QLYeC2A22bfOeItq6Dt8cX62Ufzbr91WWGTE39k/itr lNwsoEt3uBfmj88N8mTQYYG523dFEZ8WIAvJF+i7hOxWEK03zUCGfVyeubH+e14Pwysz FrK/kEQnAcNVxsdCj3nWhYpctrHv+H5BncCTVVWzZWGY7AMSuCR56iGm6PWF7eu3G/Kx z0NkQ17y4MI3Kslt2OZHn8+oUYvTPkdLbtjwU3sKeUgLcLRN7t/24ypse1A9nbVZhLfI 11eueW+Ch72T2SN/Myw7CFh2z1UKI3U6PU+iarLGUnEqOfig+d0mJ7932pSp9r6l5ids TNSA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id u19si1154303edo.5.2021.11.14.09.28.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:26 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfRs5jJ5z1qwdP; Sun, 14 Nov 2021 18:28:25 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfRs5bBWz1qqkB; Sun, 14 Nov 2021 18:28:25 +0100 (CET) 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 HJE49B1_QOY7; Sun, 14 Nov 2021 18:28:25 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:25 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id A5DEF45408E4; Sun, 14 Nov 2021 18:28:24 +0100 (CET) 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 Rsyjp81T50gc; Sun, 14 Nov 2021 18:28:21 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 82DE945427EA; Sun, 14 Nov 2021 18:27:46 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 23/36] channel_curl: store HTTP return code before callbacks Date: Sun, 14 Nov 2021 18:27:20 +0100 Message-Id: <20211114172733.71602-24-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , Callbacks need to know the HTTP return code, if any. Signed-off-by: Stefano Babic --- corelib/channel_curl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 2b9f178..3ee801f 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -185,6 +185,9 @@ size_t channel_callback_ipc(void *streamdata, size_t size, size_t nmemb, } } + if (!data->channel_data->http_response_code) + channel_map_http_code(data->this, &data->channel_data->http_response_code); + if (!data->channel_data->noipc && ipc_send_data(data->output, streamdata, (int)(size * nmemb)) < 0) { From patchwork Sun Nov 14 17:27:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554916 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=rE2OIADI; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::337; helo=mail-wm1-x337.google.com; envelope-from=swupdate+bncbcxploxj6ikrbquoywgamgqefwlhdxy@googlegroups.com; receiver=) Received: from mail-wm1-x337.google.com (mail-wm1-x337.google.com [IPv6:2a00:1450:4864:20::337]) (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 4HsfS53x7Pz9sX3 for ; Mon, 15 Nov 2021 04:28:37 +1100 (AEDT) Received: by mail-wm1-x337.google.com with SMTP id j25-20020a05600c1c1900b00332372c252dsf6924620wms.1 for ; Sun, 14 Nov 2021 09:28:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910914; cv=pass; d=google.com; s=arc-20160816; b=Ryy8VLcaJhscyPCnpqdRVfVSAE9nlWvV39ZGMeCu0WPEtOp/wP+fSu2AG2as3t55R6 Zb88x1fksQDaAqPpdlPmMg+bSg1bJJ4g7NkQ70mpt6N0qIZ7n6A9K5SlxBKSICCqrzsj x7JT3isodpWbWlzqE1Ccl0bFDETlrYTvi/QOjIa/6WoHpIibHOMf+aeuDWezUOXdIdqO 47FmVxq+2ryb2anXgzRemMGQ0622GfxgqE37KDlxEavIp0McY59wucbFGb87g6gb82Vv SD7qiTHkkYZYqZh2TLi9Hb2VwKCy7e/rebtCkY3kqJUEKkZT1bW94ujhxRu1/8YFzUuI OOrQ== 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=zXjFK4X2McTHdFsPs7MvCxjbcNU9qsK1MK6i0ctiIbU=; b=HRGh/JPCOM23tJPbqFNYs/fcWIjjSggCsdubDZHEnHy0uoKQGcPk0wCGt5Z172ecWa pEhVxEQ4rJSjBvg1eXeloSRdeaXCrgotnsEDWus5oAJ7QFfLgeQwS/iVDKpyaUaN3eUJ GN2OPnLtbo7tW5tNFChp7H8qdCMjDthBshttMnRf8yON2cHGyRB/itxtVLjOk+Q8byx6 7mZrOFhUZxMF6sw66a7dbme+rOoiY1TEoD+XRjyoTVYFpZLrdrq0Oc4sByQkEOynTVO3 PaIW3AqQoISc2E1oTis7IauK1JGzntiZrt3kepCkVMYEyxxBosY35SpHDRgbi3KRQJfD osmw== 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=zXjFK4X2McTHdFsPs7MvCxjbcNU9qsK1MK6i0ctiIbU=; b=rE2OIADIBYVJA2ODohGqOO4PDthMqv096GURROzoHdUXA8t9bKgaUpOI7xbQJg1geK 2C1SEZdVq+ht0Z6/2ReJ1t4NHEQzyBzGDcGXWysotoA/h5glxzoH8dckbOPUPZtJvyDA WL+DXOSPxYoKjpDRTecgPAJcW5uVq4qDaPvmIL2h9SKfPcT9jb/OE7xfRug+kuQUTlKa 0jV4R61WA/p4FBG4rwBSZI8HHwzi3pTdFYx26URaMBqv6OwTsExpKeUnPwgXEhBu7adV zKTt/2wVunY1HYRbUdUshASNxujPnSnczh7lBRyPOgvbNIrWhuoZUOKrx+f3WolJ9sRv oN3g== 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=zXjFK4X2McTHdFsPs7MvCxjbcNU9qsK1MK6i0ctiIbU=; b=kTpNwWC9qB6b/kpI243/RMWkinbnYStd8Ts3WRG/7tk/Wk6LizidVG5ThBm9YCc0aJ 87wHRLmPd0Ue1KbCGmDNyd0hEjm1KUs9wG6Z2Xw3VncLyqFtqd8KRpgIajePepFd//WU ydbkw4zlAqdKvfUSXc7/lZkzi6GVwoy2IQlAvgmQ/DoWEcd2hTZ2kGtSqH3YbiIzcMUc 4CIJyD0n/YoeK0ytTWi/MFs4bE9FukM+b+bvpI653UG9vGuImQP7RgGXP+LGGuNjaPs+ cVqVyBAkDfOq9iK6SnncB2AvGcwNpPaThMh1zvWcQy/PWz8mjqYkvj/Bxq1DyaQp3RZH zY/Q== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM53186yfI0nn5m+6Ix0E6rxclvL+tJg/N4mHMId4f1LbvMV3faRHe snpodD32DvooLMVqGIdSy4o= X-Google-Smtp-Source: ABdhPJwYSC3HuSJWwYXVmn2AwUqX/lgzl1Pms6fv31VLTkPP86dCW6hdjccjT2/Cs+zPQff1TZVZUA== X-Received: by 2002:a05:6000:1862:: with SMTP id d2mr38472442wri.251.1636910914808; Sun, 14 Nov 2021 09:28:34 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a5d:6a05:: with SMTP id m5ls7201193wru.3.gmail; Sun, 14 Nov 2021 09:28:34 -0800 (PST) X-Received: by 2002:a5d:548f:: with SMTP id h15mr37853115wrv.99.1636910914207; Sun, 14 Nov 2021 09:28:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910914; cv=none; d=google.com; s=arc-20160816; b=cu15N2Feovx9ouTMjBjKUaMThTvsC+ALypOdVEKkbi2R0VS2knDRsRCGfE7vsKBRjR CSgbPf76F/l7GBI+wCwTDLVgvW0sUEBoMdajUsgK+COHHekXtr+MFGHb4G6mqTRPeQDb R7QT/v1ZiLIZ+b+Ywj4hJSiWdtgZCkAt6qb8u7RLjcQcJ0KwBJeM8Hp+99FV/MGI0fgU 5kfI6un5KNv5x1gn9xTZgPFnx2TKdKynd01L0ELq8yipBXRAo+r/Q4872NreZq/rXwr8 NP+Ikh6K2p/GvRvXm8HRGuTwO0xg8RL3jNhnG15aPUUndQgQtfi6nHSSJB2hRKinqJz0 QIiA== 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=Ru16HziUXwuA958nyE4t8ZohglXPVkdCkf0bTstvwTk=; b=bWfBTEuhckw0ab8grQHV8qXDltgWAYz96oTOCkiaKJqRRa9rJ7YnTZv1hJBgAUVznC /BVflNEQ1viS4SHGM7yA4h1A7jVtm3KVoJ2tz3GlPL3tcKK5JGT6L66798ve5+OooiyI eF4G/BPWRbftoPNjyDdRoeg/ilyU2PhkX99tRYX8y9ivXOFA0GOqvzt6Bygf4AlFA0xS gRm4u3Sno/v+tfZ6flGrsRcEtKYmthtWHE4VBqdhQgth4Hh+XnzcIueAW1MKxFG0sTem HxkY+nM6zOeNU1W0pxnFnl3hDQUEDJwSzBgoJQJT+NatIq0AvXNnVDOYhhLx8RyC7jcU PF9g== 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 p11si110456wms.3.2021.11.14.09.28.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:34 -0800 (PST) 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 4HsfS172Z2z1rk5m; Sun, 14 Nov 2021 18:28:33 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfS16x5vz1qqkB; Sun, 14 Nov 2021 18:28:33 +0100 (CET) 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 HbDbcHmIyyfR; Sun, 14 Nov 2021 18:28:33 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:33 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id D2A8145408E4; Sun, 14 Nov 2021 18:28:32 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id xpzeOY2ZeIgr; Sun, 14 Nov 2021 18:28:23 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 8FDA945427FB; Sun, 14 Nov 2021 18:27:46 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 24/36] Be sure to initialize channel_data_t by users Date: Sun, 14 Nov 2021 18:27:21 +0100 Message-Id: <20211114172733.71602-25-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: , Initialize new introduced field in the structure in any use case (downloader, Hawkbit, general server). Signed-off-by: Stefano Babic --- corelib/downloader.c | 5 ++++- suricatta/server_general.c | 3 +++ suricatta/server_hawkbit.c | 11 +++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/corelib/downloader.c b/corelib/downloader.c index 8596694..9eec3f1 100644 --- a/corelib/downloader.c +++ b/corelib/downloader.c @@ -106,7 +106,10 @@ static channel_data_t channel_options = { .retries = DL_DEFAULT_RETRIES, .low_speed_timeout = DL_LOWSPEED_TIME, .headers_to_send = NULL, - .max_download_speed = 0 // Unlimited download speed is default. + .max_download_speed = 0, /* Unlimited download speed is default. */ + .noipc = false, + .range = NULL, + .headers = NULL, }; int start_download(const char *fname, int argc, char *argv[]) diff --git a/suricatta/server_general.c b/suricatta/server_general.c index 7da3c84..056e9ec 100644 --- a/suricatta/server_general.c +++ b/suricatta/server_general.c @@ -109,7 +109,10 @@ static channel_data_t channel_data_defaults = {.debug = false, #ifdef CONFIG_SURICATTA_SSL .usessl = true, #endif + .noipc = false, + .headers = NULL, .format = CHANNEL_PARSE_NONE, + .range = NULL, .nocheckanswer = true, .nofollow = true, .strictssl = true}; diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c index aa4d9a4..3fc60e3 100644 --- a/suricatta/server_hawkbit.c +++ b/suricatta/server_hawkbit.c @@ -135,10 +135,13 @@ static channel_data_t channel_data_defaults = {.debug = false, .nocheckanswer = false, .nofollow = false, .strictssl = true, - .connection_timeout = 0, - .headers_to_send = NULL, - .received_headers = NULL, - .max_download_speed = 0 // No download speed limit is default. + .max_download_speed = 0, // No download speed limit is default. + .noipc = false, + .range = NULL, + .connection_timeout = 0, + .headers = NULL, + .headers_to_send = NULL, + .received_headers = NULL }; static struct timeval server_time; From patchwork Sun Nov 14 17:27:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554915 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=BHRJUazr; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33f; helo=mail-wm1-x33f.google.com; envelope-from=swupdate+bncbcxploxj6ikrbqmoywgamgqeb7kmdta@googlegroups.com; receiver=) Received: from mail-wm1-x33f.google.com (mail-wm1-x33f.google.com [IPv6:2a00:1450:4864:20::33f]) (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 4HsfS53DFyz9sWJ for ; Mon, 15 Nov 2021 04:28:37 +1100 (AEDT) Received: by mail-wm1-x33f.google.com with SMTP id n16-20020a05600c3b9000b003331973fdbbsf6928457wms.0 for ; Sun, 14 Nov 2021 09:28:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910914; cv=pass; d=google.com; s=arc-20160816; b=FAxIugcAgWSOlE9F33tuQ1V3UiKEyy3Fm06OUXNhYABjuPao2auNqiwgfYIoQfeLMD 9nftPwUIVXSTce+3dYc3FF/eoA98KNb3bMZwwvRUilXz2+219UCphtpJpVIe+jXNhQae C3Bgm6lqdnXVJtJEcPdF11hpXd00dkJwkzIChwBOQPGWwH3N/q10kuogEJKF35I1Ifcz NqVEryYviP5RPeIeEr6R5Llu4roqKuQkHpaXLKTy3lMaB55+sp749j6cnCP9T0ndR6Yz 6hD11rTOK88p5Kx/CMlc7gfKCaVLPeffuGc4b7Ci/umUSARazvirZn1h/1HZ7QRi21bv RJQw== 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=ZRBo9TqwLhEBzLZF8p0nyVzXwlDnTPjUIRt65wwbb84=; b=KRh/2RjNtHY9qgJLAz12eCq1YRfa/ie2Yb7H5Q+rycPkZ/upMWIHm71TbBN73vs6Jm Bgthr7hHC00YPWgVAddhNmHpAaT9l6icSjJqc3HQcDoL5a3gwx6WQ8ZTz0aUWD7zilI0 yYe63x3BjzwOS54OADb8Jmu5y11P0Y0AkAseTMx5J7IdSjA1x9NcgiRoVJyMTS0+60rl TA2jIAK4mS9cuwhKpu+3sSslwR2qCwrksn8yff5uDlUU7syQ3tKs7IanWYMBbT+RQf9F phggYhaJvh57yISmotcvDwhplNP10+fNEoR+eTHDMKD3hsxdhbUFkWCniIGFcHRYdhQf xtsg== 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=ZRBo9TqwLhEBzLZF8p0nyVzXwlDnTPjUIRt65wwbb84=; b=BHRJUazrRDDVyGHbyzKtyD9gMQ5HEsJ5i7MP2sU+icS/UYbzjN9/cxa9RlBTysOBSd O43XKrdFiA+hplZxM8Suoc4hYNOqVqVYtbkdaCppGpTXozasG499i8VQsI5SWjZibiNW xKYTbPMzhvLw23bXh48FjwQjkuWBsG0404hOiijXn0WwzQcTyBtnxiYghL3WVeB0Vo1i jmQXkov4i6NsDjnO9lt8oWMgI5JKQkZXU1cQSUWpXOnLPoS9i8Gmj3BDcI+ec0uw5daG mMkzw23i/0zqSwfgh16Lz+fHHpCtux+yV+9Y0RnoPijtxGTN4nOCtyT/tHpmLva9GzBo YwCw== 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=ZRBo9TqwLhEBzLZF8p0nyVzXwlDnTPjUIRt65wwbb84=; b=MCXXVF6BN6igPZXI7JuffzkIpWANwIAjYqtPItuuaydhXgH08nG605J3B/ibRGAlF5 jJZry1EbE4WntKTgkzu351s2iXjyoVQA1eAX5Odg1W012COPbjZhHbey+8mevMrh9iIx B4YcxafwZnDzVtG8uVwL1SvqXiKkB+895nsHO6Us5xNXKeIT0a3pJG1yBerw8UsuHXCi ssywQiIsYS8ga01aDQ5eQ/HxNPiq/4qylDsErykdcWm4Ky4/2DYlnFDp/DS0RPkAjjRe zQ8u7rmq4vqrmqY2Ia1kAVuG8SxQCyWHO6f17DLQ7AhxC1rhVp8bqc3nfQ6d8nYSQUTa Skyw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531JpLmGCNGWASrbee/UouZbRt7ii7/UwYW8HC5l5qT/iKN/iE7Z PMNr2P9Wxz0djhGqcswbfOA= X-Google-Smtp-Source: ABdhPJw2tWO7Jbb0QT3Oha8bd3v5xfahanlpuLoh9zk2zZZXCboNvU5mzD16bib91bsVSKj8yoGVww== X-Received: by 2002:a1c:6a0e:: with SMTP id f14mr51788199wmc.58.1636910914157; Sun, 14 Nov 2021 09:28:34 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a5d:4092:: with SMTP id o18ls7203192wrp.1.gmail; Sun, 14 Nov 2021 09:28:33 -0800 (PST) X-Received: by 2002:adf:fd4c:: with SMTP id h12mr38478529wrs.429.1636910913367; Sun, 14 Nov 2021 09:28:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910913; cv=none; d=google.com; s=arc-20160816; b=HdqDh0VBSGgPW5gyanF6VmNYrATi1stHKUNux5aS+u0GqUeqIY72yuVyGg6or0PUKm ZCpUJA21fBWnBOlz0sNIoGknmtLgyJD1C9b9Nvem/EBKLorHkXuLiv/r/OIbwCK9uxiG NRPYr/BrbqYLgtK4jiPdQKcRUyFV212NyLqVSD8nyDLlFCJTC3xmuafGPNkBl/HXOGYL cVrblcRAlVSzlEtjL/rZfKmVnshOvrdGxSaoGEHgiuqd/4zcGT+wXXHZUlBrIxPh52Ne bfoI18Zlyf+Jb/lPZuqccgWt32G1/Oknhk/7iJcO4bMXoVUwIiEqasszv6iKFNJknLUg Bedw== 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=2dXppPk+vJJVytlKVRK6n2tvFFyhGswLZUfjWRN50Wg=; b=adgdAoxgwp1V6nTxK0tH7DvlOKoKZJ/8QjF9PwJw7HY3iRgHkrAOUn0P04ELoik8Hw IvnbEnHcv7/wI00GS2B3nnS0LFvXc1AohymZf5TvHqypvfT17wzSO5/RRlrv+BKZo1hp EMwz7pgqoLMTpIgntojBSE9h4Rs+gR/23lLS8MQWOmypeHh5MKA/L+Aj9tj9H60g6BSC 0CsahtTIIZE5D5rN0NmUGqicwVqdrLX2GjiYOHYQa3iTqyr1eSLMiWukJYcqBzIuEH7F 0swchTuBzzaI8bswfWHfn7oJ5Dglgtk3g69zDhzM5nyV2fp55s7b3fRmQGImLBRwo4kB oB8A== 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 201si1064709wma.1.2021.11.14.09.28.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:33 -0800 (PST) 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 4HsfS11WRkz1rk5m; Sun, 14 Nov 2021 18:28:33 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfS11Hp3z1qqkB; Sun, 14 Nov 2021 18:28:33 +0100 (CET) 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 cum7lNAcXBq0; Sun, 14 Nov 2021 18:28:32 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:32 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 14C584540853; Sun, 14 Nov 2021 18:28:32 +0100 (CET) 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 SNmHzvh459gV; Sun, 14 Nov 2021 18:28:24 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 9D78F4542806; Sun, 14 Nov 2021 18:27:46 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 25/36] server_general: fix warnings Date: Sun, 14 Nov 2021 18:27:22 +0100 Message-Id: <20211114172733.71602-26-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: , Signed-off-by: Stefano Babic --- suricatta/server_general.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/suricatta/server_general.c b/suricatta/server_general.c index 056e9ec..cc8cfd0 100644 --- a/suricatta/server_general.c +++ b/suricatta/server_general.c @@ -409,6 +409,9 @@ static server_op_res_t map_http_retcode(channel_op_res_t response) switch (response) { case CHANNEL_ENONET: case CHANNEL_EAGAIN: + case CHANNEL_ESSLCERT: + case CHANNEL_ESSLCONNECT: + case CHANNEL_REQUEST_PENDING: return SERVER_EAGAIN; case CHANNEL_EACCES: return SERVER_EACCES; From patchwork Sun Nov 14 17:27:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554917 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=MCNN/roQ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23a; helo=mail-lj1-x23a.google.com; envelope-from=swupdate+bncbcxploxj6ikrbrmoywgamgqetgor2py@googlegroups.com; receiver=) Received: from mail-lj1-x23a.google.com (mail-lj1-x23a.google.com [IPv6:2a00:1450:4864:20::23a]) (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 4HsfS91QZrz9sWJ for ; Mon, 15 Nov 2021 04:28:41 +1100 (AEDT) Received: by mail-lj1-x23a.google.com with SMTP id q13-20020a2e750d000000b00218c953d0b8sf4427368ljc.21 for ; Sun, 14 Nov 2021 09:28:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910917; cv=pass; d=google.com; s=arc-20160816; b=L4gz3a6RTFsCFQV+QClCm+VzQaX/u26qt3F6WD9lfOEKA61TLOrFxYWb0EBccBAmED DcFvL+lFMCixQ04d6GtsR+hdLlIjp1ReEwRSrtc0ifQorm/P5eaeR3mqiTYaEFmfgmei zo1qInL+6XsrEfumAoxBmSTdoJWNlX2JMfUXCMdWf09oV1F9z4G0RRPT4nsX+PJnpgh/ K+qKiIKhrzZayzT0V+Bv3v0JK8lBweUCFaKb3/m8J18q/E2RIbmVwM4Jf0m+gFC/eh9/ HzffCogcf19qhRMwQK+dYtSRBmB8EuIIdE1LrMt+IHQJQNBSLWbYNrsit0EtUfmZZElE oK5Q== 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=lFI+/yIp1aqSoUQBrWvwtJjz/uA67mRM+lnH6PBgaqQ=; b=Te3XnqYwA0ruI2aELLWG0z2YR56qMm9vVt6JJCBp2fjBNkRmBn3aZJxzhQxuhkdvv+ rpmEUrKohxck9ql3FiHpxEPeRCykrwK/iRhnbyk+Ae9ziTXkQ1wUfEGkQORZpAT7umMw JhlI/OfqA6RR2vKabexWDSOXb6B30YNyUNSqFrkVdkr7+FLQ4bFGlfzSPhp9EI7mWpTk j+UnbxE37zgNrUaXaKtFQpyX8vhbzN/8CE1GpDV0LPysy8GcXZ1YrpEc+/1XmDPJl/6R LbGmJjvv11UHD6wOVIcRJw3hWmb+A6heH7TCln/cE3ptqj3cU8mt764Es5eBBAx9A/7+ TTTA== 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=lFI+/yIp1aqSoUQBrWvwtJjz/uA67mRM+lnH6PBgaqQ=; b=MCNN/roQXI1W6Ryljxd+YHj/TLH+F1JAB6Zrmr/gTJIdPUlXN5oAeaOdgkcjSNRiUG 8wFyOyTa0nbo6mPRo+XDUlCSuIMtVy52Zc2M7ctGnDY4OJa0x5U4LL/PQdVP81DPkkRB PJr3U9qAYFetq/w5NGSoFYS7ww8KxkihjxjT/ospg8OAL2mf4fWkU9mk66AoDZZECNSn eNPUA7GSDybUfKBrgV2lNl9AQnzKkggGhi0s9wLUU8d4NsODBtU70heHGsfyEW1eUXoi hWLIq2hjOHGmCYhQnMMYwpn93GVcGK12TtqUOJPDDKjYRfy2GUEGsprqKxkYacZSPD6q QWCA== 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=lFI+/yIp1aqSoUQBrWvwtJjz/uA67mRM+lnH6PBgaqQ=; b=iOCTC9346sYOPBmVuk6MW0XSAphrwkOZ3Gg6pXYZ9TelUJWkQj2e8Wl+2DIwJbZgNe Yglc0SGSN/+NNTyjziEzUOkoKV6NocZlFibfpvyMr4hEE8HOpYFTbVG3eGUXwZLPZUri 6ZFnsnIeFP+aFYsT5JsT3mhac66h6AW2p8+1tHZ6dpghiwF9fqo2LrIWuh+kDX2pZl4Z zm9SAc4nAPrBzB9Bqv8hbiicWdPGTn8R00RZ9vC+LID7JwJ/DApMAhQYy5bLOvt+PWA1 6KRVedNfqPRUxJmRZct8+ERTAJZx7gqzeXMPWayOFI/JgMyD3t8hp/F2inG7005gIkOY AziA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533ojyoGvS5XDNoUCppZ7jOU9zoZmmDyDJO9r0azA+1xgBWjYaEQ ufeCDSKTYVKZff3b6ZDL4ZY= X-Google-Smtp-Source: ABdhPJygQjek7Wtti+xF7a48qdKg6nWbL8hszE5hcVkoIX4P2nKOk3nUSWfTGIGxqK5WmESy7B/wAA== X-Received: by 2002:a2e:150c:: with SMTP id s12mr31950358ljd.470.1636910917727; Sun, 14 Nov 2021 09:28:37 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:a4c2:: with SMTP id p2ls1828437ljm.4.gmail; Sun, 14 Nov 2021 09:28:36 -0800 (PST) X-Received: by 2002:a2e:bf26:: with SMTP id c38mr32421368ljr.127.1636910916845; Sun, 14 Nov 2021 09:28:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910916; cv=none; d=google.com; s=arc-20160816; b=hMgvgKjNvj7+uikv4TnWXwl7dgVoRv9kkE79EBO76MWhsCMxmeMgczZ3kBdeeJnS7w nW/5qIWnnOrIKSpp0ndZoqXVTzTxwZachlb7lRrCxoTSoCfbu5Ei/wIKkUIWyZIXQe81 ac76isJkUbjE04jO//mUGrNzoFTTtxB4MLWqtWMBN3ZAa5MWSqaAUGvtDEPAX2wKcboI b/KQhHsdm8ZgDGfUpym86DzwQhJ0jsczc+rPnxgNZ2InqOz1MDFraJhM5kqbvivhV3/E 1orvC89UVhZPJOy7fPFMecVsKw7tCV2seafB0PRKhylVwR/BQSwFg39wG42Oi3omlqUO QGIw== 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=fMzBG4xhwUbCZctmQ+8rw+2v9fGUvvWCRzyVTTP25jo=; b=VE99wWEublE5iwqpECK6aqv2G93vmDAHtEBrL6tkjPomOfKAI0k68AKERh+kM45Oys XH/Mi5JHhDA64OKQVcfEl/2Sbj4Rajo7IzMOVRZ5worrqQyMZMkH4DOAuSNwK3gXj3mS qk29UD1m7xEht52gGsne5qXV6rurjZMj/TuvpIz/F2AnMPW+1BpX7iirkWCsI0jMugkI 7WaJc8Ignbz3olhaHt9H9gYZaRLjeSSWUnIwRVCMCcrAUPN04oDS/eY1cWLYbSNG5CyU DGx1nR2fILfgyNsI/IWWRO5iph+nhUGkdXhfZxyB8c4ONFe+9lcIYcwiXlpUDlCVKP4v HfLg== 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 bn28si937924ljb.1.2021.11.14.09.28.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:36 -0800 (PST) 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 4HsfS43Bfqz1rk5m; Sun, 14 Nov 2021 18:28:36 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfS434btz1qqkB; Sun, 14 Nov 2021 18:28:36 +0100 (CET) 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 wg_y8SL46qef; Sun, 14 Nov 2021 18:28:35 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:35 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 07DCA4540853; Sun, 14 Nov 2021 18:28:35 +0100 (CET) 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 4oJo-desIyVo; Sun, 14 Nov 2021 18:28:32 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id ABA31454282A; Sun, 14 Nov 2021 18:27:46 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 26/36] delta: add process to download chunks Date: Sun, 14 Nov 2021 18:27:23 +0100 Message-Id: <20211114172733.71602-27-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: , The delta handler must download the missing parts of an artifacts. Because it runs with high rights, the download itself should be done by a separate process to avoid to break privilege separation. The process gets userid and group id from the configuration file, and as fallback will run with the same rights as the installer. The downloader will wait for requests, and it will write the downloaded data into the IPC pipe. Only one process is allowed to talk to the downloader at once. If more as one user will exist in the future, the access to the downloader should be queued (not done at the present). Signed-off-by: Stefano Babic --- handlers/delta_downloader.c | 217 ++++++++++++++++++++++++++++++++++++ handlers/delta_handler.h | 37 ++++++ include/delta_process.h | 10 ++ include/swupdate_status.h | 3 +- 4 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 handlers/delta_downloader.c create mode 100644 handlers/delta_handler.h create mode 100644 include/delta_process.h diff --git a/handlers/delta_downloader.c b/handlers/delta_downloader.c new file mode 100644 index 0000000..ddb7cdb --- /dev/null +++ b/handlers/delta_downloader.c @@ -0,0 +1,217 @@ +/* + * (C) Copyright 2021 + * Stefano Babic, sbabic@denx.de. + * + * SPDX-License-Identifier: GPL-2.0-only + */ + +/* + * This is part of the delta handler. It is started as separate process + * and gets from the main task which chunks should be downloaded. + * The main task just sends a RANGE Request, and the downloader start + * a curl connection to the server and sends the received data back to the main task. + * The IPC is message oriented, and process add small metadata + * information to inform if the download reports errors (from libcurl). + * This is used explicitely to retrieve ranges : an answer + * different as "Partial Content" (206) is rejected. This avoids that the + * whole file is downloaded if the server is not able to work with ranges. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "delta_handler.h" +#include "delta_process.h" + +/* + * Structure used in curl callbacks + */ +typedef struct { + unsigned int id; /* Request id */ + int writefd; /* IPC file descriptor */ + range_answer_t *answer; +} dwl_data_t; + +extern channel_op_res_t channel_curl_init(void); + +static channel_data_t channel_data_defaults = { + .debug = false, + .source=SOURCE_CHUNKS_DOWNLOADER, + .retries=CHANNEL_DEFAULT_RESUME_TRIES, + .retry_sleep= + CHANNEL_DEFAULT_RESUME_DELAY, + .nocheckanswer=false, + .nofollow=false, + .connection_timeout=0, + .headers_to_send = NULL, + .received_headers = NULL + }; + +/* + * Data callback: takes the buffer, surrounded with IPC meta data + * and send to the process that reqeusted the download + */ +static size_t wrdata_callback(char *buffer, size_t size, size_t nmemb, void *data) +{ + channel_data_t *channel_data = (channel_data_t *)data; + dwl_data_t *dwl = (dwl_data_t *)channel_data->user; + ssize_t nbytes = nmemb * size; + int ret; + if (!nmemb) { + return 0; + } + if (!data) + return 0; + + if (channel_data->http_response_code != 206) { + ERROR("Bytes request not supported by server, returning %ld", + channel_data->http_response_code); + return 0; + } + while (nbytes > 0) { + range_answer_t *answer = dwl->answer; + answer->id = dwl->id; + answer->type = RANGE_DATA; + answer->len = min(nbytes, RANGE_PAYLOAD_SIZE); + memcpy(answer->data, buffer, answer->len); + answer->crc = crc32(0, (unsigned char *)answer->data, answer->len); + ret = copy_write(&dwl->writefd, answer, sizeof(range_answer_t)); + if (ret < 0) { + ERROR("Error sending IPC data !"); + return 0; + } + nbytes -= answer->len; + } + + return size * nmemb; +} + +/* + * This function just extract the header and sends + * to the process initiating the transfer. + * It envelops the header in the answer struct + * The receiver knows from meta data if payload contains headers + * or data. + * A single header is encapsulated in one IPC message. + */ +static size_t delta_callback_headers(char *buffer, size_t size, size_t nitems, void *data) +{ + channel_data_t *channel_data = (channel_data_t *)data; + dwl_data_t *dwl = (dwl_data_t *)channel_data->user; + int ret; + + range_answer_t *answer = dwl->answer; + answer->id = dwl->id; + answer->type = RANGE_HEADERS; + answer->len = min(size * nitems , RANGE_PAYLOAD_SIZE - 2); + memcpy(answer->data, buffer, answer->len); + answer->len++; + answer->data[answer->len] = '\0'; + + ret = write(dwl->writefd, answer, sizeof(range_answer_t)); + if (ret != sizeof(range_answer_t)) { + ERROR("Error sending IPC data !"); + return 0; + } + + return nitems * size; +} + +/* + * Process that is spawned by the handler to download the missing chunks. + * Downloading should be done in a separate process to not break + * privilige separation + */ +int start_delta_downloader(const char __attribute__ ((__unused__)) *fname, + int __attribute__ ((__unused__)) argc, + __attribute__ ((__unused__)) char *argv[]) +{ + ssize_t ret; + range_request_t *req = NULL; + channel_op_res_t transfer; + range_answer_t *answer; + struct dict httpheaders; + dwl_data_t priv; + + TRACE("Starting Internal process for downloading chunks"); + if (channel_curl_init() != CHANNEL_OK) { + ERROR("Cannot initialize curl"); + return SERVER_EINIT; + } + req = (range_request_t *)malloc(sizeof *req); + if (!req) { + ERROR("OOM requesting request buffers !"); + exit (EXIT_FAILURE); + } + + answer = (range_answer_t *)malloc(sizeof *answer); + if (!answer) { + ERROR("OOM requesting answer buffers !"); + exit (EXIT_FAILURE); + } + + channel_data_t channel_data = channel_data_defaults; + channel_t *channel = channel_new(); + if (!channel) { + ERROR("Cannot get channel for communication"); + exit (EXIT_FAILURE); + } + LIST_INIT(&httpheaders); + if (dict_insert_value(&httpheaders, "Accept", "*/*")) { + ERROR("Database error setting Accept header"); + exit (EXIT_FAILURE); + } + + for (;;) { + ret = read(sw_sockfd, req, sizeof(range_request_t)); + if (ret < 0) { + ERROR("reading from sockfd returns error, aborting..."); + exit (EXIT_FAILURE); + } + + if ((req->urllen + req->rangelen) > ret) { + ERROR("Malformed data"); + continue; + } + priv.writefd = sw_sockfd; + priv.id = req->id; + priv.answer = answer; + channel_data.url = req->data; + channel_data.noipc = true; + channel_data.method = CHANNEL_GET; + channel_data.content_type = "*"; + channel_data.headers = delta_callback_headers; + channel_data.dwlwrdata = wrdata_callback; + channel_data.range = &req->data[req->urllen + 1]; + channel_data.user = &priv; + + if (channel->open(channel, &channel_data) == CHANNEL_OK) { + transfer = channel->get_file(channel, (void *)&channel_data); + } else { + ERROR("Cannot open channel for communication"); + transfer = CHANNEL_EINIT; + } + + answer->id = req->id; + answer->type = (transfer == CHANNEL_OK) ? RANGE_COMPLETED : RANGE_ERROR; + answer->len = 0; + if (write(sw_sockfd, answer, sizeof(*answer)) != sizeof(*answer)) { + ERROR("Answer cannot be sent back, maybe deadlock !!"); + } + + (void)channel->close(channel); + } + + exit (EXIT_SUCCESS); +} diff --git a/handlers/delta_handler.h b/handlers/delta_handler.h new file mode 100644 index 0000000..4a9196b --- /dev/null +++ b/handlers/delta_handler.h @@ -0,0 +1,37 @@ +/* + * (C) Copyright 2021 + * Stefano Babic, sbabic@denx.de. + * + * SPDX-License-Identifier: GPL-2.0-only + */ + +#pragma once + +#include +#include + +#define RANGE_PAYLOAD_SIZE (32 * 1024) +typedef enum { + RANGE_GET, + RANGE_HEADERS, + RANGE_DATA, + RANGE_COMPLETED, + RANGE_ERROR +} request_type; + +typedef struct { + uint32_t id; + request_type type; + size_t urllen; + size_t rangelen; + uint32_t crc; + char data[RANGE_PAYLOAD_SIZE]; /* URL + RANGE */ +} range_request_t; + +typedef struct { + uint32_t id; + request_type type; + size_t len; + uint32_t crc; + char data[RANGE_PAYLOAD_SIZE]; /* Payload */ +} range_answer_t; diff --git a/include/delta_process.h b/include/delta_process.h new file mode 100644 index 0000000..51d1e04 --- /dev/null +++ b/include/delta_process.h @@ -0,0 +1,10 @@ +/* + * (C) Copyright 2021 + * Stefano Babic, sbabic@denx.de. + * + * SPDX-License-Identifier: GPL-2.0-only + */ + +#pragma once + +extern int start_delta_downloader(const char *fname, int argc, char *argv[]); diff --git a/include/swupdate_status.h b/include/swupdate_status.h index 8ac9af1..29eea0f 100644 --- a/include/swupdate_status.h +++ b/include/swupdate_status.h @@ -35,7 +35,8 @@ typedef enum { SOURCE_WEBSERVER, SOURCE_SURICATTA, SOURCE_DOWNLOADER, - SOURCE_LOCAL + SOURCE_LOCAL, + SOURCE_CHUNKS_DOWNLOADER } sourcetype; #ifdef __cplusplus From patchwork Sun Nov 14 17:27:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554918 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=aFGHbuXQ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::237; helo=mail-lj1-x237.google.com; envelope-from=swupdate+bncbcxploxj6ikrbrmoywgamgqetgor2py@googlegroups.com; receiver=) Received: from mail-lj1-x237.google.com (mail-lj1-x237.google.com [IPv6:2a00:1450:4864:20::237]) (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 4HsfS93Mfmz9sX3 for ; Mon, 15 Nov 2021 04:28:41 +1100 (AEDT) Received: by mail-lj1-x237.google.com with SMTP id d20-20020a05651c111400b00218c6372b7esf4436598ljo.16 for ; Sun, 14 Nov 2021 09:28:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910918; cv=pass; d=google.com; s=arc-20160816; b=Khmf85D5+srUk5tJpnAJ13K7Xla8AUvu805Af6R1WsQ69leNWt6nlUxReY4POICXUQ WqS8wnRhAj8P+L2kf0efJJTu1acWznH1vN5uAzM/ZzT0fBAMBtMTjks2JvHWSx6TzFd9 uDLG/xU+vXW7WSRcVSwbGdVJMuQZjP7KT1tYKQl6aLmhvn9wIusjFD78/u4hKJoW7r96 fC2ng8WcTZxCtqPQhgRfYUbI10BRRhqmq6ehDCPdgyRhe5KJOjiEd1P6Ev3Hq74hAoJK 2dakHrHbXSmKoQxM5X5TChrpC619RUViMN0et+xPbljhG1Cybc7jdI4S9JzthjBFMoyj Xeug== 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=sjTA713vK53KZ5IH6hS/3/4gRe8Y+9WfBQHSuHuY4OU=; b=tJuTzMxx68JvF7X40WmqBNUyi1M+PhMMfLYCPAZzvQz8jIBUSeV8W9mozVhagkIgvo M4X+QNwi4EBw2Amlbv57rYaJOFAP+EseQqrp2dQg7nny4ja4CaL2Zcii60vDPccb91QA FsEEqmp4UL4LkmSgm/o9ts8IfiSVYqwydAaSbd4DLfaCYI1wmAibp1KkZeA2t3RnOhpO hjCGzuOyjtNJVEflg7cNcdlzHrS2LSduiTYBzELaFnsuK+DqPCkPhCdV9xGn4VnidsgW nHPDC1QQTmKg17sVb+mUpt8btJMQOEiYMEKd+FTOwVHlG6+rEo57dMKlKyrX/yaAfmEM XZRA== 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=sjTA713vK53KZ5IH6hS/3/4gRe8Y+9WfBQHSuHuY4OU=; b=aFGHbuXQ/DhbgESzQfrNXOADZXTA8Sd9UhtknAX28PZK8McYiEzO6oLywZQzaIsISA jgP9MFTHz84EcQOMBY+fYQxu+ohSzewiSjKPQ6bEdfQ6ftJkTHAg45dz01syuDefWFmt N7mg5np9jz8SrzkiUQrkaCxYwBugCvtY7KbIUkI1/PmQH7Bi7ZDhF6PJpa2yfA1ufTIV 1VNc8HjGoRDTlLiFV3Xlj8nODOs7sRh28aNSxa8vqH+BZRMQsEQvwcHa0liDwL3UYqwV ZLYP/+zMvA2JI4CmEaw7wP9F1G25x3xBfOdX4PPK1mhDrUJIUaRMFU0PJrCHT+HKl3Ez oAKQ== 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=sjTA713vK53KZ5IH6hS/3/4gRe8Y+9WfBQHSuHuY4OU=; b=5uI5N0XTdW0EtENARyBO/55fPYTl1mYFmX1jIUYlITvsOUMfzwhm1F6+VFNEsYvXOQ WE1HKcuJc9gZLyD/Ytr+LTcdAajTQugwJH4BmNUcsAhvy061zlUJhrDOyGlPzFX+EP98 wZwOXwRP7UNXPkH5kadivZkNpkTKVDwCofxkn5HiQdUxbyUoKTkwJG5eNe3WyFP3Sof4 xHUjypeDjNbohExj/XC72fh8Qfh6YXzBLIMlht9EOyYs3zj+7bqoWFtlFbu/S1MOZAeQ 8v5IBUsprwFdOFW5WvqkePliPS08uWW6xx+Q77S/QCq6zNDJAWEPGT9pyM5X2F1LdKmI L3MQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532/QQLO0SrI7bhg5eviEUe37cRnSh01Ow7tA9s/T1HSOZ6x5qIT eTGW5v87LXCTgXLMxpUuZUY= X-Google-Smtp-Source: ABdhPJw1a+eMl53Hs/u+0JGBzB7reEDeVT4OoB/pJx6VATJvimMtosgsJfvnsnW4pePRb/zwdz21lw== X-Received: by 2002:a05:6512:200d:: with SMTP id a13mr29092769lfb.522.1636910918030; Sun, 14 Nov 2021 09:28:38 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:898c:: with SMTP id c12ls1819190lji.11.gmail; Sun, 14 Nov 2021 09:28:37 -0800 (PST) X-Received: by 2002:a05:651c:50c:: with SMTP id o12mr32875045ljp.438.1636910917286; Sun, 14 Nov 2021 09:28:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910917; cv=none; d=google.com; s=arc-20160816; b=GgEsZB0lat+2Cv4idQGF3kqkgj3umBWRRYY7X2DYTiia3C/xJpEbGMcICro/9RXttP pMDTF+9wRghakONZjdCt4EnV/RB23nNaLaeCeS/JTuv52/2faAPWAOiNjfE52jtR93PE TJROjL8e9LzGCxCeHja7FQzPjW07+ES6OkvJz2ItS2X1qrUSrdCkWbFwHozl7FTseVte yi50XUZimNWpfn1In278iwlEwSEfy/LGRdRFZJ/BP3u1Uhxfq6SJg+4tDEZhhdmh8oV9 2bmwzO81hlkktji45MoMnpDVqUZc9K9xG6DlXX+DbqsXeAfgrOzfNzaVjegzB2en+kZ+ iVLw== 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=YrG4i9z3uWTGbbd4Ka/hx99YpJLUIRsWKwajnLaCeOk=; b=JZGnjHwijfzWUFy5ZhPYX3bNTttrpkXRhHvw0IAEwDicNKya2njkcLIPAva86WlPBk nXe1sg626QPJ5EObxrERqrF3FMGoMz0u3QyQ2Dqf9BSRT4eHBTsiDLDcrTG58FLJUecM FktSwgtMj5QTgyXw9VmEtAg4BDZ7io4qNaYO6ox94jn39iEH79tyWna22kZl3HVOdJaw wLaNp0o1y7LN7uuMDrDcAuEQJI3TfMuEW1yDse6wTKO/Ch2ntxPEg1GDJqCCraZDYyjk bwl0tDEte6iJkTwRTsBb93/xGTDsVQPv1CbiKus8MFEifvMUMWSym9Qe4ptAFDUau9fD K70A== 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 f25si359797lfj.4.2021.11.14.09.28.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:37 -0800 (PST) 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 4HsfS46qMkz1rk5m; Sun, 14 Nov 2021 18:28:36 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfS46jz0z1qqkB; Sun, 14 Nov 2021 18:28:36 +0100 (CET) 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 vnwjbfugG8Nw; Sun, 14 Nov 2021 18:28:36 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:36 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id D80F445408E4; Sun, 14 Nov 2021 18:28:35 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id GTF3diiMB4Cr; Sun, 14 Nov 2021 18:28:32 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id BAE2E4542881; Sun, 14 Nov 2021 18:27:46 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 27/36] tools: fix warning due to new SOURCE type Date: Sun, 14 Nov 2021 18:27:24 +0100 Message-Id: <20211114172733.71602-28-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: , Signed-off-by: Stefano Babic --- tools/swupdate-ipc.c | 2 ++ tools/swupdate-progress.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/tools/swupdate-ipc.c b/tools/swupdate-ipc.c index de1e1e1..ba15151 100644 --- a/tools/swupdate-ipc.c +++ b/tools/swupdate-ipc.c @@ -526,6 +526,8 @@ static int sysrestart(cmd_t __attribute__((__unused__)) *cmd, int argc, char *a case SOURCE_LOCAL: fprintf(stdout, "LOCAL\n\n"); break; + default: + break; } } diff --git a/tools/swupdate-progress.c b/tools/swupdate-progress.c index 716c8fb..0bb3d1f 100644 --- a/tools/swupdate-progress.c +++ b/tools/swupdate-progress.c @@ -290,6 +290,9 @@ int main(int argc, char **argv) case SOURCE_DOWNLOADER: fprintf(stdout, "DOWNLOADER\n\n"); break; + case SOURCE_CHUNKS_DOWNLOADER: + fprintf(stdout, "CHUNKS DOWNLOADER\n\n"); + break; case SOURCE_LOCAL: fprintf(stdout, "LOCAL\n\n"); break; From patchwork Sun Nov 14 17:27:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554919 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=A4Y/GpNO; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::539; helo=mail-ed1-x539.google.com; envelope-from=swupdate+bncbcxploxj6ikrbseoywgamgqem3z2x6i@googlegroups.com; receiver=) Received: from mail-ed1-x539.google.com (mail-ed1-x539.google.com [IPv6:2a00:1450:4864:20::539]) (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 4HsfSC3yC8z9sWJ for ; Mon, 15 Nov 2021 04:28:43 +1100 (AEDT) Received: by mail-ed1-x539.google.com with SMTP id i9-20020a508709000000b003dd4b55a3casf12098079edb.19 for ; Sun, 14 Nov 2021 09:28:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910920; cv=pass; d=google.com; s=arc-20160816; b=NrffVDu9wKpQMKGUa0YeqHO3MJ925dLQEF73iK0v1aliDFC8TSO4+Nogf3eVwrYky2 aL4bn94Vj9fEJ5hIzQtn7gZrt5GpgRuTq7bcRqeW6teKjiQr1AkAQMsAQnYvTTLFM7hX 6mcGt1IUNkasKZFFPopbdumJknrpFJ8jhiW7qzIRYSocnzYsU1NrZUZT1Ets/S7Qbu8F EjfSQ2rXmIIvtd8VmikGs590omLYucOKs39iD+pkVWgcEbo3FHWGwdeNFTWUg4HCmEcb 1XLadA4Aea9dZ1wKHnuezorTrgCYNghLDtVPrayp795TJgLMLr2fKw7j0591UNOPgnua 7W0Q== 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=fMNQHVhQT9p70ft9HCgHBRVq4qrLrazmQAZ+VpN0Pcg=; b=hG0NXfBhryLQEbo+20POrvLmrGcVUGQZpBwPYoE+J35/EikH2Dhnzutj9EvrPT1Tiw k+JjLyYx/94QAKEQw/vrBT24i95P2DrVHjb7VdZfVSR4qus+o5FYMOU7H0Eu9pePApg4 15D8HHaiHQlSfbme4P/P6Nry/LG6J9MSNQuMwBQbA+4959h9PXSkeQqv5+eRxN8xBFwm Dxjge1wEJOISUnk338x/sZ4zf6M9G4af4W/RXFpPBPmi2mJaHLzo3/P4NEe6PTwPq/Bs 0KYwYf2a17tEtMO+iZUJ9iYN1WR/9KMzPEvzSHDFZDdPpR7C1mmte9T9UHHGNiJMPnHO EhCA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 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=fMNQHVhQT9p70ft9HCgHBRVq4qrLrazmQAZ+VpN0Pcg=; b=A4Y/GpNOlY3PrcFvvCQwbcg/HTNkLS+D8AEZQX41FsQ2mvWl1kuU7oQtMjUUijlgQ+ T5aUDqN9whYpey82Q9da41sy1C1pxZKZZ4RNL1PrUGE0zOEXnQ5aJUDCW2kY/ttzZlUD 18qukfYjpONiQ/KyYli9uOpWSr3aUV0F8A/2LtKwY0vIp8/yQYu/8+30VMDxBlnZLDKV +8sQI1FoyKR6isAiVQn/HwJnlk418O4lf3KHOn1giCPsnWBZ6iGe/rYZ8/sxGan+gMgn XN+F5EyYoavT9M+WOCz1y20F8oaHitHuns09eypvafXULTyrvsEUoNjpn/0uXoeLpiZB Sf0g== 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=fMNQHVhQT9p70ft9HCgHBRVq4qrLrazmQAZ+VpN0Pcg=; b=4SHn2mhXduJTpRLElU69rUQAKqbocspf8f7cqKj+LQsoFMLWi4FrjlxwIDC0Ob756m UqEkG3z93sutYLCmYbwYjFIfbialkz8xgZp7a1GavEc1pOYtvSV2bTFLvcex4MJpOP4s mti6XTqwZadegu2ur1YeUhZG2B0W1GNFDvob053KWjBijApfVrgBXJY1dh+eS6X10J3Q YGicbwKKgzn4eE3df/bqXivjAV08UAn/0v5VkEfr2nQfHtZQwjYnkWiKO/T9g4Q6ruJk M393cFwPuyqEIuCIpWmxxSV9x/rSIKkAtItCb74C4W9626tmDLoN2PLjCwr5NheJiob2 zFWQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531cTi0o2dkcF09pT8h19Tjg0mSTDZaUuS+7amcc2qpNg1Ps9XZv 5Gn2kPCAXOfJXi0w1qXZL0s= X-Google-Smtp-Source: ABdhPJwMZw72COYKpwn52naofeHH450lUFi12kKOCYyPwJFilz94v+YvjCW7lS9Vz0tTtUhxPNkrbw== X-Received: by 2002:a50:9eaa:: with SMTP id a39mr44417583edf.1.1636910920777; Sun, 14 Nov 2021 09:28:40 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:907:7f0b:: with SMTP id qf11ls4624956ejc.7.gmail; Sun, 14 Nov 2021 09:28:40 -0800 (PST) X-Received: by 2002:a17:906:b254:: with SMTP id ce20mr43184804ejb.255.1636910919952; Sun, 14 Nov 2021 09:28:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910919; cv=none; d=google.com; s=arc-20160816; b=SUK8MDuj8kBwqvo78NQZTV90BJkLlb1XqRftE+xuLaFmVs3m7SFOBQfH+S11pGvU47 PqfU8URK2lVj/eBhwbIY9Y4GVnIn1jEewwetzEcvDQDCThVaioRsAch9tTiv58dmat+T 5OCRfzD2gGk4ETwWLTGQnMG6kiB3xK73c9pf/F3UNNLo0KxEtzfuykoTQdpfXQuIbD7I 614mZiZY8TpWSt+3xrkM6t2r0lxwciQ3jodZOT9ngg+Pl5DARp1H/LtBeveEDkPEWlmb PmbxBA4qjmZJTxLXNQvvmq23NUclNBGYPqY6j7Dfa0Mw51b/j86AIsc4uvrBSRsZVaNI YboQ== 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=7+E4ziKLSMjmnhIIqfko2BQEKF+kcghm9Sg1clvtJ0U=; b=YEwdAMksYJMaakMMJBgCBUV07bNVR1sDuGEvDg7HaGy+HVpsdNd0bzBNZAkizIuxbL 5lRsyt5Xba+Lj8y8uOFThKT+5vlEqQHdMkqLnMTT1Soif+jFytDRjD6i693ZHVQ3PL6U iVMSyCAxTGhlJhn8mbsRhZDJSLv86mx+Rp5tdjaXFpMNR+yd5TpHFZneQniM8oIe8AeD h2SpdD3wgID+RKd0NceIX6nq4culGuS8JKICVUvqDuC1IDRyTc3wfyTgTi/WXteEOKw8 SUYiP5a9ZDSseb6Ly4dZ/mAdyJ/zKQIdxWv1NKZ3y6Vk+xrz08GYYv320tj5EfI8I9A2 ov4A== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 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. [212.18.0.10]) by gmr-mx.google.com with ESMTPS id bi21si922543edb.0.2021.11.14.09.28.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:39 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.10 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.10; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfS75HDrz1rk5m; Sun, 14 Nov 2021 18:28:39 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfS751rCz1qqkB; Sun, 14 Nov 2021 18:28:39 +0100 (CET) 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 1wPRa5plM16w; Sun, 14 Nov 2021 18:28:38 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:38 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id ED5304540853; Sun, 14 Nov 2021 18:28:37 +0100 (CET) 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 GtOkwqM1KGP1; Sun, 14 Nov 2021 18:28:35 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id E4AAB4542885; Sun, 14 Nov 2021 18:27:46 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 28/36] example: userid and groupid in case of downloader Date: Sun, 14 Nov 2021 18:27:25 +0100 Message-Id: <20211114172733.71602-29-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.10 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: , Signed-off-by: Stefano Babic --- examples/configuration/swupdate.cfg | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/configuration/swupdate.cfg b/examples/configuration/swupdate.cfg index 7d15bb5..2f19ffa 100644 --- a/examples/configuration/swupdate.cfg +++ b/examples/configuration/swupdate.cfg @@ -82,6 +82,10 @@ logcolors : { # complete URL pointing to the SWU image of the update package # retries : integer # Number of retries (0=forever) +# userid : integer +# userID for Webserver process +# groupid : integer +# groupId for Webserver process # timeout : integer # it is the number of seconds that can be accepted without # receiving any packets. If it elapses, the connection is @@ -95,6 +99,8 @@ download : retries = 3; timeout = 1800; url = "http://example.com/software.swu"; + userid = 1000; + groupid = 1000; }; # From patchwork Sun Nov 14 17:27:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554920 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=fgWPadRy; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::238; helo=mail-lj1-x238.google.com; envelope-from=swupdate+bncbcxploxj6ikrbseoywgamgqem3z2x6i@googlegroups.com; receiver=) Received: from mail-lj1-x238.google.com (mail-lj1-x238.google.com [IPv6:2a00:1450:4864:20::238]) (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 4HsfSD2VFPz9sWJ for ; Mon, 15 Nov 2021 04:28:44 +1100 (AEDT) Received: by mail-lj1-x238.google.com with SMTP id u28-20020a2ea17c000000b0021126b5cca2sf2561486ljl.19 for ; Sun, 14 Nov 2021 09:28:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910921; cv=pass; d=google.com; s=arc-20160816; b=exy0Z/lTfJ5Y9PX63fbQPr7VN3gRJ+OWWbzHmIhXwMfYi/wVD7R32nWQ6BnSnm4qFM 9fR1iBRmooKyJLgDhUelG3T1L+geTc+ktVJ46htIc1xEfaH5mM53pY0kw+K/2DahgqFg zttCzydFCBRYqZ6xR0I/mRPHhqMe5C6Ez66YaBWz+dkjO/+AKlbBbl+J0AYyA6a8gE5b S6WCtxeAjZc4JPFIlynCw9KkcxOdEH1/pWQtybOt9/UUCsmwFa/3bVgkQ9MsHZ6XdPxH Nl1xxAYn4FPVt3Im0ru611wJEGdJ8idmlFZiffMGK8ilBvvdNy6yeO/9fTI3RJCMl+gc a3Fw== 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=acWFOJZMX6oyVyW1ZaybaPXmi+iyFgX4MO4/DxLY8hM=; b=0TW7CLsVAVfvi1ixFSB6v94mjoDwhVWzAoEg0+knoTSxjMd1yL5nGUzjx4pgzbseY/ cidI9eyPfNERCB61y9KzrQUxF5Db/1Qgcvacrn4+s2gdCaFA7iqWKa5O/KHzzwmHdN9y 8upuhO0/39pVZPILSFK33lU9XdcImjI3misUkS2uaTAp27kkC5MnL8p4IMdWut1xjQ6p bpymb1PKoNLlom0mT94iXm8jOrcMsoVjMotrtkFP9mTNlMp3BiTr2AyXODWgqymExqy5 ZUh/mZ9xfjTHQczHR5EmHHZzVJgyfQmOXYXbTRLyQ+cSBS1EzdTAwtG+B8PjQ956uTzJ QyjQ== 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=acWFOJZMX6oyVyW1ZaybaPXmi+iyFgX4MO4/DxLY8hM=; b=fgWPadRyrin8ADhIsdehy0Ff2/3qUgB3OIOVXsxgmXBpE743YPZdANeVKFtW7YTrsE sP5wlulNNePZ+nLVAjAotPKwrVRObRyeddDknhL09bksVYT1v5WaQRsvotxKoNFaBz9Z b4wNZSgoqttGSXKsFCJsgKES/vWrZcBzpEotTuYFqwYy4AmDgtuMpJTxQoRoCcj21gko DXVEdGoYWMALsQMY433IL+sCq7P/YpQmzQVWaYAtMTKFYJgz/16nICGUDat0q4QsdZsX y44dopolUydqcf/JednvCFP02VloYf0GsZ+u1JWCdqt74fwkCkp1CfJC8/ozeDqdD9+U veKg== 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=acWFOJZMX6oyVyW1ZaybaPXmi+iyFgX4MO4/DxLY8hM=; b=ejh2n4yYQAw0rrQHAJijLBGyU4G2+iFlFWshgQIWyN0y/BVRsSUFFw/FtTPhmbZcHV 2/lTgWTTWYdhw/upCTrQLDI+Zup9lx4XWZtvBqEQ+siedFvCG8aJcz3rlCFf9uGNytNe 4HvYsOMuYn8Kh3kOmN8nM8L6AlG4K3aDBWdvQLdoz8ON7XiEfFtvekmpGA8l6OVrLTn+ w+JCQy9Fd6G5BNNPQrUfeJkyQ/LEqg7/7eN78UqDeHhl/JZhvC3AfCEST4Hc0cOeFFv+ Gl5ktcDnyehbE63ExUNRJWDjZhCoYTMeVz69t3kpeYDIHYkkrATcd4ssBXDTVNPGvUA9 D8oQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533Yoif0KHK2mD+BnCYxCH1pQu11RuE8YWVFWvEUyNi+qK+S7fW/ bhg1oU9p6A1MOQkYcb3KsIg= X-Google-Smtp-Source: ABdhPJzr19H3luiyAzcmGqqFzTZ1qe0fgHcK4qQUpE3urCDZlECWdbm/etUllexOILLiBIxqRQvdpA== X-Received: by 2002:a05:651c:168a:: with SMTP id bd10mr30981404ljb.115.1636910920975; Sun, 14 Nov 2021 09:28:40 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:3499:: with SMTP id v25ls4675499lfr.0.gmail; Sun, 14 Nov 2021 09:28:40 -0800 (PST) X-Received: by 2002:a19:7709:: with SMTP id s9mr29851339lfc.682.1636910920234; Sun, 14 Nov 2021 09:28:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910920; cv=none; d=google.com; s=arc-20160816; b=DRNwy1j2IKx+G3eMhTfxF0OMwwJ2xkTvDnYtmZf19zR/j89Reer7MoIKpDqqqnekSU vaAfTi3ktU/Z84u0Ns+a7eLURnlWd8opfXlkrUjLW0cTsQWo8hhDAimvXbELKlFG8s3e BZ9Tadjs56dxG2t8NnzIaU493AWTZps6tWiOaZftvqDv3vsxpeeqI6tdNszmMfT8afgt I7JOyt242GButydwm8CN8DoOXTyIkjvksHV3nVNgKRWQfyRdwwn0CgicWkoEHE+OsU8d 0RusSWIyeT25b8mPIsso+vMEaJQQW4lXL627OnNI3vq00HM+HaEIIKZXg3US31MmGlwM 1zgA== 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=V1g+fND9bOc8sJTlX7Y2R32gvr7TPE4UvQ3cZ9RpsY0=; b=D0+YAxBL6wHqPRPHrogCQX4CLfW5ddRMb39XMIsFxKcn67DC41zZfSewaKQazuGyDf yRegIG/MWgYoowJqE1WXm2hkOCug9vBZuHnxtxyrJhDkCtS1nfbFqKDncCWUqonQt5sL lUOkdPdk8FglsDbQNn5thWeC3PH15kwgNg94Yio4gQgZBuz6JNC3vRa3E+yNYwny63DT c36Zz+9XfoCbKUYXR/Y7CnwWHd55c7faKpRCezrC8QVVF7xyZ86qM/WriLxIf7mEJhvK hm/aS2L+gvy7jOjW2QYAnVeCfz8TtKjsgiJjGbItIeEJqyesZH9tKofK5x2G2xThOVUD 5M3Q== 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 c12si932762ljf.4.2021.11.14.09.28.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:40 -0800 (PST) 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 4HsfS75TS5z1rk5n; Sun, 14 Nov 2021 18:28:39 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfS75D2Wz1qqkC; Sun, 14 Nov 2021 18:28:39 +0100 (CET) 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 i85VcljP-7-7; Sun, 14 Nov 2021 18:28:39 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:39 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id B220945408E4; Sun, 14 Nov 2021 18:28:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 062lneKhX5ye; Sun, 14 Nov 2021 18:28:35 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 01ACD4542900; Sun, 14 Nov 2021 18:27:47 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 29/36] Start chunks downloader if delta is enabled Date: Sun, 14 Nov 2021 18:27:26 +0100 Message-Id: <20211114172733.71602-30-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: , Start the downloader process if delta is activated. The process is monitored by SWUpdate. Signed-off-by: Stefano Babic --- core/swupdate.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/swupdate.c b/core/swupdate.c index d651f8e..d3b8ef3 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -41,6 +41,7 @@ #include "network_ipc.h" #include "sslapi.h" #include "suricatta/suricatta.h" +#include "delta_process.h" #include "progress.h" #include "parselib.h" #include "swupdate_settings.h" @@ -853,6 +854,17 @@ int main(int argc, char **argv) freeargs(dwlav); } #endif +#if defined(CONFIG_DELTA) + { + uid_t uid; + gid_t gid; + read_settings_user_id(&handle, "download", &uid, &gid); + start_subprocess(SOURCE_CHUNKS_DOWNLOADER, "chunks_downloader", uid, gid, + cfgfname, ac, av, + start_delta_downloader); + } +#endif + /* * Start all processes added in the config file From patchwork Sun Nov 14 17:27:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554928 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=AENo6vhk; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::43d; helo=mail-wr1-x43d.google.com; envelope-from=swupdate+bncbcxploxj6ikrb74rywgamgqe4kem6sq@googlegroups.com; receiver=) Received: from mail-wr1-x43d.google.com (mail-wr1-x43d.google.com [IPv6:2a00:1450:4864:20::43d]) (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 4Hsfch2HHkz9sR4 for ; Mon, 15 Nov 2021 04:36:02 +1100 (AEDT) Received: by mail-wr1-x43d.google.com with SMTP id h13-20020adfa4cd000000b001883fd029e8sf2593210wrb.11 for ; Sun, 14 Nov 2021 09:36:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636911360; cv=pass; d=google.com; s=arc-20160816; b=Il+m2gOgs4VuY+k3fBih/rath5MDvMLz4JqmZgBlg989aDhziA2kr9C88z+Hx4NHkV FeROL8A4VEEUmbKsQoidcNAo+Z/P861yS349So+iO7MaJWSFaNJMNXbYyrDTR9SQchIT HiDho+X4nkqpKnfbw0Ctc0cOBkNjADibyIVVGQ94MI7+1b8/+68WVc0Wa//Bm6hKhYOH lbzH5WaeljCbLMh2J8KOUhi3wereNlUFEVBlishh84jLamUvyxAmPW04EUbiNdICRBZW f4kgilODmRMuyUjw7MkB/8u5hV1Qztbk4878k1e5TesALKRhVvgZma5ywa9JbDAFb0U6 GIVw== 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=GPGnYc4z3YRebboAw0lWr7ZHPwd5+viigOYo8Ghm2+c=; b=y5/6/Az7vLc/8hQLDJhMNeKeRnTAUuFl7dZnSRy4Tuv+k0d9++ojbDycbI48QPqB5n ikoMoIyKInMDSqRb5qUHAa3q9WJrdgz72kGlKq7eQJ82bOEC5mYVQUBVoG9OYODSqNyw KBh9+4wj8yyOy/L0bQwWpKJi2ulKwKPT7GiwQkAAL+wClZGyWZlIRymqzqC2Kwwua325 Mao/uvMSa5hlUjAFtFcDPOoeP72P38JVAzshT/AB6M6k9lLw5D/esaRFDNOhY/BE4m6a U8cD0GfSzAFAg6x3HBV1YnpvtXSwsTQcUpbJpbyf6k88NsqCwbcYtgkFaLufRHReloE7 zvxA== 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=GPGnYc4z3YRebboAw0lWr7ZHPwd5+viigOYo8Ghm2+c=; b=AENo6vhkf1wN4lyPEYIzlcNCd3WV4kO3Ux+/7xQho+okDH7SYrVbqAEPopnLXAxnlo pNx5HI1To0cGkyfC4DhbJVj8yIh2ciDN6ovGREDgLMlCPtH3TuMKv7dj7gZxjFz4mPnj OxLIfpwb9Tqog7ZSc1dQJPE9K8P50UB4is77a+AVH7tnteQZKewgBkL6kmZGMN5muIoJ n2lvN6BuLTZTHtK6G+faeXA5E8vH5y0BR/QZ3AKA4rxajnAwNyEY3v6HVZRdYp9BbcU6 eHvZcdw2NX+qLzu6K5OnQyhR563PWBMhEjKEIZ9RyLpE8HM6rueR+HiZO7c0O4ew3tHc kBmA== 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=GPGnYc4z3YRebboAw0lWr7ZHPwd5+viigOYo8Ghm2+c=; b=XWxTqerAhkVvVpnZlP/QzHUHh4hptZWaLkmgHXTRyd/LzcIo7aXRPcvkHamADUOIW4 5ov22ptJY0B6Opacegfn/hw4ldgnvmovd+zh3wGcYbt5H9yc/4hXHyBg2fpRiDllxB7X inQkAlXrYglWYUANJ5l26+PyjSA3T+CwQn58PVlaALDWpq96tdkKBnxXR3CwLXkEbyAN ny71JG0kCj00s27VTU3wOCWB9qRmNNhZ2st7o8EuJ/jZ+pPzta1ry+pbHTMrMGbbIaqE yF0hOROYEHla7qRjCe1hzGp0qGaV1H9qwn/2/lPF/Ou3kwnHVIBTw7qmFHucu96BYxPf fIgA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530k6Ey0kR5eNiRe7+IZ/o7Mqgu/oXpt4ugcAtS3pqnJS9YeWY45 mi4jsbkYnwJaIRmKiVatym4= X-Google-Smtp-Source: ABdhPJy7Om7ljxQ3Irrz7pYhJkv2z6lx0USlf/+QgukY70U1ugp/hRIYT/HMRu02YlBukLbmPvVQ9w== X-Received: by 2002:adf:e810:: with SMTP id o16mr39184507wrm.359.1636911359937; Sun, 14 Nov 2021 09:35:59 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a1c:770f:: with SMTP id t15ls5667091wmi.3.gmail; Sun, 14 Nov 2021 09:35:59 -0800 (PST) X-Received: by 2002:a1c:1f94:: with SMTP id f142mr54213722wmf.192.1636911359152; Sun, 14 Nov 2021 09:35:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636911359; cv=none; d=google.com; s=arc-20160816; b=PmwDlZ/bnrNX77IyU4u+Ts0ohXMC8kFp7WK79X9bSkIAiz040RUxr5GwxEwF5A6JZ+ qG5S82bfKpQ3z0iEODu/4V4h0kYD0AH3y3pyg90B2tOvkoQSkqWTjTJ8+BoL8Hj046Pd KL4M0u/Lx4KHer0FX6PtpOVe5Y1A4LnPQnDgb9Bq/0sIw9l5J9zW6ZISEHHLVIr+4lPB sOXw3s6O6POLxiofFuswuC5n1i0EmffcRFAsyni8w8ZV0HpqcUEASFDQYGufkbPdAl07 Hs90BVu/PaH+aFnEYOKV3MSmIq9ePqq4tdp+6gd5jV6+JvL10xX+Xpx5NYVdnMRTC0Kn OCHA== 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=SuWJ3d0vBdKg2Lu4YxMxBTPPlPTvTH8oq/UQ24aG6rU=; b=b2rQjjtCdXVnS9ZWXrYIRR/VL0HXfKrgY22/ANiR2GbowDGuRBQR0k3HorIoBGmsZB h95M7ZhaBHI0DD5UC4yTYa/9q8T193Jg4c1vTvGnDIyTFE2LVmFB5seM7s0ZUxl1BolQ zhFhJKtWOzqVdjQFD0yozwc/LRCty/sidqtFGbmiryvemPmjPGU20OX1NehlXjHm0X/l +phWNXP0uLlCSScJwx2I0O3qP/gSCdJDKHlOAhWxNugSvYsIzXocf/FmVBsEyjp01tzS 7skWXsp09BO4PzvgHvAESc1kC2kwKEO+a/lBbk6MmD1l4dAwyJ6FisCY6et8dlf6M1Q1 QNfw== 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 z3si1069929wmi.2.2021.11.14.09.35.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:35:59 -0800 (PST) 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 4HsfcZ6wLBz1s9Qv; Sun, 14 Nov 2021 18:35:58 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfcZ6Mw6z1qqkB; Sun, 14 Nov 2021 18:35:58 +0100 (CET) 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 13Y5QjDsCduz; Sun, 14 Nov 2021 18:35:58 +0100 (CET) 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; Sun, 14 Nov 2021 18:35:57 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 3B7284540853; Sun, 14 Nov 2021 18:28:41 +0100 (CET) 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 9D8N6v9Yfs06; Sun, 14 Nov 2021 18:28:38 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 116AE4542913; Sun, 14 Nov 2021 18:27:47 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 30/36] Introduce own version of zckRange from zchunk Date: Sun, 14 Nov 2021 18:27:27 +0100 Message-Id: <20211114172733.71602-31-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: , Import from zchunk project code to generate a Bytes Request from a list of chunks. Code is imported to get more control and internals to the range as the original library. Signed-off-by: Stefano Babic --- handlers/zchunk_range.c | 187 ++++++++++++++++++++++++++++++++++++++++ handlers/zchunk_range.h | 41 +++++++++ 2 files changed, 228 insertions(+) create mode 100644 handlers/zchunk_range.c create mode 100644 handlers/zchunk_range.h diff --git a/handlers/zchunk_range.c b/handlers/zchunk_range.c new file mode 100644 index 0000000..5bdd5cd --- /dev/null +++ b/handlers/zchunk_range.c @@ -0,0 +1,187 @@ +/* + * (C) Copyright 2021 + * Stefano Babic, sbabic@denx.de. + * Copyright 2018 Jonathan Dieter + * + * SPDX-License-Identifier: GPL-2.0-only + */ + +/* + * This code is mostly taken from "range.c" from the zchunk project. + * See Copyright above. Changes here are to get more internals from Range, + * that are not exported by zck library. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "zchunk_range.h" +#include "util.h" + +#define BUF_SIZE 32768 +static zck_range_item *range_insert_new(zck_range_item *prev, + zck_range_item *next, uint64_t start, + uint64_t end) { + zck_range_item *new = calloc(1, sizeof(zck_range_item)); + if (!new) { + ERROR("OOM in %s", __func__); + return NULL; + } + new->start = start; + new->end = end; + if(prev) { + new->prev = prev; + prev->next = new; + } + if(next) { + new->next = next; + next->prev = new; + } + return new; +} + +static zck_range_item *range_remove(zck_range_item *range) { + zck_range_item *next = range->next; + if(range->next) + range->next->prev = range->prev; + free(range); + return next; +} + +static void range_merge_combined(zck_range *info) { + if(!info) { + ERROR("zck_range not allocated"); + return; + } + for(zck_range_item *ptr=info->first; ptr;) { + if(ptr->next && ptr->end >= ptr->next->start-1) { + if(ptr->end < ptr->next->end) + ptr->end = ptr->next->end; + ptr->next = range_remove(ptr->next); + info->count -= 1; + } else { + ptr = ptr->next; + } + } +} + +static bool range_add(zck_range *info, zckChunk *chk) { + if(info == NULL || chk == NULL) { + ERROR("zck_range or zckChunk not allocated"); + return false; + } + + size_t start = zck_get_chunk_start(chk); + size_t end = zck_get_chunk_start(chk) + zck_get_chunk_comp_size(chk) - 1; + zck_range_item *prev = info->first; + for(zck_range_item *ptr=info->first; ptr;) { + prev = ptr; + if(start > ptr->start) { + ptr = ptr->next; + continue; + } else if(start < ptr->start) { + if(range_insert_new(ptr->prev, ptr, start, end) == NULL) + return false; + if(info->first == ptr) { + info->first = ptr->prev; + } + info->count += 1; + range_merge_combined(info); + return true; + } else { // start == ptr->start + if(end > ptr->end) + ptr->end = end; + info->count += 1; + range_merge_combined(info); + return true; + } + } + /* We've only reached here if we should be last item */ + zck_range_item *new = range_insert_new(prev, NULL, start, end); + if(new == NULL) + return false; + if(info->first == NULL) + info->first = new; + info->count += 1; + range_merge_combined(info); + return true; +} + +void zchunk_range_free(zck_range **info) { + zck_range_item *next = (*info)->first; + while(next) { + zck_range_item *tmp = next; + next = next->next; + free(tmp); + } + free(*info); + *info = NULL; +} + +char *zchunk_get_range_char(zck_range *range) { + int buf_size = BUF_SIZE; + char *output = calloc(1, buf_size); + if (!output) { + ERROR ("OOM in %s", __func__); + return NULL; + } + int loc = 0; + int count = 0; + zck_range_item *ri = range->first; + while(ri) { + int length = snprintf(output+loc, buf_size-loc, "%lu-%lu,", + (long unsigned)ri->start, + (long unsigned)ri->end); + if(length < 0) { + ERROR("Unable to get range: %s", strerror(errno)); + free(output); + return NULL; + } + if(length > buf_size-loc) { + buf_size = (int)(buf_size * 1.5); + output = saferealloc(output, buf_size); + if (!output) { + ERROR ("OOM in %s", __func__); + return output; + } + continue; + } + loc += length; + count++; + ri = ri->next; + } + output[loc-1]='\0'; // Remove final comma + output = saferealloc(output, loc); + return output; +} + +zck_range *zchunk_get_missing_range(zckCtx *zck, zckChunk *first, int max_ranges) { + if (!zck) + return NULL; + zck_range *range = calloc(1, sizeof(zck_range)); + if (!range) { + ERROR ("OOM in %s", __func__); + return NULL; + } + + for(zckChunk *chk = first ? first : zck_get_first_chunk(zck); chk; chk = zck_get_next_chunk(chk)) { + if (zck_get_chunk_valid(chk)) + continue; + if(!range_add(range, chk)) { + zchunk_range_free(&range); + return NULL; + } + if(max_ranges >= 0 && range->count >= max_ranges) + break; + } + return range; +} + +int zchunk_get_range_count(zck_range *range) { + return range->count; +} diff --git a/handlers/zchunk_range.h b/handlers/zchunk_range.h new file mode 100644 index 0000000..0a770fe --- /dev/null +++ b/handlers/zchunk_range.h @@ -0,0 +1,41 @@ +/* + * (C) Copyright 2021 + * Stefano Babic, sbabic@denx.de. + * + * SPDX-License-Identifier: GPL-2.0-only + */ + +#pragma once + +#include +#include +#include +#include +#include + +/* Contains a single range */ +typedef struct zck_range_item { + size_t start; + size_t end; + struct zck_range_item *next; + struct zck_range_item *prev; +} zck_range_item; + +typedef struct zck_range { + unsigned int count; + zck_range_item *first; +} zck_range; + +/* exported function */ + +/* Get a Range from a zck context */ +zck_range *zchunk_get_missing_range(zckCtx *zck, zckChunk *chk, int max_ranges); + +/* Return number of ranges */ +int zchunk_get_range_count(zck_range *range); + +/* Return string to be used in HTTP Bytes Range */ +char *zchunk_get_range_char(zck_range *range); + +/* Free range allocated by zchunk_get_missing_range */ +void zchunk_range_free(zck_range **info); From patchwork Sun Nov 14 17:27:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554931 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=HBFvIWRm; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::53e; helo=mail-ed1-x53e.google.com; envelope-from=swupdate+bncbcxploxj6ikrbamsywgamgqenxauf6i@googlegroups.com; receiver=) Received: from mail-ed1-x53e.google.com (mail-ed1-x53e.google.com [IPv6:2a00:1450:4864:20::53e]) (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 4Hsfch6VTVz9sRR for ; Mon, 15 Nov 2021 04:36:04 +1100 (AEDT) Received: by mail-ed1-x53e.google.com with SMTP id v10-20020aa7d9ca000000b003e7bed57968sf836369eds.23 for ; Sun, 14 Nov 2021 09:36:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636911361; cv=pass; d=google.com; s=arc-20160816; b=oSPn+PqBRpC04oik+ggQ8SQix1lW0KutoxyI6B0ixkyKsIcGGHYZ1Gl3T1nrrLT8KY d/H+0e9+CIjR0QKRMSdOCxqbG6yR6Z6iVhX7co0gHcgRqgHzJw4WOPREXuz/neb/5bnV MIbMTc+UqYYRDtSoBzOO8LBsQkBV9pE4A5EjA8uL5aZ5BgfOLPp81VBI6AZUgAr6EheK Xgu7btOF5m5oOaqOBZeUEuQ5g0uUrE6Teysb7NY9C5g8gI8G8ikCTWJKVLmKog6gGNc8 1z7lA65GOD2wf4POTqKaneW/zT57C7Pz+4d7EVorvkjXidv2AgylF4v2xCl0yMCgw0ZH xF2Q== 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=eRP48KJd043h1V9MoZ2KMcvaFDIV7RloDxRJfGrEXOs=; b=MiCKKs/Tp+0aEdMKjUySnPDohXrKKUT3jNKuWOu0nGCDY0p8en0GRpEAUdTvaTKI7p s8SPnQXfKRLVoT/rHXJTI2bWbcNRnPQHJh50owlN/csi0t1v+dOQl1S5aRL9WzkTCqnB mtxFw/htoylFpuPQSovPAU1zJGFzJzcKz+kjVJ0X+8GYS+LmHRSYAOCjd3L2Rj8H2hOg SXgmROLjjvudFUhjRlGFR85LjNIdebzvXpxJ8UjwPXUQe81GNh18etqY2Btsh8xVkn/8 ZO0kpdJ7HrmxTGllPjdlr58KtkKJNqQt3heHMF1rjRhOkBBTqxAVlUvRB6p1AGWlWs4K mihw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=eRP48KJd043h1V9MoZ2KMcvaFDIV7RloDxRJfGrEXOs=; b=HBFvIWRmlYX87OWV6/yIRVCssR8dOy7Cbyk/qiLSTeuyTI9xY+clVOl7GRFfeGR7Mr Fn7OTZ2UyMuev62tXW7xK0vjtyO1zKrzoM4UWgbuJ6eF5vo0rR0EsaqcBmnMNy2JeNCC YFh9NKlILMuWmPvG7nGt1ZrpKY9UoXy0khAkYLn+nW+42TYdMVfH3KGB0lY9Tep0OSIy Qt4HmeUWfSvpoVrwTEXbhefpg0Mkp6H6wmghNixvlDPQtCIDup/gIc2nIk9+ZEd3uYkx FHRWkBtA0spcUGeAIFEiIqCliV5yKAKhRcO3jNmAXcOqpoCwcswlUXOctgMYAMyMaXnK lkmA== 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=eRP48KJd043h1V9MoZ2KMcvaFDIV7RloDxRJfGrEXOs=; b=gxmWmSlM6MDAbFrweR2zBsnVLsDtZbLJCShFlJlq2ndXE3wcSR1V3LIM2TeCsxxJ+V UYBxV7zFjqPujDc+egWjd9NSCSgwZz+0J885UpYRf0d38GJF9ajmEyCrg7JVEW5BZljN ZJ/QNnnRngNDbYPOvf1qmdatuZ1rjUxK145HDmTKC5csB7v7YODuoWvwWmfxrGNgrdSV lVuWZ/AxQe6Qg0afIOH9NEZnUftuleCmvp41z0XGOMOl0gpIUxxiIIIYkJVPtht/zEWX 5ZnFmrBF6WFEDtRJlB/l1pfT5LUp72LTlFB4BwngbquDtf7pUyF6UvDGZh5SEYrqU6H0 fbaQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532CwJnrZ5xD6EyfyXg8+R2qu2Ek91+4oH7pRFo4tPw5bKGkaShg 0y4VWuHdZN4LfX5/HPtowqg= X-Google-Smtp-Source: ABdhPJyZDXewXDAOkYdljnwcsWX8EHo/aEVkSYQ79ixo/3f5B/f22AlP/K/4mMMGWzt69LutQrZdrQ== X-Received: by 2002:a05:6402:100e:: with SMTP id c14mr46535346edu.196.1636911361257; Sun, 14 Nov 2021 09:36:01 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:907:c0a:: with SMTP id ga10ls4623495ejc.9.gmail; Sun, 14 Nov 2021 09:36:00 -0800 (PST) X-Received: by 2002:a17:907:728a:: with SMTP id dt10mr40516121ejc.526.1636911360405; Sun, 14 Nov 2021 09:36:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636911360; cv=none; d=google.com; s=arc-20160816; b=dKGyaQbhvjwwdT0/T8vnV2ys1w8T4glIN7wKQcHKFbst12ZNqDo6lqUtXrznU+L9A/ zsGG9XceWTjcfhb0uKDoj+Lqsvi5MUVqkphApsD/okLJjvqHBOVub64X3O94Zf6WFNnU 2CiCoXnYnl2bv3d67s1QnQCAKoY7YzJt15UT8cyqfxKcPvixSBFssKCmOoalPkXiFKtt M2ErGzym0AwQlgqaV7gWCc5J5M5uIO06SFw5GDmLdHUhkQSGXfaMLYzOex+gfLGu0T4H aYGzbDqkbFoaRBOzq3anQMihIxI2KJoF9Zi5iowPsNtzO6XVjsndZ5JY8seeEOTf9cpk bxig== 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=8VhGfszrsHAyUKhlAW5oXsrvYhkEPQqzpFXSxyTRyZQ=; b=FjRdMg3bkjjFL8rR+H8x+Mshr1qc26Tu0HlJAEmybybsI0QRp5lblX93EunFKWUOiP 2htfbGixQSSCAQRFD97db1jBa9CuGXF1/xF/kIokdV2r5YEEG0iX0xyM1NDjlH6RRKbm Ebt25qPK9QvP09RuHyuztsjDJC+PeZ/0ceKeKzcloRIShacADminUQmIpNpLE7zA3EWY YtJFl5dMEiN+dy+ET4xYwF6yW8lHrpXEpoJNjfHkoq8U/Zhnxv2YQHrkT9T9wpWqD8NW N/ZsT+Hu/hKUuRodpQKhencM1VJS5eNy1qFMqBobLXonW2PGpasU5pOAs5VqNxtWw6yM tRxA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id fl21si921652ejc.0.2021.11.14.09.36.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:36:00 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Hsfcc1Dpfz1qwdZ; Sun, 14 Nov 2021 18:36:00 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Hsfcc17Vqz1qqkB; Sun, 14 Nov 2021 18:36:00 +0100 (CET) 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 sk6Tl18COuaI; Sun, 14 Nov 2021 18:35:57 +0100 (CET) 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; Sun, 14 Nov 2021 18:35:57 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 4FC0E45408E4; Sun, 14 Nov 2021 18:28:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 0a4lLe_vBlwc; Sun, 14 Nov 2021 18:28:38 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 28BF2454292A; Sun, 14 Nov 2021 18:27:47 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 31/36] delta: add handler for delta update Date: Sun, 14 Nov 2021 18:27:28 +0100 Message-Id: <20211114172733.71602-32-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , Large size or small bandwidth require to reduce the size of the downloaded data. This implements a delta update using the zchunk project as basis. The full documentation and design specification is in doc. Signed-off-by: Stefano Babic --- Kconfig | 4 + Makefile.deps | 4 + Makefile.flags | 5 + handlers/Config.in | 12 + handlers/Makefile | 1 + handlers/delta_handler.c | 1072 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 1098 insertions(+) create mode 100644 handlers/delta_handler.c diff --git a/Kconfig b/Kconfig index cb86d55..e28b8a6 100644 --- a/Kconfig +++ b/Kconfig @@ -117,6 +117,10 @@ config HAVE_URIPARSER bool option env="HAVE_URIPARSER" +config HAVE_ZCK + bool + option env="HAVE_ZCK" + menu "Swupdate Settings" menu "General Configuration" diff --git a/Makefile.deps b/Makefile.deps index 3f4cbf9..58ed373 100644 --- a/Makefile.deps +++ b/Makefile.deps @@ -109,3 +109,7 @@ endif ifeq ($(HAVE_URIPARSER),) export HAVE_URIPARSER = y endif + +ifeq ($(HAVE_ZCK),) +export HAVE_ZCK = y +endif diff --git a/Makefile.flags b/Makefile.flags index e549b46..019ef77 100644 --- a/Makefile.flags +++ b/Makefile.flags @@ -226,6 +226,11 @@ ifneq ($(CONFIG_SWUFORWARDER_HANDLER),) LDLIBS += websockets uriparser endif +# Delta Update +ifneq ($(CONFIG_DELTA),) +LDLIBS += zck +endif + # If a flat binary should be built, CFLAGS_swupdate="-elf2flt" # env var should be set for make invocation. # Here we check whether CFLAGS_swupdate indeed contains that flag. diff --git a/handlers/Config.in b/handlers/Config.in index 01663db..11c0b2d 100644 --- a/handlers/Config.in +++ b/handlers/Config.in @@ -60,6 +60,18 @@ config CFIHAMMING1 You do not need this if you do not have an OMAP SoC. +config DELTA + bool "delta" + depends on HAVE_LIBCURL + depends on HAVE_ZSTD + depends on HAVE_ZCK + select CHANNEL_CURL + default n + help + Handler to enable delta images. The handler computes the differences + and download the missing parts, and pass the resulting image to the + next handler. + config DISKPART bool "diskpart" depends on HAVE_LIBFDISK diff --git a/handlers/Makefile b/handlers/Makefile index 534259c..2b6faee 100644 --- a/handlers/Makefile +++ b/handlers/Makefile @@ -11,6 +11,7 @@ obj-y += dummy_handler.o obj-$(CONFIG_ARCHIVE) += archive_handler.o obj-$(CONFIG_BOOTLOADERHANDLER) += boot_handler.o obj-$(CONFIG_CFI) += flash_handler.o +obj-$(CONFIG_DELTA) += delta_handler.o delta_downloader.o zchunk_range.o obj-$(CONFIG_DISKFORMAT_HANDLER) += diskformat_handler.o obj-$(CONFIG_DISKPART) += diskpart_handler.o obj-$(CONFIG_UNIQUEUUID) += uniqueuuid_handler.o diff --git a/handlers/delta_handler.c b/handlers/delta_handler.c new file mode 100644 index 0000000..d959509 --- /dev/null +++ b/handlers/delta_handler.c @@ -0,0 +1,1072 @@ +/* + * (C) Copyright 2021 + * Stefano Babic, sbabic@denx.de. + * + * SPDX-License-Identifier: GPL-2.0-only + */ + +/* + * This handler computes the difference between an artifact + * and an image on the device, and download the missing chunks. + * The resulting image is then passed to a chained handler for + * installing. + * The handler uses own properties and it shares th same + * img struct with the chained handler. All other fields + * in sw-description are reserved for the chain handler, that + * works as if there is no delta handler in between. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "delta_handler.h" +#include "multipart_parser.h" +#include "installer.h" +#include "zchunk_range.h" + +#define FIFO_FILE_NAME "deltafifo" +#define DEFAULT_MAX_RANGES 150 /* Apache has default = 200 */ + +const char *handlername = "delta"; +void delta_handler(void); + +/* + * Structure passed to callbacks + */ +/* + * state machine when answer from + * server is parsed. + */ +typedef enum { + NOTRUNNING, + WAITING_FOR_HEADERS, + WAITING_FOR_BOUNDARY, + WAITING_FOR_FIRST_DATA, + WAITING_FOR_DATA, + END_TRANSFER +} dwl_state_t; + +/* + * There are two kind of answer from an HTTP Range request: + * - if just one range is selected, the server sends a + * content-range header with the delivered bytes as + * -/ + * - if multiple ranges are requested, the server sends + * a multipart answer and sends a header with + * Content-Type: multipart/byteranges; boundary= + */ +typedef enum { + NONE_RANGE, /* Range not found in Headers */ + SINGLE_RANGE, + MULTIPART_RANGE +} range_type_t; + +struct dwlchunk { + unsigned char *buf; + size_t chunksize; + size_t nbytes; + bool completed; +}; + +struct hnd_priv { + /* Attributes retrieved from sw-descritpion */ + char *url; /* URL to get full ZCK file */ + char *srcdev; /* device as source for comparison */ + char *chainhandler; /* Handler to pass the decompressed image */ + zck_log_type zckloglevel; /* if found, set log level for ZCK to this */ + unsigned long max_ranges; /* Max allowed ranges (configured via sw-description) */ + /* Data to be transferred to chain handler */ + struct img_type img; + char fifo[80]; + int fdout; + int fdsrc; + zckCtx *tgt; + /* Structures for downloading chunks */ + bool dwlrunning; + range_type_t range_type; /* Single or multipart */ + char boundary[SWUPDATE_GENERAL_STRING_SIZE]; + int pipetodwl; /* pipe to downloader process */ + dwl_state_t dwlstate; /* for internal state machine */ + range_answer_t *answer; /* data from downloader */ + uint32_t reqid; /* Current request id to downloader */ + struct dwlchunk current; /* Structure to collect data for working chunk */ + zckChunk *chunk; /* Current chunk to be processed */ + size_t rangelen; /* Value from Content-range header */ + size_t rangestart; /* Value from Content-range header */ + bool content_range_received; /* Flag to indicate that last header is content-range */ + bool error_in_parser; /* Flag to report if an error occurred */ + multipart_parser *parser; /* pointer to parser, allocated at any download */ + /* Some nice statistics */ + size_t bytes_to_be_reused; + size_t bytes_to_download; + size_t totaldwlbytes; /* bytes downloaded, including headers */ + /* flags to improve logging */ + bool debugchunks; +}; + +static bool copy_existing_chunks(zckChunk **dstChunk, struct hnd_priv *priv); + +/* + * Callbacks for multipart parsing. + */ +static int network_process_data(multipart_parser* p, const char *at, size_t length) +{ + struct hnd_priv *priv = (struct hnd_priv *)multipart_parser_get_data(p); + size_t nbytes = length; + const char *bufSrc = at; + int ret; + + /* Stop if previous error occurred */ + if (priv->error_in_parser) + return -EFAULT; + + while (nbytes) { + size_t to_be_filled = priv->current.chunksize - priv->current.nbytes; + size_t tobecopied = min(nbytes, to_be_filled); + memcpy(&priv->current.buf[priv->current.nbytes], bufSrc, tobecopied); + priv->current.nbytes += tobecopied; + nbytes -= tobecopied; + bufSrc += tobecopied; + /* + * Chunk complete, it must be copied + */ + if (priv->current.nbytes == priv->current.chunksize) { + char *sha = zck_get_chunk_digest(priv->chunk); + unsigned char hash[SHA256_HASH_LENGTH]; /* SHA-256 is 32 byte */ + ascii_to_hash(hash, sha); + free(sha); + + if (priv->debugchunks) + TRACE("Copying chunk %ld from NETWORK, size %ld", + zck_get_chunk_number(priv->chunk), + priv->current.chunksize); + if (priv->current.chunksize != 0) { + ret = copybuffer(priv->current.buf, + &priv->fdout, + priv->current.chunksize, + COMPRESSED_ZSTD, + hash, + 0, + NULL, + NULL); + } else + ret = 0; /* skipping, nothing to be copied */ + /* Buffer can be discarged */ + free(priv->current.buf); + priv->current.buf = NULL; + /* + * if an error occurred, stops + */ + if (ret) { + ERROR("copybuffer failed !"); + priv->error_in_parser = true; + return -EFAULT; + } + /* + * Set the chunk as completed and switch to next one + */ + priv->chunk = zck_get_next_chunk(priv->chunk); + if (!priv->chunk && nbytes > 0) { + WARN("Still data in range, but no chunks anymore !"); + close(priv->fdout); + } + if (!priv->chunk) + break; + + size_t current_chunk_size = zck_get_chunk_comp_size(priv->chunk); + priv->current.buf = (unsigned char *)malloc(current_chunk_size); + if (!priv->current.buf) { + ERROR("OOM allocating new chunk %lu!", current_chunk_size); + priv->error_in_parser = true; + return -ENOMEM; + } + + priv->current.nbytes = 0; + priv->current.chunksize = current_chunk_size; + } + } + return 0; +} + +/* + * This is called after headers are processed. Allocate a + * buffer big enough to contain the next chunk to be processed + */ +static int multipart_data_complete(multipart_parser* p) +{ + struct hnd_priv *priv = (struct hnd_priv *)multipart_parser_get_data(p); + size_t current_chunk_size; + + current_chunk_size = zck_get_chunk_comp_size(priv->chunk); + priv->current.buf = (unsigned char *)malloc(current_chunk_size); + priv->current.nbytes = 0; + priv->current.chunksize = current_chunk_size; + /* + * Buffer check should be done in each callback + */ + if (!priv->current.buf) { + ERROR("OOM allocating new chunk !"); + return -ENOMEM; + } + + return 0; +} + +/* + * This is called after a range is completed and before next range + * is processed. Between two ranges, chunks are taken from SRC. + * Checks which chunks should be copied and copy them until a chunk must + * be retrieved from network + */ +static int multipart_data_end(multipart_parser* p) +{ + struct hnd_priv *priv = (struct hnd_priv *)multipart_parser_get_data(p); + free(priv->current.buf); + priv->current.buf = NULL; + priv->content_range_received = true; + copy_existing_chunks(&priv->chunk, priv); + return 0; +} + +/* + * Set multipart parser callbacks. + * No need at the moment to process multipart headers + */ +static multipart_parser_settings multipart_callbacks = { + .on_part_data = network_process_data, + .on_headers_complete = multipart_data_complete, + .on_part_data_end = multipart_data_end +}; + +/* + * Debug function to output all chunks and show if the chunk + * can be copied from current software or must be downloaded + */ +static size_t get_total_size(zckCtx *zck, struct hnd_priv *priv) { + zckChunk *iter = zck_get_first_chunk(zck); + size_t pos = 0; + priv->bytes_to_be_reused = 0; + priv->bytes_to_download = 0; + if (priv->debugchunks) + TRACE("Index Typ HASH %*c START(chunk) SIZE(uncomp) Pos(Device) SIZE(comp)", + (((int)zck_get_chunk_digest_size(zck) * 2) - (int)strlen("HASH")), ' ' + ); + while (iter) { + if (priv->debugchunks) + TRACE("%12lu %s %s %12lu %12lu %12lu %12lu", + zck_get_chunk_number(iter), + zck_get_chunk_valid(iter) ? "SRC" : "DST", + zck_get_chunk_digest_uncompressed(iter), + zck_get_chunk_start(iter), + zck_get_chunk_size(iter), + pos, + zck_get_chunk_comp_size(iter)); + + pos += zck_get_chunk_size(iter); + if (!zck_get_chunk_valid(iter)) { + priv->bytes_to_download += zck_get_chunk_comp_size(iter); + } else { + priv->bytes_to_be_reused += zck_get_chunk_size(iter); + } + iter = zck_get_next_chunk(iter); + } + + INFO("Total bytes to be reused : %12lu\n", priv->bytes_to_be_reused); + INFO("Total bytes to be downloaded : %12lu\n", priv->bytes_to_download); + + return pos; +} + +/* + * Get attributes from sw-description + */ +static int delta_retrieve_attributes(struct img_type *img, struct hnd_priv *priv) { + if (!priv) + return -EINVAL; + + priv->zckloglevel = ZCK_LOG_DDEBUG; + priv->url = dict_get_value(&img->properties, "url"); + priv->srcdev = dict_get_value(&img->properties, "source"); + priv->chainhandler = dict_get_value(&img->properties, "chain"); + if (!priv->url || !priv->srcdev || + !priv->chainhandler || !strcmp(priv->chainhandler, handlername)) { + ERROR("Wrong Attributes in sw-description: url=%s source=%s, handler=%s", + priv->url, priv->srcdev, priv->chainhandler); + free(priv->url); + free(priv->srcdev); + free(priv->chainhandler); + return -EINVAL; + } + errno = 0; + if (dict_get_value(&img->properties, "max-ranges")) + priv->max_ranges = strtoul(dict_get_value(&img->properties, "max-ranges"), NULL, 10); + if (errno || priv->max_ranges == 0) + priv->max_ranges = DEFAULT_MAX_RANGES; + + char *zckloglevel = dict_get_value(&img->properties, "zckloglevel"); + if (!zckloglevel) + return 0; + if (!strcmp(zckloglevel, "debug")) + priv->zckloglevel = ZCK_LOG_DEBUG; + else if (!strcmp(zckloglevel, "info")) + priv->zckloglevel = ZCK_LOG_INFO; + else if (!strcmp(zckloglevel, "warn")) + priv->zckloglevel = ZCK_LOG_WARNING; + else if (!strcmp(zckloglevel, "error")) + priv->zckloglevel = ZCK_LOG_ERROR; + else if (!strcmp(zckloglevel, "none")) + priv->zckloglevel = ZCK_LOG_NONE; + + char *debug = dict_get_value(&img->properties, "debug-chunks"); + if (debug) { + priv->debugchunks = true; + } + + return 0; +} + +/* + * Prepare a request for the chunk downloader process + * It fills a range_request structure with data for the + * connection + */ + +static range_request_t *prepare_range_request(const char *url, const char *range, size_t *len) +{ + range_request_t *req = NULL; + + if (!url || !len) + return NULL; + + if (strlen(range) > RANGE_PAYLOAD_SIZE - 1) { + ERROR("RANGE request too long !"); + return NULL; + } + req = (range_request_t *)calloc(1, sizeof(*req)); + if (req) { + req->id = rand(); + req->type = RANGE_GET; + req->urllen = strlen(url); + req->rangelen = strlen(range); + strcpy(req->data, url); + strcpy(&req->data[strlen(url) + 1], range); + } else { + ERROR("OOM preparing internal IPC !"); + return NULL; + } + + return req; +} + +/* + * ZCK and SWUpdate have different levels for logging + * so map them + */ +static zck_log_type map_swupdate_to_zck_loglevel(LOGLEVEL level) { + + switch (level) { + case OFF: + return ZCK_LOG_NONE; + case ERRORLEVEL: + return ZCK_LOG_ERROR; + case WARNLEVEL: + return ZCK_LOG_WARNING; + case INFOLEVEL: + return ZCK_LOG_INFO; + case TRACELEVEL: + return ZCK_LOG_DEBUG; + case DEBUGLEVEL: + return ZCK_LOG_DDEBUG; + } + return ZCK_LOG_ERROR; +} + +static LOGLEVEL map_zck_to_swupdate_loglevel(zck_log_type lt) { + switch (lt) { + case ZCK_LOG_NONE: + return OFF; + case ZCK_LOG_ERROR: + return ERRORLEVEL; + case ZCK_LOG_WARNING: + return WARNLEVEL; + case ZCK_LOG_INFO: + return INFOLEVEL; + case ZCK_LOG_DEBUG: + return TRACELEVEL; + case ZCK_LOG_DDEBUG: + return DEBUGLEVEL; + } + return loglevel; +} + +/* + * Callback for ZCK to send ZCK logs to SWUpdate instead of writing + * into a file + */ +static void zck_log_toswupdate(const char *function, zck_log_type lt, + const char *format, va_list args) { + LOGLEVEL l = map_zck_to_swupdate_loglevel(lt); + char buf[NOTIFY_BUF_SIZE]; + int pos; + + pos = snprintf(buf, NOTIFY_BUF_SIZE - 1, "(%s) ", function); + vsnprintf(buf + pos, NOTIFY_BUF_SIZE - 1 - pos, format, args); + + switch(l) { + case ERRORLEVEL: + ERROR("%s", buf); + return; + case WARNLEVEL: + WARN("%s", buf); + return; + case INFOLEVEL: + INFO("%s", buf); + return; + case TRACELEVEL: + TRACE("%s", buf); + return; + case DEBUGLEVEL: + TRACE("%s", buf); + return; + default: + return; + } +} + +/* + * Create a zck Index from a file + */ +static bool create_zckindex(zckCtx *zck, int fd) +{ + const size_t bufsize = 16384; + char *buf = malloc(bufsize); + ssize_t n; + int ret; + + if (!buf) { + ERROR("OOM creating temporary buffer"); + return false; + } + while ((n = read(fd, buf, bufsize)) > 0) { + ret = zck_write(zck, buf, n); + if (ret < 0) { + ERROR("ZCK returns %s", zck_get_error(zck)); + free(buf); + return false; + } + } + + free(buf); + + return true; +} + +/* + * Thread to start the chained handler. + * This received from FIFO the reassembled stream with + * the artifact and can pass it to the handler responsible for the install. + */ +static void *chain_handler_thread(void *data) +{ + struct hnd_priv *priv = (struct hnd_priv *)data; + struct img_type *img = &priv->img; + unsigned long ret; + + thread_ready(); + /* + * Try sometimes to open FIFO + */ + if (!priv->fifo) { + ERROR("Named FIFO not set, thread exiting !"); + return (void *)1; + } + for (int cnt = 5; cnt > 0; cnt--) { + img->fdin = open(priv->fifo, O_RDONLY); + if (img->fdin > 0) + break; + sleep(1); + } + if (img->fdin < 0) { + ERROR("Named FIFO cannot be opened, exiting"); + return (void *)1; + } + + img->install_directly = true; + ret = install_single_image(img, false); + + if (ret) { + ERROR("Chain handler return with Error"); + close(img->fdin); + } + + return (void *)ret; +} + +/* + * Chunks must be retrieved from network, prepare an send + * a request for the downloader + */ +static bool trigger_download(struct hnd_priv *priv) +{ + range_request_t *req = NULL; + zckCtx *tgt = priv->tgt; + size_t reqlen; + zck_range *range; + bool status = true; + + + priv->boundary[0] = '\0'; + + range = zchunk_get_missing_range(tgt, priv->chunk, priv->max_ranges); + TRACE("Range request : %s", zchunk_get_range_char(range)); + + req = prepare_range_request(priv->url, zchunk_get_range_char(range), &reqlen); + if (!req) { + ERROR(" Internal chunk request cannot be prepared"); + free(range); + return false; + } + + /* Store request id to compare later */ + priv->reqid = req->id; + priv->range_type = NONE_RANGE; + + if (write(priv->pipetodwl, req, sizeof(*req)) != sizeof(*req)) { + ERROR("Cannot write all bytes to pipe"); + status = false; + } + + free(req); + free(range); + priv->dwlrunning = true; + return status; +} + +/* + * drop all temporary data collected during download + */ +static void dwl_cleanup(struct hnd_priv *priv) +{ + multipart_parser_free(priv->parser); + priv->parser = NULL; +} + +static bool read_and_validate_package(struct hnd_priv *priv) +{ + ssize_t nbytes = sizeof(range_answer_t); + range_answer_t *answer; + int count = -1; + uint32_t crc; + + do { + count++; + if (count == 1) + DEBUG("id does not match in IPC, skipping.."); + + char *buf = (char *)priv->answer; + do { + ssize_t ret; + ret = read(priv->pipetodwl, buf, sizeof(range_answer_t)); + if (ret < 0) + return false; + buf += ret; + nbytes -= ret; + } while (nbytes > 0); + answer = priv->answer; + + if (nbytes < 0) + return false; + } while (answer->id != priv->reqid); + + + if (answer->type == RANGE_ERROR) { + ERROR("Transfer was unsuccessful, aborting..."); + priv->dwlrunning = false; + dwl_cleanup(priv); + return false; + } + + if (answer->type == RANGE_DATA) { + crc = crc32(0, (unsigned char *)answer->data, answer->len); + if (crc != answer->crc) { + ERROR("Corrupted package received !"); + exit(1); + return false; + } + } + + priv->totaldwlbytes += answer->len; + + return true; +} + +/* + * This is called to parse the HTTP headers + * It searches for content-ranges and select a SINGLE or + * MULTIPARTS answer. + */ +static bool parse_headers(struct hnd_priv *priv) +{ + int nconv; + char *header = NULL, *value = NULL, *boundary_string = NULL; + char **pair; + int cnt; + + range_answer_t *answer = priv->answer; + answer->data[answer->len] = '\0'; + /* Converto to lower case to make comparison easier */ + string_tolower(answer->data); + + /* Check for multipart */ + nconv = sscanf(answer->data, "%ms %ms %ms", &header, &value, &boundary_string); + + if (nconv == 3) { + if (!strncmp(header, "content-type", strlen("content-type")) && + !strncmp(boundary_string, "boundary", strlen("boundary"))) { + pair = string_split(boundary_string, '='); + cnt = count_string_array((const char **)pair); + if (cnt == 2) { + memset(priv->boundary, '-', 2); + strlcpy(&priv->boundary[2], pair[1], sizeof(priv->boundary) - 2); + priv->range_type = MULTIPART_RANGE; + } + free_string_array(pair); + } + + if (!strncmp(header, "content-range", strlen("content-range")) && + !strncmp(value, "bytes", strlen("bytes"))) { + pair = string_split(boundary_string, '-'); + priv->range_type = SINGLE_RANGE; + size_t start = strtoul(pair[0], NULL, 10); + size_t end = strtoul(pair[1], NULL, 10); + free_string_array(pair); + priv->rangestart = start; + priv->rangelen = end - start; + } + free(header); + free(value); + free(boundary_string); + } else if (nconv == 1) { + free(header); + } else if (nconv == 2) { + free(header); + free(value); + } + + return true; +} + +static bool search_boundary_in_body(struct hnd_priv *priv) +{ + char *s; + range_answer_t *answer = priv->answer; + size_t i; + + if (priv->range_type == NONE_RANGE) { + ERROR("Malformed body, no boundary found"); + return false; + } + + if (priv->range_type == SINGLE_RANGE) { + /* Body contains just one range, it is data, do nothing */ + return true; + } + s = answer->data; + for (i = 0; i < answer->len; i++, s++) { + if (!strncmp(s, priv->boundary, strlen(priv->boundary))) { + DEBUG("Boundary found in body"); + /* Reset buffer to start from here */ + if (i != 0) + memcpy(answer->data, s, answer->len - i); + answer->len -=i; + return true; + } + } + + return false; +} + +static bool fill_buffers_list(struct hnd_priv *priv) +{ + range_answer_t *answer = priv->answer; + /* + * If there is a single range, all chunks + * are consecutive. Same processing can be done + * as with multipart and data is received. + */ + if (priv->range_type == SINGLE_RANGE) { + return network_process_data(priv->parser, answer->data, answer->len) == 0; + } + + multipart_parser_execute(priv->parser, answer->data, answer->len); + + return true; +} + +/* + * copy_network_chunk() retrieves chunks from network and triggers + * a network transfer if no one is running. + * It collects data in a buffer until the chunk is fully + * downloaded, and then copies to the pipe to the installer thread + * starting the chained handler. + */ +static bool copy_network_chunks(zckChunk **dstChunk, struct hnd_priv *priv) +{ + range_answer_t *answer; + + priv->chunk = *dstChunk; + priv->error_in_parser = false; + while (1) { + switch (priv->dwlstate) { + case NOTRUNNING: + if (!trigger_download(priv)) + return false; + priv->dwlstate = WAITING_FOR_HEADERS; + break; + case WAITING_FOR_HEADERS: + if (!read_and_validate_package(priv)) + return false; + answer = priv->answer; + if (answer->type == RANGE_HEADERS) { + if (!parse_headers(priv)) { + return false; + } + } + if ((answer->type == RANGE_DATA)) { + priv->dwlstate = WAITING_FOR_BOUNDARY; + } + break; + case WAITING_FOR_BOUNDARY: + /* + * Not needed to read data because package + * was already written as last step in WAITING_FOR_HEADERS + */ + if (!search_boundary_in_body(priv)) + return false; + priv->parser = multipart_parser_init(priv->boundary, + &multipart_callbacks); + multipart_parser_set_data(priv->parser, priv); + priv->dwlstate = WAITING_FOR_FIRST_DATA; + break; + case WAITING_FOR_FIRST_DATA: + if (!fill_buffers_list(priv)) + return false; + priv->dwlstate = WAITING_FOR_DATA; + break; + case WAITING_FOR_DATA: + if (!read_and_validate_package(priv)) + return false; + answer = priv->answer; + if ((answer->type == RANGE_COMPLETED)) { + priv->dwlstate = END_TRANSFER; + } else if (!fill_buffers_list(priv)) + return false; + break; + case END_TRANSFER: + dwl_cleanup(priv); + priv->dwlstate = NOTRUNNING; + *dstChunk = priv->chunk; + return !priv->error_in_parser; + } + } + + return !priv->error_in_parser; +} + +/* + * This writes a chunk from an existing copy on the source path + * The chunk to be copied is retrieved via zck_get_src_chunk() + */ +static bool copy_existing_chunks(zckChunk **dstChunk, struct hnd_priv *priv) +{ + unsigned long offset = 0; + uint32_t checksum; + int ret; + unsigned char hash[SHA256_HASH_LENGTH]; + + while (*dstChunk && zck_get_chunk_valid(*dstChunk)) { + zckChunk *chunk = zck_get_src_chunk(*dstChunk); + size_t len = zck_get_chunk_size(chunk); + size_t start = zck_get_chunk_start(chunk); + char *sha = zck_get_chunk_digest_uncompressed(chunk); + if (!len) { + *dstChunk = zck_get_next_chunk(*dstChunk); + continue; + } + if (!sha) { + ERROR("Cannot get hash for chunk %ld", zck_get_chunk_number(chunk)); + return false; + } + if (lseek(priv->fdsrc, start, SEEK_SET) < 0) { + ERROR("Seeking source file at %lu", start); + free(sha); + return false; + } + + ascii_to_hash(hash, sha); + + if (priv->debugchunks) + TRACE("Copying chunk %ld from SRC %ld, start %ld size %ld", + zck_get_chunk_number(*dstChunk), + zck_get_chunk_number(chunk), + start, + len); + ret = copyfile(priv->fdsrc, &priv->fdout, len, &offset, 0, 0, COMPRESSED_FALSE, + &checksum, hash, false, NULL, NULL); + + free(sha); + if (ret) + return false; + + *dstChunk = zck_get_next_chunk(*dstChunk); + } + return true; +} + +/* + * Handler entry point + */ +static int install_delta(struct img_type *img, + void __attribute__ ((__unused__)) *data) +{ + struct hnd_priv *priv; + int ret = -1; + int dst_fd = -1, in_fd = -1; + zckChunk *iter; + range_request_t *req = NULL; + zckCtx *zckSrc = NULL, *zckDst = NULL; + char *FIFO = NULL; + pthread_t chain_handler_thread_id; + + /* + * No streaming allowed + */ + if (img->install_directly) { + ERROR("Do not set install-directly with delta, the header cannot be streamed"); + return -EINVAL; + } + + /* + * Initialize handler data + */ + priv = (struct hnd_priv *)calloc(1, sizeof(*priv)); + if (!priv) { + ERROR("OOM when allocating handler data !"); + return -ENOMEM; + } + priv->answer = (range_answer_t *)malloc(sizeof(*priv->answer)); + if (!priv->answer) { + ERROR("OOM when allocating buffer !"); + free(priv); + return -ENOMEM; + } + + /* + * Read setup from sw-description + */ + if (delta_retrieve_attributes(img, priv)) { + ret = -EINVAL; + goto cleanup; + } + + + priv->pipetodwl = pctl_getfd_from_type(SOURCE_CHUNKS_DOWNLOADER); + + if (priv->pipetodwl < 0) { + ERROR("Chunks dowbnloader is not running, delta update not available !"); + ret = -EINVAL; + goto cleanup; + } + + if ((asprintf(&FIFO, "%s/%s", get_tmpdir(), FIFO_FILE_NAME) == + ENOMEM_ASPRINTF)) { + ERROR("Path too long: %s", get_tmpdir()); + ret = -ENOMEM; + goto cleanup; + } + + /* + * FIFO to communicate with the chainhandler thread + */ + unlink(FIFO); + ret = mkfifo(FIFO, 0600); + if (ret) { + ERROR("FIFO cannot be created in delta handler"); + goto cleanup; + } + /* + * Open files + */ + dst_fd = open("/dev/null", O_TRUNC | O_WRONLY | O_CREAT, 0666); + if (!dst_fd) { + ERROR("/dev/null not present or cannot be opened, aborting..."); + goto cleanup; + } + in_fd = open(priv->srcdev, O_RDONLY); + if(in_fd < 0) { + ERROR("Unable to open Source : %s for reading", priv->srcdev); + goto cleanup; + } + + /* + * Set ZCK log level + */ + zck_set_log_level(priv->zckloglevel >= 0 ? + priv->zckloglevel : map_swupdate_to_zck_loglevel(loglevel)); + zck_set_log_callback(zck_log_toswupdate); + + /* + * Initialize zck context for source and destination + * source : device / file of current software + * dst : final software to be installed + */ + zckSrc = zck_create(); + if (!zckSrc) { + ERROR("Cannot create ZCK Source %s", zck_get_error(NULL)); + zck_clear_error(NULL); + goto cleanup; + } + zckDst = zck_create(); + if (!zckDst) { + ERROR("Cannot create ZCK Destination %s", zck_get_error(NULL)); + zck_clear_error(NULL); + goto cleanup; + } + + /* + * Prepare zckSrc for writing: the ZCK header must be computed from + * the running source + */ + if(!zck_init_write(zckSrc, dst_fd)) { + ERROR("Cannot initialize ZCK for writing (%s), aborting..", + zck_get_error(zckSrc)); + goto cleanup; + } + if (!zck_init_read(zckDst, img->fdin)) { + ERROR("Unable to read ZCK header from %s : %s", + img->fname, + zck_get_error(zckDst)); + goto cleanup; + } + + TRACE("ZCK Header read successfully from SWU, creating header from %s", + priv->srcdev); + /* + * Now read completely source and generate the index file + * with hashes for the uncompressed data + */ + if (!zck_set_ioption(zckSrc, ZCK_UNCOMP_HEADER, 1)) { + ERROR("%s\n", zck_get_error(zckSrc)); + goto cleanup; + } + if (!zck_set_ioption(zckSrc, ZCK_COMP_TYPE, ZCK_COMP_NONE)) { + ERROR("Error setting ZCK_COMP_NONE %s\n", zck_get_error(zckSrc)); + goto cleanup; + } + if (!zck_set_ioption(zckSrc, ZCK_HASH_CHUNK_TYPE, ZCK_HASH_SHA256)) { + ERROR("Error setting HASH Type %s\n", zck_get_error(zckSrc)); + goto cleanup; + } + + if (!create_zckindex(zckSrc, in_fd)) { + WARN("ZCK Header form %s cannot be created, fallback to full download", + priv->srcdev); + } else { + zck_generate_hashdb(zckSrc); + zck_find_matching_chunks(zckSrc, zckDst); + } + + size_t uncompressed_size = get_total_size(zckDst, priv); + INFO("Size of artifact to be installed : %lu", uncompressed_size); + + /* + * Everything checked: now starts to combine + * source data and ranges from server + */ + + + /* Overwrite some parameters for chained handler */ + memcpy(&priv->img, img, sizeof(*img)); + priv->img.compressed = COMPRESSED_FALSE; + priv->img.size = uncompressed_size; + memset(priv->img.sha256, 0, SHA256_HASH_LENGTH); + strlcpy(priv->img.type, priv->chainhandler, sizeof(priv->img.type)); + strlcpy(priv->fifo, FIFO, sizeof(priv->fifo)); + + signal(SIGPIPE, SIG_IGN); + + chain_handler_thread_id = start_thread(chain_handler_thread, priv); + wait_threads_ready(); + + priv->fdout = open(FIFO, O_WRONLY); + if (priv->fdout < 0) { + ERROR("Failed to open FIFO %s", FIFO); + goto cleanup; + } + + ret = 0; + + iter = zck_get_first_chunk(zckDst); + bool success; + priv->tgt = zckDst; + priv->fdsrc = in_fd; + while (iter) { + if (zck_get_chunk_valid(iter)) { + success = copy_existing_chunks(&iter, priv); + } else { + success = copy_network_chunks(&iter, priv); + } + if (!success) { + ERROR("Delta Update fails : aborting"); + ret = -1; + goto cleanup; + } + } + + INFO("Total downloaded data : %ld bytes", priv->totaldwlbytes); + + void *status; + ret = pthread_join(chain_handler_thread_id, &status); + if (ret) { + ERROR("return code from pthread_join() is %d", ret); + } + ret = (unsigned long)status; + TRACE("Chained handler returned %d", ret); + +cleanup: + if (zckSrc) zck_free(&zckSrc); + if (zckDst) zck_free(&zckDst); + if (req) free(req); + if (dst_fd > 0) close(dst_fd); + if (in_fd > 0) close(in_fd); + if (FIFO) { + unlink(FIFO); + free(FIFO); + } + if (priv->answer) free(priv->answer); + free(priv); + return ret; +} + +__attribute__((constructor)) +void delta_handler(void) +{ + register_handler(handlername, install_delta, + IMAGE_HANDLER | FILE_HANDLER, NULL); +} From patchwork Sun Nov 14 17:27:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1556019 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=e3DFfEmf; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::f3f; helo=mail-qv1-xf3f.google.com; envelope-from=swupdate+bncbaabbix52cgamgqetwhry4a@googlegroups.com; receiver=) Received: from mail-qv1-xf3f.google.com (mail-qv1-xf3f.google.com [IPv6:2607:f8b0:4864:20::f3f]) (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 4Hv2Lq1XbGz9s5P for ; Wed, 17 Nov 2021 10:28:49 +1100 (AEDT) Received: by mail-qv1-xf3f.google.com with SMTP id n4-20020a0ce944000000b003bdcabf4cdfsf858550qvo.16 for ; Tue, 16 Nov 2021 15:28:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1637105325; cv=pass; d=google.com; s=arc-20160816; b=lrlcNjFw1Se9t4N9hmp9z5PmCNLIrDsgW354sJrenySAR3fdfhJ/OrRmSIXRjzY9c0 Y89AFlYjiyxD603gwpeVKH+eNwNCtN1vEgasg57xisAnE2HMWuNyY7OnbT14ADlAbxlf 93GavDKAzBMCMph2AHEmkpCLgl615HCm0/SuOyFEJbWGqkJDiDOeaGKzHIQjzrnYgJZp fH347FRLBUb254FAGNKBPig9uOvxGttmCnSqiqf8c6gKDqljgGwAqE9xIwbnJYmwVSEz cJcluWY+lUtslXA2g4EChM95QHD2lHZKAkczNzKgBM+r1L2WDIssK+jvpjGGYrtG0IYS sRpQ== 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=/0W6y2ZhiC0GDvE0yXc8IIWjMCKpIiQl8s0HW+y5u1c=; b=AuuEHJjPZyvFR+AjkaD0kLsrhUPTZKPWyIztCDOiEgf+nwRBRumXcZ+z3Fs0PonpSe GvF7lf3kV+Ip3E3GLsXY5K+38vHgLDysq6X5Z3xauNk2T0wvqVEeVu9pzKsD8Y5Hue5u iB4L5oSgAG7tCUDP1hGQifH2TrtV7F7jR+/pmqfwWVbeAQN4DFDs0v9cOnSSNrrgINvS MCRbHeKpUAzqPFRuT7KCIL+MAF2i6ZEekcpqDLE9jS5yc/VG9iwMQ0EhE5oulTg4dogj MBz/NM4gPIMPnN36pFioLQQcZjCc04WUsjhiBtskPsLAJJXQndH5YQ92o25Kw2JgARSL AlVQ== 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=/0W6y2ZhiC0GDvE0yXc8IIWjMCKpIiQl8s0HW+y5u1c=; b=e3DFfEmfxnMFZ/c2c49UYNtUZoHPYMHSXwXaMoZuMuz/hKHV2VJQd9SVqB2Wc0O7xn KnpY7Ig9g4oNPWIjswgMYvtAl2d8ymhW6DbneIqW+iQxyvCSjQo6R2UL4CYE9ULlPQGy VsJ/+nvzExCuRuLPi9m5ZohAhop9RudFGcHD5Pz4NEyjIpt03NsEkvrB0nx32dHv/rh/ AEyCjlqHM+Flp8O25HSWe0WNmWN6XKwGdoHLHNbuCg667v9nn7eqpBvwN5j8KSaVUn/Y jqQp6VrPIr7DpgLy48LCoJX5bnUtMpl3mOjEMe+3QoyfUdIkqK62u6vN4JSTfS0LzgLd K8GQ== 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 :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=/0W6y2ZhiC0GDvE0yXc8IIWjMCKpIiQl8s0HW+y5u1c=; b=r8pVq2mX0+1J727pab830CJJv2LCCVXs3exOXv7cYHWTVgNndNWglz7u4NvpsSFXGq RPN4aw1ltWmDwDXcdE/oHf5EWfNrdE7wPV/g6ZdbEM/ACYeW2p37AyO5PtHOVcs7RK0C is3hhr5wfrxGrdlsryCNGywBMyLVZQ2NLKtbX/gn1ZFTNllhxXmuXsC1r2itsOL16E31 vUTQKsJNZOdgVIKBLJwUKdjw7R1Sh+7W2oLn3btwgFCTKnYyzNjNW/bnOQqmBc4QDbvI GVPk1UPVX03RUc3n/AH3RHJijuX7Uti5YXQH1EPk5cd+l8bnpYfVPaYXIxGPotC+4CaH 0goQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530jojbe32kDT5FKWT13v9yrdzJsQquwSGGYOzZYp9Ek7ka/wLZI +WV5dmpDvx2TdQhapgDU3r0= X-Google-Smtp-Source: ABdhPJzYPHONsR84A4IhvracEv4FPw1H3RxaHhe+8RV83xog+eh/b9s3y+6nQH3bwsE/3uKPwSyiKw== X-Received: by 2002:a05:620a:a45:: with SMTP id j5mr9535746qka.392.1637105315103; Tue, 16 Nov 2021 15:28:35 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:620a:1926:: with SMTP id bj38ls10441634qkb.7.gmail; Tue, 16 Nov 2021 15:28:34 -0800 (PST) X-Received: by 2002:a05:620a:4481:: with SMTP id x1mr9401323qkp.423.1637105314742; Tue, 16 Nov 2021 15:28:34 -0800 (PST) Received: by 2002:a05:620a:15ec:b0:467:8880:b933 with SMTP id af79cd13be357-467df3c090fms85a; Sun, 14 Nov 2021 09:36:00 -0800 (PST) X-Received: by 2002:ac2:5d46:: with SMTP id w6mr27708860lfd.15.1636911359689; Sun, 14 Nov 2021 09:35:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636911359; cv=none; d=google.com; s=arc-20160816; b=qxG9CbAO/tTowRBz4nYSQASuxocyUFQsGLEL5kTa4DJEmvHm8bAo7U5R6PbWqt6RvW MwoLJg+rsckDjI0aM3USNO1MZBuXLSdbY6Z4mDWXIvyrG6iIatX8GNGTOshRQbV/P5M6 xTordjbx98RetNPVaf71zS+wde8Xa8UfzfYhWr4PTX+T6maLZ5VhBcO2A7qctOu4kaet CubflJRTNW8CM40Y6hEkun37MWW0kVP+uxvfs+baynGxIYvpQ6UKv1kBy0kgEYZB4Oc9 QPiDUDBcFT0mnX6QNCGGc5TIfvup2l/8zRGSjdCElMQRwSRk/1GMwWTNonooJD/sEgdZ pG8g== 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=hDRYRXItDcBdo7ipv+VH8f65KkoOkLU+zOpwYg77FLY=; b=OXixqPhsm00zcJM2CydnS3IaQY3TLw10aieVDaGxsNlsWUcdwi8eErZSwUXjxLMx+6 Q2mrnv3Pu14YP+c0dIoIAJyHcV6fGTa6x4xMVJzNlA7gljpv1X0NyRB/TE6Dq9lAHSYQ hYiqC3GVjErj6CUBsKhrjDB0OTM2+LcLsQDFA/6W3FlxJBfJIWWch/BwQ29U2m7/nVqG DW9aWImE5+BM3L5sJFf6uVeLJaPfm/UKlXd77iynGY1y8422qhOlBb26n9MzN1mJ96Ep jg/J1HArCklh2AemCwvJ9a2Q1jRuqzHVMafbBaXdNjc6loAtQ2eGwh7wrkTovpj3k0Co 9Y8A== 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 b29si889726ljf.6.2021.11.14.09.35.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:35:59 -0800 (PST) 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 4Hsfcb1Rhyz1s9RM; Sun, 14 Nov 2021 18:35:59 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Hsfcb1KwFz1qqkB; Sun, 14 Nov 2021 18:35:59 +0100 (CET) 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 tBvod08QEMuv; Sun, 14 Nov 2021 18:35:57 +0100 (CET) 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; Sun, 14 Nov 2021 18:35:57 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 4D69D4541B5B; Sun, 14 Nov 2021 18:28:44 +0100 (CET) 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 U8xokYM63sFn; Sun, 14 Nov 2021 18:28:41 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 39D38454292B; Sun, 14 Nov 2021 18:27:47 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 32/36] doc: add documentation for delta handler Date: Sun, 14 Nov 2021 18:27:29 +0100 Message-Id: <20211114172733.71602-33-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Explain attributes and properties for the delta update handler. Signed-off-by: Stefano Babic --- doc/source/handlers.rst | 80 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/doc/source/handlers.rst b/doc/source/handlers.rst index ed811e3..8d78bbd 100644 --- a/doc/source/handlers.rst +++ b/doc/source/handlers.rst @@ -936,3 +936,83 @@ found on the device. It is a partition handler and it runs before any image is i "18e12df1-d8e1-4283-8727-37727eb4261d"]; } }); + +Delta Update Handler +-------------------- + +The handler processes a ZCHUNK header and finds which chunks should be downloaded +after generating the corresponding header of the running artifact to be updated. +The handler uses just a couple of attributes from the main setup, and gets more information +from the properties. The attributes are then passed to a secondary handler that +will install the artefact after the delta handler has assembled it. +The handler requires ZST because this is the compression format for Zchunk. + +The SWU must just contain the ZCK's header, while the ZCK file is put as it is on the server. +The utilities in Zchunk project are used to build the zck file. + +:: + + zck -u -h sha256 + +This will generates a file .zck. To extract the header, use the `zck_read_header` +utility: + +:: + + HSIZE=`zck_read_header -v .zck | grep "Header size" | cut -d':' -f2` + dd if=.zck of=.header bs=1 count=$((HSIZE)) + +The resulting header file must be packed inside the SWU. + +.. table:: Properties for delta update handler + + +-------------+-------------+----------------------------------------------------+ + | Name | Type | Description | + +=============+=============+====================================================+ + | url | string | This is the URL from where the handler will | + | | | download the missing chunks. | + | | | The server must support byte range header. | + +-------------+-------------+----------------------------------------------------+ + | source | string | name of the device or file to be used for | + | | | the comparison. | + +-------------+-------------+----------------------------------------------------+ + | chain | string | this is the name (type) of the handler | + | | | that is called after reassembling | + | | | the artifact. | + +-------------+-------------+----------------------------------------------------+ + | max-ranges | string | Max number of ranges that a server can | + | | | accept. Default value (150) should be ok | + | | | for most servers. | + +-------------+-------------+----------------------------------------------------+ + | zckloglevel | string | this sets the log level of the zcklib. | + | | | Logs are intercepted by SWupdate and | + | | | appear in SWUpdate's log. | + | | | Value is one of debug,info | + | | | warn,error,none | + +-------------+-------------+----------------------------------------------------+ + | debug-chunks| string | "true", default is not set. | + | | | This activates more verbose debugging | + | | | output and the list of all chunks is | + | | | printed, and it reports if a chunk | + | | | is downloaded or copied from the source. | + +-------------+-------------+----------------------------------------------------+ + + +Example: + +:: + + { + filename = "software.header"; + type = "delta"; + + device = "/dev/mmcblk0p2"; + properties: { + url = "http://examples.com/software.zck"; + chain = "raw"; + source = "/dev/mmcblk0p3"; + zckloglevel = "error"; + /* debug-chunks = "true"; */ + }; + } + From patchwork Sun Nov 14 17:27:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554929 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=g3yBkTVT; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::43e; helo=mail-wr1-x43e.google.com; envelope-from=swupdate+bncbcxploxj6ikrb74rywgamgqe4kem6sq@googlegroups.com; receiver=) Received: from mail-wr1-x43e.google.com (mail-wr1-x43e.google.com [IPv6:2a00:1450:4864:20::43e]) (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 4Hsfch2X2wz9sRK for ; Mon, 15 Nov 2021 04:36:03 +1100 (AEDT) Received: by mail-wr1-x43e.google.com with SMTP id z5-20020a5d6405000000b00182083d7d2asf2575612wru.13 for ; Sun, 14 Nov 2021 09:36:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636911359; cv=pass; d=google.com; s=arc-20160816; b=tRDGeKGKs9YHHlHdqnof1LtAYwhmBLbaUxsRJNAXwEdnbmYyhF1wvhKhaHw6BoQvB0 GyjUmzM1zGQQxdfAJa79cJSvp741FfDk6JuPQjJOov7ztWxSmBvyo7foRkguop34kdDT fmsotN6FZ7p7boEzRgeGYAtoyYqqVovH4LYK/5o61ct/2dfZsAWxhyDboxF48v5pDiOS AlYOuFx10dPdq4hpFlmOqXtn9qi+YikrRMmoW+d2pe21BGuAgfsJ17pH4r9sZLyneXeh u+YT7O/3sHAT6PocNLBjMLYDo8Z4wjItRGhrtul9Dzih4ubjlC0vzULhAOFKdF9djAeU Cc+Q== 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=W7mU7s1aYYUhZJSoVXvRPz4xQXlBDYen3FtSuNGva2U=; b=ZxPU27IFsKAWfTPr4VAFhGpvqQay5BiBrA0Siqf1q58N6Ji0T+Sj4ImkbUpKMgVkuU jh34dLgTm1tv1Nz4XTi1U27wAg1FZ8k8TIrnLuhb3D9zTO4nB0+cUQ/AgZ55F5qDiZ6s QnJs6DSTiwsUYirr8rrsO6BbvlitZgn/Sns2V76xQrtDaDM04kODtn7bluEwbzZ38fA/ FgXnJu0bXqkzuBNRCp+YNSO+7fyQVD5lPE/0v98fJEn+tFFompCpu1nyzB3aoYHYF2Db Elgi45bG+Zub84KOZVGAjluMvyu8xCl4tbWKZoW9XFTbui51s7VIP7o1plTRYGBSviAb tNmg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=W7mU7s1aYYUhZJSoVXvRPz4xQXlBDYen3FtSuNGva2U=; b=g3yBkTVTpXBd0HBGUqtq8X2sJ7xUvk6EmTEPX4xKMUGZo9L2BOOfpvUy0iGD31HI/h qNZRxv0EwLCdHa917eaIAFE7MKfdjmS4bKh1cY6ktxpKHgRFjf9qHq0vY5Oo7blqE+jv pdUh9iw3uhkb4kRUvgJIx65keXAnjf+pd7wkvfiH6hFjrNJm1eSJ1rAigf0BpTG+/e64 AeGsBylKsPXqqGoG3KoxGQQfLRpUUehzeQBR6setfQGTM/lv7Yh45sEdVgOBpMaUly7U 4kuRsJJnuMSyfVPvzkMOmXaJrYdd+944ZW5qns/cnF+c9YBEVnoE0HMJ9T2M1OVivQqi WABA== 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=W7mU7s1aYYUhZJSoVXvRPz4xQXlBDYen3FtSuNGva2U=; b=D2OhdgxNE32J8PPxqGU/CxsYwIT2a55CvR1I3bxb6+5O8uSPnAjpJRDEftIWNMJ8fR TqI2PiIVvQdC5kB1IGdJGczWFwqpdlRM9hPOa5XGS7zkLtTRAN3nVkYu/oMY9FL/Gpxw KiVaEG5qQJv5xvS+F/Tn6p06ZmPgHsQagNcKE2RwbU1k8HDqmqP06afxVFjOIJD4p7t1 8sxXooNZFOOu0xaCcyETtVsXlLKiRZZcBf9G4hbu+A/zG9eDp9lJmnyOhBXB5bPbYlNM 25VaCFPXXaARq6N+AJHRdi1dCHVPJisOQRBTtLYLkJhioFMGu3td+rV8Sqh+uijA8VI6 g2ew== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532RPoBV6nOQQS9roSZKM05EO5p2ou9sWZWDimZGEM8VjvLp/oSV qJD/BNAHt1pLh0QaSPzyS98= X-Google-Smtp-Source: ABdhPJxgZ7XpI/qPXRWDGxn1t1jq5cA6sSr03JpkvnhTk9iaN+62X/p+IwgnqI5TR76AWkNhXD5R2w== X-Received: by 2002:adf:e38d:: with SMTP id e13mr39000880wrm.402.1636911359275; Sun, 14 Nov 2021 09:35:59 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a5d:6a05:: with SMTP id m5ls7213781wru.3.gmail; Sun, 14 Nov 2021 09:35:58 -0800 (PST) X-Received: by 2002:adf:f708:: with SMTP id r8mr38898709wrp.198.1636911358665; Sun, 14 Nov 2021 09:35:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636911358; cv=none; d=google.com; s=arc-20160816; b=bGz8dypk5Y/Oi6yyW/5rLo8Nhtqw9097O8kxSwyyo3yWLmCUVEyExuAewHoJebvETw gcC4r3THkiiW8laccyaOo1NNwfTdgjEB/BVuRTy4vuFDcyGjgctlWS2Ps0vlbTa1fW6F O3R0sv/tazeEPeXrASKZDiydPJMsP76MIMIB3mPdAJGvnDUWqmQByx7jovFphRM/JMUj NF4yBovmMcwN+6gZYGBkj0bzDkR+pc0P67sqK7s7+K8zQVlseSLuSe5o2T1nl+4hVAXL 0kjasXDR0eHyuJJtteuRFsDkq7fIy38N45bSheOMQN9fZG6r5IK1dt7k9wUZ8AGgfN9f 38VQ== 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=d4yBXBRv+RwinCaR1vHr6+iLZFDgA+7yupXqAl8WozI=; b=Rc9ncDQ9vvEjIUvwl4oLMorw92Dg3krFcRoeLckLrM9zeEPraP+TF7T0R4ulDk+Vw7 y4gC+r99m2oUeXVZGQy/QXHA5FumaKK2XqH9wUeouluE1EXbA5iMI0q1NcalBAxaU1Vi BB1kcCzGVVmTpN7y6Ge4t2CesrWkRCrGAUEhusvZro8K7KO+ipiw9vFAZMfqgc/2JjuU DWJwlFHQb9vjwF1//5DTflgOi4ll9iG4VetjI14rqGJFeV3MBIMrfMDG9h43DnxuTCIM ELiQDuwJTFSetjIK6s6qCopInLTldZEqXo326zF2x6LMOt1vbXFpCpIEDyM0G5SmZpbH y39w== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id 201si1066047wma.1.2021.11.14.09.35.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:35:58 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfcZ3dhHz1qwdg; Sun, 14 Nov 2021 18:35:58 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfcZ3Vj9z1qqkC; Sun, 14 Nov 2021 18:35:58 +0100 (CET) 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 Odre2TmOE3Sm; Sun, 14 Nov 2021 18:35:57 +0100 (CET) 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; Sun, 14 Nov 2021 18:35:57 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 150E04541B62; Sun, 14 Nov 2021 18:28:45 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id RqfahI0EEQM5; Sun, 14 Nov 2021 18:28:42 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 459B14542933; Sun, 14 Nov 2021 18:27:47 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 33/36] doc: drop delta update from roadmap Date: Sun, 14 Nov 2021 18:27:30 +0100 Message-Id: <20211114172733.71602-34-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , Signed-off-by: Stefano Babic --- doc/source/roadmap.rst | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/doc/source/roadmap.rst b/doc/source/roadmap.rst index 39bdb78..73831db 100644 --- a/doc/source/roadmap.rst +++ b/doc/source/roadmap.rst @@ -32,25 +32,6 @@ To reduce bandwidth or for big images, a stronger compressor could help. Adding a new compressor must be careful done because it changes the core of handling an image. -More efficient delta updates -============================ - -A whole update could be very traffic intensive. Specially in case -of low-bandwidth connections, it could be interesting to introduce -a way for delta binary updates. -There was already several discussions on the Mailing List about -this. If introducing binary delta is high desired, on the other side -it is strictly required to not reduce the reliability of the update -and the feature should not introduce leaks and make the system -more vulnerable. It is accepted that different technologies could be added, -each of them solves a specific use case for a delta update. - -SWUpdate is already able to perform delta updates based on librsync library. This is -currently a good compromise to reduce complexity. Anyway, this helps in case of -small changes, and it is not a general solution between two generic releases. -A general approach could be to integrate SWUpdate with a storage to allow one -a delta upgrade from any release. - Support for OpenWRT =================== From patchwork Sun Nov 14 17:27:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554927 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=jG+lmmm1; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::53f; helo=mail-ed1-x53f.google.com; envelope-from=swupdate+bncbcxploxj6ikrb74rywgamgqe4kem6sq@googlegroups.com; receiver=) Received: from mail-ed1-x53f.google.com (mail-ed1-x53f.google.com [IPv6:2a00:1450:4864:20::53f]) (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 4Hsfch2FT1z9sPf for ; Mon, 15 Nov 2021 04:36:03 +1100 (AEDT) Received: by mail-ed1-x53f.google.com with SMTP id l15-20020a056402124f00b003e57269ab87sf5439129edw.6 for ; Sun, 14 Nov 2021 09:36:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636911359; cv=pass; d=google.com; s=arc-20160816; b=tTzklSPRvPUwZ0p265cLvSj69bXLnNL+uUmhPYENLw4CYejYrViWMFDwsQXrl4C+ye ZyE23CyvgV1I3BESPITzmtvx89gK9JdWu6UnnUZaqmsBSE8NvHn0S3aV+PhZ8uKBVVB1 kwdmm0DGIL6/ry4QuFXJXQ/Y5pUFYV9R9z+m5loAucnXnRLbv8CbpQ3DiUgxLB7p2aHS PObPSDMQUmdzFSePtW/YoQxwQ7ANT3higtMlWbq2K26T/VcJE0tL42yb1GIxyI8TcYxK R2edu0KTUvrzrA3iCWcXcAYdgIphUHL+TWcD+gXDQ/3E/JVD+y51N7A9lTPPapzjLs01 e0tQ== 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=6XXVraxsnvYMSDx5DIEKRznswtnE1RuweU++plG/pJc=; b=ocKslRgBNg80BKDijatNMKLMibE0xANKGXQuaaX4N9Y/TIDcsP2CDmi5u1rCD0yTWG j3I4+j3z3Hc8FHAviaguMwLPNjKVRwBTX3ZTIr0Y+3UPbhFSSJJme65+jM8ctJe4BOA8 +U/dNjkTTGV0/zBLAoeY42E4Sjv0lwvdr8Ro3ACaU+mTQtD7jZcXWRXLNMX4QvUKXlfC icxMYXwRf6c+rkWOz194pVV5dgLC1/PxXkilJ2GHWCQgohFyeqFDYGTnk3+m3KmnmHSM 0VE4h3iw1XfUgqVl4lnpv/UpQqObFyrjdyAWt4E7AjJSfwap8NY10yEx7gEOikm53rcV epEw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=6XXVraxsnvYMSDx5DIEKRznswtnE1RuweU++plG/pJc=; b=jG+lmmm1RnQeonA5PHhDj/Tj1ZgRFopQjM+mluS5+gPd6YvSU0HIhAuOFF4f549R0f 13aW0xCygSCnCIoX5TE3qFAHPOYBXxsVcDrVrobJrAojVzOlDwUyU8XhZGrorGBfV255 MKSitak+v9R6vyxpFlKsHuY497O/DidNziZDijx5HgW5MO4A3C8dQFOCBIVyaP2UOTVI l76448C3W16TJsHaOhTKX1JEVGvIMGtvZnI/ay8MNDn1chhVPS+X1syRZodLvn6jkjH4 nmCVxcieTL4WzB3aZEMGquq7vUSqM2eCsPB/BsWy3093cKPbRwu3IAiQNzVe1JiciMYd pY1A== 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=6XXVraxsnvYMSDx5DIEKRznswtnE1RuweU++plG/pJc=; b=T330Woandj7nhHtBZXGWA8+qbmjwCAXStl+giEbIMsUXFRcQLXFJ77tl2qBCV7XTAX cigKVcnyu4bfOCUZY7Dk2MYf9EYBPboYQ+zlPLKOJjOZ3gQV6a2kLBNUp/OPeLinsSzM OZ0bzJPsbqPIegrr2v2AAfPqds4PkOgWRx0xe/2r4oiaJnlMmqc2pH8sqq9Xo3g3oieS KVeAAWWLeu7pGiYOyRxQBOC3pxscCIj44GXt3AbwRbGRNI7SAnczHTLr2eO+tEV0ttdW NVF2+7jOdLDg7qq7vGQTufY3cOrHmBc080dn1Jr5+UJC//FrDmqh8oWLoVFHBbtcr4Ri NO2A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532N/wIbXA1U4LAtYVkC+rPAQZPzc787Wk48KTW93KCSMjYaL9de hiO026uJWw+BySDhX/SMiQA= X-Google-Smtp-Source: ABdhPJwzRs6cpmHa7ml3PwT8mh8w4u/jo+jVWn/JWk/zDPCEfutV3kSAaKNZ2cS5tG3weUq9y8ooug== X-Received: by 2002:a17:907:3e25:: with SMTP id hp37mr41579958ejc.43.1636911359435; Sun, 14 Nov 2021 09:35:59 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a50:8e41:: with SMTP id 1ls3830438edx.0.gmail; Sun, 14 Nov 2021 09:35:58 -0800 (PST) X-Received: by 2002:a05:6402:3586:: with SMTP id y6mr45944651edc.332.1636911358747; Sun, 14 Nov 2021 09:35:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636911358; cv=none; d=google.com; s=arc-20160816; b=UrhYa1HZrxZDu/HzYbgkpl3MYwbs3RpHjGsBSmUgJbJWiShxriHJ6/8Gk4XJVj94qC 9OtkjzC1iEw/z1wTI7cu5j76J85Vw4SM37EQesdxjdWbiEIwuSdfWFSWA8pDmHeyqqFU ibOG+yiNgASoOe4pEn/RkGPPSuumIQWt+L7TRQe2WFyDxbV421kRHklphboH6zvCZ07o WGtPCnvniu5F1FnoepAnLoGOA5tI4CgEeD5GoZQEohDEvNEA9T4IZQCfqCvkhg9ZGplu 2FMJPSG37b8iQjeZWjLOhybPCAD/4f8HTIHuwXv/WLWTzid4ncp0Ll4H0DiY1+//MNHB 33kw== 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=f23ApHvZEI02DrFW3Hs2o9GE+X3G05zm3O6UO6Q0qRk=; b=mVrXRS94r0p+7ejGsSF+ZaG3StfqV8+luK5GSM0ZvPr+PtQOfNOGfA0RHyrqjNaWvs nfOwNXtxlJUFPTMGMT7/9Uihmzj3MsfPQJ2mUt+BnuLy1fkWpEEizaMPdpzjGjwJUw37 07V9aWsGuTjwU16B+8x4r5hlNXFHRvruMeLCHz694gwZVVM3jcXT3t7vJbmT4YyePo72 A6fcr+AydcBoBbVpBqzz0oKiwAw4y0ehdZMt4fuo7CUn80RrxrOLRBLMXS5U6PK+QnCL PLpocTJzRCvLcyfTIEp14vzK20ci/X/Sx6VHyEwDXl+ZI0J35FwMOKkKJfrToTm1SF67 kKqA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id u19si1155525edo.5.2021.11.14.09.35.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:35:58 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfcZ3ZDHz1qwdZ; Sun, 14 Nov 2021 18:35:58 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfcZ3SVhz1qqkB; Sun, 14 Nov 2021 18:35:58 +0100 (CET) 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 cwhXLIWcHDP9; Sun, 14 Nov 2021 18:35:57 +0100 (CET) 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; Sun, 14 Nov 2021 18:35:57 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 8361B4541BC4; Sun, 14 Nov 2021 18:28:47 +0100 (CET) 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 tgU0PnJdUppB; Sun, 14 Nov 2021 18:28:44 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 5588E4542939; Sun, 14 Nov 2021 18:27:47 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 34/36] delta: add the option to limit size for source Date: Sun, 14 Nov 2021 18:27:31 +0100 Message-Id: <20211114172733.71602-35-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , When upgrading a partition, the filesystem could be much more smaller as the partition itself. The handler as default will read the whole partition and it will create the whole ZCK index for it, but this requires more memory as really needed. Add a way to check the real size of the filesystem, and do not index the rest of the partition. Signed-off-by: Stefano Babic --- doc/source/handlers.rst | 6 ++++++ handlers/delta_handler.c | 42 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/doc/source/handlers.rst b/doc/source/handlers.rst index 8d78bbd..ecd2bf5 100644 --- a/doc/source/handlers.rst +++ b/doc/source/handlers.rst @@ -996,6 +996,12 @@ The resulting header file must be packed inside the SWU. | | | printed, and it reports if a chunk | | | | is downloaded or copied from the source. | +-------------+-------------+----------------------------------------------------+ + | source-size | string | This limits the index of the source | + | | | It is helpful in case of filesystem in much | + | | | bigger partition. It has the value for the size | + | | | or it can be set to "detect" and the handler | + | | | will try to find the effective size of fs. | + +-------------+-------------+----------------------------------------------------+ Example: diff --git a/handlers/delta_handler.c b/handlers/delta_handler.c index d959509..5229657 100644 --- a/handlers/delta_handler.c +++ b/handlers/delta_handler.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,7 @@ #include #include #include +#include #include "delta_handler.h" #include "multipart_parser.h" #include "installer.h" @@ -90,6 +92,8 @@ struct hnd_priv { char *srcdev; /* device as source for comparison */ char *chainhandler; /* Handler to pass the decompressed image */ zck_log_type zckloglevel; /* if found, set log level for ZCK to this */ + bool detectsrcsize; /* if set, try to compute size of filesystem in srcdev */ + size_t srcsize; /* Size of source */ unsigned long max_ranges; /* Max allowed ranges (configured via sw-description) */ /* Data to be transferred to chain handler */ struct img_type img; @@ -319,6 +323,15 @@ static int delta_retrieve_attributes(struct img_type *img, struct hnd_priv *priv if (errno || priv->max_ranges == 0) priv->max_ranges = DEFAULT_MAX_RANGES; + char *srcsize; + srcsize = dict_get_value(&img->properties, "source-size"); + if (srcsize) { + if (!strcmp(srcsize, "detect")) + priv->detectsrcsize = true; + else + priv->srcsize = ustrtoull(srcsize, 10); + } + char *zckloglevel = dict_get_value(&img->properties, "zckloglevel"); if (!zckloglevel) return 0; @@ -452,7 +465,7 @@ static void zck_log_toswupdate(const char *function, zck_log_type lt, /* * Create a zck Index from a file */ -static bool create_zckindex(zckCtx *zck, int fd) +static bool create_zckindex(zckCtx *zck, int fd, size_t maxbytes) { const size_t bufsize = 16384; char *buf = malloc(bufsize); @@ -470,6 +483,8 @@ static bool create_zckindex(zckCtx *zck, int fd) free(buf); return false; } + if (maxbytes && n > maxbytes) + break; } free(buf); @@ -918,6 +933,29 @@ static int install_delta(struct img_type *img, ERROR("/dev/null not present or cannot be opened, aborting..."); goto cleanup; } + + if (priv->detectsrcsize) { +#if defined(CONFIG_DISKFORMAT) + char *filesystem = diskformat_fs_detect(priv->srcdev); + if (filesystem) { + char* DATADST_DIR = alloca(strlen(get_tmpdir())+strlen(DATADST_DIR_SUFFIX)+1); + sprintf(DATADST_DIR, "%s%s", get_tmpdir(), DATADST_DIR_SUFFIX); + if (!swupdate_mount(priv->srcdev, DATADST_DIR, filesystem)) { + struct statvfs vfs; + if (!statvfs(DATADST_DIR, &vfs)) { + TRACE("Detected filesystem %s, block size : %lu, %lu blocks = %lu size", + filesystem, vfs.f_frsize, vfs.f_blocks, vfs.f_frsize * vfs.f_blocks); + priv->srcsize = vfs.f_frsize * vfs.f_blocks; + } + swupdate_umount(DATADST_DIR); + } + free(filesystem); + } +#else + WARN("SWUPdate not compiled with DISKFORMAT, skipping size detection.."); +#endif + } + in_fd = open(priv->srcdev, O_RDONLY); if(in_fd < 0) { ERROR("Unable to open Source : %s for reading", priv->srcdev); @@ -984,7 +1022,7 @@ static int install_delta(struct img_type *img, goto cleanup; } - if (!create_zckindex(zckSrc, in_fd)) { + if (!create_zckindex(zckSrc, in_fd, priv->srcsize)) { WARN("ZCK Header form %s cannot be created, fallback to full download", priv->srcdev); } else { From patchwork Sun Nov 14 17:27: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: 1554930 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=DX1x0jiN; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::537; helo=mail-ed1-x537.google.com; envelope-from=swupdate+bncbcxploxj6ikrbaesywgamgqebvgq72a@googlegroups.com; receiver=) Received: from mail-ed1-x537.google.com (mail-ed1-x537.google.com [IPv6:2a00:1450:4864:20::537]) (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 4Hsfch2qcGz9sRN for ; Mon, 15 Nov 2021 04:36:03 +1100 (AEDT) Received: by mail-ed1-x537.google.com with SMTP id g3-20020a056402424300b003e2981e1edbsf12164365edb.3 for ; Sun, 14 Nov 2021 09:36:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636911360; cv=pass; d=google.com; s=arc-20160816; b=bFo7YvbV16yn3Ce+MpUZfnycTWIn2HXEcoDuxypVGswztyLuxGUxQ8nimtJK5kmSjb iUVI6qC7XJHfEhDPNtbdXwRX3ALaPW0bmgJKWJ299cPD/EI0lfUDCpbT1L6DsGEADLyC OMVcOny5ZCV/z4LlCNfzdoeLkKRHvPIHmBQP0cN3jerfmGLSAKpdX+9KoZwRSvo//AK/ NCcmQqiP2QKciR3tFhlJFLueNguUVuW5GknRFzFeWNzE/hojdTJZL6G7RFPje73CPacC DEgVCxoF+chJGKQD3Kqcj5Wi1q6ywZEk8RJV/vdpErwQqnhnOFEB1qGg1vcnJwqeNWDc 77YA== 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=NneGAvmP4Ry1R5dIUIVDvHaSAuV0INe3L06UPAqWUI0=; b=vQPONQJ0ievV8jB/UQPNefvb8o/DLIRQrcZ2Rhho2Wsm5/KKUcbplmXimkDKqI9Y1s kGt9BseAh72hzNVffcTd2P5Us1eqjKJE76WvUM1hkMGsiQGtqNzA8nd4VrxCpik7Y/Xa VzTDXLXrg2TosC8jyBoO3VggFIiKOkiRHlfnndWttlB534cX8LuOj6BwDPbvT0mesvX8 40aY/q9syO9IvJMtJ5SGgi0V5O2kTypjV9hJm83ApZk5Un9i/FCjjSo9YOpG3fESf0yi j1+SONUTEXFmEPxmN2RcfnRDckQIoOo4OvXv7iMVNAbm35cMCDuHtFoqyjkv/CCiSkmk MZRg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=NneGAvmP4Ry1R5dIUIVDvHaSAuV0INe3L06UPAqWUI0=; b=DX1x0jiNqu02IkK73Y5c7qW5lKnTlQVqkCCaUhU59B/qwgQSInsK/J+XMIY6o1QxDp nnA2Nk6rznEV4Osw2SVmQgDCRHnzWhp/oaJfoA13k2YhyYI+kNW9OzHNIGy8ZDr3mVYg MS+sD6E1r+yhCxrkSmVVRlzxOaezC6qtXk/WH43ifJnIj5Q1qYgHZKt/MOXO/OyvXsjj mx8fFFohjmlzr8+lmRlWSqZRF+Zm2d+SnQs6eKTT92eE3FWAZg9D8jjYuCnH7/5cland xPyKZVAyhGb4/huQazm8z19i6ZHON4hAn12vpn0r68X4PWrO4E4LbSE02VnOPuA8Y3kp ON4Q== 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=NneGAvmP4Ry1R5dIUIVDvHaSAuV0INe3L06UPAqWUI0=; b=idpRZ7zZVEySPRGvQK5j+gSLdZYcl1RLlep9HV25Yrf/En14apaJyhr926e9EVSVXC 5te1V/lKmWR2CTppIHaeOxRQkJ71yOr09DIgFF/KcaMRqIEm+qgQEnFnBcygcTwtiCiX Fj+ByyK7K0FTh6c/OzLlKMGoggByA1APIJCdRJusy1FcKthoFkJCKRxr+oDSNTC1BCF0 DfD3yZmfKhOsnAwOnv4g6WzCdXoRaUoEGBCq2Z9+/gMGNvBEG2sNYJuZolgcA02s+NLT TxSiTVh4VzZswOOHMD7oiTyVepQEOPijxLJeXyDcbDWJjsOsLzCOhfzCxvtWLNSQvmC0 8jRw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5303meI2f+Sw7dOQRybCBU5riLMPDGHlJgKr7VHNldyS/yCCYFNr FmzlrigxeyUBmBB8GNIE8nc= X-Google-Smtp-Source: ABdhPJxI1QPVHBqtOmj4hHR8niNkVfDVA+hX32IxO3/9dHyoklHcCcyCaOCZH0Zgo8uqbmKW0sxKhw== X-Received: by 2002:a17:907:2d8c:: with SMTP id gt12mr41202272ejc.61.1636911360580; Sun, 14 Nov 2021 09:36:00 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a50:fd09:: with SMTP id i9ls3833263eds.3.gmail; Sun, 14 Nov 2021 09:35:59 -0800 (PST) X-Received: by 2002:a05:6402:c8:: with SMTP id i8mr38853140edu.183.1636911359840; Sun, 14 Nov 2021 09:35:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636911359; cv=none; d=google.com; s=arc-20160816; b=dLwxBvwKfG4ghwz0b1vQCn5x3JudbwnejUb493M+8G6RkB8jRoqGN6EE7Gnq//YUTC XCT7L11a3lmk49yQOKCVFJsHR4CR1V1arnktmUQtIKXJmd/tJ3A7wsbZpeh7uKBFYMjp XPRf9iPJGr9me3cJydYoqkWew7Uu3t39RY4NL4OT4AvfJkqZ1i+roRJP55b8a0cZ6LrZ iY6866PV8JoDN10TbVLm7wWNjalOXAULA9UPvSljwCpt9f63tOHGH0tzWv8XJSx0PRtO +Gph3uOBs8Q7LJnZjDCblg+A8v93zdEYHGzuhsHMn+QiVcSoEzzwH/c0ExptuKpXJ1FY a5jw== 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=WSqDkxApiLD7e/jDLMpbJWFlJz/z9hi8m0RGmdEvS7o=; b=R1sT+UX08gdYDz8pS45JIs8jTpnVKQ2cjscGEUQnGPZLbsRhfvBX1Hld2KItlR4J8K LV91KLh6l3To7EL/5/ePPJnDh5N93mWCxANFysmEsAkzy/OppMnbACu61GiEs7UeTLUs JDuAn1IjVAQYNqHb6QeSWF6YRAP6NR7Cl+0UOJsiMj30s3l+lokR/qWtCpUmUh2hg2Mc VQ0srgqHkvPV+Ti9+jwIFRpsh6auUfaFl82UQ2CYRocHEJ0t76S9Aej4wjlYhOEkrknX MXu4oFmi0lD+6zfXaMP27uCBtt5AfjHgv9SJTaVOmxqnEaHywKRsdh5ahtxNqbgzcNZ3 9S4w== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id u19si1155528edo.5.2021.11.14.09.35.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:35:59 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Hsfcb4V8Cz1qwdZ; Sun, 14 Nov 2021 18:35:59 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Hsfcb4Pskz1qqkB; Sun, 14 Nov 2021 18:35:59 +0100 (CET) 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 eFEJbjwocB6w; Sun, 14 Nov 2021 18:35:58 +0100 (CET) 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; Sun, 14 Nov 2021 18:35:58 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 725164541B6E; Sun, 14 Nov 2021 18:28:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Acnukf_NyD9k; Sun, 14 Nov 2021 18:28:45 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 6611E4542941; Sun, 14 Nov 2021 18:27:47 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 35/36] all_handlers_defconfig: add delta and unique Date: Sun, 14 Nov 2021 18:27:32 +0100 Message-Id: <20211114172733.71602-36-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , This is used for CI, so all handlers should be on. Signed-off-by: Stefano Babic --- configs/all_handlers_defconfig | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/configs/all_handlers_defconfig b/configs/all_handlers_defconfig index 384238a..5ae1b54 100644 --- a/configs/all_handlers_defconfig +++ b/configs/all_handlers_defconfig @@ -10,23 +10,26 @@ CONFIG_SURICATTA=y CONFIG_SURICATTA_SSL=y CONFIG_WEBSERVER=y CONFIG_MONGOOSESSL=y +CONFIG_ZSTD=y CONFIG_LUAEXTERNAL=y -CONFIG_UBIVOL=y +CONFIG_ARCHIVE=y +CONFIG_BOOTLOADERHANDLER=y CONFIG_CFI=y +CONFIG_DELTA=y CONFIG_DISKPART=y -CONFIG_DISKFORMAT=y +CONFIG_DISKPART_FORMAT=y CONFIG_DISKFORMAT_HANDLER=y CONFIG_FAT_FILESYSTEM=y CONFIG_EXT_FILESYSTEM=y +CONFIG_LUASCRIPTHANDLER=y +CONFIG_HANDLER_IN_LUA=y CONFIG_RAW=y CONFIG_RDIFFHANDLER=y CONFIG_READBACKHANDLER=y -CONFIG_LUASCRIPTHANDLER=y -CONFIG_SHELLSCRIPTHANDLER=y -CONFIG_HANDLER_IN_LUA=y -CONFIG_ARCHIVE=y CONFIG_REMOTE_HANDLER=y +CONFIG_SHELLSCRIPTHANDLER=y CONFIG_SWUFORWARDER_HANDLER=y -CONFIG_BOOTLOADERHANDLER=y CONFIG_SSBLSWITCH=y +CONFIG_UBIVOL=y CONFIG_UCFWHANDLER=y +CONFIG_UNIQUEUUID=y From patchwork Sun Nov 14 17:27:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1554921 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=qCGfd+42; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33d; helo=mail-wm1-x33d.google.com; envelope-from=swupdate+bncbcxploxj6ikrbveoywgamgqezlgotly@googlegroups.com; receiver=) Received: from mail-wm1-x33d.google.com (mail-wm1-x33d.google.com [IPv6:2a00:1450:4864:20::33d]) (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 4HsfSR1ZHFz9sWJ for ; Mon, 15 Nov 2021 04:28:55 +1100 (AEDT) Received: by mail-wm1-x33d.google.com with SMTP id v10-20020a1cf70a000000b00318203a6bd1sf6910237wmh.6 for ; Sun, 14 Nov 2021 09:28:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1636910932; cv=pass; d=google.com; s=arc-20160816; b=TKVgwhOKZ49m9N8Y26mXve53M5qj6iGvlj0EgHzij4cgp/0eOhQBF5KQ1WEK4jPaN6 pmGncvH0yNhc4eSh36sEPYRPtF0IPKXYAL3fRcORh8h9tJIkTm8876ZH7e5I49NLdtGE 7McFQ+zkePreDL38iG7GQhBjfEFGKaVZ0PCnw3iPXkTUQr4pxuPRuS+hotR9nrU/jSjN PG+fOSPK2BgG6+5sZol0xaEcLrH5rLRfigV9i90tMdKM+8OotwOnQrf/UP++c/l+eSbc MqqjniAd+tePhAzUWUEzfMQ+nxMQmXgFtICYBRAyOIRdwVLLg/+6FnoP1anJVRi1RjTw yh1w== 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=yKYdxBZ6ziUrVW/hHYiFgekBfW9Hol+SwghVXmTAbOo=; b=gixy5PDrAPHf16zfx95r6fg2YHrbCKNu56WzYLPjk4xsSJUslZpEGjkGnVAgbFedv/ TGjRG+UyYpUkmw27Ur3C/71BXbVcMnxEeFSkavSFkuKEwxdu2TADwgb+6fCpACrLv2d+ l/lNiUWSrcF+3TGfHyiPZQf0p+CwtC5VxUQO1qonuLOsvQty8EFV40TcGVcRTEtSfGnb IEwg3e9FtK9C2WRPVYt2Ix3Xfg7sm79XPsuEU8ooKZCfUwPaUO3OOswEO9CqZOQ0OVPG iFhZ1ffbZJ7/lfiyEvGPFK/Yy7N236kyKUXYYTtrmzGUPfK+inNazhmk0vAtmhP4Hjku fDqA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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=yKYdxBZ6ziUrVW/hHYiFgekBfW9Hol+SwghVXmTAbOo=; b=qCGfd+425WeZzWsUBHKh1XPgv3eXd9Q66jIHE3q02uO60I6zyFkgiCZRcdNz20byAg 6tKO5jTFtlk6IhVkhc6xn4MW9DY6XGqm//xjxwS+xKOlg8qSSbFwz2g/VSU6fWF2hTry jh42736Al1rLgxe08ZiILR9bkcbOw5BOdY3/Zpjb3TCFI5+YDGazuq1bGgwklNybRKIj YIPSHR9CqRvnUiCWRBiU3GCTXRSXKsodavA/hfgi5f+IdncfE6MRHGfZTFM+Iq4wa6tP jqe2R9q6sQolUS8VR7wP+6G0rxYfFhAMe17x8754AXl4q1UiaeaQqAYxQNaX3eDaL355 fCRw== 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=yKYdxBZ6ziUrVW/hHYiFgekBfW9Hol+SwghVXmTAbOo=; b=BB3T0viRieSdKGlQWh2xif7xlzQO2MUSWkON5ZYmPOsnLMMcxHNEZuP1NVuUp6pesZ kzK7SKQEGsXD13aqszJ5jBK88F/hr7O4Ume35UcGYhEVvDsuAmwSBEOIkQrnnDYV0apW 1x8e2PKWaqeG2ptESJHtFV9q+QmFLBfD4A+Mmb5d9XaWMgbJ94wEQJZprfovjVdaig5v zLk2ft37hgaX8qos1RTiKqgw1WzEenjwXrpIWqCGAo3wngjuHTfX8T6xwRQ0h+3rp5WK OQbUA00zh74RL4O6ZRYoBl1WO0SqnE2djoOUDfF/sCFecVa8R7ihwNWjieE+NEiOGObC SgYQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533nI8qqTEhQTlG4OmhjWi/j/elHL+BjWjMKz+Sr8v5f3MfnkFAT kgwxRyGnScv7rLbDdtj5MxA= X-Google-Smtp-Source: ABdhPJxGP+96oZexltw/JVMKBFFOOKRxzEbasyFIwSCZ+DUzAFxchHsbI0xl4WcRR+Yu2cgDrqq5QQ== X-Received: by 2002:a05:6000:381:: with SMTP id u1mr37546424wrf.383.1636910932481; Sun, 14 Nov 2021 09:28:52 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:ad6:: with SMTP id c22ls9086765wmr.1.canary-gmail; Sun, 14 Nov 2021 09:28:51 -0800 (PST) X-Received: by 2002:a05:600c:3584:: with SMTP id p4mr51822550wmq.109.1636910931868; Sun, 14 Nov 2021 09:28:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636910931; cv=none; d=google.com; s=arc-20160816; b=JcIommvSWECWbkVihxHPU1gatrP3/zAHcGRFsKDhMVw1Y3qjcg9OI6b1pNLaG0Z7Cf kHaYZhpqdgIyEqs4m73b1XpkclZ4auwOl5mKkCATd7w8e+I/tQykLWK1zJT4cwFj2txY FBjVZgAsbD0a/h+4yZLPeCNxYXU5QT/E9IWahNMKKorY7pBuDh3BmReE9+0AZOFVYhXA Dm+oVoYWQ33PjuX7ZJeOCJuSlwp+vney0/sRGdO8Xv5AKbqX/6HPp+p/RSAxFoshyDtr txsX93y+4AGK9jC2pAFXZRG1zYzt/P+zrZg2Z3zG1BTw0ROYF3bXXR/V8xDiEHRw6oDD fQAQ== 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=fko4V3Mrt/74MkOFfdUBntxp5sy8CJqjmyWODwraNFA=; b=dVpXlAuqqRwvBFWyVaT/efdTS6FvLMLdZF12yAm4ztbvXMovbPVe4Mfd56vUWqvTOS F2SduqUhuglKLvjXdLWTcLkJC2vs2ZGTco5JbNOMNJz+qXDIYyJXQRV4ixTY38o9yVJL CNbSdNwrpvV42iNEDWH+Z5igIfSXlDPV3aFIEsxEZUvkOaxaBwBritlyfRCfTNooMYDu n+Pk+Dnor3msDVu4ovzB89RuFdSUQOhpFROJf2vIXzQNx/Jh2k6NhGH4hLMQ7PKgRigD 3L3QByrFv0jWPAFv1smwEwTEoPcoGCOQJ4Eu/2009pLV0PVAlKaTB4k53bzxWJ2pAiBC OV1Q== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 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. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id p11si110492wms.3.2021.11.14.09.28.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Nov 2021 09:28:51 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4HsfSM527Cz1qwdg; Sun, 14 Nov 2021 18:28:51 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4HsfSM4xPYz1qqkB; Sun, 14 Nov 2021 18:28:51 +0100 (CET) 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 dm4O0i_bmOsi; Sun, 14 Nov 2021 18:28:50 +0100 (CET) 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; Sun, 14 Nov 2021 18:28:50 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 5F8114542618; Sun, 14 Nov 2021 18:28:50 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id pBGtbyrvRH0C; Sun, 14 Nov 2021 18:28:47 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 74EC3454299B; Sun, 14 Nov 2021 18:27:47 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2 36/36] Updated roadmap Date: Sun, 14 Nov 2021 18:27:33 +0100 Message-Id: <20211114172733.71602-37-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211114172733.71602-1-sbabic@denx.de> References: <20211114172733.71602-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: 212.18.0.9 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: , Signed-off-by: Stefano Babic --- doc/source/roadmap.rst | 61 +++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/doc/source/roadmap.rst b/doc/source/roadmap.rst index 73831db..dc7d547 100644 --- a/doc/source/roadmap.rst +++ b/doc/source/roadmap.rst @@ -23,8 +23,11 @@ SWUpdate suitable for a large number of products. This will help to build a community around the project itself. +Core features +============= + Support for further compressors -=============================== +------------------------------- SWUpdate supports image compressed with following formats: zlib, zstd. This is a compromise between compression rate and speed to decompress the single artifact. @@ -33,27 +36,25 @@ Adding a new compressor must be careful done because it changes the core of handling an image. Support for OpenWRT -=================== +------------------- OpenWRT is used on many routers and has its own way for updating that is not power-cut safe. Selective downloading -===================== +--------------------- Bandwidth can be saved not only via delta, but identifying which part of the SWu must be loaded and skipping the rest. For example, SWUpdate can detect the versions for artifact before downloading them and ask the servers to send just the relevant artifacts. -Support for BTRFS snapshot -========================== - -BTRFS supports subvolume and delta backup for volumes - supporting subvolumes is a way -to move the delta approach to filesystems, while SWUpdate should apply the deltas -generated by BTRFS utilities. +Software-Software compatibility +------------------------------- -Note: research in this direction was stopped due to License conflicts with btrfs-utils. -They are now solved on btrfs-utils top of tree (libraries are now LGPLv2.1 and can be used -by SWUpdate). +SWUpdate has from the early stage a hardware to software compatibility check. In case +software is split in several components (like OS and application), it is desirable to have +a sort of software compatibility check. For example, SWUpdate verifies if a component +(like an application) is compatible with a runningOS and reject the update in case of +mismatch. Parser ====== @@ -62,8 +63,23 @@ SWUpdate supports two parsers : libconfig and JSON. It would be nice if tools ca be used to convert from one format to the other one. Currently, due to some specialties in libconfig, a manual conversion is still required. +Fetcher and interfaces +====================== + +Downloader +---------- + +The downloader is a one-shot command: when -d is set, SWUpdate loads the SWU from the provided +URL. This behavior is high requested and must be even supported in future, but another +use case is to run the downloader as daemon (like suricatta) and checks if a new SWU is +available at the specified URL. It should be as an alternative server for suricatta and +this allows to control it via IPC (enable/disable/trigger). + +Tools and utilities +=================== + Self contained tool to generate Update Packages (SWU) -===================================================== +----------------------------------------------------- Generation of SWUs is fully supported inside OE via meta-swupdate, but there is no support at all with other buildsystems (Buildroot, Debian). The user have a not preordered @@ -73,14 +89,6 @@ form a configuration a SWU. The tool must support all features, that means it sh to pack artfact, generate sw-description from templates, sign the SWU, encrypt the artifact, etc. -Software-Software compatibility -=============================== - -SWUpdate has from the early stage a hardware to software compatibility check. In case -software is split in several components (like OS and application), it is desirable to have -a sort of software compatibility check. For example, SWUpdate verifies if a component -(like an application) is compatible with a runningOS and reject the update in case of -mismatch. Lua === @@ -123,10 +131,17 @@ Current release supports verified images. That means that a handler written in Lua could be now be part of the compound image, because a unauthenticated handler cannot run. +Support for BTRFS snapshot +-------------------------- + +BTRFS supports subvolume and delta backup for volumes - supporting subvolumes is a way +to move the delta approach to filesystems, while SWUpdate should apply the deltas +generated by BTRFS utilities. + Security ======== -- add support for asymmetryc encryption +- add support for asymmetryc decryption Support for evaluation boards ============================= @@ -201,3 +216,5 @@ Documentation ============= Documentation is a central point in SWUpdate - maintaining it up to date is a must in this project. +Help from any user fixing wrong sentence, bad english, adding missing topics is high +appreciated.