xdr_buf_to_sg_alloc(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 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 β€” the xdr_buf to map. literally the thing you’re mapping, bestie πŸ¦‹
  • offset β€” starting byte offset within buf.
  • 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 in sg_head.
  • sg_overflow β€” OUT: chained extension, or NULL when sg_head sufficed.
  • 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:


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