mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
12867d60ad
This will replace the /dev/tty symlink created by SystemServer, so instead of a symlink, a character device will be created. When doing read(2), write(2) and ioctl(2) on this device, it will "redirect" these operations to the attached TTY of the current process.
32 lines
960 B
C++
32 lines
960 B
C++
/*
|
|
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <Kernel/Devices/CharacterDevice.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class SelfTTYDevice final : public CharacterDevice {
|
|
friend class DeviceManagement;
|
|
|
|
public:
|
|
static NonnullRefPtr<SelfTTYDevice> must_create();
|
|
virtual ~SelfTTYDevice() override;
|
|
|
|
private:
|
|
SelfTTYDevice();
|
|
|
|
// ^CharacterDevice
|
|
virtual ErrorOr<NonnullRefPtr<OpenFileDescription>> open(int options) override;
|
|
virtual ErrorOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;
|
|
virtual ErrorOr<size_t> write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override;
|
|
virtual bool can_read(OpenFileDescription const&, u64) const override;
|
|
virtual bool can_write(OpenFileDescription const&, u64) const override;
|
|
virtual StringView class_name() const override { return "SelfTTYDevice"sv; }
|
|
};
|
|
|
|
}
|