mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 05:55:13 +00:00
Ext2FS: Fix inode link leak on all new inodes
The initial inode link count was wrong in Ext2FS, as the act of adding
new inodes to their new parent bumps the count.
This regressed in df66c28479
.
This commit is contained in:
parent
0f6de0c45a
commit
607e085823
Notes:
sideshowbarker
2024-07-19 03:25:13 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/607e0858232
1 changed files with 3 additions and 7 deletions
|
@ -1428,12 +1428,6 @@ KResultOr<NonnullRefPtr<Inode>> Ext2FS::create_inode(InodeIdentifier parent_id,
|
||||||
bool success = set_inode_allocation_state(inode_id, true);
|
bool success = set_inode_allocation_state(inode_id, true);
|
||||||
ASSERT(success);
|
ASSERT(success);
|
||||||
|
|
||||||
unsigned initial_links_count;
|
|
||||||
if (is_directory(mode))
|
|
||||||
initial_links_count = 2; // (parent directory + "." entry in self)
|
|
||||||
else
|
|
||||||
initial_links_count = 1;
|
|
||||||
|
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
kgettimeofday(now);
|
kgettimeofday(now);
|
||||||
ext2_inode e2inode;
|
ext2_inode e2inode;
|
||||||
|
@ -1446,7 +1440,9 @@ KResultOr<NonnullRefPtr<Inode>> Ext2FS::create_inode(InodeIdentifier parent_id,
|
||||||
e2inode.i_ctime = now.tv_sec;
|
e2inode.i_ctime = now.tv_sec;
|
||||||
e2inode.i_mtime = now.tv_sec;
|
e2inode.i_mtime = now.tv_sec;
|
||||||
e2inode.i_dtime = 0;
|
e2inode.i_dtime = 0;
|
||||||
e2inode.i_links_count = initial_links_count;
|
|
||||||
|
// For directories, add +1 link count for the "." entry in self.
|
||||||
|
e2inode.i_links_count = is_directory(mode);
|
||||||
|
|
||||||
if (is_character_device(mode))
|
if (is_character_device(mode))
|
||||||
e2inode.i_block[0] = dev;
|
e2inode.i_block[0] = dev;
|
||||||
|
|
Loading…
Add table
Reference in a new issue