2018-10-14 03:59:22 +03:00
|
|
|
#include "NullDevice.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>
|
2018-10-14 03:59:22 +03:00
|
|
|
|
2019-02-12 13:25:25 +03:00
|
|
|
static NullDevice* s_the;
|
|
|
|
|
|
|
|
NullDevice& NullDevice::the()
|
|
|
|
{
|
|
|
|
ASSERT(s_the);
|
|
|
|
return *s_the;
|
|
|
|
}
|
|
|
|
|
2018-10-14 03:59:22 +03:00
|
|
|
NullDevice::NullDevice()
|
2018-10-30 15:59:29 +03:00
|
|
|
: CharacterDevice(1, 3)
|
2018-10-14 03:59:22 +03:00
|
|
|
{
|
2019-02-12 13:25:25 +03:00
|
|
|
s_the = this;
|
2018-10-14 03:59:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NullDevice::~NullDevice()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-06-07 10:36:51 +03:00
|
|
|
bool NullDevice::can_read(FileDescription&) const
|
2018-10-25 14:07:59 +03:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-07-03 22:17:35 +03:00
|
|
|
ssize_t NullDevice::read(FileDescription&, u8*, ssize_t)
|
2018-10-14 03:59:22 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-07-03 22:17:35 +03:00
|
|
|
ssize_t NullDevice::write(FileDescription&, const u8*, ssize_t buffer_size)
|
2018-10-14 03:59:22 +03:00
|
|
|
{
|
2019-04-03 14:18:42 +03:00
|
|
|
return min(PAGE_SIZE, buffer_size);
|
2018-10-14 03:59:22 +03:00
|
|
|
}
|