xdr_buf_to_sg_alloc(9)
πΈ NAME πΈ
okay bestie, meet xdr_buf_to_sg_alloc β the function that populates a scatterlist for an xdr_buf range. This is the xdr_buf_to_sg_alloc(9) page from the Kernel API Manual, and yes, weβre gonna get through it together π
β¨ SYNOPSIS β¨
int xdr_buf_to_sg_alloc (const struct xdr_buf *buf , unsigned int offset
, unsigned int len , struct scatterlist *sg_head , unsigned int
sg_head_nents , struct scatterlist **sg_overflow , gfp_t gfp );
π«Ά ARGUMENTS π«Ά
bufβ thexdr_bufto map. literally the thing youβre mapping, bestie π¦offsetβ starting byte offset withinbuf.lenβ number of bytes to cover.sg_headβ caller-provided scatterlist array (typically stack-allocated). yes, you bring the array, iconic of you πsg_head_nentsβ number of entries insg_head.sg_overflowβ OUT: chained extension, orNULLwhensg_headsufficed.gfpβ memory allocation flags for overflow.
π DESCRIPTION π
When the xdr_buf fits, it populates sg_head directly. When more entries are needed, an overflow scatterlist is allocated and chained from sg_head so that the result is traversable with sg_next. thatβs the whole vibe: direct fill if it fits, chained overflow if it doesnβt π
π RETURN π
On success, the return value is the number of populated scatterlist entries (counting only data entries, not chain entries). sg_head is the head of the resulting list. Caller must kfree sg_overflow when done. On failure, a negative errno. do not forget the kfree, bestie, Iβm serious π
π¦ SEE ALSO π¦
Kernel file ./net/sunrpc/xdr.c β and the whole squad:
xdr_encode_opaque_fixed(9)xdr_encode_opaque(9)xdr_terminate_string(9)xdr_buf_to_bvec(9)xdr_buf_to_sg(9)xdr_inline_pages(9)_shift_data_left_pages(9)_shift_data_right_pages(9)_copy_to_pages(9)_copy_from_pages(9)xdr_buf_pages_zero(9)xdr_shrink_bufhead(9)xdr_shrink_pagelen(9)xdr_stream_pos(9)xdr_page_pos(9)xdr_init_encode(9)xdr_init_encode_pages(9)__xdr_commit_encode(9)xdr_reserve_space(9)xdr_reserve_space_vec(9)xdr_truncate_encode(9)xdr_truncate_decode(9)xdr_restrict_buflen(9)xdr_write_pages(9)xdr_init_decode(9)xdr_init_decode_pages(9)xdr_finish_decode(9)xdr_inline_decode(9)xdr_read_pages(9)xdr_set_pagelen(9)xdr_enter_page(9)xdr_buf_subsegment(9)xdr_stream_subsegment(9)xdr_stream_move_subsegment(9)xdr_stream_zero(9)xdr_buf_trim(9)xdr_stream_decode_string_dup(9)xdr_stream_decode_opaque_auth(9)xdr_stream_encode_opaque_auth(9)
This gem is from ./net/sunrpc, dated October 2026, and itβs literally xdr_buf_to_sg_alloc(9) β mwah, go slay your scatterlist πβ¨
π¦ 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