All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cmd: ubi: add a command to rename volume
@ 2020-03-19 19:05 Philippe Reynes
  2020-03-19 20:40 ` Wolfgang Denk
  0 siblings, 1 reply; 3+ messages in thread
From: Philippe Reynes @ 2020-03-19 19:05 UTC (permalink / raw)
  To: u-boot

This commit add the command ubi rename to rename an ubi volume.
The format of the command is: ubi rename <oldname> <newname>.

Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
---
 cmd/ubi.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/cmd/ubi.c b/cmd/ubi.c
index cecf251..424f555 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 (strncmp(argv[1], "rename", 6) == 0)
+		return ubi_rename_vol(argv[2], argv[3]);
+
 	if (strncmp(argv[1], "skipcheck", 9) == 0) {
 		/* E.g., change skip_check flag */
 		if (argc == 4) {
@@ -693,6 +729,7 @@ U_BOOT_CMD(
 	"ubi remove[vol] volume"
 		" - Remove volume\n"
 	"ubi skipcheck volume on/off - Set or clear skip_check flag in volume header\n"
+	"ubi rename oldname newname\n"
 	"[Legends]\n"
 	" volume: character name\n"
 	" size: specified in bytes\n"
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] cmd: ubi: add a command to rename volume
  2020-03-19 19:05 [PATCH] cmd: ubi: add a command to rename volume Philippe Reynes
@ 2020-03-19 20:40 ` Wolfgang Denk
  2020-03-20  9:44   ` [*** MED SPAM ***]Re: " Philippe REYNES
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Denk @ 2020-03-19 20:40 UTC (permalink / raw)
  To: u-boot

Dear Philippe,

In message <1584644739-10258-1-git-send-email-philippe.reynes@softathome.com> you wrote:
> This commit add the command ubi rename to rename an ubi volume.
> The format of the command is: ubi rename <oldname> <newname>.

Can we plase make this optional / configurable?

Thanks!

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Every revolutionary idea - in science, politics, art, or  whatever  -
evokes three stages of reaction in a hearer:
  1. It is completely impossible - don't waste my time.
  2. It is possible, but it is not worth doing.
  3. I said it was a good idea all along.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [*** MED SPAM ***]Re: [PATCH] cmd: ubi: add a command to rename volume
  2020-03-19 20:40 ` Wolfgang Denk
@ 2020-03-20  9:44   ` Philippe REYNES
  0 siblings, 0 replies; 3+ messages in thread
From: Philippe REYNES @ 2020-03-20  9:44 UTC (permalink / raw)
  To: u-boot

Hi Wolfgang,

> Dear Philippe,
> 
> In message <1584644739-10258-1-git-send-email-philippe.reynes@softathome.com>
> you wrote:
>> This commit add the command ubi rename to rename an ubi volume.
>> The format of the command is: ubi rename <oldname> <newname>.
> 
> Can we plase make this optional / configurable?

Yes, of course, I sent a v2 with an option CMD_UBI_RENAME.
 
> Thanks!
> 
> Wolfgang Denk

Regards,
Philippe

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-20  9:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19 19:05 [PATCH] cmd: ubi: add a command to rename volume Philippe Reynes
2020-03-19 20:40 ` Wolfgang Denk
2020-03-20  9:44   ` [*** MED SPAM ***]Re: " Philippe REYNES

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.