fsck.f2fs: fix dirent position check for encrypted+casefolded dentries

fsck.f2fs reports corruption if the filesystem contains any encrypted +
casefolded directories with any substantial number of dentries:

    [ASSERT] (f2fs_check_dirent_position:1374)  --> Wrong position of dirent pino:8, name:۟�[I�^*�(�5~�}�D��#]7�8�ˎ�, level:1, dir_level:0, pgofs:4, correct range:[2, 3]

The problem is that f2fs_check_dirent_position() computes the wrong hash
for encrypted+casefolded dentries.  It's not actually possible for it to
compute the correct hash, because it would need the encryption key.

However, the on-disk dentry already contains the hash code, and its
correctness was already verified by f2fs_check_hash_code() if possible.

So, make f2fs_check_dirent_position() use the hash code from disk rather
than recompute it.

Also fix it to print the filename in human-readable form.

This bug was causing 'kvm-xfstests -c f2fs/encrypt -g casefold'
to fail with the test_dummy_encryption_v2 and encryption+casefolding
kernel patches applied.

Fixes: 7f3767ee8dc5 ("f2fs-tools: Casefolded Encryption support")
Cc: Daniel Rosenberg <drosen@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 file changed