diff options
author | Sergey Bugaev <bugaevc@gmail.com> | 2020-01-12 18:28:23 +0300 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2020-01-12 20:02:11 +0100 |
commit | 3393b786238b43ac1faef20fb393d4efd3d8ce3c (patch) | |
tree | 7184bcb1785271f55f752858e4e33678f8b1123f /Kernel/FileSystem/FileDescription.cpp | |
parent | 35b0f10f202c80cdc51661d11c0a9affb3d71a58 (diff) | |
download | serenity-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.cpp | 14 |
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(); |