write_leb(9)
πΈ NAME πΈ
okay bestie, welcome to the write_leb(9) page from the Kernel API Manual β this is literally all about write_leb, which writes update data. no cap. π
β¨ SYNOPSIS β¨
here's the exact signature, copied with love and zero edits:
int write_leb (struct ubi_device *ubi , struct ubi_volume *vol , int
lnum , void *buf , int len , int used_ebs );
π«Ά ARGUMENTS π«Ά
ubiβ UBI device description object. iconic.volβ volume description object. also iconic.lnumβ logical eraseblock number. remember it. πbufβ data to write. the actual goods.lenβ data size. yes, the length.used_ebsβ how many logical eraseblocks will this volume contain (static volumes only). static volumes only, okay? π
π DESCRIPTION π
Okay so write_leb writes update data to the corresponding logical eraseblock. Main character behavior: in the case of a dynamic volume, this function checks if the data contains 0xFF bytes at the end. If yes, the 0xFF bytes are cut and not written. So if the whole buffer contains only 0xFF bytes, the LEB is left unmapped. π
Why skip the trailing 0xFF bytes in the dynamic-volume case? Because we want to make sure that more data may be appended to the logical eraseblock in future. Indeed, writing 0xFF bytes may have side effects and this PEB won't be writable anymore. So if one writes the file-system image to the UBI volume where 0xFFs mean free space β UBI makes sure this free space is writable after the update. π¦
We do not do this for static volumes because they are read-only. But this also cannot be done because we have to store per-LEB CRC and the correct data length. periodt. π
This function returns zero in case of success and a negative error code in case of failure. Do not ignore that negative error code, bestie. π
π₯ SEE ALSO π₯
- Kernel file
./drivers/mtd/ubi/upd.c:set_update_marker(9),clear_update_marker(9),ubi_start_update(9),ubi_start_leb_change(9),ubi_more_update_data(9),ubi_more_leb_change_data(9). Go read those next, iykyk. π
π§ sign-off: source/version ./drivers/mtd/ubi, dated October 2026, page write_leb(9) β bye bestie! π
π¦ 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