ladybird/Kernel/FullDevice.cpp
Andreas Kling beda478821 Kernel: Make syscalls that take a buffer size use ssize_t instead of size_t.
Dealing with the unsigned overflow propagation here just seems unreasonably
error prone. Let's limit ourselves to 2GB buffer sizes instead.
2019-02-25 21:21:12 +01:00

35 lines
578 B
C++

#include "FullDevice.h"
#include "Limits.h"
#include <LibC/errno_numbers.h>
#include <AK/StdLibExtras.h>
#include <AK/kstdio.h>
FullDevice::FullDevice()
: CharacterDevice(1, 7)
{
}
FullDevice::~FullDevice()
{
}
bool FullDevice::can_read(Process&) const
{
return true;
}
ssize_t FullDevice::read(Process&, byte* buffer, ssize_t size)
{
ssize_t count = min(GoodBufferSize, size);
memset(buffer, 0, (size_t)count);
return count;
}
ssize_t FullDevice::write(Process&, const byte*, ssize_t size)
{
if (size == 0)
return 0;
return -ENOSPC;
}