From: Philippe REYNES <philippe.reynes@softathome.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2] cmd: ubi: add a command to rename volume
Date: Mon, 23 Mar 2020 18:16:13 +0100 (CET) [thread overview]
Message-ID: <712753422.1363518.1584983773442.JavaMail.zimbra@softathome.com> (raw)
In-Reply-To: <CAPnjgZ2278XbEo9D+xwhzVioD0CUrpTrdsKhM5TesZRUFMbLWQ@mail.gmail.com>
Hi Simon,
> Hi Philippe,
>
> On Fri, 20 Mar 2020 at 03:55, Philippe Reynes
> <philippe.reynes@softathome.com> wrote:
>>
>> This commit add the command ubi rename to rename an ubi volume.
>
> adds
>
>> 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 | 43 +++++++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 51 insertions(+)
>>
>> Changelog:
>> 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..4885661 100644
>> --- a/cmd/ubi.c
>> +++ b/cmd/ubi.c
>> @@ -251,6 +251,41 @@ out_err:
>> return err;
>> }
>>
>> +#ifdef CONFIG_CMD_UBI_RENAME
>> +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);
>> +}
>> +#endif /* CONFIG_CMD_UBI_RENAME */
>> +
>> static int ubi_volume_continue_write(char *volume, void *buf, size_t size)
>> {
>> int err = 1;
>> @@ -604,6 +639,11 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc,
>> char * const argv[])
>> return ubi_remove_vol(argv[2]);
>> }
>>
>> +#ifdef CONFIG_CMD_UBI_RENAME
>
> Can you use IS_ENABLED(CONFIG_...) and drop the #ifdef way above?
I've sent a v3 where I use IS_ENABLED instead of #ifdef.
But I've kept a #if IS_ENABLED(...) around the function ubi_rename_vol.
Otherwise if this option is not enabled, there is a warning when building :
CC cmd/ubi.o
cmd/ubi.c:254:12: warning: 'ubi_rename_vol' defined but not used [-Wunused-function]
static int ubi_rename_vol(char *oldname, char *newname)
^~~~~~~~~~~~~~
>> + if (strncmp(argv[1], "rename", 6) == 0)
>> + return ubi_rename_vol(argv[2], argv[3]);
>> +#endif
>> +
> [..]
>
> Regards,
> Simon
Regards,
Philippe
next prev parent reply other threads:[~2020-03-23 17:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-20 9:55 [PATCH v2] cmd: ubi: add a command to rename volume Philippe Reynes
2020-03-23 15:37 ` Simon Glass
2020-03-23 17:16 ` Philippe REYNES [this message]
2020-03-23 17:47 ` Rasmus Villemoes
2020-03-23 18:24 ` Philippe REYNES
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=712753422.1363518.1584983773442.JavaMail.zimbra@softathome.com \
--to=philippe.reynes@softathome.com \
--cc=u-boot@lists.denx.de \
/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