ladybird/Kernel/Devices/FullDevice.cpp

33 lines
572 B
C++
Raw Normal View History

2018-10-14 14:16:09 +03:00
#include "FullDevice.h"
#include <AK/StdLibExtras.h>
#include <AK/kstdio.h>
#include <LibC/errno_numbers.h>
2018-10-14 14:16:09 +03:00
FullDevice::FullDevice()
: CharacterDevice(1, 7)
2018-10-14 14:16:09 +03:00
{
}
FullDevice::~FullDevice()
{
}
bool FullDevice::can_read(FileDescription&) const
{
return true;
}
ssize_t FullDevice::read(FileDescription&, u8* buffer, ssize_t size)
2018-10-14 14:16:09 +03:00
{
2019-04-03 14:18:42 +03:00
ssize_t count = min(PAGE_SIZE, size);
memset(buffer, 0, (size_t)count);
2018-10-14 14:16:09 +03:00
return count;
}
ssize_t FullDevice::write(FileDescription&, const u8*, ssize_t size)
2018-10-14 14:16:09 +03:00
{
if (size == 0)
2018-10-14 14:16:09 +03:00
return 0;
return -ENOSPC;
}