Skip to contentSkip to conversation

UBI/UBIFS: Automatically unmount UBIFS volume upon UBI partition change

PATCH Superseded Stefan Roese 1 participant 2 messages Nov 1, 2010 – Dec 3, 2010

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 4/4 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.

---
This patch replaces the patch [UBI/UBIFS: Prevent UBI partition change while UBIFS is mounted].

 common/cmd_ubi.c   |   11 +++++++++++
 common/cmd_ubifs.c |   26 ++++++++++++++++++++------
 2 files changed, 31 insertions(+), 6 deletions(-)
common/cmd_ubi.c +11 -0
index 7692ac7..0ec87e2 100644
@@ -42,6 +42,9 @@ struct selected_dev {
 
 static struct selected_dev ubi_dev;
 
+int ubifs_is_mounted(void);
+void cmd_ubifs_umount(void);
+
 static void ubi_dump_vol_info(const struct ubi_volume *vol)
 {
 	ubi_msg("volume information dump:");
@@ -472,6 +475,14 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 		if (argc < 3)
 			return cmd_usage(cmdtp);
 
+		/*
+		 * Automatically unmount UBIFS partition when user
+		 * changes the UBI device. Otherwise the following
+		 * UBIFS commands will crash.
+		 */
+		if (ubifs_is_mounted())
+			cmd_ubifs_umount();
+
 		/* todo: get dev number for NAND... */
 		ubi_dev.nr = 0;
 
common/cmd_ubifs.c +20 -6
index 9526780..3cd2d8f 100644
@@ -72,6 +72,25 @@ int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
+int ubifs_is_mounted(void)
+{
+	return ubifs_mounted;
+}
+
+void cmd_ubifs_umount(void)
+{
+
+	if (ubifs_sb) {
+		printf("Unmounting UBIFS volume %s!\n",
+		       ((struct ubifs_info *)(ubifs_sb->s_fs_info))->vi.name);
+		ubifs_umount(ubifs_sb->s_fs_info);
+	}
+
+	ubifs_sb = NULL;
+	ubifs_mounted = 0;
+	ubifs_initialized = 0;
+}
+
 int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	if (argc != 1)
@@ -82,12 +101,7 @@ int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		return -1;
 	}
 
-	if (ubifs_sb)
-		ubifs_umount(ubifs_sb->s_fs_info);
-
-	ubifs_sb = NULL;
-	ubifs_mounted = 0;
-	ubifs_initialized = 0;
+	cmd_ubifs_umount();
 
 	return 0;
 }
Signature · 1 line
1.7.3.2
#1 lore raw

PATCH 4/4 UBI/UBIFS: Automatically unmount UBIFS volume upon UBI partition change

Quoted 2 lines · On Monday 01 November 2010 17:28:22 Stefan Roese wrote:

Automatically unmount UBIFS partition when user changes the UBI device. Otherwise the following UBIFS commands will crash.

Applied to u-boot-ubi/master. Thanks.

Cheers,
Stefan

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de