From 853eb183d46c1410507c53d19b00c52162592cfc Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 17 Aug 2026 17:52:00 +0200 Subject: kapi: port block_special_file to std::span --- kapi/kapi/filesystem/block_special_file.hpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'kapi') 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 #include +#include 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 buffer) const -> kstd::result = 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 = 0; + auto virtual write_block(std::size_t block_index, std::span buffer) + -> kstd::result = 0; //! Get the block size in bytes. [[nodiscard]] auto virtual block_size() const -> kstd::units::bytes = 0; -- cgit v1.2.3