nla_strscpy(9)
π nla_strscpy(9) β the kernel API manual, bestie edition π
okay so you found your way into the nla_strscpy(9) page, welcome, this is the kernel API manual and we're gonna get you fluent in it, no cap π«Ά
β¨ NAME β¨
nla_strscpy β copy a string attribute payload into a sized buffer. that's it, that's the whole vibe π
π¦ SYNOPSIS π¦
ssize_t nla_strscpy (char *dst , const struct nlattr *nla , size_t
dstsize );
like, look at her. iconic signature. three args, one return type, zero drama β
πΈ ARGUMENTS πΈ
dstβ where the string gets copied to. your destination. the place she's moving into πnlaβ the attribute you're copying the string from. the source of truth, the origin story π«dstsizeβ the size of the destination buffer. how much roomdstactually has. respect the boundary bestie π
π DESCRIPTION π
so what does she do. she copies at most dstsize - 1 bytes into the destination buffer. that "-1" is not a typo, that's the NUL terminator reserving its little seat, periodt π
and here's the glow-up: unlike strscpy, the destination buffer is always padded out. literally always. she does not skip the padding, she does not half-do it, she pads. main character energy π₯
π RETURN π
srclenβ returns the nla length, and just so we're clear that's not including the trailing NUL. the NUL is not invited to the count π«-E2BIGβ returned ifdstsizeis0, ordstsizeis greater thanU16_MAX, or the nla length is greater thandstsize. too big, too small, wrong vibe, she's saying no π
π SEE ALSO π
the whole friend group, fr fr β kernel file ./lib/nlattr.c, __nla_validate(9), nla_policy_len(9), __nla_parse(9), nla_find(9), nla_strdup(9), nla_memcpy(9), nla_memcmp(9), nla_strcmp(9), __nla_reserve(9), __nla_reserve_64bit(9), __nla_reserve_nohdr(9), nla_reserve(9), nla_reserve_64bit(9), nla_reserve_nohdr(9), __nla_put(9), __nla_put_64bit(9), __nla_put_nohdr(9), nla_put(9), nla_put_64bit(9), nla_put_nohdr(9), nla_append(9) π¦
and that's the page!! mwah π this one lives in ./lib, dated October 2026, and it's nla_strscpy(9) signing off β go pad a buffer responsibly, ily π§π
π¦ 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