Serenity Operating System
1/*
2 * Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
3 * Copyright (c) 2022-2023, Liav A. <liavalb@hotmail.co.il>
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 */
7
8#pragma once
9
10#include <Kernel/FileSystem/FileSystem.h>
11#include <Kernel/FileSystem/Inode.h>
12#include <Kernel/Forward.h>
13
14namespace Kernel {
15
16class RAMFS final : public FileSystem {
17 friend class RAMFSInode;
18
19public:
20 virtual ~RAMFS() override;
21 static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create();
22 virtual ErrorOr<void> initialize() override;
23
24 virtual StringView class_name() const override { return "RAMFS"sv; }
25
26 virtual bool supports_watchers() const override { return true; }
27
28 virtual Inode& root_inode() override;
29
30private:
31 RAMFS();
32
33 RefPtr<RAMFSInode> m_root_inode;
34
35 // NOTE: We start by assigning InodeIndex of 2, because 0 is invalid and 1
36 // is reserved for the root directory inode.
37 unsigned m_next_inode_index { 2 };
38 unsigned next_inode_index();
39};
40
41}