summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Brüns <stefan.bruens@rwth-aachen.de>2016-09-06 05:36:53 +0300
committerDongjin Kim <tobetter@gmail.com>2020-02-10 16:44:41 +0300
commit06dbd7089b214069396143d408391313ad514aa2 (patch)
treee19fcce94d84d3ae2799061b5670ff10f6c9076e
parenta147552e2552ff6e7719f178396e7a20b63728e2 (diff)
downloadu-boot-06dbd7089b214069396143d408391313ad514aa2.tar.xz
ext4: initialize full inode for inodes bigger than 128 bytes
Make sure the the extra_isize field (offset 128) is initialized to 0, to mark any extra data as invalid. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
-rw-r--r--fs/ext4/ext4_write.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index 92919412cb..4cd241eaef 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -563,7 +563,7 @@ static int ext4fs_delete_file(int inodeno)
read_buffer = read_buffer + blkoff;
inode_buffer = (struct ext2_inode *)read_buffer;
- memset(inode_buffer, '\0', sizeof(struct ext2_inode));
+ memset(inode_buffer, '\0', fs->inodesz);
/* write the inode to original position in inode table */
if (ext4fs_put_metadata(start_block_address, blkno))
@@ -889,7 +889,7 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
ALLOC_CACHE_ALIGN_BUFFER(char, filename, 256);
memset(filename, 0x00, 256);
- g_parent_inode = zalloc(sizeof(struct ext2_inode));
+ g_parent_inode = zalloc(fs->inodesz);
if (!g_parent_inode)
goto fail;
@@ -992,8 +992,7 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
if (ext4fs_log_journal(temp_ptr, parent_itable_blkno))
goto fail;
- memcpy(temp_ptr + blkoff, g_parent_inode,
- sizeof(struct ext2_inode));
+ memcpy(temp_ptr + blkoff, g_parent_inode, fs->inodesz);
if (ext4fs_put_metadata(temp_ptr, parent_itable_blkno))
goto fail;
} else {
@@ -1001,8 +1000,7 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
* If parent and child fall in same inode table block
* both should be kept in 1 buffer
*/
- memcpy(temp_ptr + blkoff, g_parent_inode,
- sizeof(struct ext2_inode));
+ memcpy(temp_ptr + blkoff, g_parent_inode, fs->inodesz);
gd_index--;
if (ext4fs_put_metadata(temp_ptr, itable_blkno))
goto fail;