Kernel: Convert the DiskBackedFS write API to take "const u8*"

This way clients are not required to have instantiated ByteBuffers
and can choose whatever memory scheme works best for them.

Also converted some of the Ext2FS code to use stack buffers instead.
This commit is contained in:
Andreas Kling 2019-09-30 11:20:51 +02:00
commit 922fd703c9
Notes: sideshowbarker 2024-07-19 11:52:41 +09:00
4 changed files with 29 additions and 32 deletions

View file

@ -81,15 +81,13 @@ DiskBackedFS::~DiskBackedFS()
{
}
bool DiskBackedFS::write_block(unsigned index, const ByteBuffer& data)
bool DiskBackedFS::write_block(unsigned index, const u8* data)
{
#ifdef DBFS_DEBUG
kprintf("DiskBackedFileSystem::write_block %u, size=%u\n", index, data.size());
#endif
ASSERT(data.size() == block_size());
auto& entry = cache().get(index);
memcpy(entry.data, data.data(), data.size());
memcpy(entry.data, data, block_size());
entry.is_dirty = true;
entry.has_data = true;
@ -97,13 +95,13 @@ bool DiskBackedFS::write_block(unsigned index, const ByteBuffer& data)
return true;
}
bool DiskBackedFS::write_blocks(unsigned index, unsigned count, const ByteBuffer& data)
bool DiskBackedFS::write_blocks(unsigned index, unsigned count, const u8* data)
{
#ifdef DBFS_DEBUG
kprintf("DiskBackedFileSystem::write_blocks %u x%u\n", index, count);
#endif
for (unsigned i = 0; i < count; ++i)
write_block(index + i, data.slice(i * block_size(), block_size()));
write_block(index + i, data + i * block_size());
return true;
}