ubi_io_write(9)
π ubi_io_write(9) π
okay so bestie, welcome to the Kernel API Manual β this is the page for ubi_io_write(9), and honestly? it's giving "tiny function, big responsibility." let's get into it β¨
β¨ NAME β¨
ubi_io_write β write data to a physical eraseblock. that's it. that's the whole vibe. π
πΈ SYNOPSIS πΈ
int ubi_io_write (struct ubi_device *ubi , const void *buf , int pnum ,
int offset , int len );
literally just five things and a return type, no cap π«Ά
π¦ ARGUMENTS π¦
ubiβ the UBI device description object. the whole main character of this operation tbh πbufβ buffer with the data to write. this is the stuff you're sending out into the world πpnumβ physical eraseblock number to write to. yes, the actual one you're targeting, not a vibe πoffsetβ offset within the physical eraseblock where to write. like, where inside the block. precision matters bestie π―lenβ how many bytes to write. the length. the amount. thelen. π
π₯ DESCRIPTION π₯
so this function writes len bytes of data from buffer buf to offset offset of physical eraseblock pnum. that's the whole thing β write, bytes, offset, block. slay.
if all the data were successfully written, zero is returned. yes, 0 = we ate. π
if an error occurred, this function returns a negative error code instead. and here's the part where you gotta pay attention:
if -EIO is returned, the physical eraseblock most probably went bad. π like, it's cooked. it's not okay. it's giving hardware betrayal. ngl, that's a bad sign.
and also, one more thing that's genuinely important to know:
note, in case of an error, it is possible that something was still written to the flash media, but may be some garbage. π so like. the write failed but the flash still has... something. maybe. garbage. not your data, not useful data β garbage. this is the "we tried but the vibes were off" scenario, fr fr.
β SEE ALSO β
the whole friend group π (kernel file ./drivers/mtd/ubi/io.c is where they all live, btw):
ubi_io_read(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)
aaaand that's the page!! π§β¨ cute sign-off time: this one lives in ./drivers/mtd/ubi and it's dated October 2026 β so go forth, write your bytes, check for -EIO, and don't trust a bad eraseblock. mwah ππ
π¦ 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