summaryrefslogtreecommitdiff
path: root/common/cmd_ubi.c
diff options
context:
space:
mode:
authorStefan Roese <sr@denx.de>2010-11-01 17:28:22 +0100
committerStefan Roese <sr@denx.de>2010-12-03 18:24:04 +0100
commit2f15cfd187f1cf7a0606a1ec3e637954311a735a (patch)
treeb60cf597e60ddd1e01035a137c01a442807a13c3 /common/cmd_ubi.c
parentb1a14f8a1c2e72d5c58269d0200f722d8eec19c4 (diff)
downloadu-boot-imx-2f15cfd187f1cf7a0606a1ec3e637954311a735a.zip
u-boot-imx-2f15cfd187f1cf7a0606a1ec3e637954311a735a.tar.gz
u-boot-imx-2f15cfd187f1cf7a0606a1ec3e637954311a735a.tar.bz2
UBI/UBIFS: Automatically unmount UBIFS volume upon UBI partition change
Automatically unmount UBIFS partition when user changes the UBI device. Otherwise the following UBIFS commands will crash. Signed-off-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'common/cmd_ubi.c')
-rw-r--r--common/cmd_ubi.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c
index 7692ac7..b486ca8 100644
--- a/common/cmd_ubi.c
+++ b/common/cmd_ubi.c
@@ -42,6 +42,11 @@ struct selected_dev {
static struct selected_dev ubi_dev;
+#ifdef CONFIG_CMD_UBIFS
+int ubifs_is_mounted(void);
+void cmd_ubifs_umount(void);
+#endif
+
static void ubi_dump_vol_info(const struct ubi_volume *vol)
{
ubi_msg("volume information dump:");
@@ -472,6 +477,16 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
if (argc < 3)
return cmd_usage(cmdtp);
+#ifdef CONFIG_CMD_UBIFS
+ /*
+ * Automatically unmount UBIFS partition when user
+ * changes the UBI device. Otherwise the following
+ * UBIFS commands will crash.
+ */
+ if (ubifs_is_mounted())
+ cmd_ubifs_umount();
+#endif
+
/* todo: get dev number for NAND... */
ubi_dev.nr = 0;