summaryrefslogtreecommitdiff
path: root/Kernel/Devices/NullDevice.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-03 12:36:40 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-03 12:36:40 +0200
commitab43658c5537c03d075f8abc57fe90e940023779 (patch)
tree01bd0f73784dd42372dd8a8f065a3a8c6b3d9858 /Kernel/Devices/NullDevice.cpp
parent072ea7eece8607efec8e2824307b0a6209e4d014 (diff)
downloadserenity-ab43658c5537c03d075f8abc57fe90e940023779.zip
Kernel: Move devices into Kernel/Devices/.
Diffstat (limited to 'Kernel/Devices/NullDevice.cpp')
-rw-r--r--Kernel/Devices/NullDevice.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/Kernel/Devices/NullDevice.cpp b/Kernel/Devices/NullDevice.cpp
new file mode 100644
index 0000000000..cfb73450e1
--- /dev/null
+++ b/Kernel/Devices/NullDevice.cpp
@@ -0,0 +1,38 @@
+#include "NullDevice.h"
+#include "Limits.h"
+#include <AK/StdLibExtras.h>
+#include <AK/kstdio.h>
+
+static NullDevice* s_the;
+
+NullDevice& NullDevice::the()
+{
+ ASSERT(s_the);
+ return *s_the;
+}
+
+NullDevice::NullDevice()
+ : CharacterDevice(1, 3)
+{
+ s_the = this;
+}
+
+NullDevice::~NullDevice()
+{
+}
+
+bool NullDevice::can_read(Process&) const
+{
+ return true;
+}
+
+ssize_t NullDevice::read(Process&, byte*, ssize_t)
+{
+ return 0;
+}
+
+ssize_t NullDevice::write(Process&, const byte*, ssize_t buffer_size)
+{
+ return min(GoodBufferSize, buffer_size);
+}
+