STRUCT UBI_AINF_PEB(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ struct ubi_ainf_peb β€” Kernel API Manual ✨

ok so bestie, welcome to the struct ubi_ainf_peb(9) page πŸ’… this is straight out of the Kernel API Manual and honestly it's giving "backstage pass to UBI" energy. let's get into it 🫢


🌸 NAME 🌸

struct ubi_ainf_peb β€” attach information about a physical eraseblock. literally that's the whole vibe, it's the little info-bundle for one PEB while attaching πŸ”₯


πŸŽ€ SYNOPSIS πŸŽ€

struct ubi_ainf_peb {
    int ec;
    int pnum;
    int vol_id;
    int lnum;
    unsigned int scrub:1;
    unsigned int copy_flag:1;
    unsigned long long sqnum;
    union {
      struct rb_node rb;
      struct list_head list;
    } u;
 };

πŸ‘‘ Members πŸ‘‘

here's the whole cast, no cap, every single one πŸ’–

  • ec β€” the erase counter (it's UBI_UNKNOWN if it's, y'know, unknown πŸ™ˆ)
  • pnum β€” the physical eraseblock number
  • vol_id β€” the ID of the volume this LEB belongs to
  • lnum β€” the logical eraseblock number
  • scrub β€” set if this physical eraseblock needs scrubbing 🧚
  • copy_flag β€” this LEB is a copy (the copy_flag is set in the VID header of this LEB, iykyk)
  • sqnum β€” sequence number
  • u β€” a union of the RB-tree or list links ✨
    • u.rb β€” the link in the per-volume RB-tree of struct ubi_ainf_peb objects
    • u.list β€” the link in one of the eraseblock lists

🌈 Description 🌈

okay so the way this works: one object of this type gets allocated for each physical eraseblock when you're attaching an MTD device. main character allocation energy 😭

⭐ lowkey important note: if this PEB doesn't belong to any LEB / volume, then the vol_id and lnum fields get initialized to UBI_UNKNOWN. fr fr, don't forget that.

πŸ’œ SEE ALSO πŸ’œ

Kernel file ./drivers/mtd/ubi/ubi.h plus the whole friend group πŸ’…:

struct ubi_vid_io_buf(9), struct ubi_wl_entry(9), struct ubi_ltree_entry(9), struct ubi_rename_entry(9), struct ubi_fastmap_layout(9), struct ubi_fm_pool(9), struct ubi_eba_leb_desc(9), struct ubi_volume(9), struct ubi_volume_desc(9), struct ubi_debug_info(9), struct ubi_device(9), struct ubi_ainf_volume(9), struct ubi_attach_info(9), struct ubi_work(9), ubi_init_vid_buf(9), ubi_free_vid_buf(9), ubi_get_vid_hdr(9), ubi_ro_mode(9), vol_id2idx(9), idx2vol_id(9), ubi_is_fm_vol(9), ubi_find_fm_block(9)


and that's the page bestie!! πŸ¦‹ source is ./drivers/mtd/ubi, dated October 2026 β€” iconic, slay, periodt πŸ’–βœ¨ no thoughts just eraseblocks πŸ“

πŸ“¦ where this page comes from