diff options
author | Darrick J. Wong <djwong@us.ibm.com> | 2012-08-02 17:27:43 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-08-02 17:27:43 -0400 |
commit | 81683c6a32045cf04d76a024e6f1753535b97c22 (patch) | |
tree | 0b624027ad1a3c3210907c0739c29e46ad040ec7 /lib/ext2fs/dir_iterate.c | |
parent | 07307114dea005917b0c3a18a08948435f4a2abc (diff) | |
download | e2fsprogs-81683c6a32045cf04d76a024e6f1753535b97c22.tar.gz |
libext2fs: add checksums to the end of directory leaf nodes
Introduce small structures for recording directory tree checksums, and
some API changes to support writing out directory blocks with
checksums.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'lib/ext2fs/dir_iterate.c')
-rw-r--r-- | lib/ext2fs/dir_iterate.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/ext2fs/dir_iterate.c b/lib/ext2fs/dir_iterate.c index 5125d199..c24015cc 100644 --- a/lib/ext2fs/dir_iterate.c +++ b/lib/ext2fs/dir_iterate.c @@ -192,17 +192,23 @@ int ext2fs_process_dir_block(ext2_filsys fs, unsigned int rec_len, size; int entry; struct ext2_dir_entry *dirent; + int csum_size = 0; if (blockcnt < 0) return 0; entry = blockcnt ? DIRENT_OTHER_FILE : DIRENT_DOT_FILE; - ctx->errcode = ext2fs_read_dir_block3(fs, *blocknr, ctx->buf, 0); + ctx->errcode = ext2fs_read_dir_block4(fs, *blocknr, ctx->buf, 0, + ctx->dir); if (ctx->errcode) return BLOCK_ABORT; - while (offset < fs->blocksize) { + if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super, + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) + csum_size = sizeof(struct ext2_dir_entry_tail); + + while (offset < (fs->blocksize - csum_size)) { dirent = (struct ext2_dir_entry *) (ctx->buf + offset); if (ext2fs_get_rec_len(fs, dirent, &rec_len)) return BLOCK_ABORT; @@ -259,8 +265,8 @@ next: } if (changed) { - ctx->errcode = ext2fs_write_dir_block3(fs, *blocknr, ctx->buf, - 0); + ctx->errcode = ext2fs_write_dir_block4(fs, *blocknr, ctx->buf, + 0, ctx->dir); if (ctx->errcode) return BLOCK_ABORT; } |