1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 12:37:45 +00:00

Kernel: Make /proc/PID/fds display something useful for character devices.

This commit is contained in:
Andreas Kling 2019-01-21 02:33:01 +01:00
parent 786b903d62
commit e6fc84e234
14 changed files with 46 additions and 6 deletions

View file

@ -18,10 +18,12 @@ public:
Console();
virtual ~Console() override;
// ^CharacterDevice
virtual bool can_read(Process&) const override;
virtual bool can_write(Process&) const override { return true; }
virtual ssize_t read(Process&, byte* buffer, size_t size) override;
virtual ssize_t write(Process&, const byte* data, size_t size) override;
virtual const char* class_name() const override { return "Console"; }
void setImplementation(ConsoleImplementation* implementation) { m_implementation = implementation; }

View file

@ -13,4 +13,5 @@ private:
virtual ssize_t write(Process&, const byte* buffer, size_t bufferSize) override;
virtual bool can_read(Process&) const override;
virtual bool can_write(Process&) const override { return true; }
virtual const char* class_name() const override { return "GUIEventDevice"; }
};

View file

@ -42,6 +42,9 @@ private:
// ^IRQHandler
virtual void handle_irq() override;
// ^CharacterDevice
virtual const char* class_name() const override { return "Keyboard"; }
void emit(byte);
KeyboardClient* m_client { nullptr };

View file

@ -10,6 +10,7 @@ public:
explicit MasterPTY(unsigned index);
virtual ~MasterPTY() override;
// ^CharacterDevice
virtual ssize_t read(Process&, byte*, size_t) override;
virtual ssize_t write(Process&, const byte*, size_t) override;
virtual bool can_read(Process&) const override;
@ -21,6 +22,9 @@ public:
void on_slave_write(const byte*, size_t);
private:
// ^CharacterDevice
virtual const char* class_name() const override { return "MasterPTY"; }
SlavePTY& m_slave;
unsigned m_index;
DoubleBuffer m_buffer;

View file

@ -20,6 +20,9 @@ private:
// ^IRQHandler
virtual void handle_irq() override;
// ^CharacterDevice
virtual const char* class_name() const override { return "PS2MouseDevice"; }
void initialize();
void prepare_for_input();
void prepare_for_output();

View file

@ -19,6 +19,9 @@ public:
virtual bool can_write(Process&) const override { return true; }
private:
// ^CharacterDevice
virtual const char* class_name() const override { return "PTYMultiplexer"; }
Lock m_lock;
Vector<RetainPtr<MasterPTY>> m_freelist;
};

View file

@ -8,16 +8,18 @@ class SlavePTY final : public TTY {
public:
virtual ~SlavePTY() override;
virtual String tty_name() const override;
void on_master_write(const byte*, size_t);
unsigned index() const { return m_index; }
protected:
virtual void on_tty_write(const byte*, size_t) override;
virtual bool can_write(Process&) const override;
private:
// ^TTY
virtual String tty_name() const override;
virtual void on_tty_write(const byte*, size_t) override;
// ^CharacterDevice
virtual bool can_write(Process&) const override;
virtual const char* class_name() const override { return "SlavePTY"; }
friend class MasterPTY;
SlavePTY(MasterPTY&, unsigned index);

View file

@ -26,6 +26,9 @@ private:
virtual void on_tty_write(const byte*, size_t) override;
virtual String tty_name() const override;
// ^CharacterDevice
virtual const char* class_name() const override { return "VirtualConsole"; }
void set_active(bool);
void on_char(byte);