ubi_compare_lebs(9)
π 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 thestruct ubi_ainf_pebbaddie.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'sconst, 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 bypnumandvid_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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms