STRUCT MTD_OOB_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct mtd_oob_ops(9) β€” the Kernel API Manual, bestie edition

okay so picture this: you're poking at the MTD layer and you need a little struct to carry your OOB operands around. that's literally her. <pink>struct mtd_oob_ops</pink> is the oob operation operands and she is carrying everything for the trip πŸŽ€

She lives in ./include/linux/mtd and she's giving October 2026 energy, but we'll get to that at the end, mwah πŸ’‹


✨ SYNOPSIS ✨

here she is in all her glory, no notes, copy her exactly bestie:

struct mtd_oob_ops {
    unsigned int    mode;
    size_t len;
    size_t retlen;
    size_t ooblen;
    size_t oobretlen;
    uint32_t ooboffs;
    uint8_t *datbuf;
    uint8_t *oobbuf;
    struct mtd_req_stats *stats;
 };

she's got nine members and honestly? main character energy 🌟


🌸 Members 🌸

okay let's go member by member, i gotchu:

  • mode β€” the operation mode, i.e. what vibe are we on today πŸ’«
  • len β€” how many data bytes you wanna write/read. the data budget fr
  • retlen β€” how many data bytes actually got written/read. the receipts 🧾
  • ooblen β€” how many OOB bytes you wanna write/read
  • oobretlen β€” how many OOB bytes actually got written/read
  • ooboffs β€” the offset of the oob data inside the oob area. ⚠️ highkey important: this only matters when mode = MTD_OPS_PLACE_OOB or MTD_OPS_RAW, so don't come for her otherwise πŸ™ˆ
  • datbuf β€” the data buffer. and like, plot twist: if it's NULL, then only oob data are read/written. iconic behaviour honestly
  • oobbuf β€” the oob data buffer, the oob-est buffer of them all πŸ¦‹
  • stats β€” she's right there in the struct, chillin'. the page literally does not describe her, so i'm not gonna make something up. we respect the mystery πŸ’œ

🫢 Description 🫢

so here's the tea, and please actually listen because this is the part that bites people 😭

not every MTD driver is gonna let you write more than one OOB area at one go. that's just not the vibe some drivers are on. and if you try it anyway on one of those MTD devices? she will hit you with <red>-EINVAL</red>. straight up. no negotiation, no warning shot πŸ’€

so if you want your implementation to be portable on all kinds of MTD devices, you gotta split that write request into several sub-requests when the request crosses a page boundary. yes, it's extra work. no, there's no shortcut. periodt πŸ‘‘

⭐ SEE ALSO ⭐

go read these next, bestie, they're all under the Kernel file ./include/linux/mtd/mtd.h umbrella:

  • struct mtd_oob_region(9)
  • struct mtd_pairing_info(9)
  • struct mtd_pairing_scheme(9)
  • struct mtd_debug_info(9)
  • struct mtd_part(9)
  • struct mtd_master(9)
  • mtd_align_erase_req(9)

and that's the whole page, no crumbs left πŸ“

kisses, this was struct mtd_oob_ops(9) from ./include/linux/mtd, dated October 2026 β€” go slay your OOB writes, and remember: split those sub-requests before a page boundary ruins your whole day πŸ’–βœ¨

πŸ“¦ where this page comes from