ubi_leb_write(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– 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 to
  • buf β€” data to write
  • offset β€” offset within the logical eraseblock where to write
  • len β€” 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:


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