diff options
author | Ćukasz Majewski <l.majewski@samsung.com> | 2014-05-06 09:36:05 +0200 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2014-05-12 16:31:50 -0400 |
commit | 8b454eeeea0ba021ee27f3e103daf1f8fa87bd16 (patch) | |
tree | 7aea0d65b3a11b11181e700b1a4053189209a819 /include/ext4fs.h | |
parent | 35dd055b94eb3ed8c21595eedd740431866b2f26 (diff) | |
download | u-boot-imx-8b454eeeea0ba021ee27f3e103daf1f8fa87bd16.zip u-boot-imx-8b454eeeea0ba021ee27f3e103daf1f8fa87bd16.tar.gz u-boot-imx-8b454eeeea0ba021ee27f3e103daf1f8fa87bd16.tar.bz2 |
fs:ext4:write:fix: Reinitialize global variables after updating a file
This bug shows up when file stored on the ext4 file system is updated.
The ext4fs_delete_file() is responsible for deleting file's (e.g. uImage)
data.
However some global data (especially ext4fs_indir2_block), which is used
during file deletion are left unchanged.
The ext4fs_indir2_block pointer stores reference to old ext4 double
indirect allocated blocks. When it is unchanged, after file deletion,
ext4fs_write_file() uses the same pointer (since it is already initialized
- i.e. not NULL) to return number of blocks to write. This trunks larger
file when previous one was smaller.
Lets consider following scenario:
1. Flash target with ext4 formatted boot.img (which has uImage [*] on itself)
2. Developer wants to upload their custom uImage [**]
- When new uImage [**] is smaller than the [*] - everything works
correctly - we are able to store the whole smaller file with corrupted
ext4fs_indir2_block pointer
- When new uImage [**] is larger than the [*] - theCRC is corrupted,
since truncation on data stored at eMMC was done.
3. When uImage CRC error appears, then reboot and LTHOR/DFU reflashing causes
proper setting of ext4fs_indir2_block() and after that uImage[**]
is successfully stored (correct uImage [*] metadata is stored at an
eMMC on the first flashing).
Due to above the bug was very difficult to reproduce.
This patch sets default values for all ext4fs_indir* pointers/variables.
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Diffstat (limited to 'include/ext4fs.h')
-rw-r--r-- | include/ext4fs.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/ext4fs.h b/include/ext4fs.h index aacb147..fbbb002 100644 --- a/include/ext4fs.h +++ b/include/ext4fs.h @@ -133,6 +133,7 @@ int ext4fs_open(const char *filename); int ext4fs_read(char *buf, unsigned len); int ext4fs_mount(unsigned part_length); void ext4fs_close(void); +void ext4fs_reinit_global(void); int ext4fs_ls(const char *dirname); int ext4fs_exists(const char *filename); void ext4fs_free_node(struct ext2fs_node *node, struct ext2fs_node *currroot); |