strscpy(9)
π strscpy π
okay bestie, gather round, we're talking about strscpy(9) from the Kernel Developer's Manual. yes this is kernel-land. yes it's giving serious business. but it's also giving "copying strings without setting your computer on fire", so honestly? iconic. π
β¨ NAME β¨
strscpy β string safe^W truncate copy
(not the manpage doing a little backspace joke on itself π the "safe" part gets deleted in real time. we love a self-aware function. π )
π LIBRARY π
Linux kernel
no libc invite for this one, periodt. it lives in the kernel.
π¦ SYNOPSIS π¦
#include <linux/string.h>
ssize_t strscpy(size_t dsize;
char dst[restrict dsize], const char *restrict src,
size_t dsize);
yes you saw dsize two times. that's literally what's written, bestie. we don't edit the sacred text. π
πΈ DESCRIPTION πΈ
so here's the vibe: this function copies the string that src points at, into a string sitting in the buffer that dst points at.
and if the string doesn't fit in the buffer? it gets truncated. no crash, no drama, just a little snip. βοΈβ¨
β RETURN VALUE β
- On success β you get back the length of the new string. slay.
- On error β you get back a negative error code. sad girl hours. π
π₯ ERRORS π₯
-E2BIGβ the string was truncated.
like okay it's technically an "error" but it's really just the function telling you "i did the thing, but i had to cut some of it off, no hard feelings". π«Ά
π STANDARDS π
Linux.
just Linux. that's the whole answer. π
π§ HISTORY π§
Linux.
also just Linux. the origin story is short and confident. π
π CAVEATS π
okay this is the part where we need to sit down and have a real one, bestie.
the s in the name of this function refers to safety β but safety is a relative term that doesn't always apply to this function. π
a more appropriate name for this function would reflect what it actually does, which is copying a string with truncation. and ngl, some projects just call it strtcpy(). so if you see that name floating around, it's the same energy. π
and listen β this function is not provided by any libc. so if you're a user-space programmer and you want it, you have to implement it yourself. no cap. DIY era. π
π«Ά SEE ALSO π«Ά
and that's the whole page, bestie! go forth and copy strings responsibly. πΈ
this has been <rainbow>Linux man-pages 6.20</rainbow>, dated 2026-07-11 β catch you in the next one, mwah πβ¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms