/* * 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 KResultOr> try_create(); virtual KResult initialize() override; virtual StringView class_name() const override { return "DevPtsFS"sv; } virtual Inode& root_inode() override; private: DevPtsFS(); KResultOr> 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 KResultOr read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, FileDescription*) const override; virtual InodeMetadata metadata() const override; virtual KResult traverse_as_directory(Function) const override; virtual KResultOr> lookup(StringView name) override; virtual void flush_metadata() override; virtual KResultOr write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, FileDescription*) override; virtual KResultOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual KResult add_child(Inode&, const StringView& name, mode_t) override; virtual KResult remove_child(const StringView& name) override; virtual KResult chmod(mode_t) override; virtual KResult chown(UserID, GroupID) override; WeakPtr m_pty; InodeMetadata m_metadata; }; }