2018-10-14 14:16:09 +03:00
|
|
|
#include "FullDevice.h"
|
2018-12-04 02:27:16 +03:00
|
|
|
#include <AK/StdLibExtras.h>
|
2018-10-16 15:33:16 +03:00
|
|
|
#include <AK/kstdio.h>
|
2019-06-07 12:43:58 +03:00
|
|
|
#include <LibC/errno_numbers.h>
|
2018-10-14 14:16:09 +03:00
|
|
|
|
|
|
|
FullDevice::FullDevice()
|
2018-10-30 15:59:29 +03:00
|
|
|
: CharacterDevice(1, 7)
|
2018-10-14 14:16:09 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
FullDevice::~FullDevice()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-06-07 10:36:51 +03:00
|
|
|
bool FullDevice::can_read(FileDescription&) const
|
2018-10-25 14:07:59 +03:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-07-03 22:17:35 +03:00
|
|
|
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);
|
2019-02-25 23:19:57 +03:00
|
|
|
memset(buffer, 0, (size_t)count);
|
2018-10-14 14:16:09 +03:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2019-07-03 22:17:35 +03:00
|
|
|
ssize_t FullDevice::write(FileDescription&, const u8*, ssize_t size)
|
2018-10-14 14:16:09 +03:00
|
|
|
{
|
2019-02-25 23:19:57 +03:00
|
|
|
if (size == 0)
|
2018-10-14 14:16:09 +03:00
|
|
|
return 0;
|
|
|
|
return -ENOSPC;
|
|
|
|
}
|