From patchwork Thu Mar 19 19:05:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe REYNES X-Patchwork-Id: 1258388 X-Patchwork-Delegate: hs@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=softathome.com Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48jxFh3Z5Hz9sPF for ; Fri, 20 Mar 2020 06:06:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C22BD811FC; Thu, 19 Mar 2020 20:05:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id A4B04811FC; Thu, 19 Mar 2020 20:05:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from vrout30.yaziba.net (vrout30.yaziba.net [185.56.204.33]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9EF9E800DF for ; Thu, 19 Mar 2020 20:05:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=philippe.reynes@softathome.com Received: from mtaout20.int.yaziba.net (mtaout20.int.yaziba.net [10.4.20.37]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by vrout30.yaziba.net (mx10.yaziba.net) with ESMTPS id E70DF51F06; Thu, 19 Mar 2020 20:05:47 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mtaout20.int.yaziba.net (Postfix) with ESMTP id DABB61603B6; Thu, 19 Mar 2020 20:05:47 +0100 (CET) Received: from mtaout20.int.yaziba.net ([127.0.0.1]) by localhost (mtaout20.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id dHNIjZ1f3GZa; Thu, 19 Mar 2020 20:05:47 +0100 (CET) Received: from sahnlpt0333.softathome.com (lfbn-idf3-1-1227-240.w92-170.abo.wanadoo.fr [92.170.165.240]) by mtaout20.int.yaziba.net (Postfix) with ESMTPSA id 22B591602F9; Thu, 19 Mar 2020 20:05:47 +0100 (CET) From: Philippe Reynes To: sjg@chromium.org, hs@denx.de, sr@denx.de, agust@denx.de, joe.hershberger@ni.com, quentin.schulz@bootlin.com Cc: u-boot@lists.denx.de, Philippe Reynes Subject: [PATCH] cmd: ubi: add a command to rename volume Date: Thu, 19 Mar 2020 20:05:39 +0100 Message-Id: <1584644739-10258-1-git-send-email-philippe.reynes@softathome.com> X-Mailer: git-send-email 2.7.4 X-CLAMAV-SCAN: ok X-VRSPAM-SCORE: 0 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrgedugedrudefledguddvtdcutefuodetggdotefrucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofestddtredtredttdenucfhrhhomheprfhhihhlihhpphgvucftvgihnhgvshcuoehphhhilhhiphhpvgdrrhgvhihnvghssehsohhfthgrthhhohhmvgdrtghomheqnecukfhppeelvddrudejtddrudeihedrvdegtdenucfrrghrrghmpehmohguvgepshhmthhpohhuth X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean This commit add the command ubi rename to rename an ubi volume. The format of the command is: ubi rename . Signed-off-by: Philippe Reynes --- 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"