summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-11-07 17:42:02 +0100
committerAndreas Kling <kling@serenityos.org>2020-11-07 17:48:22 +0100
commit1da828b8bf9cb49a274e5a2fc76fdc843d19396f (patch)
tree7502b4844fd2c52a88dab49238b7936393b5401a
parentbab24ce34c6d48b478026ade3ee759ba4830744f (diff)
downloadserenity-1da828b8bf9cb49a274e5a2fc76fdc843d19396f.zip
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.
-rw-r--r--Kernel/FileSystem/Ext2FileSystem.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp
index d991924b95..10750282f5 100644
--- a/Kernel/FileSystem/Ext2FileSystem.cpp
+++ b/Kernel/FileSystem/Ext2FileSystem.cpp
@@ -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()) {