/* * 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 FS { friend class DevPtsFSInode; public: virtual ~DevPtsFS() override; static NonnullRefPtr create(); virtual bool initialize() override; virtual const char* class_name() const override { return "DevPtsFS"; } virtual NonnullRefPtr root_inode() const override; static void register_slave_pty(SlavePTY&); static void unregister_slave_pty(SlavePTY&); private: DevPtsFS(); RefPtr get_inode(InodeIdentifier) const; RefPtr m_root_inode; }; class DevPtsFSInode final : public Inode { friend class DevPtsFS; public: virtual ~DevPtsFSInode() override; 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 RefPtr 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(const String& name, mode_t, dev_t, uid_t, gid_t) override; virtual KResult add_child(Inode&, const StringView& name, mode_t) override; virtual KResult remove_child(const StringView& name) override; virtual KResultOr directory_entry_count() const override; virtual KResult chmod(mode_t) override; virtual KResult chown(uid_t, gid_t) override; WeakPtr m_pty; InodeMetadata m_metadata; }; }