1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 18:14:58 +00:00
serenity/Kernel/FileSystem/RAMFS/FileSystem.h
Ali Mohammad Pur b545427d53 Kernel: Make RAMFS pass along the inode type when traversing as a dir
RAMFS was passing 0, which lead to the userspace seeing all entries as
DT_UNKNOWN when iterating over the directory contents.
To repro prior to this commit, simply check `echo /tmp/*/`.
2023-12-01 20:46:16 +01:00

54 lines
1.3 KiB
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;
virtual u8 internal_file_type_to_directory_entry_type(DirectoryEntryView const& entry) const override;
enum class FileType : u8 {
Directory,
Character,
Block,
Regular,
FIFO,
Link,
Socket,
Unknown,
};
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();
};
}