[PATCH 1/4] UBI: Add ubidetach command

Sascha Hauer s.hauer at pengutronix.de
Tue Jul 23 06:27:59 EDT 2013


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/ubi.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/commands/ubi.c b/commands/ubi.c
index 7348394..854ea83 100644
--- a/commands/ubi.c
+++ b/commands/ubi.c
@@ -92,6 +92,32 @@ BAREBOX_CMD_START(ubiattach)
 	BAREBOX_CMD_HELP(cmd_ubiattach_help)
 BAREBOX_CMD_END
 
+static int do_ubidetach(int argc, char *argv[])
+{
+	int ubi_num, ret;
+
+	if (argc != 2)
+		return COMMAND_ERROR_USAGE;
+
+	ubi_num = simple_strtoul(argv[1], NULL, 0);
+	ret = ubi_detach_mtd_dev(ubi_num, 1);
+
+	if (ret)
+		printf("failed to detach: %s\n", strerror(-ret));
+
+	return ret;
+}
+
+static const __maybe_unused char cmd_ubidetach_help[] =
+"Usage: ubidetach <ubinum>\n"
+"Detach <ubinum> from ubi\n";
+
+BAREBOX_CMD_START(ubidetach)
+	.cmd		= do_ubidetach,
+	.usage		= "detach an ubi dev",
+	BAREBOX_CMD_HELP(cmd_ubidetach_help)
+BAREBOX_CMD_END
+
 static int do_ubirmvol(int argc, char *argv[])
 {
 	struct ubi_mkvol_req req;
-- 
1.8.3.2




More information about the barebox mailing list