* [PATCH v4] cmd: ubi: add a command to rename volume
@ 2020-03-23 18:20 Philippe Reynes
2020-03-23 18:42 ` Simon Glass
2020-04-21 5:57 ` Heiko Schocher
0 siblings, 2 replies; 3+ messages in thread
From: Philippe Reynes @ 2020-03-23 18:20 UTC (permalink / raw)
To: u-boot
This commit adds the command ubi rename to rename an ubi volume.
The format of the command is: ubi rename <oldname> <newname>.
To enable this command, the option CMD_UBI_RENAME must be selected.
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
---
cmd/Kconfig | 8 ++++++++
cmd/ubi.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
Changelog:
v4:
- fix usage of IS_ENABLED (feedback from Rasmus)
- use ! instead of == 0
v3:
- use IS_ENABLED instead of #ifdef (feedback from Simon)
- fix comment (feedback from Simon)
v2:
- added an option CMD_UBI_RENAME (feedback from Wolfgang)
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 6403bc4..1564694 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2172,6 +2172,14 @@ config CMD_UBI
It is also strongly encouraged to also enable CONFIG_MTD to get full
partition support.
+config CMD_UBI_RENAME
+ bool "Enable rename"
+ depends on CMD_UBI
+ default n
+ help
+ Enable a "ubi" command to rename ubi volume:
+ ubi rename <oldname> <newname>
+
config CMD_UBIFS
tristate "Enable UBIFS - Unsorted block images filesystem commands"
depends on CMD_UBI
diff --git a/cmd/ubi.c b/cmd/ubi.c
index cecf251..54d128d 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -251,6 +251,39 @@ out_err:
return err;
}
+static int ubi_rename_vol(char *oldname, char *newname)
+{
+ struct ubi_volume *vol;
+ struct ubi_rename_entry rename;
+ struct ubi_volume_desc desc;
+ struct list_head list;
+
+ vol = ubi_find_volume(oldname);
+ if (!vol) {
+ printf("%s: volume %s doesn't exist\n", __func__, oldname);
+ return ENODEV;
+ }
+
+ printf("Rename UBI volume %s to %s\n", oldname, newname);
+
+ if (ubi->ro_mode) {
+ printf("%s: ubi device is in read-only mode\n", __func__);
+ return EROFS;
+ }
+
+ rename.new_name_len = strlen(newname);
+ strcpy(rename.new_name, newname);
+ rename.remove = 0;
+ desc.vol = vol;
+ desc.mode = 0;
+ rename.desc = &desc;
+ INIT_LIST_HEAD(&rename.list);
+ INIT_LIST_HEAD(&list);
+ list_add(&rename.list, &list);
+
+ return ubi_rename_volumes(ubi, &list);
+}
+
static int ubi_volume_continue_write(char *volume, void *buf, size_t size)
{
int err = 1;
@@ -604,6 +637,9 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return ubi_remove_vol(argv[2]);
}
+ if (IS_ENABLED(CONFIG_CMD_UBI_RENAME) && !strncmp(argv[1], "rename", 6))
+ return ubi_rename_vol(argv[2], argv[3]);
+
if (strncmp(argv[1], "skipcheck", 9) == 0) {
/* E.g., change skip_check flag */
if (argc == 4) {
@@ -692,6 +728,9 @@ U_BOOT_CMD(
" - Read volume to address with size\n"
"ubi remove[vol] volume"
" - Remove volume\n"
+#if IS_ENABLED(CONFIG_CMD_UBI_RENAME)
+ "ubi rename oldname newname\n"
+#endif
"ubi skipcheck volume on/off - Set or clear skip_check flag in volume header\n"
"[Legends]\n"
" volume: character name\n"
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v4] cmd: ubi: add a command to rename volume
2020-03-23 18:20 [PATCH v4] cmd: ubi: add a command to rename volume Philippe Reynes
@ 2020-03-23 18:42 ` Simon Glass
2020-04-21 5:57 ` Heiko Schocher
1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2020-03-23 18:42 UTC (permalink / raw)
To: u-boot
On Mon, 23 Mar 2020 at 12:20, Philippe Reynes
<philippe.reynes@softathome.com> wrote:
>
> This commit adds the command ubi rename to rename an ubi volume.
> The format of the command is: ubi rename <oldname> <newname>.
> To enable this command, the option CMD_UBI_RENAME must be selected.
>
> Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
> ---
> cmd/Kconfig | 8 ++++++++
> cmd/ubi.c | 39 +++++++++++++++++++++++++++++++++++++++
> 2 files changed, 47 insertions(+)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v4] cmd: ubi: add a command to rename volume
2020-03-23 18:20 [PATCH v4] cmd: ubi: add a command to rename volume Philippe Reynes
2020-03-23 18:42 ` Simon Glass
@ 2020-04-21 5:57 ` Heiko Schocher
1 sibling, 0 replies; 3+ messages in thread
From: Heiko Schocher @ 2020-04-21 5:57 UTC (permalink / raw)
To: u-boot
Hello Philippe,
Am 23.03.2020 um 19:20 schrieb Philippe Reynes:
> This commit adds the command ubi rename to rename an ubi volume.
> The format of the command is: ubi rename <oldname> <newname>.
> To enable this command, the option CMD_UBI_RENAME must be selected.
>
> Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
> ---
> cmd/Kconfig | 8 ++++++++
> cmd/ubi.c | 39 +++++++++++++++++++++++++++++++++++++++
> 2 files changed, 47 insertions(+)
Applied to u-boot-ubi master, thanks!
bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-21 5:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-23 18:20 [PATCH v4] cmd: ubi: add a command to rename volume Philippe Reynes
2020-03-23 18:42 ` Simon Glass
2020-04-21 5:57 ` Heiko Schocher
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.