From patchwork Thu Aug 16 17:05:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnout Vandecappelle X-Patchwork-Id: 958503 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13e; helo=mail-lf1-x13e.google.com; envelope-from=swupdate+bncbdjllh4stydrb6g523nqkgqevim3gci@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mind.be Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="Yu5fb6GF"; dkim-atps=neutral Received: from mail-lf1-x13e.google.com (mail-lf1-x13e.google.com [IPv6:2a00:1450:4864:20::13e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41rt5R4JqWz9s4V for ; Fri, 17 Aug 2018 03:06:03 +1000 (AEST) Received: by mail-lf1-x13e.google.com with SMTP id z12-v6sf1285420lfe.2 for ; Thu, 16 Aug 2018 10:06:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1534439160; cv=pass; d=google.com; s=arc-20160816; b=0RT6a5HbK33BDBqRGV/ShBxP6s7wQjyUV9SB7s+7MGnAiCoIZUu2FDhWIfNewcMJO7 yACiQ3p6rjmQxfiYVz22XoyzJj9KpSbNm4wZblcy4rCRqOXfUaVuv/n7+nCvw842IjPv 9OVHNKnuAodwf0CkP1LTWwTSC61k2Y7AIcECl8k4iAnvVwZpYURNcCBoUC0r1gbmomia SMnk7lb5V1io0jt6hWjqqWoM9soCOWC7YAz8at15EYISR7k/+48CNGtmKWqWsQDK1ha6 tmRXzaV5o21Jh19nIIDrUcbslulKVEVgjxoYEiWki4Rm2ZTuuaeq12yjNtv5G7ellfnA b+6g== 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:message-id:date:subject:cc:to:from :arc-authentication-results:arc-message-signature:mime-version :sender:dkim-signature:arc-authentication-results; bh=2oidOj+D8D4Ojoskv5tkeQGeUtj5LvbroNV6FdWsiPU=; b=nkekeP8st02gCg5DktC7OTZlx4iWg6a87snxb5Gv42oeTbQFGt93hejdB99wS5Rj7o jqOsJ4fT4X9gmjCFksDzKGkAUTSj14KWjDMjmdzBj+jnkUU/MsP2J4uHmsSn58226Mzo WDEU6ZV9bAQXZbLXgN6DyzCzH5f79y6anHc89mjIJK6F23wjr3Olu+VJvVlfJZDhLOBu r69H//2LPonc5drw8iNwzhlcj2/g2GGpAyfTGPGYhzY+OXd3j+9R73l1oH0ftfNtrTpW 8hh50N/yLeI+d1NEGb9rSr7h5kqauFE6s7ud5eVfG1YzZeXFsbTXOaZ9QIQDAkui/WR6 Jfnw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@mind-be.20150623.gappssmtp.com header.s=20150623 header.b=zfiaJdBO; spf=softfail (google.com: domain of transitioning arnout.vandecappelle@essensium.com does not designate 2a00:1450:4864:20::443 as permitted sender) smtp.mailfrom=arnout.vandecappelle@essensium.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=2oidOj+D8D4Ojoskv5tkeQGeUtj5LvbroNV6FdWsiPU=; b=Yu5fb6GFCCAU1OtZcGLk98INEtxOTdC2pUsPH44sc+e0kk8WRIuOmjPOWxOaNyk1ys 2SDwMRtuUPwsHY9NiuE9R0UTRTBe3XRd2mM4nI0PT63iMPml96BKh9V2/NiTgebN2Ngf vzvvjKYt4NVVJum20sqSRJjFhun40HNYs3cKxDNEtBJakSvNY5+J1W2s/nk32dy9k8O8 ZWVY0TqC2YUMYtm/FVdwweH0sM7RKxoOyHCKNGM5IPS3iKp4VOHSTdY6uKgtNehH6IsP lHVPhDox4GH9wEYFiHSdcm8C4kwDRL/SfGCvKeYWYbMRottnR297gri7LIzuey7lH5qH JVRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id: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=2oidOj+D8D4Ojoskv5tkeQGeUtj5LvbroNV6FdWsiPU=; b=VuW2dJq1I8x3XvcnqnY0BBzhcncOxNwPo7gWcD++pe88Db74ejBMoZsIUtS9k4PPGq wqzJ5vmAVr9wY8k1nSnGorOCrW8dddEV/fmNWwm5usov1/zaNaaoyYgQekThOCm/RF84 3TYwJA87FZlAUzHNrShvoC2PmcsfPElv6Zfsh2q1i94EUyRIEPHzfAVI24xuQUHZNSaD wL3hzAII7zVwLR6zsXBdVGGpRkb46kK4bS6vTQVewgcGVX/COWGrIw2lhg0l1OqZjpFM FBaExq+MT3WssZR02kou+68tE6gV8fT7Q4YfF4dfSJBd6T6b+3ay1/o1IqrepBnRr3L0 ZvHg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOUpUlHZrQevCQV+i8ha6Br+F7b5LIKZ8FVhQ00D6GyTTTZ+GJCatuP0 tyIWR0f26Av7VyIgkwPwSvs= X-Google-Smtp-Source: AA+uWPyAfRCi6tk+sr2hjzuRrLXbU4A9pHWWWzC5PHpQHyygPy6rBw1GFsaHI3BP7y7FfJUB/fRKWA== X-Received: by 2002:a19:1f14:: with SMTP id f20-v6mr221845lff.3.1534439160798; Thu, 16 Aug 2018 10:06:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:cdd2:: with SMTP id d201-v6ls136390lfg.30.gmail; Thu, 16 Aug 2018 10:06:00 -0700 (PDT) X-Received: by 2002:a19:ec09:: with SMTP id b9-v6mr1487308lfa.5.1534439160117; Thu, 16 Aug 2018 10:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534439160; cv=none; d=google.com; s=arc-20160816; b=Y+nxe6NnAmpsbvmdAi4IoGW5XQRAqiqpP/UfNzQmWdJSBvwdDRLbp4g0TWLmgK7FAr VuYQwCSuFJzbwXxMZ/gSACusWXFp44MnzPoGJm+FnB+97oK+yerhVBjzsa6NpIwlMb90 mntLDoWsBO7Jcx4XnLk3kCo3VltkohgW6VVlHI/3TtNjgS7Nm9gfls3jGiANJPlZ45z6 Nw0lq+J80Xz1ABXHFdQm9S9vhE95e0hmlTvmbF2U643qVvQWnUtlaUHWCBWowIVyuoRt bupEh8Rfh9hAxOS0susXOJqX8jvB/UaUEH0qJIAJBnwwDrxjaozX5uZ7MogfWoGMQVpq LAmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=y0mXw03l8T67+UHqO+ySUqBIeAJubSAHFV9TDDc8ZF8=; b=d9uuHCw4TZZXanFYOOsE6nUJVVa4xLnIgKecxesH7ZRhiPLsNRFmBZlB+BR23Vk/Sn qqY3g6VUiPE9HjFT3ffo9g2KZnv+R/ZMjq31Pe1C8P0LJmr94HH2PsWeIgIIkc2omfDj C4Y9I8KobZFV1Cv9Lx8gZNlMWTlhWcolN7Z4DzEaKQRZL93EhIPdUvvPu1jEEWjkogbe 6o98GKTdK9NCnEX+8XDIOJuFwuECA+rpcrZo5UtNPsqU1mivY1sxKm5SuC03tf5w75RQ CBQ5R01SQxgdin2mzJ6WXqBuCSspkATIXQyF5n2b2Ps1RPXGi5ZPPmMHNrUod/VZg/oz L06Q== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@mind-be.20150623.gappssmtp.com header.s=20150623 header.b=zfiaJdBO; spf=softfail (google.com: domain of transitioning arnout.vandecappelle@essensium.com does not designate 2a00:1450:4864:20::443 as permitted sender) smtp.mailfrom=arnout.vandecappelle@essensium.com Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com. [2a00:1450:4864:20::443]) by gmr-mx.google.com with ESMTPS id y5-v6si185845lfe.5.2018.08.16.10.05.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 10:05:59 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning arnout.vandecappelle@essensium.com does not designate 2a00:1450:4864:20::443 as permitted sender) client-ip=2a00:1450:4864:20::443; Received: by mail-wr1-x443.google.com with SMTP id h15-v6so4781491wrs.7 for ; Thu, 16 Aug 2018 10:05:59 -0700 (PDT) X-Received: by 2002:adf:df12:: with SMTP id y18-v6mr1377710wrl.26.1534439159020; Thu, 16 Aug 2018 10:05:59 -0700 (PDT) Received: from vandecaa-laptop.local.ess-mail.com (ip-188-118-3-185.reverse.destiny.be. [188.118.3.185]) by smtp.gmail.com with ESMTPSA id m68-v6sm3486541wmb.10.2018.08.16.10.05.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 10:05:58 -0700 (PDT) From: "Arnout Vandecappelle (Essensium/Mind)" To: swupdate@googlegroups.com Cc: "Arnout Vandecappelle (Essensium/Mind)" Subject: [swupdate] [PATCH v2] UBI handler: allow mtd device to be specified by name Date: Thu, 16 Aug 2018 19:05:50 +0200 Message-Id: <20180816170550.16089-1-arnout@mind.be> X-Mailer: git-send-email 2.18.0 X-Original-Sender: arnout@mind.be X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@mind-be.20150623.gappssmtp.com header.s=20150623 header.b=zfiaJdBO; spf=softfail (google.com: domain of transitioning arnout.vandecappelle@essensium.com does not designate 2a00:1450:4864:20::443 as permitted sender) smtp.mailfrom=arnout.vandecappelle@essensium.com 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: , It is often more convenient to specify the partition by name instead of by number. This is especially true for boards with multiple chips, where the numbering may change after an update of the kernel. If get_mtd_from_device fails, fall back to get_mtd_from_name. In other words, if mtd partition mtd5 is named "mtd0" (which would be a stupid thing to do), "mtd0" will still resolve to /dev/mtd0. Note that currently, the flash handler (i.e., the handler for images with type = flash) already has this feature. However, for the flash handler, you have to use 'device' if you specify the mtd number and 'mtdname' if you specify the mtd name. For the ubivol handler (where the mtd device is specified in the 'partitions' section, not in the 'images' section, so it's not entirely comparable), we choose to use 'device' both for the mtd number and the mtd name. The description of this feature is added to sw-description.rst. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) Acked-by: Stefano Babic --- v2: - rework commit message - add documentation In the review of v1, Stefano asked to document the behaviour is doc/source/handlers.rst. However, the information given for the UBI handler in that section is currently not consistent with reality, which makes it hard to do it there. Instead, I've documented the feature in sw-description.rst in this patch, and I'll make a separate patch next week to correct handlers.rst. --- doc/source/sw-description.rst | 6 +++++- handlers/ubivol_handler.c | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/source/sw-description.rst b/doc/source/sw-description.rst index 55821ad..ec32e8e 100644 --- a/doc/source/sw-description.rst +++ b/doc/source/sw-description.rst @@ -294,7 +294,11 @@ in kernel. All fields are mandatory. SWUpdate searches for a volume of the selected name and adjusts the size, or creates a new volume if -no volume with the given name exists. +no volume with the given name exists. In the latter case, it is +created on the UBI device attached to the MTD device given by +"device". "device" can be given by number (e.g. "mtd4") or by name +(the name of the MTD device, e.g. "ubi_partition"). The UBI device +is attached automatically. images ------ diff --git a/handlers/ubivol_handler.c b/handlers/ubivol_handler.c index 247a644..909a215 100644 --- a/handlers/ubivol_handler.c +++ b/handlers/ubivol_handler.c @@ -169,6 +169,10 @@ static int adjust_volume(struct img_type *cfg, * Other MTD are not touched */ mtdnum = get_mtd_from_device(cfg->device); + if (mtdnum < 0) { + /* Allow device to be specified by name OR number */ + mtdnum = get_mtd_from_name(cfg->device); + } if (mtdnum < 0 || !mtd_dev_present(flash->libmtd, mtdnum)) { ERROR("%s does not exist: partitioning not possible", cfg->device);