From patchwork Thu Apr 4 15:29:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Doyle X-Patchwork-Id: 1077422 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZXdRLRu+"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="n/fopCLY"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44Zn1r46r1z9sPJ for ; Fri, 5 Apr 2019 02:29:52 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=H8/bquIjEvTrQq0jXArA8dcQ3CS3wtxDccoz6cPh89g=; b=ZXd RLRu+6KtZvNE58YZ/zN25r6wSGm1MnAXZCmUxu4D2dx5jKhN1OvnfJ9SUn+s3XbEWEFzGy7FVdNdS 47Js4djO4+rK85Z5CpPmuO+AcF6Rink2r6D08XlbHZlsqFMx0ksoBkueK1G6i9kf3J9aLjopXmgp/ 0MR+91xpuljN4a9eXEbe446oCPn1GiPHNVHHrt7+3W0L7VWoqH2gUMXZV+8L749Mzslji1Lo1kVqw 4IbEHREvRDlzgN1yMTCYKgdkkGkuvtqr6s3xlp/5liPBJqHnsyGkaQW3dYQxHAUHQ2X52aL6vuc9D luBXETiRS7YTEbNdLbcoshswD85C0uw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hC4JG-0004Bf-FB; Thu, 04 Apr 2019 15:29:46 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hC4JD-0004B4-6Y for linux-mtd@lists.infradead.org; Thu, 04 Apr 2019 15:29:44 +0000 Received: by mail-qt1-x841.google.com with SMTP id s15so3733607qtn.3 for ; Thu, 04 Apr 2019 08:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=hfqm1+CpqUNUVt9XQAcAVAzX6iPv2FM9q6ijwYDMLvM=; b=n/fopCLYxpdiVZLfWGzGsuJoj/huKyafDFot2vmt13L9R2+JTtrzt4y0MFF66n8LOs RO+TzVOeEtSNJajJWoB8TEck3FlXjTeURdbuAxdCxCdzwMHQDYt2Um3wa8vG1eIuZ2k0 r35Ze+oyXowIUf5LpEkpV7uoMtcHuXQIS4f0Hd675BBreUhF0l+RtYEIlokjmN+++P62 uSgDhKtpVqWpGPPgiRmPKnEEazlLay0d6HvztAtmH4RCudRo0OBr+SKmvcpKmKi/7uN3 J8BVDLd5AFr20kqQ+nPLfjrLCp8sVrsw8sU3LJ7E8yDMsGOLa05WK2OdWhI8hVtnMXAY 36yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=hfqm1+CpqUNUVt9XQAcAVAzX6iPv2FM9q6ijwYDMLvM=; b=n/1TGpKteCrnqXggfpB0hKU1XNsT6OiTyWXMGTbQfDzoHtZY0qsLYgXgCKPpWtlLcX 6G0Z3/zUWk6FSDYSy8Q7WMKs8Cwd6SsrgHmKCErD2iclrf7Yx8e8m8LUVmaiOznGyLy5 tZq4lXUo7wOUxJXuMupb8BUjTvnZVtsQtBZ8FJOYQPuNCQT+/d6WhpV73d87CmqYR0qg u6DkrNzj4U1+1jzZM155kYqnD6fAqYGw6wkOQZGimBnqaX9YjJr8jl4wcXlfwd13tYaC PuaH3WECdIzC8gSk75GDfx/k0WMAUgwfHbvKuSaJ7FBbliJElHfmUGchjdXXo+Vb7IoF Om5w== X-Gm-Message-State: APjAAAXZ3T5iNeAtxsHMUMdcz0TMXQAo0UQ/pb34/IYpo6oEDLgd0gr0 YEHUmm4s9Hrq+y6Mx7t3mYGmz0CHDnZYMAY9AKg= X-Google-Smtp-Source: APXvYqwVssYMJnOlZdCpKAdpWw/hJhkKfVJ1DkQIlX0o6mjCkLR+qASvElnkYFaaUHeW41Y9aC08HqLYYp14JXKMKLM= X-Received: by 2002:ac8:21c7:: with SMTP id 7mr6158304qtz.66.1554391782319; Thu, 04 Apr 2019 08:29:42 -0700 (PDT) MIME-Version: 1.0 From: Patrick Doyle Date: Thu, 4 Apr 2019 11:29:16 -0400 Message-ID: Subject: [PATCH 1/1] ubi: Allow ubiblock devices nodes to be created by volume name instead of volume ID. To: Artem Bityutskiy , Richard Weinberger , linux-mtd@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190404_082943_263039_3F8BECDE X-CRM114-Status: GOOD ( 10.24 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:841 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (wpdster[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add support for CONFIG_MTD_UBI_BLOCK_BY_NAME, which enables ubi block devices to be named by their volume name: /dev/ubiblock%d_%s rather than their volume ID /dev/ubiblock%d_%d, so that one can mount e.g. a root filesystem by UBI name instead of volume ID. UBI volumes can be renamed on-the-fly in user space. This allows the root file system to be swapped from an "A" volume to a "B" volume without having to change the mount options. Signed-off-by: Patrick Doyle --- drivers/mtd/ubi/Kconfig | 12 ++++++++++++ drivers/mtd/ubi/block.c | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig index 43d131f..d9320f0 100644 --- a/drivers/mtd/ubi/Kconfig +++ b/drivers/mtd/ubi/Kconfig @@ -103,4 +103,16 @@ config MTD_UBI_BLOCK If in doubt, say "N". +config MTD_UBI_BLOCK_BY_NAME + bool "Create ubi block device nodes by name instead of volume ID" + default n + depends on MTD_UBI_BLOCK + help + This option enables ubi block devices to be named by their volume name + /dev/ubiblock%d_%s rather than their volume ID /dev/ubiblock%d_%d, so that + one can mount e.g. a root filesystem by UBI name instead of volume ID. + UBI volumes can be renamed on-the-fly in user space. This allows the root + file system to be swapped from an "A" volume to a "B" volume without having to + change the mount options. + endif # MTD_UBI diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c index d0b63bbf..ac2d480 100644 --- a/drivers/mtd/ubi/block.c +++ b/drivers/mtd/ubi/block.c @@ -399,7 +399,11 @@ int ubiblock_create(struct ubi_volume_info *vi) goto out_put_disk; } gd->private_data = dev; +#ifdef CONFIG_MTD_UBI_BLOCK_BY_NAME + sprintf(gd->disk_name, "ubiblock%d_%s", dev->ubi_num, vi->name); +#else sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id); +#endif set_capacity(gd, disk_capacity); dev->gd = gd;