]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
UBIFS: Add ubifsumount command to unmount an active volume
authorStefan Roese <sr@denx.de>
Thu, 28 Oct 2010 12:09:22 +0000 (14:09 +0200)
committerStefan Roese <sr@denx.de>
Fri, 3 Dec 2010 15:32:09 +0000 (16:32 +0100)
This new ubifsumount command allows the user to unmount a previously
mounted UBIFS volume.

Signed-off-by: Stefan Roese <sr@denx.de>
common/cmd_ubifs.c
fs/ubifs/super.c

index a0ec184486dc08a330e063a97b55990fab69f7ae..30b23d31008d4d7a9ab10c09447a0d3c56b2f47b 100644 (file)
 #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,6 +72,26 @@ int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        return 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;
+       }
+
+       if (ubifs_sb)
+               ubifs_umount(ubifs_sb->s_fs_info);
+
+       ubifs_sb = NULL;
+       ubifs_mounted = 0;
+       ubifs_initialized = 0;
+
+       return 0;
+}
+
 int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        char *filename = "/";
@@ -131,6 +156,12 @@ U_BOOT_CMD(
        "    - mount 'volume-name' volume"
 );
 
+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",
index 39e3efec802d6929ac914ec88d10afa720e74d47..63b2164d30484072a1ff010ea046acf38d9d020f 100644 (file)
@@ -824,7 +824,7 @@ out_free:
  * through mounting (error path cleanup function). So it has to make sure the
  * resource was actually allocated before freeing it.
  */
-static void ubifs_umount(struct ubifs_info *c)
+void ubifs_umount(struct ubifs_info *c)
 {
        dbg_gen("un-mounting UBI device %d, volume %d", c->vi.ubi_num,
                c->vi.vol_id);