find_or_add_av(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ find_or_add_av(9) ✨

okay so bestie, we're deep in the Kernel API Manual today and this one is literally called find_or_add_av β€” the internal function that finds a volume, adds a volume, or does both (find and add if missing). multi-talented icon behaviour fr fr πŸ’…


🌸 SYNOPSIS 🌸

struct ubi_ainf_volume * find_or_add_av (struct ubi_attach_info *ai ,
int vol_id , unsigned int flags , bool *created );

that's the whole vibe check right there πŸ¦‹


πŸ’– ARGUMENTS πŸ’–

  • ai β€” the attaching information. like, the whole context of what we're attaching. πŸŽ€
  • vol_id β€” the volume ID you're asking for. the one you want. the main character. πŸ‘‘
  • flags β€” a combination of the AV_FIND and AV_ADD flags, and they describe the expected operation. this is the important part so pay attention bestie 😭
    • If only AV_ADD is set, -EEXIST is returned if the volume already exists.
    • If only AV_FIND is set, NULL is returned if the volume does not exist.
    • And if both flags are set, the helper first tries to find an existing volume, and if it does not exist it creates a new one. two-for-one combo, we love to see it ✨
  • created β€” an in value used to inform the caller whether it's a newly created volume or not. so like, "hey, was this fresh out the oven or already here?" πŸ“

πŸ¦‹ DESCRIPTION πŸ¦‹

This function returns a pointer to a volume description β€” or an ERR_PTR if the operation failed. 😭

It can also return NULL if only AV_FIND is set and the volume does not exist. no cap, that's a whole three-way exit situation, so check your returns properly πŸ™ˆ


πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./drivers/mtd/ubi/attach.c plus the whole friend group:


πŸ’€ reminder bestie: this lives in ./drivers/mtd/ubi and it's the October 2026 edition of the page. go off, read the source, slay πŸ’œ

mwah πŸ’– thanks for reading my ted talk, now go call find_or_add_av responsibly 🧚

πŸ“¦ where this page comes from