2018-10-14 13:16:09 +02:00
|
|
|
#include "FullDevice.h"
|
2018-11-07 21:19:47 +01:00
|
|
|
#include <LibC/errno_numbers.h>
|
2018-12-04 00:27:16 +01:00
|
|
|
#include <AK/StdLibExtras.h>
|
2018-10-16 14:33:16 +02:00
|
|
|
#include <AK/kstdio.h>
|
2018-10-14 13:16:09 +02:00
|
|
|
|
|
|
|
|
FullDevice::FullDevice()
|
2018-10-30 13:59:29 +01:00
|
|
|
: CharacterDevice(1, 7)
|
2018-10-14 13:16:09 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FullDevice::~FullDevice()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-29 13:58:40 +02:00
|
|
|
bool FullDevice::can_read(FileDescriptor&) const
|
2018-10-25 13:07:59 +02:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-29 13:58:40 +02:00
|
|
|
ssize_t FullDevice::read(FileDescriptor&, byte* buffer, ssize_t size)
|
2018-10-14 13:16:09 +02:00
|
|
|
{
|
2019-04-03 13:18:42 +02:00
|
|
|
ssize_t count = min(PAGE_SIZE, size);
|
2019-02-25 21:19:57 +01:00
|
|
|
memset(buffer, 0, (size_t)count);
|
2018-10-14 13:16:09 +02:00
|
|
|
return count;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-29 13:58:40 +02:00
|
|
|
ssize_t FullDevice::write(FileDescriptor&, const byte*, ssize_t size)
|
2018-10-14 13:16:09 +02:00
|
|
|
{
|
2019-02-25 21:19:57 +01:00
|
|
|
if (size == 0)
|
2018-10-14 13:16:09 +02:00
|
|
|
return 0;
|
|
|
|
|
return -ENOSPC;
|
|
|
|
|
}
|
|
|
|
|
|