mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
ed67a877a3
This filesystem is based on the code of the long-lived TmpFS. It differs from that filesystem in one keypoint - its root inode doesn't have a sticky bit on it. Therefore, we mount it on /dev, to ensure only root can modify files on that directory. In addition to that, /tmp is mounted directly in the SystemServer main (start) code, so it's no longer specified in the fstab file. We ensure that /tmp has a sticky bit and has the value 0777 for root directory permissions, which is certainly a special case when using RAM-backed (and in general other) filesystems. Because of these 2 changes, it's no longer needed to maintain the TmpFS filesystem, hence it's removed (renamed to RAMFS), because the RAMFS represents the purpose of this filesystem in a much better way - it relies on being backed by RAM "storage", and therefore it's easy to conclude it's temporary and volatile, so its content is gone on either system shutdown or unmounting of the filesystem.
41 lines
1,002 B
C++
41 lines
1,002 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<NonnullLockRefPtr<FileSystem>> try_create();
|
|
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();
|
|
|
|
LockRefPtr<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();
|
|
};
|
|
|
|
}
|