From: Patrick Doyle <wpdster@gmail.com>
To: Artem Bityutskiy <dedekind1@gmail.com>,
Richard Weinberger <richard@nod.at>,
linux-mtd@lists.infradead.org
Subject: [PATCH 1/1] ubi: Allow ubiblock devices nodes to be created by volume name instead of volume ID.
Date: Thu, 4 Apr 2019 11:29:16 -0400 [thread overview]
Message-ID: <CAF_dkJA2DFr3Vgk5ie=V5YitZr8HaiXWuQ+SKsHzzmLBFnhyeg@mail.gmail.com> (raw)
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 <pdoyle@irobot.com>
---
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;
--
2.7.4
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next reply other threads:[~2019-04-04 15:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-04 15:29 Patrick Doyle [this message]
2019-04-04 19:37 ` [PATCH 1/1] ubi: Allow ubiblock devices nodes to be created by volume name instead of volume ID Richard Weinberger
2019-08-14 12:34 ` Emil Lenngren
2019-08-14 18:06 ` Patrick Doyle
2019-08-18 21:03 ` Richard Weinberger
2019-08-18 20:49 ` Richard Weinberger
2019-08-28 13:38 ` Emil Lenngren
2019-08-28 14:13 ` Richard Weinberger
2019-09-29 13:39 ` Jan Kardell
2019-09-29 13:39 ` Jan Kardell
2019-09-29 17:40 ` Richard Weinberger
2019-12-30 17:31 ` Ezequiel Garcia
2020-01-02 19:06 ` Patrick Doyle
2020-01-08 22:43 ` Richard Weinberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAF_dkJA2DFr3Vgk5ie=V5YitZr8HaiXWuQ+SKsHzzmLBFnhyeg@mail.gmail.com' \
--to=wpdster@gmail.com \
--cc=dedekind1@gmail.com \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).