1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 11:54:59 +00:00
serenity/Kernel/FileSystem/RAMFS/FileSystem.h
Liav A 23a7ccf607 Kernel+LibCore+LibC: Split the mount syscall into multiple syscalls
This is a preparation before we can create a usable mechanism to use
filesystem-specific mount flags.
To keep some compatibility with userland code, LibC and LibCore mount
functions are kept being usable, but now instead of doing an "atomic"
syscall, they do multiple syscalls to perform the complete procedure of
mounting a filesystem.

The FileBackedFileSystem IntrusiveList in the VFS code is now changed to
be protected by a Mutex, because when we mount a new filesystem, we need
to check if a filesystem is already created for a given source_fd so we
do a scan for that OpenFileDescription in that list. If we fail to find
an already-created filesystem we create a new one and register it in the
list if we successfully mounted it. We use a Mutex because we might need
to initiate disk access during the filesystem creation, which will take
other mutexes in other parts of the kernel, therefore making it not
possible to take a spinlock while doing this.
2023-07-02 01:04:51 +02:00

41 lines
1,007 B
C++

/*
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
* Copyright (c) 2022-2023, 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 RAMFS final : public FileSystem {
friend class RAMFSInode;
public:
virtual ~RAMFS() override;
static ErrorOr<NonnullRefPtr<FileSystem>> try_create(ReadonlyBytes);
virtual ErrorOr<void> initialize() override;
virtual StringView class_name() const override { return "RAMFS"sv; }
virtual bool supports_watchers() const override { return true; }
virtual Inode& root_inode() override;
private:
RAMFS();
RefPtr<RAMFSInode> m_root_inode;
// NOTE: We start by assigning InodeIndex of 2, because 0 is invalid and 1
// is reserved for the root directory inode.
unsigned m_next_inode_index { 2 };
unsigned next_inode_index();
};
}