pathname(7)
๐ pathname(7) โ a little chat about pathnames ๐
okay bestie, gather round, we're talking pathname(7) from the Miscellaneous Information Manual and honestly? it's giving foundational. it's giving "everything you love is built on this." let's go ๐ฆ
โจ NAME โจ
pathname, filename โ how pathnames get encoded and interpreted. that's the whole vibe. ๐
๐ธ DESCRIPTION ๐ธ
so like, some system calls let you pass a pathname as a parameter. iconic of them. but when you're writing code that deals with pathnames, there's a whole situation you gotta respect:
- there are kernel-space requirements that you must comply with (no negotiating, bestie, this is non-negotiable)
- and there are user-space requirements that you should comply with (soft launch rules, but still, do them)
๐ the C string thing (iykyk)
the kernel stores pathnames as C strings โ that means sequences of non-null bytes, terminated by a null byte. periodt.
and there are a few general rules that apply to all pathnames:
- the last byte in the sequence needs to be a null byte โ that's the closer, the mic drop, the end of the sentence ๐
- any other bytes in the sequence need to be non-null bytes โ no sneak-attack nulls in the middle, we don't do that here ๐
- a
0x2Fbyte ('/') is always interpreted as a directory separator, and it literally cannot be part of a filename. sorry. it's taken. - a pathname can be at most
PATH_MAXbytes long (seelimits.h(0p)). and if your pathname is longer thanPATH_MAXbytes? not me panicking, because you can split it into multiple smaller pathnames and open it piecewise usingopenat(2). slay, we love a workaround ๐ซถ - a filename can be at most a certain number of bytes long, and that number is filesystem-specific (see
_PC_NAME_MAXinfpathconf(3)). for maximum portability, programs should be able to handle filenames that are as long as the relevant filesystems will allow. and โ also for maximum portability โ programs and users should limit the length of their own pathnames toNAME_MAXbytes (seelimits.h(0p)). yes, both. the code and the human. we're all in this together ๐ญ
๐ฆ further restrictions (the plot thickens)
some filesystems or APIs may apply further restrictions, like:
- requiring shorter filenames
- restricting the allowed bytes in a filename
so like, don't assume your fave filesystem's rules are everyone's rules. vibe check your filesystem first ๐ซ
and for maximum interoperability, programs and users should also limit the characters they use for their own pathnames to characters in the POSIX Portable Filename Character Set. that's the safe little garden of characters, bestie. stay in the garden ๐ธ
๐ VERSIONS ๐
POSIX.1-2024 encourages implementations to disallow creation of filenames containing new-line characters.
Linux does not follow this, and allows using new-line characters. not Linux being the rebellious main character ๐๐
๐ SEE ALSO ๐
go read them, they're all part of the lore ๐ฅ
mwah ๐ that's the page. sourced from Linux man-pages 6.20, dated 2026-02-08 โ love her, cite her, she ate ๐๐โจ
๐ฆ 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
- Copyright 2025, Jason Yundt <jason@jasonyundt.email>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms