xdr_stream_d...e_string_dup(9)
π xdr_stream_decode_string_dup(9) β the Kernel API Manual, bestie edition π
okay so real talk: this is a page from the Kernel API Manual, and it's about one very specific little function that decodes a variable-length string and duplicates it for you. she's giving "short but iconic." let's get into it π
β¨ NAME β¨
xdr_stream_decode_string_dup β Decode and duplicate variable length string
that's it. that's the whole vibe. she decodes, she duplicates, she leaves. main character energy fr fr π¦
πΈ SYNOPSIS πΈ
ssize_t xdr_stream_decode_string_dup (struct xdr_stream *xdr , char
**str , size_t maxlen , gfp_t gfp_flags );
look at her go π four whole params, returns a ssize_t, no notes.
π ARGUMENTS π
okay so every single one of these matters, don't skip:
xdrβ pointer toxdr_stream. this is your stream, your source, your whole situation.strβ location to store pointer to string. this is where the pointer to the string gets parked, bestie π«Άmaxlenβ maximum acceptable string length. like a bouncer at the club, but for string length. anything longer is not getting in π«gfp_flagsβ GFP mask to use. yes, she allocates. we'll get to that. π
π₯ DESCRIPTION π₯
bestie. the description section on this page is literally just the return values. no cap, that's what's on the page, so that's what you get:
Return values: on success, returns length of NUL-terminated string stored in *ptr.
and then the little list of ways it can go wrong, because of course there's a list:
-EBADMSGon XDR buffer overflow-EMSGSIZEif the size of the string would exceedmaxlen-ENOMEMon memory allocation failure
ngl that-ENOMEMis the one that lives in my head rent free. remember thatgfp_flagsparam? yeah. that's her whole job β she's doing an allocation in there, and if it fails you're getting-ENOMEMback, periodt. π
π¦ SEE ALSO π¦
she comes with a whole friend group. kernel file ./net/sunrpc/xdr.c, and then literally everyone she knows:
xdr_encode_opaque_fixed(9)xdr_encode_opaque(9)xdr_terminate_string(9)xdr_buf_to_bvec(9)xdr_buf_to_sg(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_opaque_auth(9)xdr_stream_encode_opaque_auth(9)
that's forty (40) pages. collectively they ate and left absolutely no crumbs. π β¨ iykyk.
and that's the page!! π this little gem lives under ./net/sunrpc and the version tag on it is from October 2026 ποΈ β so mark your calendars, bestie, and go read xdr.c if you wanna see her in her natural habitat π§π
mwah π go decode something.
π¦ 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