Files
ladybird/VirtualFileSystem/CharacterDevice.h
Andreas Kling 2f74c2f430 Add basic PTY support.
For now, there are four hard-coded PTYs: /dev/pt{m,s}[0123]
Use this in the Terminal to open a pty pair and spawn a shell.
2019-01-15 06:30:19 +01:00

35 lines
858 B
C++

#pragma once
#include <AK/Types.h>
#include "Limits.h"
#include "FileDescriptor.h"
class Process;
class CharacterDevice {
public:
virtual ~CharacterDevice();
RetainPtr<FileDescriptor> open(int options);
virtual bool has_data_available_for_reading(Process&) const = 0;
virtual ssize_t read(byte* buffer, size_t bufferSize) = 0;
virtual ssize_t write(const byte* buffer, size_t bufferSize) = 0;
unsigned major() const { return m_major; }
unsigned minor() const { return m_minor; }
virtual bool is_tty() const { return false; }
virtual bool is_master_pty() const { return false; }
virtual int ioctl(Process&, unsigned request, unsigned arg);
protected:
CharacterDevice(unsigned major, unsigned minor) : m_major(major), m_minor(minor) { }
private:
unsigned m_major { 0 };
unsigned m_minor { 0 };
};