2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2019-01-15 06:30:19 +01:00
|
|
|
#pragma once
|
|
|
|
|
2019-04-29 04:55:54 +02:00
|
|
|
#include <Kernel/FileSystem/InodeIdentifier.h>
|
2019-04-03 12:28:45 +02:00
|
|
|
#include <Kernel/TTY/TTY.h>
|
2019-01-15 06:30:19 +01:00
|
|
|
|
2020-02-16 01:27:42 +01:00
|
|
|
namespace Kernel {
|
|
|
|
|
2019-01-15 06:30:19 +01:00
|
|
|
class MasterPTY;
|
|
|
|
|
|
|
|
class SlavePTY final : public TTY {
|
|
|
|
public:
|
|
|
|
virtual ~SlavePTY() override;
|
|
|
|
|
2021-06-16 15:20:35 +02:00
|
|
|
void on_master_write(const UserOrKernelBuffer&, size_t);
|
2019-01-16 13:36:10 +01:00
|
|
|
unsigned index() const { return m_index; }
|
2019-01-15 06:30:19 +01:00
|
|
|
|
2020-09-06 18:48:24 +02:00
|
|
|
time_t time_of_last_write() const { return m_time_of_last_write; }
|
|
|
|
|
2020-11-29 16:05:27 -07:00
|
|
|
virtual FileBlockCondition& block_condition() override;
|
|
|
|
|
2019-01-21 02:33:01 +01:00
|
|
|
private:
|
|
|
|
// ^TTY
|
2021-05-12 22:47:06 +02:00
|
|
|
virtual String const& tty_name() const override;
|
2021-06-16 15:20:35 +02:00
|
|
|
virtual KResultOr<size_t> on_tty_write(const UserOrKernelBuffer&, size_t) override;
|
2019-10-20 19:12:00 +13:00
|
|
|
virtual void echo(u8) override;
|
2019-01-21 02:33:01 +01:00
|
|
|
|
|
|
|
// ^CharacterDevice
|
2020-04-10 19:44:42 +10:00
|
|
|
virtual bool can_read(const FileDescription&, size_t) const override;
|
2021-03-17 13:18:51 +01:00
|
|
|
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
2020-04-10 19:44:42 +10:00
|
|
|
virtual bool can_write(const FileDescription&, size_t) const override;
|
2019-01-21 02:33:01 +01:00
|
|
|
virtual const char* class_name() const override { return "SlavePTY"; }
|
2020-06-02 19:20:05 +03:00
|
|
|
virtual KResult close() override;
|
2019-01-15 06:30:19 +01:00
|
|
|
|
2021-01-21 18:49:56 +01:00
|
|
|
// ^Device
|
|
|
|
virtual String device_name() const override;
|
|
|
|
|
2019-01-16 02:11:50 +01:00
|
|
|
friend class MasterPTY;
|
|
|
|
SlavePTY(MasterPTY&, unsigned index);
|
|
|
|
|
2019-06-21 18:37:47 +02:00
|
|
|
RefPtr<MasterPTY> m_master;
|
2020-09-06 18:48:24 +02:00
|
|
|
time_t m_time_of_last_write { 0 };
|
|
|
|
unsigned m_index { 0 };
|
2021-02-17 16:37:11 +01:00
|
|
|
String m_tty_name;
|
2019-01-15 06:30:19 +01:00
|
|
|
};
|
2020-02-16 01:27:42 +01:00
|
|
|
|
|
|
|
}
|