ubi_io_read(9)
π ubi_io_read(9) β bestie edition
ok so you found yourself in the ubi_io_read(9) page of the Kernel API Manual and you're like "what is this" β don't worry, I gotchu. this is genuinely one of the cutest little read functions in the UBI corner of the kernel, and we're gonna get through it together π«Ά
β¨ NAME β¨
ubi_io_read β read data from a physical eraseblock. that's it. that's the vibe. πΈ
π SYNOPSIS π
int ubi_io_read (const struct ubi_device *ubi , void *buf , int pnum ,
int offset , int len );
look at that signature. five args. she's lowkey kinda elegant ngl π
π¦ ARGUMENTS π¦
ubiβ the UBI device description object. like, the whole device's little ID card πͺͺbufβ the buffer where we're gonna store the data we read. this is the destination, the moment, the main character πpnumβ the physical eraseblock number we're reading from. which PEB we're visiting today πoffsetβ the offset within that physical eraseblock where the reading starts. so pnum says "which block" and offset says "where inside it" β iconic teamwork fr fr β¨lenβ how many bytes to read. the amount. the quantity. the length bestie π
π DESCRIPTION π
okay so here's the tea: this function reads data from offset (that's the offset offset inside physical eraseblock pnum) and it puts everything it read into the buf buffer. simple as that, no cap.
but the return codes are where it gets juicy, and you literally need to know all of them, so let's go through them one by one π
0β slay π all the requested data was successfully read. perfect. flawless. no notes.UBI_IO_BITFLIPSβ okay so all the requested data WAS successfully read, but correctable bit-flips were detected. and bestie, listen: this is harmless β but it may mean this eraseblock could become bad soon (emphasis on may though, it does not have to happen, so don't spiral π). think of it as a little "hmm π" from your flash.-EBADMSGβ the MTD subsystem reported data integrity problems. for example it can be an ECC error in case of NAND. this most probably means the data is corrupted π so like, not a vibe.-EIOβ some I/O error occurred. the hardware said "no β€οΈ" π- other negative error codes β in case of other errors. yes, that's the whole description. sometimes life just hands you an unspecified negative integer π«
ngl the difference between0andUBI_IO_BITFLIPSmatters β both mean your data arrived intact, but one of them is your eraseblock subtly telling you to keep an eye on it β¨
π SEE ALSO π
the source lives in the kernel file ./drivers/mtd/ubi/io.c, and here's the whole friend group β go say hi to all of them:
ubi_io_write(9)do_sync_erase(9)torture_peb(9)nor_erase_prepare(9)ubi_io_sync_erase(9)ubi_io_is_bad(9)ubi_io_mark_bad(9)validate_ec_hdr(9)ubi_io_read_ec_hdr(9)ubi_io_write_ec_hdr(9)validate_vid_hdr(9)ubi_io_read_vid_hdr(9)ubi_io_write_vid_hdr(9)self_check_not_bad(9)self_check_ec_hdr(9)self_check_peb_ec_hdr(9)self_check_vid_hdr(9)self_check_peb_vid_hdr(9)self_check_write(9)ubi_self_check_all_ff(9)
and that's the whole page, bestie, you ate that π quick sign-off before you go: this one lives under ./drivers/mtd/ubi, dated October 2026, and honestly? she's iconic. now go read some eraseblocks responsibly πβ¨
π¦ 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