summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r--Kernel/FileSystem/DevPtsFS/FileSystem.cpp67
-rw-r--r--Kernel/FileSystem/DevPtsFS/FileSystem.h37
-rw-r--r--Kernel/FileSystem/DevPtsFS/Inode.cpp (renamed from Kernel/FileSystem/DevPtsFS.cpp)56
-rw-r--r--Kernel/FileSystem/DevPtsFS/Inode.h (renamed from Kernel/FileSystem/DevPtsFS.h)25
4 files changed, 107 insertions, 78 deletions
diff --git a/Kernel/FileSystem/DevPtsFS/FileSystem.cpp b/Kernel/FileSystem/DevPtsFS/FileSystem.cpp
new file mode 100644
index 0000000000..1cc4da8018
--- /dev/null
+++ b/Kernel/FileSystem/DevPtsFS/FileSystem.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
+ * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <Kernel/Devices/DeviceManagement.h>
+#include <Kernel/FileSystem/DevPtsFS/FileSystem.h>
+#include <Kernel/FileSystem/DevPtsFS/Inode.h>
+#include <Kernel/TTY/SlavePTY.h>
+
+namespace Kernel {
+
+ErrorOr<NonnullLockRefPtr<FileSystem>> DevPtsFS::try_create()
+{
+ return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevPtsFS));
+}
+
+DevPtsFS::DevPtsFS() = default;
+DevPtsFS::~DevPtsFS() = default;
+
+ErrorOr<void> DevPtsFS::initialize()
+{
+ m_root_inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevPtsFSInode(*this, 1, nullptr)));
+ 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 = TimeManagement::boot_time();
+ return {};
+}
+
+static unsigned inode_index_to_pty_index(InodeIndex inode_index)
+{
+ VERIFY(inode_index > 1);
+ return inode_index.value() - 2;
+}
+
+Inode& DevPtsFS::root_inode()
+{
+ return *m_root_inode;
+}
+
+ErrorOr<NonnullLockRefPtr<Inode>> DevPtsFS::get_inode(InodeIdentifier inode_id) const
+{
+ if (inode_id.index() == 1)
+ return *m_root_inode;
+
+ unsigned pty_index = inode_index_to_pty_index(inode_id.index());
+ auto* device = DeviceManagement::the().get_device(201, pty_index);
+ VERIFY(device);
+
+ auto inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevPtsFSInode(const_cast<DevPtsFS&>(*this), inode_id.index(), static_cast<SlavePTY*>(device))));
+ inode->m_metadata.inode = inode_id;
+ inode->m_metadata.size = 0;
+ inode->m_metadata.uid = device->uid();
+ inode->m_metadata.gid = device->gid();
+ inode->m_metadata.mode = 0020600;
+ inode->m_metadata.major_device = device->major();
+ inode->m_metadata.minor_device = device->minor();
+ inode->m_metadata.mtime = TimeManagement::boot_time();
+ return inode;
+}
+
+}
diff --git a/Kernel/FileSystem/DevPtsFS/FileSystem.h b/Kernel/FileSystem/DevPtsFS/FileSystem.h
new file mode 100644
index 0000000000..801347387d
--- /dev/null
+++ b/Kernel/FileSystem/DevPtsFS/FileSystem.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/Types.h>
+#include <Kernel/FileSystem/FileSystem.h>
+#include <Kernel/FileSystem/Inode.h>
+
+namespace Kernel {
+
+class SlavePTY;
+class DevPtsFSInode;
+
+class DevPtsFS final : public FileSystem {
+ friend class DevPtsFSInode;
+
+public:
+ virtual ~DevPtsFS() override;
+ static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create();
+
+ virtual ErrorOr<void> initialize() override;
+ virtual StringView class_name() const override { return "DevPtsFS"sv; }
+
+ virtual Inode& root_inode() override;
+
+private:
+ DevPtsFS();
+ ErrorOr<NonnullLockRefPtr<Inode>> get_inode(InodeIdentifier) const;
+
+ LockRefPtr<DevPtsFSInode> m_root_inode;
+};
+
+}
diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS/Inode.cpp
index 1643cddadc..116a9f3db6 100644
--- a/Kernel/FileSystem/DevPtsFS.cpp
+++ b/Kernel/FileSystem/DevPtsFS/Inode.cpp
@@ -6,69 +6,15 @@
*/
#include <Kernel/Devices/DeviceManagement.h>
-#include <Kernel/FileSystem/DevPtsFS.h>
-#include <Kernel/FileSystem/VirtualFileSystem.h>
-#include <Kernel/TTY/SlavePTY.h>
+#include <Kernel/FileSystem/DevPtsFS/Inode.h>
namespace Kernel {
-ErrorOr<NonnullLockRefPtr<FileSystem>> DevPtsFS::try_create()
-{
- return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevPtsFS));
-}
-
-DevPtsFS::DevPtsFS() = default;
-DevPtsFS::~DevPtsFS() = default;
-
-ErrorOr<void> DevPtsFS::initialize()
-{
- m_root_inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevPtsFSInode(*this, 1, nullptr)));
- 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 = TimeManagement::boot_time();
- return {};
-}
-
-static unsigned inode_index_to_pty_index(InodeIndex inode_index)
-{
- VERIFY(inode_index > 1);
- return inode_index.value() - 2;
-}
-
static InodeIndex pty_index_to_inode_index(unsigned pty_index)
{
return pty_index + 2;
}
-Inode& DevPtsFS::root_inode()
-{
- return *m_root_inode;
-}
-
-ErrorOr<NonnullLockRefPtr<Inode>> DevPtsFS::get_inode(InodeIdentifier inode_id) const
-{
- if (inode_id.index() == 1)
- return *m_root_inode;
-
- unsigned pty_index = inode_index_to_pty_index(inode_id.index());
- auto* device = DeviceManagement::the().get_device(201, pty_index);
- VERIFY(device);
-
- auto inode = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) DevPtsFSInode(const_cast<DevPtsFS&>(*this), inode_id.index(), static_cast<SlavePTY*>(device))));
- inode->m_metadata.inode = inode_id;
- inode->m_metadata.size = 0;
- inode->m_metadata.uid = device->uid();
- inode->m_metadata.gid = device->gid();
- inode->m_metadata.mode = 0020600;
- inode->m_metadata.major_device = device->major();
- inode->m_metadata.minor_device = device->minor();
- inode->m_metadata.mtime = TimeManagement::boot_time();
- return inode;
-}
-
DevPtsFSInode::DevPtsFSInode(DevPtsFS& fs, InodeIndex index, SlavePTY* pty)
: Inode(fs, index)
{
diff --git a/Kernel/FileSystem/DevPtsFS.h b/Kernel/FileSystem/DevPtsFS/Inode.h
index 9b3951820b..4d67ec6ba2 100644
--- a/Kernel/FileSystem/DevPtsFS.h
+++ b/Kernel/FileSystem/DevPtsFS/Inode.h
@@ -7,33 +7,12 @@
#pragma once
#include <AK/Types.h>
-#include <Kernel/FileSystem/FileSystem.h>
+#include <Kernel/FileSystem/DevPtsFS/FileSystem.h>
#include <Kernel/FileSystem/Inode.h>
+#include <Kernel/TTY/SlavePTY.h>
namespace Kernel {
-class SlavePTY;
-class DevPtsFSInode;
-
-class DevPtsFS final : public FileSystem {
- friend class DevPtsFSInode;
-
-public:
- virtual ~DevPtsFS() override;
- static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create();
-
- virtual ErrorOr<void> initialize() override;
- virtual StringView class_name() const override { return "DevPtsFS"sv; }
-
- virtual Inode& root_inode() override;
-
-private:
- DevPtsFS();
- ErrorOr<NonnullLockRefPtr<Inode>> get_inode(InodeIdentifier) const;
-
- LockRefPtr<DevPtsFSInode> m_root_inode;
-};
-
class DevPtsFSInode final : public Inode {
friend class DevPtsFS;