2018-10-14 02:59:22 +02:00
|
|
|
#include "NullDevice.h"
|
|
|
|
#include "Limits.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 02:59:22 +02:00
|
|
|
|
2019-02-12 11:25:25 +01:00
|
|
|
static NullDevice* s_the;
|
|
|
|
|
|
|
|
NullDevice& NullDevice::the()
|
|
|
|
{
|
|
|
|
ASSERT(s_the);
|
|
|
|
return *s_the;
|
|
|
|
}
|
|
|
|
|
2018-10-14 02:59:22 +02:00
|
|
|
NullDevice::NullDevice()
|
2018-10-30 13:59:29 +01:00
|
|
|
: CharacterDevice(1, 3)
|
2018-10-14 02:59:22 +02:00
|
|
|
{
|
2019-02-12 11:25:25 +01:00
|
|
|
s_the = this;
|
2018-10-14 02:59:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
NullDevice::~NullDevice()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-01-16 00:10:13 +01:00
|
|
|
bool NullDevice::can_read(Process&) const
|
2018-10-25 13:07:59 +02:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-02-25 21:19:57 +01:00
|
|
|
ssize_t NullDevice::read(Process&, byte*, ssize_t)
|
2018-10-14 02:59:22 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-25 21:19:57 +01:00
|
|
|
ssize_t NullDevice::write(Process&, const byte*, ssize_t buffer_size)
|
2018-10-14 02:59:22 +02:00
|
|
|
{
|
2019-02-25 21:19:57 +01:00
|
|
|
return min(GoodBufferSize, buffer_size);
|
2018-10-14 02:59:22 +02:00
|
|
|
}
|
|
|
|
|