[Concept,06/21] linux: buffer_head: Implement map_bh() properly

Message ID 20260416165733.2923423-7-sjg@u-boot.org
State New
Headers
Series fs: Add ISO 9660 filesystem driver ported from Linux |

Commit Message

Simon Glass April 16, 2026, 4:56 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

The map_bh() macro is used by isofs_get_blocks() to record the
physical block number for a mapped buffer head. The current no-op
stub causes isofs_bmap() to return uninitialised block numbers,
leading to reads from invalid disk locations.

Implement map_bh() to set b_blocknr and mark the buffer as mapped.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/linux/buffer_head.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Patch

diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index ea317a6488d..3b829e035aa 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -283,7 +283,8 @@  static inline void end_buffer_read_sync(struct buffer_head *bh, int uptodate)
 #define try_to_free_buffers(f)		({ (void)(f); true; })
 #define block_commit_write(f, f2, t)	do { } while (0)
 #define block_page_mkwrite(v, f, g)	((vm_fault_t)0)
-#define map_bh(bh, sb, block)		do { } while (0)
+#define map_bh(bh, sb, blk) \
+	do { (bh)->b_blocknr = (blk); set_buffer_mapped(bh); } while (0)
 #define block_read_full_folio(folio, get_block) \
 	({ (void)(folio); (void)(get_block); 0; })