summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/FileDescription.cpp
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2020-01-12 18:28:23 +0300
committerAndreas Kling <awesomekling@gmail.com>2020-01-12 20:02:11 +0100
commit3393b786238b43ac1faef20fb393d4efd3d8ce3c (patch)
tree7184bcb1785271f55f752858e4e33678f8b1123f /Kernel/FileSystem/FileDescription.cpp
parent35b0f10f202c80cdc51661d11c0a9affb3d71a58 (diff)
downloadserenity-3393b786238b43ac1faef20fb393d4efd3d8ce3c.zip
Kernel: Allow getting a Device from a FileDescription
Like we already do for other kinds of files.
Diffstat (limited to 'Kernel/FileSystem/FileDescription.cpp')
-rw-r--r--Kernel/FileSystem/FileDescription.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/Kernel/FileSystem/FileDescription.cpp b/Kernel/FileSystem/FileDescription.cpp
index 13c3850ffd..ad7be299f7 100644
--- a/Kernel/FileSystem/FileDescription.cpp
+++ b/Kernel/FileSystem/FileDescription.cpp
@@ -172,6 +172,20 @@ bool FileDescription::is_device() const
return m_file->is_device();
}
+const Device* FileDescription::device() const
+{
+ if (!is_device())
+ return nullptr;
+ return static_cast<const Device*>(m_file.ptr());
+}
+
+Device* FileDescription::device()
+{
+ if (!is_device())
+ return nullptr;
+ return static_cast<Device*>(m_file.ptr());
+}
+
bool FileDescription::is_tty() const
{
return m_file->is_tty();