mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 07:24:58 +00:00
Add basic character device support. Start with null and zero.
This commit is contained in:
parent
fa3b11ac64
commit
93556d6743
14 changed files with 157 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "FileHandle.h"
|
||||
#include "FileSystem.h"
|
||||
#include "CharacterDevice.h"
|
||||
|
||||
FileHandle::FileHandle(RetainPtr<VirtualFileSystem::Node>&& vnode)
|
||||
: m_vnode(std::move(vnode))
|
||||
|
@ -10,8 +11,15 @@ FileHandle::~FileHandle()
|
|||
{
|
||||
}
|
||||
|
||||
ByteBuffer FileHandle::read() const
|
||||
ByteBuffer FileHandle::read()
|
||||
{
|
||||
if (m_vnode->isCharacterDevice()) {
|
||||
auto buffer = ByteBuffer::createUninitialized(1024);
|
||||
ssize_t nread = m_vnode->characterDevice()->read(buffer.pointer(), buffer.size());
|
||||
buffer.trim(nread);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
return m_vnode->fileSystem()->readInode(m_vnode->inode);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue