In limits.h, and in various places in the POSIX manpages, there are references to PATH_MAX and NAME_MAX.
How do these relate to one another?
Where is the official documentation for them?
How can I obtain them at run time, and (where relevant) compile time for the C, Python, and GNU (shell) environments?
PATH_MAX is the maximum length of a filesystem path. NAME_MAX is the maximum length of a filename (in a particular spot). So, /foo/bar is restricted by PATH_MAX, and only the bar portion has its length limited by NAME_MAX.
You can get these at run time via pathconf, as _PC_PATH_MAX and _PC_NAME_MAX, although standard practice is generally just to use the static macros at compile time. I suppose it would be better to use the run-time option because you could potentially support longer values that way, but I'm not sure what (if any) systems actually provide a return from pathconf which is greater than the value of the POSIX_FOO_MAX values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With