aboutsummaryrefslogtreecommitdiff
path: root/kapi
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-08-17 17:52:00 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-08-17 17:52:00 +0200
commit853eb183d46c1410507c53d19b00c52162592cfc (patch)
tree84a96082d3eb54be3c7c0b97859001b0a83c4833 /kapi
parent62f66862047e56656476e7590f83082477d1bcd9 (diff)
downloadkernel-853eb183d46c1410507c53d19b00c52162592cfc.tar.xz
kernel-853eb183d46c1410507c53d19b00c52162592cfc.zip
kapi: port block_special_file to std::span
Diffstat (limited to 'kapi')
-rw-r--r--kapi/kapi/filesystem/block_special_file.hpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/kapi/kapi/filesystem/block_special_file.hpp b/kapi/kapi/filesystem/block_special_file.hpp
index 0e44fe35..ada1edf2 100644
--- a/kapi/kapi/filesystem/block_special_file.hpp
+++ b/kapi/kapi/filesystem/block_special_file.hpp
@@ -9,6 +9,7 @@
#include <kstd/units.hpp>
#include <cstddef>
+#include <span>
namespace kapi::filesystem
{
@@ -22,22 +23,28 @@ namespace kapi::filesystem
//! Read data from a block into a given buffer.
//!
- //! If the selected block is smaller than the buffer, a partial read will occur.
+ //! A partial read occurs if either the block size is smaller than the provided buffer, or the provided buffer is
+ //! smaller than the block size. In the first case, the bytes of the buffer beyond the block size will remain
+ //! untouched.
//!
//! @param block_index The number of the block to read from.
//! @param buffer The buffer to read into.
//! @return The number of bytes read on success, an error otherwise.
- [[nodiscard]] auto virtual read_block(size_t block_index, void * buffer) const
+ [[nodiscard]] auto virtual read_block(size_t block_index, std::span<std::byte> buffer) const
-> kstd::result<kstd::units::bytes> = 0;
//! Write data from a buffer into a block.
//!
- //! If the buffer is larger than the selected block, a partial write will occur.
+ //! A partial write occurs if either the block size if smaller than the provided buffer, or the provided buffer is
+ //! smaller than the block size. In the first case, the bytes of the buffer beyond the block size are ignored and
+ //! not written to the device. In the second case, the bytes of the block beyond the buffer size will remain
+ //! untouched.
//!
//! @param block_index The number of the block to write to.
//! @param buffer The buffer to write from.
//! @return The number of bytes written on success, an error otherwise.
- auto virtual write_block(std::size_t block_index, void const * buffer) -> kstd::result<kstd::units::bytes> = 0;
+ auto virtual write_block(std::size_t block_index, std::span<std::byte const> buffer)
+ -> kstd::result<kstd::units::bytes> = 0;
//! Get the block size in bytes.
[[nodiscard]] auto virtual block_size() const -> kstd::units::bytes = 0;