开发者

What is the relation between PATH_MAX and NAME_MAX, and how do I obtain?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜