From 9f9b4a23823a851d632a0b2e757f1232b5de5620 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 14 Oct 2018 13:16:09 +0200 Subject: Add a simple /dev/full. --- VirtualFileSystem/FullDevice.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 VirtualFileSystem/FullDevice.cpp (limited to 'VirtualFileSystem/FullDevice.cpp') diff --git a/VirtualFileSystem/FullDevice.cpp b/VirtualFileSystem/FullDevice.cpp new file mode 100644 index 0000000000..2ef60e6299 --- /dev/null +++ b/VirtualFileSystem/FullDevice.cpp @@ -0,0 +1,30 @@ +#include "FullDevice.h" +#include "Limits.h" +#include "sys-errno.h" +#include +#include +#include + +FullDevice::FullDevice() +{ +} + +FullDevice::~FullDevice() +{ +} + +ssize_t FullDevice::read(byte* buffer, size_t bufferSize) +{ + printf("read from full device\n"); + size_t count = min(GoodBufferSize, bufferSize); + memset(buffer, 0, count); + return count; +} + +ssize_t FullDevice::write(const byte*, size_t bufferSize) +{ + if (bufferSize == 0) + return 0; + return -ENOSPC; +} + -- cgit v1.2.3