aboutsummaryrefslogtreecommitdiff
path: root/lib/ext2fs/dir_iterate.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2012-10-14 06:34:09 -0400
committerTheodore Ts'o <tytso@mit.edu>2012-10-14 06:35:26 -0400
commit41bf599391faaf6523c9997eb467a86888542339 (patch)
tree9cb6a02261717bd0cec20a3e2df83a9f9819f611 /lib/ext2fs/dir_iterate.c
parent24980deeafda25e3a415a1acd20dc39c04b149c6 (diff)
downloade2fsprogs-41bf599391faaf6523c9997eb467a86888542339.tar.gz
debugfs: teach the htree and ls commands to show directory checksums
In addition, make the directory interator more robust in the case where the file system has the metadata checksum feature enabled, but the directory checksum is not present in a directory block. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib/ext2fs/dir_iterate.c')
-rw-r--r--lib/ext2fs/dir_iterate.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/ext2fs/dir_iterate.c b/lib/ext2fs/dir_iterate.c
index c24015cc..1a4bf5cf 100644
--- a/lib/ext2fs/dir_iterate.c
+++ b/lib/ext2fs/dir_iterate.c
@@ -208,7 +208,7 @@ int ext2fs_process_dir_block(ext2_filsys fs,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
csum_size = sizeof(struct ext2_dir_entry_tail);
- while (offset < (fs->blocksize - csum_size)) {
+ while (offset < fs->blocksize) {
dirent = (struct ext2_dir_entry *) (ctx->buf + offset);
if (ext2fs_get_rec_len(fs, dirent, &rec_len))
return BLOCK_ABORT;
@@ -219,9 +219,16 @@ int ext2fs_process_dir_block(ext2_filsys fs,
ctx->errcode = EXT2_ET_DIR_CORRUPTED;
return BLOCK_ABORT;
}
- if (!dirent->inode &&
- !(ctx->flags & DIRENT_FLAG_INCLUDE_EMPTY))
- goto next;
+ if (!dirent->inode) {
+ if ((offset == fs->blocksize - csum_size) &&
+ (dirent->rec_len == csum_size) &&
+ (dirent->name_len == EXT2_DIR_NAME_LEN_CSUM)) {
+ if (!(ctx->flags & DIRENT_FLAG_INCLUDE_CSUM))
+ goto next;
+ entry = DIRENT_CHECKSUM;
+ } else if (!(ctx->flags & DIRENT_FLAG_INCLUDE_EMPTY))
+ goto next;
+ }
ret = (ctx->func)(ctx->dir,
(next_real_entry > offset) ?