1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 07:05:07 +00:00
serenity/Kernel/Devices/NullDevice.cpp
Andreas Kling 8cbb7f101f Kernel: Have File virtuals take a FileDescriptor& rather than a Process&.
This will allow us to implement different behaviors depending on the role
of the descriptor a File is being accessed through.
2019-04-29 13:58:40 +02:00

37 lines
554 B
C++

#include "NullDevice.h"
#include <AK/StdLibExtras.h>
#include <AK/kstdio.h>
static NullDevice* s_the;
NullDevice& NullDevice::the()
{
ASSERT(s_the);
return *s_the;
}
NullDevice::NullDevice()
: CharacterDevice(1, 3)
{
s_the = this;
}
NullDevice::~NullDevice()
{
}
bool NullDevice::can_read(FileDescriptor&) const
{
return true;
}
ssize_t NullDevice::read(FileDescriptor&, byte*, ssize_t)
{
return 0;
}
ssize_t NullDevice::write(FileDescriptor&, const byte*, ssize_t buffer_size)
{
return min(PAGE_SIZE, buffer_size);
}