summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/DevPtsFS.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-08-14 14:02:47 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-14 15:19:00 +0200
commitd30d776ca46b12d7f4f9b5b7bdbfb247813a94af (patch)
tree396e08592d2c733fa1414314a1a63f031bd8686e /Kernel/FileSystem/DevPtsFS.cpp
parent46b93174fce7ec46f45529f83672ccdac9dd6079 (diff)
downloadserenity-d30d776ca46b12d7f4f9b5b7bdbfb247813a94af.zip
Kernel: Make FileSystem::initialize() return KResult
This forced me to also come up with error codes for a bunch of situations where we'd previously just panic the kernel.
Diffstat (limited to 'Kernel/FileSystem/DevPtsFS.cpp')
-rw-r--r--Kernel/FileSystem/DevPtsFS.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS.cpp
index ee5c2a4b46..2290449b29 100644
--- a/Kernel/FileSystem/DevPtsFS.cpp
+++ b/Kernel/FileSystem/DevPtsFS.cpp
@@ -27,17 +27,19 @@ DevPtsFS::~DevPtsFS()
static Singleton<HashTable<unsigned>> s_ptys;
-bool DevPtsFS::initialize()
+KResult DevPtsFS::initialize()
{
- m_root_inode = adopt_ref(*new DevPtsFSInode(*this, 1, nullptr));
+ m_root_inode = adopt_ref_if_nonnull(new (nothrow) DevPtsFSInode(*this, 1, nullptr));
+ if (!m_root_inode)
+ return ENOMEM;
+
m_root_inode->m_metadata.inode = { fsid(), 1 };
m_root_inode->m_metadata.mode = 0040555;
m_root_inode->m_metadata.uid = 0;
m_root_inode->m_metadata.gid = 0;
m_root_inode->m_metadata.size = 0;
m_root_inode->m_metadata.mtime = mepoch;
-
- return true;
+ return KSuccess;
}
static unsigned inode_index_to_pty_index(InodeIndex inode_index)