All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 4/4] UBI/UBIFS: Prevent UBI partition change while UBIFS is mounted
@ 2010-10-28 12:09 Stefan Roese
  2010-10-29 14:01 ` Ben Gardiner
  2010-10-29 21:06 ` Wolfgang Denk
  0 siblings, 2 replies; 9+ messages in thread
From: Stefan Roese @ 2010-10-28 12:09 UTC (permalink / raw)
  To: u-boot

Only allow (re-)assignment to an UBI partition/device when UBIFS is
currently not mounted. Otherwise the following UBIFS commands will
crash.

Signed-off-by: Stefan Roese <sr@denx.de>
---
 common/cmd_ubi.c   |   13 +++++++++++++
 common/cmd_ubifs.c |    5 +++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c
index 7692ac7..1e73f48 100644
--- a/common/cmd_ubi.c
+++ b/common/cmd_ubi.c
@@ -42,6 +42,8 @@ struct selected_dev {
 
 static struct selected_dev ubi_dev;
 
+int ubifs_is_mounted(void);
+
 static void ubi_dump_vol_info(const struct ubi_volume *vol)
 {
 	ubi_msg("volume information dump:");
@@ -472,6 +474,17 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 		if (argc < 3)
 			return cmd_usage(cmdtp);
 
+		/*
+		 * Only allow (re-)assignment to an UBI partition/device
+		 * when UBIFS is currently not mounted. Otherwise
+		 * the following UBIFS commands will crash.
+		 */
+		if (ubifs_is_mounted()) {
+			printf("UBIFS is currently mounted!"
+			       " Unmount using ubifsumount first!\n");
+			return -EPERM;
+		}
+
 		/* todo: get dev number for NAND... */
 		ubi_dev.nr = 0;
 
diff --git a/common/cmd_ubifs.c b/common/cmd_ubifs.c
index 9526780..76fe057 100644
--- a/common/cmd_ubifs.c
+++ b/common/cmd_ubifs.c
@@ -92,6 +92,11 @@ int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	return 0;
 }
 
+int ubifs_is_mounted(void)
+{
+	return ubifs_mounted;
+}
+
 int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	char *filename = "/";
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-11-14 21:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-28 12:09 [U-Boot] [PATCH 4/4] UBI/UBIFS: Prevent UBI partition change while UBIFS is mounted Stefan Roese
2010-10-29 14:01 ` Ben Gardiner
2010-10-29 21:06 ` Wolfgang Denk
2010-11-01 13:20   ` Stefan Roese
2010-11-01 19:06     ` Wolfgang Denk
2010-11-02  0:31       ` Gray Remlin
2010-11-02 10:49       ` Stefan Roese
2010-11-02 14:33         ` Ben Gardiner
2010-11-14 21:06         ` Wolfgang Denk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.