ida_alloc_range(9)
π ida_alloc_range(9) β a Kernel API Manual moment π
okay bestie, welcome to the Kernel API Manual, and today's main character is ida_alloc_range β¨ she's literally here to hand you an unused ID and she eats every time π
πΈ NAME πΈ
ida_alloc_range β allocate an unused ID, no cap π«Ά
π¦ SYNOPSIS π¦
int ida_alloc_range (struct ida *ida , unsigned int min , unsigned int max , gfp_t gfp );
π ARGUMENTS π
idaβ your IDA handle, like her little backstage pass πminβ the lowest ID to allocate, the floor, the bare minimum, periodtmaxβ the highest ID to allocate, the ceiling, the limit, the "don't even try it" β¨gfpβ memory allocation flags, the whole vibe check for how memory gets grabbed π§
π DESCRIPTION π
So here's the tea: this function allocates an ID between min and max, inclusive β both ends are invited to the party π The allocated ID will not exceed INT_MAX, even if max is larger. Like, she said "I'm not going past INT_MAX, bestie, don't test me" π
π CONTEXT π
Any context. It is safe to call this function without locking in your code, so you can literally just call her β no lock needed, no stress, main character energy only πβ¨
β RETURN β
- The allocated ID β slay, you got one π
-ENOMEMif memory could not be allocated π-ENOSPCif there are no free IDs π
π₯ SEE ALSO π₯
Kernel file ./lib/idr.c β and the whole friend group:
idr_alloc_u32(9)idr_alloc(9)idr_alloc_cyclic(9)idr_remove(9)idr_find(9)idr_for_each(9)idr_get_next_ul(9)idr_get_next(9)idr_replace(9)IDA description(9)ida_find_first_range(9)ida_free(9)ida_destroy(9)
lowkey if you're out here allocating IDs, remember:minandmaxare inclusive, andINT_MAXis the final boss you cannot pass π«Ά
mwah π huge kiss to ./lib for bringing us this iconic function, dated October 2026 β catch you in the next manpage, 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