linux/fs/ufs
Ali Ahmet Memis 08edfb34ee
ufs: do not treat unreadable directory blocks as empty
ufs_empty_dir() scans every directory block to decide whether a
directory is empty before rmdir() removes it. When ufs_get_folio()
cannot read or validate a block it returns an error pointer, and the
loop currently skips that block with continue and keeps scanning the
remaining blocks.

If none of the readable blocks hold an entry, the function returns 1
and the caller unlinks the directory. A directory whose contents live
in a block that cannot be read, for example because of an I/O error or
corrupted directory metadata, is therefore seen as empty and removed,
losing the entries it still holds.

Follow the ext2 behaviour and treat an unreadable block as a reason to
consider the directory not empty, so rmdir() fails instead of
discarding data that could not be verified.

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Signed-off-by: Ali Ahmet Memis <ali@iusegentoo.com>
Link: https://patch.msgid.link/20260801013942.279992-1-ali@iusegentoo.com
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
2026-08-25 14:44:18 +02:00
..
balloc.c treewide: change inode->i_ino from unsigned long to u64 2026-03-06 14:31:28 +01:00
cylinder.c ufs: validate cylinder group metadata before caching it 2026-08-25 14:41:49 +02:00
dir.c ufs: do not treat unreadable directory blocks as empty 2026-08-25 14:44:18 +02:00
file.c fs: Rename generic_file_fsync() to simple_fsync() 2026-03-26 15:03:28 +01:00
ialloc.c treewide: change inode->i_ino from unsigned long to u64 2026-03-06 14:31:28 +01:00
inode.c vfs-7.1-rc1.bh.metadata 2026-04-13 12:46:42 -07:00
Kconfig fs: add CONFIG_BUFFER_HEAD 2023-08-02 09:13:09 -06:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
namei.c vfs-7.3-rc1.misc 2026-08-17 12:56:12 -07:00
super.c ufs: create the root dentry after loading cylinder metadata 2026-08-25 14:41:49 +02:00
swab.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ufs_fs.h treewide: change inode->i_ino from unsigned long to u64 2026-03-06 14:31:28 +01:00
ufs.h ufs: split ->s_mount_opt - don't mix flavour and on-error 2025-05-14 22:40:55 -04:00
util.c treewide: change inode->i_ino from unsigned long to u64 2026-03-06 14:31:28 +01:00
util.h ufs: get rid of ubh_{ubhcpymem,memcpyubh}() 2024-10-18 17:35:31 -04:00