mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
Kernel: Create SelfTTYDevice class to help replace /dev/tty symlink
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.
This commit is contained in:
parent
2fb9eb5257
commit
12867d60ad
4 changed files with 102 additions and 0 deletions
32
Kernel/Devices/SelfTTYDevice.h
Normal file
32
Kernel/Devices/SelfTTYDevice.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* 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; }
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue