strscpy_pad(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ strscpy_pad ✨

okay so this is a page straight out of the Kernel API Manual (strscpy_pad(9) if you're fancy and citing your sources πŸ’…), and bestie, it's literally about copying a C-string into a sized buffer. no cap, that's the whole gig.


πŸŽ€ NAME πŸŽ€

strscpy_pad β€” copy a C-string into a sized buffer. that's it, that's the function 🫢


🌸 SYNOPSIS 🌸

strscpy_pad (dst , src , ... );

yes the ... is real, we're doing variadic-looking vibes here, stay with me 🧚


πŸ’– ARGUMENTS πŸ’–

  • dst β€” where you're copying the string to, aka the destination, aka the place it's gonna live 🏠
  • src β€” where you're copying the string from, aka the source, the origin story, the main character 🌟
  • ... β€” the size of the destination buffer. yes it's hiding in the ... and honestly? iconic of it 😭

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜•: it copies the string β€” or as much of it as actually fits β€” into the dest buffer. lowkey generous.

⚠️ behavior is undefined if the string buffers overlap. fr fr, don't do that. overlapping buffers = chaos, and undefined behavior means the kernel is not gonna hold your hand πŸ’€

the destination buffer is always NUL terminated… unless it's zero-sized. zero-sized buffers said "not today" πŸ™ˆ

and if the source string is shorter than the destination buffer? the remaining bytes in the buffer get filled with NUL bytes. padded, slayed, immaculate ✨

then there's this line, which in the original is literally just:

"For full explanation of why you may want to consider using the"

…and that's where it stops 😭 bestie the sentence got cut off mid-thought. it's giving cliffhanger. iykyk, the source of truth ends right there so we're ending right there too πŸŽ€


πŸ”₯ RETURN πŸ”₯

  • the number of characters copied β€” not including the trailing NULs πŸ’…
  • -E2BIG if count is 0 or if src was truncated. yeah. that's the error. it's giving "too big, too much, overwhelmed" 😭

🌈 SEE ALSO 🌈

kernel file ./include/linux/string.h, plus the whole friend group:


and that's the whole page, bestie 🫢 this beauty lives over in ./include/linux and it's stamped October 2026 ⭐ go forth and copy your strings safely, NUL-terminated and padded like the queen you are πŸ‘‘πŸ’œ

πŸ“¦ where this page comes from