Ext2FS: Zero out inode metadata when deleting them

This isn't strictly necessary but it seems like a reasonable thing
to be doing. Note that we still populate the dtime field with the
time of deletion.
This commit is contained in:
Andreas Kling 2020-11-07 17:42:02 +01:00
parent bab24ce34c
commit 1da828b8bf
Notes: sideshowbarker 2024-07-19 01:31:46 +09:00

View file

@ -522,11 +522,6 @@ void Ext2FS::free_inode(Ext2FSInode& inode)
dbg() << "Ext2FS: Inode " << inode.identifier() << " has no more links, time to delete!";
#endif
struct timeval now;
kgettimeofday(now);
inode.m_raw_inode.i_dtime = now.tv_sec;
write_ext2_inode(inode.index(), inode.m_raw_inode);
auto block_list = block_list_for_inode(inode.m_raw_inode, true);
for (auto block_index : block_list) {
@ -535,6 +530,12 @@ void Ext2FS::free_inode(Ext2FSInode& inode)
set_block_allocation_state(block_index, false);
}
struct timeval now;
kgettimeofday(now);
memset(&inode.m_raw_inode, 0, sizeof(ext2_inode));
inode.m_raw_inode.i_dtime = now.tv_sec;
write_ext2_inode(inode.index(), inode.m_raw_inode);
set_inode_allocation_state(inode.index(), false);
if (inode.is_directory()) {