ubi_compare_lebs(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… ubi_compare_lebs β€” like, the kernel API manual, but make it make sense

okay so bestie, today we're learning about ubi_compare_lebs from the kernel API manual. yes it's a mouthful, no you're not gonna be weird about it. it's literally just "which of these two eraseblocks is the newer one" energy and honestly? iconic. πŸ¦‹


✨ NAME ✨

ubi_compare_lebs β€” find out which logical eraseblock is newer.

like a vibe check but for LEBs. no cap.


🌸 SYNOPSIS 🌸

int ubi_compare_lebs (struct ubi_device *ubi , const struct ubi_ainf_peb
*aeb , int pnum , const struct ubi_vid_hdr *vid_hdr );

that's the whole signature, copy it exactly, don't @ me πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • ubi β€” the UBI device description object. it's giving "the whole situation" energy.
  • aeb β€” the first logical eraseblock you wanna compare. this one's the struct ubi_ainf_peb baddie.
  • pnum β€” the physical eraseblock number of the second logical eraseblock in this little showdown.
  • vid_hdr β€” the volume identifier header of that second logical eraseblock. yes it's const, yes it's slaying.

🧚 DESCRIPTION 🧚

okay so here's the tea: this function compares 2 copies of a LEB and tells you which one is newer. periodt.

If it works? you get a positive value back. If it fails? negative error code, sadly. 😭

Now the success return codes are giving bitmask realness, so let's break it down bit by bit, iykyk:

  • bit 0 cleared β€” the first PEB (the one described by aeb) is newer than the second PEB (the one described by pnum and vid_hdr).
  • bit 0 set β€” the second PEB is the newer one. she's fresh. ✨
  • bit 1 cleared β€” no bit-flips were detected in the newer LEB. clean. flawless. no notes.
  • bit 1 set β€” bit-flips were detected in the newer LEB. uh oh πŸ’€
  • bit 2 cleared β€” the older LEB is not corrupted. okay she's fine.
  • bit 2 set β€” the older LEB is corrupted. not fine. sending thoughts and prayers 🫢
fr fr, read those bits carefully β€” bit 0 is the "who's newer" bit, bit 1 is the "the newer one has bit-flips" bit, and bit 2 is the "the older one is corrupted" bit. don't mix them up, bestie.

πŸ‘‘ SEE ALSO πŸ‘‘

if you liked this one, you're gonna love the rest of the lineup. these all live in the kernel file ./drivers/mtd/ubi/attach.c:

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_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), scan_peb(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 the whole squad, go say hi 🌈


and that's the page, bestie! πŸŽ€ this one comes to you from ./drivers/mtd/ubi, dated October 2026 β€” go off, you absolutely ate. πŸ’–πŸ”₯

πŸ“¦ where this page comes from