From patchwork Fri Feb 7 15:02:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Eggers X-Patchwork-Id: 1235035 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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+bncbaabbjxy6xyqkgqeu5mrl7y@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arri.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=SP3M1y+T; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 48DdpL2xJFz9s3x for ; Sat, 8 Feb 2020 02:03:06 +1100 (AEDT) Received: by mail-wr1-x43c.google.com with SMTP id c6sf1361081wrm.18 for ; Fri, 07 Feb 2020 07:03:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1581087782; cv=pass; d=google.com; s=arc-20160816; b=Wybqo8ACCehLTgDIRfZ7w5gAXg52Aa7N+U9RUp4f7wP+RkxkpHAtnwL25NLli7FXjJ Vh1lz5x5elGCkswYCsK8HiSG/dtixHAUeAkP9r/u3TR6wDa56WMBlYQZzF1NgqvT5C8f FBhQVzETm+1LBZZEc//8hfgvOh7vrtZnASr2yImBdkyqhAEXuhmQMQj55sHXmCTO5r4e BVvbOlcaD5+pIgNASEHMqIwLG57Pn7oXPTzBn2Xv2B27UkgYJOoCdFP6w0+RjjMySKn4 Jtw2T9QvflH82i5ivK0e8sC712iq3VkZa4Uh2SpEx5jYGUU1JNEwzAU/Zq4v0NmZ9qjv 8Gcw== 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:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=KEnPkYnhcn3P1ptV8dDFdDs/iX2aAbLIg1QSiqe0hrk=; b=xe7KCGTFKrM807m2drZKjvTWX/agtRFrgxN2T+r3G47IAwbXJtJpuidkJ5XKwCt80i AIZDrAfflzMqYvBxBLjaCsofoAY3BsXUXUpaZtrs2isLrNVdNslaop9yTlaocPwLd0LX 0azivgA2Wg/2YkxNlTMXoA0JP9NO5RnE139yk3DrSM9U9kpRWNco/jfC5UJcOjo65efT aw6OF7PkYAKbFjFlM1XAus5ZQPy+QSPCTS7rl4kkd+50CiPcGMDRJiVHvIl9oNzjqUic nDmfNJyAlxK5EC4IT04nZrb5DQcj3hBpb00czs/fnP8bQPTEMXNoOsYyHe65qv+6UT5j IlLw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of ceggers@arri.de designates 94.199.90.95 as permitted sender) smtp.mailfrom=CEggers@arri.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id: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=KEnPkYnhcn3P1ptV8dDFdDs/iX2aAbLIg1QSiqe0hrk=; b=SP3M1y+T9bmdUBxTrFb9OTZG0uCMrx9cP9BKjTypl1tC6vSNBpm8QvAPwGEXXuy4iS z6AxxApmF2Z7YNU3KtjnTPl1x9vEUP0m1CorWeCqlybK3ezEnpTYNrEbhsrxvyOxzk/q dhCKRYTzO5kiFVp9ysxNPQXqAdSDHgN6pValEjRG2wNSiEIUYb+LCJ8Akrci9KX6BYA3 xFIBXs4R7CDWzKb2dFqG3APvDjFlL2473Meu4ScEmTrZ5C4UAtTyGHT8DiJBMTLS3av1 DRjwbqttvZuTmg602xZg+fFG+YSnCPIlZjD9GffzXORKzRkSuobsPZae3DKLKYjqTTNL L+hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :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=KEnPkYnhcn3P1ptV8dDFdDs/iX2aAbLIg1QSiqe0hrk=; b=a9DZy+f8xXqCbikpvDIYSunOdJ+WxHpScvcSEc23FnUILG5nHXfyCCCkooQp1GtTKP pnqtV1FxPy3PUg5lxSDeJnwpHr2qAgppAPRMAQpjgkz/NL9bRJhw3ahFDKlrLXAxKT79 2VhIqYkAGisAI/IGIsVAdTG3nBZq3mPNhWUKTHHxMTfGFGo0O32evfnABEOAq0xPMkK9 D4o+fCKKABiADerHdiCUdAZO97tCjs9BW29yhwn9yAMZTX+eshwYqOvEEjbo8mrOaabS DsctCVv9NGYE9OZuYynRUAfkXRijywRqR2kXRm3A65N+ZuurfL9v9k5GtyTaZqFhY4ds YbqQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: APjAAAXM2N/luZfyaMxUKuIpT7mREKjj5g9js0jKB4Ugrbc5N5u8lZNm ysWb5Roc4lzcKNwNHJ3Y/is= X-Google-Smtp-Source: APXvYqxlXrwnE+HcfweCPWMGV3DqmXnTzYluSfb/vuLge8BSDiYX8bi6v59D9Q8Y7MJBxjNpXk9PzQ== X-Received: by 2002:a5d:61cb:: with SMTP id q11mr5422534wrv.71.1581087782467; Fri, 07 Feb 2020 07:03:02 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a7b:c452:: with SMTP id l18ls8300283wmi.1.canary-gmail; Fri, 07 Feb 2020 07:03:01 -0800 (PST) X-Received: by 2002:a7b:c651:: with SMTP id q17mr5030505wmk.5.1581087781886; Fri, 07 Feb 2020 07:03:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581087781; cv=none; d=google.com; s=arc-20160816; b=eLaH3l7HfGgKayUMqRNFUxvWaJjXA23BPyB7kMbxFlullbThioxRVotDv8dpHTugQ7 n2Ji0cBwUjN8qzQs1+OOkvwoLwWmKfzlSDIxCBIonosphsjHqQU4OPzs5WcicCjIg1uQ z/Ko0uQ4gB9lvkK/TXyF4ryAYk0xFRzXDyHOky4WusNqBpUg4MrcKZ5MdbygC1dhli5a CoW9pcPxPmnlxzTE+ogRLQHlwDy5ZZnqA8HWAJlenTmKXg5Go1K72w4cuyFAnBRx3zk4 5JvebAdxB1/i43JNAy7OXLRRCp6DdO5Sifdrlla7DneRWg1bmqI+wxiaaLJJAB1yl/zu /l1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:message-id:date:subject:cc:to:from; bh=Z3Mg6quF8FMxm4HDDlkxyoDrPO2ln8bHMlw+lmlayMc=; b=H36y46udTs0kpw4qowEqg3P4ocMrWWtgsMD3jAF8z43lQcY9E9/wM0G6Jc19W4pkKF bPUV1KYDJ1C1T+EYvkA/cbqpuWiwjQlUBuIQhTVd3KpbKvNikR5T9Ue7lRrtdrAQTMLN EShdHQjYdmLJ6sHGEzaludeBN19Gx7T0GZl1DHJmWbgbUAW9iYwza1vCov7PlNr0iLoL 9ymoWK1v++CaBdeFibuuPE4bc4SPFdirDBOGCln1zFSiEUZKmNQGMhCG8wUP2nEzda4l 3nEd3invcNBvqqy0HaYXWKsMtYNvG5Hp0EZqR3gALwyXbGCoh1g3r+fTvOxzeu3rnjtr M+sg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of ceggers@arri.de designates 94.199.90.95 as permitted sender) smtp.mailfrom=CEggers@arri.de Received: from mailout07.rmx.de (mailout07.rmx.de. [94.199.90.95]) by gmr-mx.google.com with ESMTPS id y185si286994wmd.2.2020.02.07.07.03.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Feb 2020 07:03:01 -0800 (PST) Received-SPF: pass (google.com: domain of ceggers@arri.de designates 94.199.90.95 as permitted sender) client-ip=94.199.90.95; Received: from kdin01.retarus.com (unknown [172.19.17.48]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout07.rmx.de (Postfix) with ESMTPS id 48DdpC62wwzBwlW for ; Fri, 7 Feb 2020 16:02:59 +0100 (CET) Received: from ppmail.arri.de (unknown [217.111.95.7]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by kdin01.retarus.com (Postfix) with ESMTPS id 48Ddp90jj9z2xF5 for ; Fri, 7 Feb 2020 16:02:57 +0100 (CET) Received: from mta.arri.de ([192.168.100.141]) by ppmail.arri.de over TLS secured channel with Microsoft SMTPSVC(7.0.6002.18264); Fri, 7 Feb 2020 16:02:53 +0100 Received: from N95HX1G2.arri.de (192.168.201.254) by mta.arri.de (192.168.100.104) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 7 Feb 2020 16:02:53 +0100 From: Christian Eggers To: CC: , Christian Eggers Subject: [swupdate] [PATCH] handlers: ubivol: Special handling for zero sized volumes Date: Fri, 7 Feb 2020 16:02:43 +0100 Message-ID: <20200207150243.15333-1-ceggers@arri.de> X-Mailer: git-send-email 2.16.4 MIME-Version: 1.0 X-Originating-IP: [192.168.201.254] X-OriginalArrivalTime: 07 Feb 2020 15:02:53.0695 (UTC) FILETIME=[AC5798F0:01D5DDC7] X-RMX-ID: 20200207-160257-48Ddp90jj9z2xF5-0@172 X-RMX-SOURCE: 217.111.95.7 X-Original-Sender: ceggers@arri.de X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ceggers@arri.de designates 94.199.90.95 as permitted sender) smtp.mailfrom=CEggers@arri.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 ubifs kernel driver doesn't allow creation of zero sized volumes. Check for zero size in order to avoid an error and allow the following partition description in order to get rid of volumes not required anymore: partitions: ( { type = "ubipartition"; name = "app0"; size = 0; /* remove possible orphan UBI volume */ device = "root"; }, ... ); Signed-off-by: Christian Eggers --- doc/source/sw-description.rst | 3 ++ handlers/ubivol_handler.c | 74 ++++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/doc/source/sw-description.rst b/doc/source/sw-description.rst index e9be1c0..e1950f8 100644 --- a/doc/source/sw-description.rst +++ b/doc/source/sw-description.rst @@ -610,6 +610,9 @@ The default behavior of swupdate is to create a dynamic UBI volume. To create a static volume, add a line ``data = "static";`` to the respective partition entry. +If a size of 0 is given, the volume will be deleted if it exists. This +can be used to remove orphan volumes possibly created by older software +versions which are not required anymore. images ------ diff --git a/handlers/ubivol_handler.c b/handlers/ubivol_handler.c index 0f53a0a..21e88ec 100644 --- a/handlers/ubivol_handler.c +++ b/handlers/ubivol_handler.c @@ -307,44 +307,46 @@ static int resize_volume(struct img_type *cfg, long long size) free(ubivol); } - /* We do not need a volume to get the right node */ - snprintf(node, sizeof(node), "/dev/ubi%d", mtd_info->dev_info.dev_num); - - /* - * Creates all other partitions as specified in the description file - * Volumes are empty, and they are filled later by the update procedure - */ - memset(&req, 0, sizeof(req)); - req.vol_type = req_vol_type; - req.vol_id = UBI_VOL_NUM_AUTO; - req.alignment = 1; - req.bytes = size; - req.name = cfg->volname; - err = ubi_mkvol(nandubi->libubi, node, &req); - if (err < 0) { - ERROR("cannot create %s UBI volume %s of %lld bytes", - (req_vol_type == UBI_DYNAMIC_VOLUME) ? "dynamic" : "static", - req.name, req.bytes); - return err; - } + if (size) { + /* We do not need a volume to get the right node */ + snprintf(node, sizeof(node), "/dev/ubi%d", mtd_info->dev_info.dev_num); + + /* + * Creates all other partitions as specified in the description file + * Volumes are empty, and they are filled later by the update procedure + */ + memset(&req, 0, sizeof(req)); + req.vol_type = req_vol_type; + req.vol_id = UBI_VOL_NUM_AUTO; + req.alignment = 1; + req.bytes = size; + req.name = cfg->volname; + err = ubi_mkvol(nandubi->libubi, node, &req); + if (err < 0) { + ERROR("cannot create %s UBI volume %s of %lld bytes", + (req_vol_type == UBI_DYNAMIC_VOLUME) ? "dynamic" : "static", + req.name, req.bytes); + return err; + } - ubivol = (struct ubi_part *)calloc(1, sizeof(struct ubi_part)); - if (!ubivol) { - ERROR("No memory: malloc failed"); - return -ENOMEM; - } - err = ubi_get_vol_info1(nandubi->libubi, - mtd_info->dev_info.dev_num, req.vol_id, - &ubivol->vol_info); - if (err) { - ERROR("cannot get information about " - "newly created UBI volume"); - return err; + ubivol = (struct ubi_part *)calloc(1, sizeof(struct ubi_part)); + if (!ubivol) { + ERROR("No memory: malloc failed"); + return -ENOMEM; + } + err = ubi_get_vol_info1(nandubi->libubi, + mtd_info->dev_info.dev_num, req.vol_id, + &ubivol->vol_info); + if (err) { + ERROR("cannot get information about " + "newly created UBI volume"); + return err; + } + LIST_INSERT_HEAD(&mtd_info->ubi_partitions, ubivol, next); + TRACE("Created %s UBI volume %s of %lld bytes (old size %lld)", + (req_vol_type == UBI_DYNAMIC_VOLUME) ? "dynamic" : "static", + req.name, req.bytes, ubivol->vol_info.rsvd_bytes); } - LIST_INSERT_HEAD(&mtd_info->ubi_partitions, ubivol, next); - TRACE("Created %s UBI volume %s of %lld bytes (old size %lld)", - (req_vol_type == UBI_DYNAMIC_VOLUME) ? "dynamic" : "static", - req.name, req.bytes, ubivol->vol_info.rsvd_bytes); return 0; }