get_bbt_block(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– get_bbt_block(9) πŸ’–

okay so bestie, we're in the Kernel API Manual today and this one is a little NAND-flash baddie called get_bbt_block. she's lowkey the one who finds you a place to live. let's get into it 🫢


✨ NAME ✨

get_bbt_block β€” get the first valid eraseblock suitable to store a BBT 🌸


✨ SYNOPSIS ✨

int get_bbt_block (struct nand_chip *this , struct nand_bbt_descr *td ,
struct nand_bbt_descr *md , int chip );

✨ ARGUMENTS ✨

  • this β€” the NAND device itself, the main character πŸ’…
  • td β€” the BBT description, aka the vibe info for the BBT
  • md β€” the mirror BBT descriptor (yes girl, she has a mirror version too πŸͺž)
  • chip β€” the CHIP selector, so we know which chip we're talking about

🌈 DESCRIPTION 🌈

so this function returns a positive block number pointing at a valid eraseblock that's suitable to store a BBT β€” meaning it's inside the range reserved for BBT, no cap ✨. if all the blocks are already used or marked bad, she hits you with -ENOSPC and it's giving "no space, sorry bestie" 😭.

and here's the cute part: if td->pages[chip] was already pointing to a valid block, we just re-use it πŸŽ€. she's not gonna do extra work for no reason. otherwise, we go searching for the next valid one, like a little scavenger hunt but for eraseblocks πŸ¦‹β­

ngl, -ENOSPC means everything's taken or marked bad β€” no block for you, and that's just how it is πŸ’€

πŸ’œ SEE ALSO πŸ’œ

Kernel file ./drivers/mtd/nand/raw/nand_bbt.c, plus the whole friend group:

check_pattern(9), check_short_pattern(9), add_marker_len(9), read_bbt(9), read_abs_bbt(9), scan_read_oob(9), read_abs_bbts(9), create_bbt(9), search_bbt(9), search_read_bbts(9), mark_bbt_block_bad(9), write_bbt(9), nand_memory_bbt(9), check_create(9), nand_update_bbt(9), mark_bbt_region(9), verify_bbt_descr(9), nand_scan_bbt(9), nand_create_badblock_pattern(9), nand_create_bbt(9), nand_isreserved_bbt(9), nand_isbad_bbt(9), nand_markbad_bbt(9) πŸ‘‘


and that's the whole page, icon. straight out of ./drivers/mtd/nand/raw, dated October 2026 β€” periodt, go read the source, ily, bye πŸ§šπŸ’–

πŸ“¦ where this page comes from