This commit is contained in:
parent
b0506bf88f
commit
a98e9e8009
@ -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
|
||||
|
@ -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();
|
||||
|
||||
|
7
kernel/src/fs/devices/FullDevice.cpp
Normal file
7
kernel/src/fs/devices/FullDevice.cpp
Normal 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");
|
||||
}
|
28
kernel/src/fs/devices/FullDevice.h
Normal file
28
kernel/src/fs/devices/FullDevice.h
Normal 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;
|
||||
};
|
Loading…
Reference in New Issue
Block a user