scan_peb(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… scan_peb(9) β€” like, the whole kernel API manual page, but make it make sense

okay bestie, gather round, because today we're reading a page from the Kernel API Manual and honestly? it's kind of a bop. it's called scan_peb and it does exactly one thing but it does it iconically. no cap. πŸŽ€


✨ NAME ✨

scan_peb β€” scan and process UBI headers of a PEB.

like, that's it. that's the whole vibe. it scans, it processes, it handles its business. πŸ¦‹


✨ SYNOPSIS ✨

int scan_peb (struct ubi_device *ubi , struct ubi_attach_info *ai , int
pnum , bool fast );

look at that signature. four arguments, one int return, zero notes. she's busy, she's booked, she's got a job to do. πŸ”₯


✨ ARGUMENTS ✨

  • ubi β€” the UBI device description object. this is the main character of the whole situation, the device we're talking about. πŸ‘‘
  • ai β€” the attaching information. yes, that's the "attaching info" structure you'll be hearing about again in like two seconds. keep her in mind. πŸ’œ
  • pnum β€” the physical eraseblock number. which PEB are we scanning? this one. literally this one. πŸ“
  • fast β€” a bool, and it's true if we're scanning for a Fastmap. so if you're in fastmap mode, this is your girl. ⭐

✨ DESCRIPTION ✨

okay so here's what actually happens, and pay attention because this is the whole plot:

this function reads the UBI headers of PEB pnum, checks them, and then adds information about this PEB to the corresponding list or RB-tree in the "attaching info" structure. 🫢

that's the tea. read headers β†’ check headers β†’ file the info away in the right list or RB-tree inside ai. very organized, very demure, very "everything in its place."

as for what it gives back:

  • it returns zero if the physical eraseblock was successfully handled πŸŽ€
  • and a negative error code in case of failure 😭
ngl bestie, always check that return value. zero = slay, negative = we have a problem. fr fr.

✨ SEE ALSO ✨

the kernel file lives at ./drivers/mtd/ubi/attach.c, and here's the whole friend group β€” every single one of them, no gatekeeping:

find_or_add_av(9), ubi_find_or_add_av(9), ubi_alloc_aeb(9), ubi_free_aeb(9), add_to_list(9), add_corrupted(9), add_fastmap(9), validate_vid_hdr(9), add_volume(9), ubi_compare_lebs(9), ubi_add_to_av(9), ubi_add_av(9), ubi_find_av(9), ubi_remove_av(9), early_erase_peb(9), ubi_early_get_peb(9), check_corruption(9), late_analysis(9), destroy_av(9), destroy_ai(9), scan_all(9), scan_fast(9), ubi_attach(9), self_check_ai(9)

that's twenty-three functions. twenty-three! we ate. πŸ’…


anyway, that's the page babes. it shipped from ./drivers/mtd/ubi and it's dated October 2026, so like, mark your calendar. periodt. πŸŒΈπŸ’–

πŸ“¦ where this page comes from