summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/DevPtsFS.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-01 09:23:46 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-01 10:56:17 +0100
commitc44b4d61f350703fcf1bbd8f6e353b9c6c4210c2 (patch)
tree0606651fd0fce5148286f20f7c67a00b7d1383cf /Kernel/FileSystem/DevPtsFS.cpp
parent5aa37f6f5c9026346e8dbc7db26cf73516a7a876 (diff)
downloadserenity-c44b4d61f350703fcf1bbd8f6e353b9c6c4210c2.zip
Kernel: Make Inode::lookup() return a RefPtr<Inode>
Previously this API would return an InodeIdentifier, which meant that there was a race in path resolution where an inode could be unlinked in between finding the InodeIdentifier for a path component, and actually resolving that to an Inode object. Attaching a test that would quickly trip an assertion before. Test: Kernel/path-resolution-race.cpp
Diffstat (limited to 'Kernel/FileSystem/DevPtsFS.cpp')
-rw-r--r--Kernel/FileSystem/DevPtsFS.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS.cpp
index bec4c302d9..d7d618d77e 100644
--- a/Kernel/FileSystem/DevPtsFS.cpp
+++ b/Kernel/FileSystem/DevPtsFS.cpp
@@ -169,17 +169,17 @@ size_t DevPtsFSInode::directory_entry_count() const
return 2 + ptys->size();
}
-InodeIdentifier DevPtsFSInode::lookup(StringView name)
+RefPtr<Inode> DevPtsFSInode::lookup(StringView name)
{
ASSERT(identifier().index() == 1);
if (name == "." || name == "..")
- return identifier();
+ return fs().get_inode(identifier());
bool ok;
unsigned pty_index = name.to_uint(ok);
if (ok && ptys->contains(pty_index)) {
- return { fsid(), pty_index_to_inode_index(pty_index) };
+ return fs().get_inode({ fsid(), pty_index_to_inode_index(pty_index) });
}
return {};