mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-02-16 14:08:45 +00:00
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. Signed-off-by: Stefan Roese <sr@denx.de>
This commit is contained in:
parent
b1a14f8a1c
commit
2f15cfd187
2 changed files with 35 additions and 6 deletions
|
@ -42,6 +42,11 @@ struct selected_dev {
|
||||||
|
|
||||||
static struct selected_dev ubi_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)
|
static void ubi_dump_vol_info(const struct ubi_volume *vol)
|
||||||
{
|
{
|
||||||
ubi_msg("volume information dump:");
|
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)
|
if (argc < 3)
|
||||||
return cmd_usage(cmdtp);
|
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... */
|
/* todo: get dev number for NAND... */
|
||||||
ubi_dev.nr = 0;
|
ubi_dev.nr = 0;
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,25 @@ int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
return 0;
|
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[])
|
int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
|
@ -82,12 +101,7 @@ int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ubifs_sb)
|
cmd_ubifs_umount();
|
||||||
ubifs_umount(ubifs_sb->s_fs_info);
|
|
||||||
|
|
||||||
ubifs_sb = NULL;
|
|
||||||
ubifs_mounted = 0;
|
|
||||||
ubifs_initialized = 0;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue