summaryrefslogtreecommitdiff
path: root/common/cmd_ubifs.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/cmd_ubifs.c')
-rw-r--r--common/cmd_ubifs.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/common/cmd_ubifs.c b/common/cmd_ubifs.c
index a0ec184..3cd2d8f 100644
--- a/common/cmd_ubifs.c
+++ b/common/cmd_ubifs.c
@@ -33,12 +33,17 @@
#include <config.h>
#include <command.h>
+#include "../fs/ubifs/ubifs.h"
+
static int ubifs_initialized;
static int ubifs_mounted;
+extern struct super_block *ubifs_sb;
+
/* Prototypes */
int ubifs_init(void);
int ubifs_mount(char *vol_name);
+void ubifs_umount(struct ubifs_info *c);
int ubifs_ls(char *dir_name);
int ubifs_load(char *filename, u32 addr, u32 size);
@@ -67,13 +72,47 @@ 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)
+ return cmd_usage(cmdtp);
+
+ if (ubifs_initialized == 0) {
+ printf("No UBIFS volume mounted!\n");
+ return -1;
+ }
+
+ cmd_ubifs_umount();
+
+ return 0;
+}
+
int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
char *filename = "/";
int ret;
if (!ubifs_mounted) {
- printf("UBIFS not mounted, use ubifs mount to mount volume first!\n");
+ printf("UBIFS not mounted, use ubifsmount to mount volume first!\n");
return -1;
}
@@ -132,6 +171,12 @@ U_BOOT_CMD(
);
U_BOOT_CMD(
+ ubifsumount, 1, 0, do_ubifs_umount,
+ "unmount UBIFS volume",
+ " - unmount current volume"
+);
+
+U_BOOT_CMD(
ubifsls, 2, 0, do_ubifs_ls,
"list files in a directory",
"[directory]\n"