kernel: Add /dev/full
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-05-27 10:42:45 +02:00
parent b0506bf88f
commit a98e9e8009
Signed by: apio
GPG Key ID: B8A7D06E42258954
4 changed files with 38 additions and 0 deletions

View File

@ -47,6 +47,7 @@ set(SOURCES
src/fs/devices/DeviceRegistry.cpp
src/fs/devices/NullDevice.cpp
src/fs/devices/ZeroDevice.cpp
src/fs/devices/FullDevice.cpp
src/fs/devices/ConsoleDevice.cpp
src/fs/devices/FramebufferDevice.cpp
src/fs/InitRD.cpp

View File

@ -3,6 +3,7 @@
#include "fs/VFS.h"
#include "fs/devices/ConsoleDevice.h"
#include "fs/devices/FramebufferDevice.h"
#include "fs/devices/FullDevice.h"
#include "fs/devices/NullDevice.h"
#include "fs/devices/ZeroDevice.h"
#include "fs/tmpfs/FileSystem.h"
@ -69,6 +70,7 @@ namespace DeviceRegistry
NullDevice::create();
ZeroDevice::create();
FullDevice::create();
ConsoleDevice::create();
FramebufferDevice::create();

View File

@ -0,0 +1,7 @@
#include "fs/devices/FullDevice.h"
Result<void> FullDevice::create()
{
auto device = (SharedPtr<Device>)TRY(make_shared<FullDevice>());
return DeviceRegistry::register_special_device(DeviceRegistry::Memory, 2, device, "full");
}

View File

@ -0,0 +1,28 @@
#pragma once
#include "fs/devices/DeviceRegistry.h"
class FullDevice : public Device
{
public:
// Initializer for DeviceRegistry.
static Result<void> create();
Result<usize> read(u8* buf, usize, usize length) const override
{
__builtin_memset(buf, 0, length);
return length;
}
Result<usize> write(const u8*, usize, usize) override
{
return err(ENOSPC);
}
bool blocking() const override
{
return false;
}
virtual ~FullDevice() = default;
};