summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-01-21 02:33:01 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-01-21 02:33:01 +0100
commite6fc84e2349c13c51d379f77b84bcdd4d8c6f9c8 (patch)
treee9fcb1afb31a4fab79e0c076ef05732252b10557
parent786b903d62f86ee8e17b3ab7b77d4aeebe32847a (diff)
downloadserenity-e6fc84e2349c13c51d379f77b84bcdd4d8c6f9c8.zip
Kernel: Make /proc/PID/fds display something useful for character devices.
-rw-r--r--Kernel/Console.h2
-rw-r--r--Kernel/GUIEventDevice.h1
-rw-r--r--Kernel/Keyboard.h3
-rw-r--r--Kernel/MasterPTY.h4
-rw-r--r--Kernel/PS2MouseDevice.h3
-rw-r--r--Kernel/PTYMultiplexer.h3
-rw-r--r--Kernel/SlavePTY.h10
-rw-r--r--Kernel/VirtualConsole.h3
-rw-r--r--VirtualFileSystem/CharacterDevice.h2
-rw-r--r--VirtualFileSystem/FileDescriptor.cpp5
-rw-r--r--VirtualFileSystem/FullDevice.h3
-rw-r--r--VirtualFileSystem/NullDevice.h3
-rw-r--r--VirtualFileSystem/RandomDevice.h3
-rw-r--r--VirtualFileSystem/ZeroDevice.h3
14 files changed, 44 insertions, 4 deletions
diff --git a/Kernel/Console.h b/Kernel/Console.h
index fe4c3aea70..962ff09aab 100644
--- a/Kernel/Console.h
+++ b/Kernel/Console.h
@@ -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; }
diff --git a/Kernel/GUIEventDevice.h b/Kernel/GUIEventDevice.h
index e98b208f05..6fe7dfd314 100644
--- a/Kernel/GUIEventDevice.h
+++ b/Kernel/GUIEventDevice.h
@@ -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"; }
};
diff --git a/Kernel/Keyboard.h b/Kernel/Keyboard.h
index e7debc403b..924a3a3a06 100644
--- a/Kernel/Keyboard.h
+++ b/Kernel/Keyboard.h
@@ -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 };
diff --git a/Kernel/MasterPTY.h b/Kernel/MasterPTY.h
index aa4a27daf0..7c85dfea56 100644
--- a/Kernel/MasterPTY.h
+++ b/Kernel/MasterPTY.h
@@ -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;
diff --git a/Kernel/PS2MouseDevice.h b/Kernel/PS2MouseDevice.h
index cb68b3f3e2..a06975c047 100644
--- a/Kernel/PS2MouseDevice.h
+++ b/Kernel/PS2MouseDevice.h
@@ -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();
diff --git a/Kernel/PTYMultiplexer.h b/Kernel/PTYMultiplexer.h
index fe91f6eb34..bd1afe6a66 100644
--- a/Kernel/PTYMultiplexer.h
+++ b/Kernel/PTYMultiplexer.h
@@ -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;
};
diff --git a/Kernel/SlavePTY.h b/Kernel/SlavePTY.h
index 1b01219349..23aa996840 100644
--- a/Kernel/SlavePTY.h
+++ b/Kernel/SlavePTY.h
@@ -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:
+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"; }
-private:
friend class MasterPTY;
SlavePTY(MasterPTY&, unsigned index);
diff --git a/Kernel/VirtualConsole.h b/Kernel/VirtualConsole.h
index 2888ced10d..3b688174d7 100644
--- a/Kernel/VirtualConsole.h
+++ b/Kernel/VirtualConsole.h
@@ -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);
diff --git a/VirtualFileSystem/CharacterDevice.h b/VirtualFileSystem/CharacterDevice.h
index 92c29ed2cd..c37cbf0600 100644
--- a/VirtualFileSystem/CharacterDevice.h
+++ b/VirtualFileSystem/CharacterDevice.h
@@ -29,6 +29,8 @@ public:
virtual int ioctl(Process&, unsigned request, unsigned arg);
+ virtual const char* class_name() const = 0;
+
protected:
CharacterDevice(unsigned major, unsigned minor) : m_major(major), m_minor(minor) { }
diff --git a/VirtualFileSystem/FileDescriptor.cpp b/VirtualFileSystem/FileDescriptor.cpp
index 6b20ee8ef9..15d2a79b68 100644
--- a/VirtualFileSystem/FileDescriptor.cpp
+++ b/VirtualFileSystem/FileDescriptor.cpp
@@ -297,6 +297,11 @@ String FileDescriptor::absolute_path()
ksprintf(buf, "fifo:%x", m_fifo.ptr());
return buf;
}
+ if (is_character_device()) {
+ char buf[128];
+ ksprintf(buf, "device:%u,%u (%s)", m_device->major(), m_device->minor(), m_device->class_name());
+ return buf;
+ }
ASSERT(m_inode);
return VFS::the().absolute_path(*m_inode);
}
diff --git a/VirtualFileSystem/FullDevice.h b/VirtualFileSystem/FullDevice.h
index 44b6af0a8c..a900ac2536 100644
--- a/VirtualFileSystem/FullDevice.h
+++ b/VirtualFileSystem/FullDevice.h
@@ -8,9 +8,12 @@ public:
FullDevice();
virtual ~FullDevice() override;
+private:
+ // ^CharacterDevice
virtual ssize_t read(Process&, byte* buffer, size_t bufferSize) override;
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 "FullDevice"; }
};
diff --git a/VirtualFileSystem/NullDevice.h b/VirtualFileSystem/NullDevice.h
index 9e51f1da5c..22c3637bb0 100644
--- a/VirtualFileSystem/NullDevice.h
+++ b/VirtualFileSystem/NullDevice.h
@@ -8,9 +8,12 @@ public:
NullDevice();
virtual ~NullDevice() override;
+private:
+ // ^CharacterDevice
virtual ssize_t read(Process&, byte* buffer, size_t bufferSize) override;
virtual ssize_t write(Process&, const byte* buffer, size_t bufferSize) override;
virtual bool can_write(Process&) const override { return true; }
virtual bool can_read(Process&) const override;
+ virtual const char* class_name() const override { return "CharacterDevice"; }
};
diff --git a/VirtualFileSystem/RandomDevice.h b/VirtualFileSystem/RandomDevice.h
index 4711542a54..defaebff9d 100644
--- a/VirtualFileSystem/RandomDevice.h
+++ b/VirtualFileSystem/RandomDevice.h
@@ -8,9 +8,12 @@ public:
RandomDevice();
virtual ~RandomDevice() override;
+private:
+ // ^CharacterDevice
virtual ssize_t read(Process&, byte* buffer, size_t bufferSize) override;
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 "RandomDevice"; }
};
diff --git a/VirtualFileSystem/ZeroDevice.h b/VirtualFileSystem/ZeroDevice.h
index d3440781a0..ee7f2dde37 100644
--- a/VirtualFileSystem/ZeroDevice.h
+++ b/VirtualFileSystem/ZeroDevice.h
@@ -8,9 +8,12 @@ public:
ZeroDevice();
virtual ~ZeroDevice() override;
+private:
+ // ^CharacterDevice
virtual ssize_t read(Process&, byte* buffer, size_t bufferSize) override;
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 "ZeroDevice"; }
};