ubi_leb_write(9)
π ubi_leb_write(9) π
okay so we're in the Kernel API Manual, bestie, and this is the page for ubi_leb_write(9) β the write function for UBI logical eraseblocks. Let's get into it π
β¨ NAME β¨
ubi_leb_write β write data.
π SYNOPSIS π
int ubi_leb_write (struct ubi_volume_desc *desc , int lnum , const void
*buf , int offset , int len );
πΈ ARGUMENTS πΈ
descβ volume descriptor (your little handle to the volume)lnumβ logical eraseblock number to write tobufβ data to writeoffsetβ offset within the logical eraseblock where to writelenβ how many bytes to write
π¦ DESCRIPTION π¦
Okay so picture this: this function writes len bytes of data from buf to offset offset of logical eraseblock lnum. Literally just drops your bytes where they belong.
And it's not messy about it β it takes care of physical eraseblock write failures. If a write to the physical eraseblock fails, UBI re-maps the logical eraseblock to another physical eraseblock, recovers the data, and the write finishes. UBI keeps a pool of reserved physical eraseblocks for exactly this situation. No cap, that's iconic.
If all the data were successfully written, you get zero back. If an error occurred and UBI has not been able to recover from it, this function returns a negative error code.
β οΈ Note that in case of an error, it is possible that something was still written to the flash media β but that may be some garbage. So yeah, not guaranteed clean. π
If the volume is damaged because of an interrupted update, this function just returns immediately with -EBADF. Like it's not even gonna try, bestie.
π SEE ALSO π
The kernel file is ./drivers/mtd/ubi/kapi.c, and here are the related besties:
ubi_do_get_device_info(9)ubi_get_device_info(9)ubi_do_get_volume_info(9)ubi_get_volume_info(9)ubi_open_volume(9)ubi_open_volume_nm(9)ubi_get_num_by_path(9)ubi_open_volume_path(9)ubi_close_volume(9)leb_read_sanity_check(9)ubi_leb_read(9)ubi_leb_read_sg(9)ubi_leb_erase(9)ubi_leb_unmap(9)ubi_leb_map(9)ubi_is_mapped(9)ubi_sync(9)ubi_register_volume_notifier(9)ubi_unregister_volume_notifier(9)
and that's the page! π source: ./drivers/mtd/ubi Β· date/version: October 2026 Β· page: ubi_leb_write(9) β slay, go write some data 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