sg_nents_for_len(9)
β¨ sg_nents_for_len(9) β¨
Okay so bestie, welcome to the sg_nents_for_len(9) page from the Kernel API Manual β yes that's the manual name, yes it's a mouthful, no we're not skipping it π
This little function is genuinely iconic if you're doing scatterlist math, so let's get into it.
πΈ NAME πΈ
sg_nents_for_len β returns the total count of entries in a scatterlist that you need to satisfy the length you supplied π
π¦ SYNOPSIS π¦
int sg_nents_for_len (struct scatterlist *sg , u64 len );
β ARGUMENTS β
sgβ the scatterlist itself, your main character π«Άlenβ the total required length, like the amount of stuff you're trying to fit
π DESCRIPTION π
So what this does: it figures out the number of entries in sg that are required to meet the supplied length β and lowkey the important part is that it takes chaining into account as well. No cap, chaining is included in the vibe check π
π₯ RETURN π₯
It hands you back the number of sg entries needed β¨ β and if something goes wrong you get a negative error on failure. So like, negative = bad vibes, check it π
π SEE ALSO π
Kernel file ./lib/scatterlist.c β and honestly the whole scatterlist friend group showed up, so here they all are:
sg_nents(9)sg_nents_for_dma(9)sg_last(9)sg_init_table(9)sg_init_one(9)__sg_free_table(9)sg_free_append_table(9)sg_free_table(9)__sg_alloc_table(9)sg_alloc_table(9)sg_alloc_append_table_from_pages(9)sg_alloc_table_from_pages_segment(9)sgl_alloc_order(9)sgl_alloc(9)sgl_free_n_order(9)sgl_free_order(9)sgl_free(9)sg_miter_start(9)sg_miter_skip(9)sg_miter_next(9)sg_miter_stop(9)sg_copy_buffer(9)sg_copy_from_buffer(9)sg_copy_to_buffer(9)sg_pcopy_from_buffer(9)sg_pcopy_to_buffer(9)sg_zero_buffer(9)extract_iter_to_sg(9)
Ok that's the whole page bestie, nothing skipped, every flag and reference intact β go forth and count your sg entries π
Big kiss, this page lived in ./lib and it's dated October 2026 β so it's basically a time traveler and we stan π§β¨
π¦ 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