summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2022-10-23 22:01:40 +0300
committerAndrew Kaster <andrewdkaster@gmail.com>2022-11-08 02:54:48 -0700
commit5e6101dd3ef17e07a9bceb13f355e1e496f62d4f (patch)
tree9843feacd2290fd3c18d7cf02a1ffe2fc1baaf69 /Kernel
parentf53149d5f61422bad5507661af2ff3374bc0f9c8 (diff)
downloadserenity-5e6101dd3ef17e07a9bceb13f355e1e496f62d4f.zip
Kernel: Split the TmpFS core files into smaller components
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/CMakeLists.txt3
-rw-r--r--Kernel/FileSystem/TmpFS/FileSystem.cpp40
-rw-r--r--Kernel/FileSystem/TmpFS/FileSystem.h39
-rw-r--r--Kernel/FileSystem/TmpFS/Inode.cpp (renamed from Kernel/FileSystem/TmpFS.cpp)30
-rw-r--r--Kernel/FileSystem/TmpFS/Inode.h (renamed from Kernel/FileSystem/TmpFS.h)29
-rw-r--r--Kernel/Forward.h1
-rw-r--r--Kernel/Syscalls/mount.cpp2
7 files changed, 85 insertions, 59 deletions
diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt
index cf54143dc1..c44af9b2bb 100644
--- a/Kernel/CMakeLists.txt
+++ b/Kernel/CMakeLists.txt
@@ -183,7 +183,8 @@ set(KERNEL_SOURCES
FileSystem/SysFS/Subsystems/Kernel/Variables/Directory.cpp
FileSystem/SysFS/Subsystems/Kernel/Variables/DumpKmallocStack.cpp
FileSystem/SysFS/Subsystems/Kernel/Variables/UBSANDeadly.cpp
- FileSystem/TmpFS.cpp
+ FileSystem/TmpFS/FileSystem.cpp
+ FileSystem/TmpFS/Inode.cpp
FileSystem/VirtualFileSystem.cpp
Firmware/BIOS.cpp
Firmware/ACPI/Initialize.cpp
diff --git a/Kernel/FileSystem/TmpFS/FileSystem.cpp b/Kernel/FileSystem/TmpFS/FileSystem.cpp
new file mode 100644
index 0000000000..26926ef0c3
--- /dev/null
+++ b/Kernel/FileSystem/TmpFS/FileSystem.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
+ * Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <Kernel/FileSystem/TmpFS/FileSystem.h>
+#include <Kernel/FileSystem/TmpFS/Inode.h>
+
+namespace Kernel {
+
+ErrorOr<NonnullLockRefPtr<FileSystem>> TmpFS::try_create()
+{
+ return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) TmpFS));
+}
+
+TmpFS::TmpFS() = default;
+TmpFS::~TmpFS() = default;
+
+ErrorOr<void> TmpFS::initialize()
+{
+ m_root_inode = TRY(TmpFSInode::try_create_root(*this));
+ return {};
+}
+
+Inode& TmpFS::root_inode()
+{
+ VERIFY(!m_root_inode.is_null());
+ return *m_root_inode;
+}
+
+unsigned TmpFS::next_inode_index()
+{
+ MutexLocker locker(m_lock);
+
+ return m_next_inode_index++;
+}
+
+}
diff --git a/Kernel/FileSystem/TmpFS/FileSystem.h b/Kernel/FileSystem/TmpFS/FileSystem.h
new file mode 100644
index 0000000000..13c0fbbb75
--- /dev/null
+++ b/Kernel/FileSystem/TmpFS/FileSystem.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
+ * Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <Kernel/FileSystem/FileSystem.h>
+#include <Kernel/FileSystem/Inode.h>
+#include <Kernel/Forward.h>
+
+namespace Kernel {
+
+class TmpFS final : public FileSystem {
+ friend class TmpFSInode;
+
+public:
+ virtual ~TmpFS() override;
+ static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create();
+ virtual ErrorOr<void> initialize() override;
+
+ virtual StringView class_name() const override { return "TmpFS"sv; }
+
+ virtual bool supports_watchers() const override { return true; }
+
+ virtual Inode& root_inode() override;
+
+private:
+ TmpFS();
+
+ LockRefPtr<TmpFSInode> m_root_inode;
+
+ unsigned m_next_inode_index { 1 };
+ unsigned next_inode_index();
+};
+
+}
diff --git a/Kernel/FileSystem/TmpFS.cpp b/Kernel/FileSystem/TmpFS/Inode.cpp
index 7f66a9b4d4..166df6de03 100644
--- a/Kernel/FileSystem/TmpFS.cpp
+++ b/Kernel/FileSystem/TmpFS/Inode.cpp
@@ -5,39 +5,11 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <Kernel/FileSystem/TmpFS.h>
+#include <Kernel/FileSystem/TmpFS/Inode.h>
#include <Kernel/Process.h>
-#include <LibC/limits.h>
namespace Kernel {
-ErrorOr<NonnullLockRefPtr<FileSystem>> TmpFS::try_create()
-{
- return TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) TmpFS));
-}
-
-TmpFS::TmpFS() = default;
-TmpFS::~TmpFS() = default;
-
-ErrorOr<void> TmpFS::initialize()
-{
- m_root_inode = TRY(TmpFSInode::try_create_root(*this));
- return {};
-}
-
-Inode& TmpFS::root_inode()
-{
- VERIFY(!m_root_inode.is_null());
- return *m_root_inode;
-}
-
-unsigned TmpFS::next_inode_index()
-{
- MutexLocker locker(m_lock);
-
- return m_next_inode_index++;
-}
-
TmpFSInode::TmpFSInode(TmpFS& fs, InodeMetadata const& metadata, LockWeakPtr<TmpFSInode> parent)
: Inode(fs, fs.next_inode_index())
, m_metadata(metadata)
diff --git a/Kernel/FileSystem/TmpFS.h b/Kernel/FileSystem/TmpFS/Inode.h
index 3a98c89de2..667f0a9aad 100644
--- a/Kernel/FileSystem/TmpFS.h
+++ b/Kernel/FileSystem/TmpFS/Inode.h
@@ -7,39 +7,12 @@
#pragma once
-#include <Kernel/FileSystem/FileSystem.h>
#include <Kernel/FileSystem/Inode.h>
-#include <Kernel/KBuffer.h>
-#include <Kernel/Locking/MutexProtected.h>
+#include <Kernel/FileSystem/TmpFS/FileSystem.h>
#include <Kernel/Memory/AnonymousVMObject.h>
namespace Kernel {
-class TmpFSInode;
-
-class TmpFS final : public FileSystem {
- friend class TmpFSInode;
-
-public:
- virtual ~TmpFS() override;
- static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create();
- virtual ErrorOr<void> initialize() override;
-
- virtual StringView class_name() const override { return "TmpFS"sv; }
-
- virtual bool supports_watchers() const override { return true; }
-
- virtual Inode& root_inode() override;
-
-private:
- TmpFS();
-
- LockRefPtr<TmpFSInode> m_root_inode;
-
- unsigned m_next_inode_index { 1 };
- unsigned next_inode_index();
-};
-
class TmpFSInode final : public Inode {
friend class TmpFS;
diff --git a/Kernel/Forward.h b/Kernel/Forward.h
index ba2c62bb68..e83f87cb8c 100644
--- a/Kernel/Forward.h
+++ b/Kernel/Forward.h
@@ -61,6 +61,7 @@ class TCPSocket;
class TTY;
class Thread;
class ThreadTracer;
+class TmpFSInode;
class UDPSocket;
class UserOrKernelBuffer;
class VirtualFileSystem;
diff --git a/Kernel/Syscalls/mount.cpp b/Kernel/Syscalls/mount.cpp
index 792169c81e..5169911780 100644
--- a/Kernel/Syscalls/mount.cpp
+++ b/Kernel/Syscalls/mount.cpp
@@ -12,7 +12,7 @@
#include <Kernel/FileSystem/Plan9FileSystem.h>
#include <Kernel/FileSystem/ProcFS.h>
#include <Kernel/FileSystem/SysFS/FileSystem.h>
-#include <Kernel/FileSystem/TmpFS.h>
+#include <Kernel/FileSystem/TmpFS/FileSystem.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/Process.h>