add_to_list(9)
π add_to_list(9) π
okay so welcome to the Kernel API Manual, section 9, bestie β this is the add_to_list page and honestly it's giving "tiny function, big responsibility" energy. let's get into it π«Ά
β¨ NAME β¨
add_to_list β add physical eraseblock to a list. that's it, that's the whole vibe π
π SYNOPSIS π
int add_to_list (struct ubi_attach_info *ai , int pnum , int vol_id ,
int lnum , int ec , int to_head , struct list_head *list );
like look at all those arguments. she's thorough. she has range π₯
πΈ ARGUMENTS πΈ
aiβ the attaching information. the main-character struct of this whole operation πpnumβ the physical eraseblock number you want to add. this is literally the PEB in question π―vol_idβ the last used volume id for the PEBlnumβ the last used LEB number for the PEBecβ the erase counter of the physical eraseblock. keeping track of wear, iconic behaviour βto_headβ if it's not zero, the PEB gets added to the head of the list instead of wherever. queue-jumping, but make it intentional πlistβ the list to add to. pick your girl, she's going on one of them π
π¦ DESCRIPTION π¦
so what this function actually does: it allocates a struct ubi_ainf_peb object for the physical eraseblock pnum and adds it to one of the "free", "erase", or "alien" lists. yes, those are the real names, and yes, the "alien" list is exactly as mysterious as it sounds π
it also stores lnum and vol_id alongside β and both of those can be UBI_UNKNOWN if they're not available, not readable, or not assigned. no info? no problem, she still files it π
now for to_head. if it's not zero, the PEB goes to the head of the list, which basically means it gets processed first later. and there's a genuinely good reason for that, bestie: corrupted PEBs (corrupted due to power cuts, the classic π) get added to the head of the erase list so we erase them first and get rid of the corruption ASAP. priority queue of problems. we love a proactive queen β‘
return value: zero on success, a negative error code on failure. periodt. β¨
π«Ά SEE ALSO π«Ά
Kernel file ./drivers/mtd/ubi/attach.c, plus the whole friend group (fr fr, this is a big friend group):
find_or_add_av(9)ubi_find_or_add_av(9)ubi_alloc_aeb(9)ubi_free_aeb(9)add_corrupted(9)add_fastmap(9)validate_vid_hdr(9)add_volume(9)ubi_compare_lebs(9)ubi_add_to_av(9)ubi_add_av(9)ubi_find_av(9)ubi_remove_av(9)early_erase_peb(9)ubi_early_get_peb(9)check_corruption(9)scan_peb(9)late_analysis(9)destroy_av(9)destroy_ai(9)scan_all(9)scan_fast(9)ubi_attach(9)self_check_ai(9)
aaaand that's the page!! mwah π this one lives in ./drivers/mtd/ubi, it's tagged October 2026, and it is β say it with me β add_to_list(9). go read the other 20-something pages now, i believe in you π§ββοΈπ
π¦ 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