mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:38:11 +00:00
Kernel: Split the TmpFS core files into smaller components
This commit is contained in:
parent
f53149d5f6
commit
5e6101dd3e
7 changed files with 85 additions and 59 deletions
|
@ -183,7 +183,8 @@ set(KERNEL_SOURCES
|
||||||
FileSystem/SysFS/Subsystems/Kernel/Variables/Directory.cpp
|
FileSystem/SysFS/Subsystems/Kernel/Variables/Directory.cpp
|
||||||
FileSystem/SysFS/Subsystems/Kernel/Variables/DumpKmallocStack.cpp
|
FileSystem/SysFS/Subsystems/Kernel/Variables/DumpKmallocStack.cpp
|
||||||
FileSystem/SysFS/Subsystems/Kernel/Variables/UBSANDeadly.cpp
|
FileSystem/SysFS/Subsystems/Kernel/Variables/UBSANDeadly.cpp
|
||||||
FileSystem/TmpFS.cpp
|
FileSystem/TmpFS/FileSystem.cpp
|
||||||
|
FileSystem/TmpFS/Inode.cpp
|
||||||
FileSystem/VirtualFileSystem.cpp
|
FileSystem/VirtualFileSystem.cpp
|
||||||
Firmware/BIOS.cpp
|
Firmware/BIOS.cpp
|
||||||
Firmware/ACPI/Initialize.cpp
|
Firmware/ACPI/Initialize.cpp
|
||||||
|
|
40
Kernel/FileSystem/TmpFS/FileSystem.cpp
Normal file
40
Kernel/FileSystem/TmpFS/FileSystem.cpp
Normal file
|
@ -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++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
39
Kernel/FileSystem/TmpFS/FileSystem.h
Normal file
39
Kernel/FileSystem/TmpFS/FileSystem.h
Normal file
|
@ -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();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -5,39 +5,11 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Kernel/FileSystem/TmpFS.h>
|
#include <Kernel/FileSystem/TmpFS/Inode.h>
|
||||||
#include <Kernel/Process.h>
|
#include <Kernel/Process.h>
|
||||||
#include <LibC/limits.h>
|
|
||||||
|
|
||||||
namespace Kernel {
|
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)
|
TmpFSInode::TmpFSInode(TmpFS& fs, InodeMetadata const& metadata, LockWeakPtr<TmpFSInode> parent)
|
||||||
: Inode(fs, fs.next_inode_index())
|
: Inode(fs, fs.next_inode_index())
|
||||||
, m_metadata(metadata)
|
, m_metadata(metadata)
|
|
@ -7,39 +7,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Kernel/FileSystem/FileSystem.h>
|
|
||||||
#include <Kernel/FileSystem/Inode.h>
|
#include <Kernel/FileSystem/Inode.h>
|
||||||
#include <Kernel/KBuffer.h>
|
#include <Kernel/FileSystem/TmpFS/FileSystem.h>
|
||||||
#include <Kernel/Locking/MutexProtected.h>
|
|
||||||
#include <Kernel/Memory/AnonymousVMObject.h>
|
#include <Kernel/Memory/AnonymousVMObject.h>
|
||||||
|
|
||||||
namespace Kernel {
|
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 {
|
class TmpFSInode final : public Inode {
|
||||||
friend class TmpFS;
|
friend class TmpFS;
|
||||||
|
|
|
@ -61,6 +61,7 @@ class TCPSocket;
|
||||||
class TTY;
|
class TTY;
|
||||||
class Thread;
|
class Thread;
|
||||||
class ThreadTracer;
|
class ThreadTracer;
|
||||||
|
class TmpFSInode;
|
||||||
class UDPSocket;
|
class UDPSocket;
|
||||||
class UserOrKernelBuffer;
|
class UserOrKernelBuffer;
|
||||||
class VirtualFileSystem;
|
class VirtualFileSystem;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <Kernel/FileSystem/Plan9FileSystem.h>
|
#include <Kernel/FileSystem/Plan9FileSystem.h>
|
||||||
#include <Kernel/FileSystem/ProcFS.h>
|
#include <Kernel/FileSystem/ProcFS.h>
|
||||||
#include <Kernel/FileSystem/SysFS/FileSystem.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/FileSystem/VirtualFileSystem.h>
|
||||||
#include <Kernel/Process.h>
|
#include <Kernel/Process.h>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue