* [U-Boot] [PATCH v2] UBI/UBIFS: Automatically unmount UBIFS volume upon UBI partition change
@ 2010-12-03 17:23 Stefan Roese
2010-12-04 10:00 ` Stefan Roese
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Roese @ 2010-12-03 17:23 UTC (permalink / raw)
To: u-boot
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>
---
v2:
- Only try to unmount the ubifs partition if UBIFS is is really enabled.
Otherwise compiling fails.
common/cmd_ubi.c | 15 +++++++++++++++
common/cmd_ubifs.c | 26 ++++++++++++++++++++------
2 files changed, 35 insertions(+), 6 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;
diff --git a/common/cmd_ubifs.c b/common/cmd_ubifs.c
index 9526780..3cd2d8f 100644
--- a/common/cmd_ubifs.c
+++ b/common/cmd_ubifs.c
@@ -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;
}
--
1.7.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH v2] UBI/UBIFS: Automatically unmount UBIFS volume upon UBI partition change
2010-12-03 17:23 [U-Boot] [PATCH v2] UBI/UBIFS: Automatically unmount UBIFS volume upon UBI partition change Stefan Roese
@ 2010-12-04 10:00 ` Stefan Roese
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Roese @ 2010-12-04 10:00 UTC (permalink / raw)
To: u-boot
On Friday 03 December 2010 18:23:23 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 (instead of the 1st patch version).
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-12-04 10:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-03 17:23 [U-Boot] [PATCH v2] UBI/UBIFS: Automatically unmount UBIFS volume upon UBI partition change Stefan Roese
2010-12-04 10:00 ` Stefan Roese
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox