Skip to content

Commit

Permalink
ext4: avoid remove directory when directory is corrupted
Browse files Browse the repository at this point in the history
Now if check directoy entry is corrupted, ext4_empty_dir may return true
then directory will be removed when file system mounted with "errors=continue".
In order not to make things worse just return false when directory is corrupted.

Signed-off-by: Ye Bin <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Theodore Ts'o <[email protected]>
  • Loading branch information
Ye Bin authored and tytso committed Aug 3, 2022
1 parent c64a929 commit b24e77e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions fs/ext4/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -3067,11 +3067,8 @@ bool ext4_empty_dir(struct inode *inode)
de = (struct ext4_dir_entry_2 *) (bh->b_data +
(offset & (sb->s_blocksize - 1)));
if (ext4_check_dir_entry(inode, NULL, de, bh,
bh->b_data, bh->b_size, offset)) {
offset = (offset | (sb->s_blocksize - 1)) + 1;
continue;
}
if (le32_to_cpu(de->inode)) {
bh->b_data, bh->b_size, offset) ||
le32_to_cpu(de->inode)) {
brelse(bh);
return false;
}
Expand Down

0 comments on commit b24e77e

Please sign in to comment.