/* * Copyright (c) 2019-2020, Sergey Bugaev * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Kernel { class SlavePTY; class DevPtsFSInode; class DevPtsFS final : public FileSystem { friend class DevPtsFSInode; public: virtual ~DevPtsFS() override; static ErrorOr> try_create(); virtual ErrorOr initialize() override; virtual StringView class_name() const override { return "DevPtsFS"sv; } virtual Inode& root_inode() override; private: DevPtsFS(); ErrorOr> get_inode(InodeIdentifier) const; RefPtr m_root_inode; }; class DevPtsFSInode final : public Inode { friend class DevPtsFS; public: virtual ~DevPtsFSInode() override; DevPtsFS& fs() { return static_cast(Inode::fs()); } DevPtsFS const& fs() const { return static_cast(Inode::fs()); } private: DevPtsFSInode(DevPtsFS&, InodeIndex, SlavePTY*); // ^Inode virtual ErrorOr read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override; virtual InodeMetadata metadata() const override; virtual ErrorOr traverse_as_directory(Function(FileSystem::DirectoryEntryView const&)>) const override; virtual ErrorOr> lookup(StringView name) override; virtual ErrorOr flush_metadata() override; virtual ErrorOr write_bytes(off_t, size_t, UserOrKernelBuffer const& buffer, OpenFileDescription*) override; virtual ErrorOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual ErrorOr add_child(Inode&, StringView name, mode_t) override; virtual ErrorOr remove_child(StringView name) override; virtual ErrorOr chmod(mode_t) override; virtual ErrorOr chown(UserID, GroupID) override; WeakPtr m_pty; InodeMetadata m_metadata; }; }