X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lib%2Fext2fs%2Fextent.c;h=3ccae6620c1e0a7d4e26a78f11bf2b5a9a0dfca1;hb=d5fc19fc96a03bed964c7bd995202dfc88f6c4de;hp=0bf82ea4b9a88bb624b2f27eacb6c4c1da173264;hpb=156a151f3177a826f8ad7c360440abf6656f5aae;p=tools%2Fe2fsprogs.git diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c index 0bf82ea..3ccae66 100644 --- a/lib/ext2fs/extent.c +++ b/lib/ext2fs/extent.c @@ -455,6 +455,13 @@ retry: return retval; } + if (!(handle->fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) && + !ext2fs_extent_block_csum_verify(handle->fs, handle->ino, + eh)) { + handle->level--; + return EXT2_ET_EXTENT_CSUM_INVALID; + } + newpath->left = newpath->entries = ext2fs_le16_to_cpu(eh->eh_entries); newpath->max_entries = ext2fs_le16_to_cpu(eh->eh_max); @@ -541,6 +548,7 @@ static errcode_t update_path(ext2_extent_handle_t handle) blk64_t blk; errcode_t retval; struct ext3_extent_idx *ix; + struct ext3_extent_header *eh; if (handle->level == 0) { retval = ext2fs_write_inode(handle->fs, handle->ino, @@ -550,6 +558,14 @@ static errcode_t update_path(ext2_extent_handle_t handle) blk = ext2fs_le32_to_cpu(ix->ei_leaf) + ((__u64) ext2fs_le16_to_cpu(ix->ei_leaf_hi) << 32); + /* then update the checksum */ + eh = (struct ext3_extent_header *) + handle->path[handle->level].buf; + retval = ext2fs_extent_block_csum_set(handle->fs, handle->ino, + eh); + if (retval) + return retval; + retval = io_channel_write_blk64(handle->fs->io, blk, 1, handle->path[handle->level].buf); } @@ -963,6 +979,11 @@ errcode_t ext2fs_extent_node_split(ext2_extent_handle_t handle) new_node_start = ext2fs_le32_to_cpu(EXT_FIRST_INDEX(neweh)->ei_block); + /* then update the checksum */ + retval = ext2fs_extent_block_csum_set(handle->fs, handle->ino, neweh); + if (retval) + goto done; + /* ...and write the new node block out to disk. */ retval = io_channel_write_blk64(handle->fs->io, new_node_pblk, 1, block_buf);