}
-
size_t kblock_read(struct KBlock *b, block_idx_t idx, void *buf, size_t offset, size_t size)
{
ASSERT(b);
}
+int kblock_trim(struct KBlock *b, block_idx_t start, block_idx_t count)
+{
+ ASSERT(start + count <= b->blk_cnt);
+
+ if (!kblock_loadPage(b, start))
+ return EOF;
+
+ b->priv.blk_start += start;
+ b->priv.curr_blk = 0; // adjust logical address
+ b->blk_cnt = count;
+ return 0;
+}
+
+
size_t kblock_write(struct KBlock *b, block_idx_t idx, const void *buf, size_t offset, size_t size)
{
ASSERT(b);
* \param start The index of the start block for the limiting window in logical addressing units.
* \param count The number of blocks to be used.
*
+ * \return 0 if all is OK, EOF on errors.
*/
-INLINE void kblock_trim(struct KBlock *b, block_idx_t start, block_idx_t count)
-{
- ASSERT(start + count <= b->blk_cnt);
- b->priv.blk_start += start;
- b->blk_cnt = count;
-}
+int kblock_trim(struct KBlock *b, block_idx_t start, block_idx_t count);
#define KB_ASSERT_METHOD(b, method) \