xdr_buf_to_sg(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… xdr_buf_to_sg β€” like, the kernel-API-manual energy, but make it make sense

okay so bestie, the manual name here is xdr_buf_to_sg(9) β€” a kernel API page, section 9, and honestly? she's a little workhorse and we're gonna give her main character energy. ✨


🌸 NAME 🌸

xdr_buf_to_sg β€” populate a scatterlist from an xdr_buf range. that's the whole vibe. one job, does it well, periodt. πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

int xdr_buf_to_sg (const struct xdr_buf *buf , unsigned int offset ,
       unsigned int len , struct scatterlist *sg , unsigned int nsg );

yes she takes five arguments and yes every single one of them matters, we're getting to that 🫢


✨ ARGUMENTS ✨

  • buf β€” the xdr_buf we're mapping. the source of truth, the moment, the blueprint πŸ’…
  • offset β€” starting byte offset within buf. like where in the buf we're starting, bestie, not where in the world
  • len β€” number of bytes to cover. exactly this many, no more no less 🎯
  • sg β€” the scatterlist array, and ngl it has to be pre-initialized with sg_init_table β€” do not skip that step, it's giving prerequisites
  • nsg β€” how many entries you actually have available in sg. the budget. the limit. respect it 😌

πŸ¦‹ DESCRIPTION πŸ¦‹

so the thing to know, and this is the iconique detail: sg is traversed with sg_next, which means callers can absolutely pass a list that was assembled with sg_chain. like, chained lists? valid. welcome. we love that for you. 🌈


πŸ”₯ RETURN πŸ”₯

  • success β€” you get back the number of scatterlist entries used, and the last used entry is marked with sg_mark_end so everyone knows where the party ends πŸŽ‰
  • failure β€” a negative errno. that's it. that's the whole sad moment 😭

πŸ‘‘ SEE ALSO πŸ‘‘

okay this list is literally the entire xdr.c friend group, no cap. the kernel file is ./net/sunrpc/xdr.c and here's everybody:

xdr_encode_opaque_fixed(9), xdr_encode_opaque(9), xdr_terminate_string(9), xdr_buf_to_bvec(9), xdr_buf_to_sg_alloc(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)

like… that's the whole group chat. say hi. πŸ‘‹

also a tiny reminder to my fellow scatterlist girlies: sg_init_table on sg before you call, and keep nsg honest, because this function is not here to save you from yourself πŸ’€

🌸 okay bye bestie, go populate some scatterlists 🌸

source/version: ./net/sunrpc Β· date: October 2026 β€” and that's the sign-off, mwah πŸ’‹ πŸŽ€

πŸ“¦ where this page comes from