+
+/**
+ * \return The current cached block number if the device is buffered.
+ * \param b KBlock device.
+ * \note This function will throw an ASSERT if called on a non buffered KBlock.
+ * \sa kblock_buffered(), kblock_cacheDirty().
+ */
+INLINE block_idx_t kblock_cachedBlock(struct KBlock *b)
+{
+ ASSERT(kblock_buffered(b));
+ return b->priv.curr_blk;
+}
+
+
+/**
+ * Return the status of the internal cache.
+ *
+ * \param b KBlock device.
+ * \return If the device supports buffering, returns true if the cache is dirty,
+ * false if the cache is clean and coherent with device content.
+ * \note This function will throw an ASSERT if called on a non buffered KBlock.
+ * \sa kblock_cachedBlock(), kblock_buffered().
+ */
+INLINE bool kblock_cacheDirty(struct KBlock *b)
+{
+ ASSERT(kblock_buffered(b));
+ return kblock_buffered(b) && (b->priv.flags & KB_CACHE_DIRTY);
+}
+
+/**
+ * \return true if the device \a b supports partial block write. That is, you
+ * can call kblock_write() with a size which is lesser than the block
+ * size.
+ * \param b KBlock device.
+ * \sa kblock_write().
+ */
+INLINE bool kblock_partialWrite(struct KBlock *b)
+{
+ ASSERT(b);
+ return (b->priv.flags & KB_PARTIAL_WRITE);
+}
+
+/**
+ * Read data from the block device.
+ *
+ * This function will read \a size bytes from block \a idx starting at
+ * address \a offset inside the block.
+ *
+ * Most block devices (almost all flash memories, for instance),
+ * can efficiently read even a part of the block.
+ *
+ * \note This function can be slow if you try to partial read a block from
+ * a device which does not support partial block reads and is opened
+ * in unbuffered mode.
+ *
+ * \param b KBlock device.
+ * \param idx the block number where you want to read.
+ * \param buf a buffer where the data will be read.
+ * \param offset the offset inside the block from which data reading will start.
+ * \param size the size of data to be read.
+ *
+ * \return the number of bytes read.
+ *
+ * \sa kblock_write().
+ */