开发者

size of _POSIX_PATH_MAX

Is size开发者_StackOverflow社区 of _POSIX_PATH_MAX is same for all unix flovors(linux,solaris)..


No, it's not even necessarily the same for given instances of the exact same version of the kernel. In most kernel's its a configurable parameter. It will often require a kernel recompile or relink to change, but it can change without having a whole new kernel.

On some (I think most nowadays) systems that macro doesn't translate into an integer literal, it translates to a system call that returns an integer. So if the kernel allows the system to be reconfigured at runtime it will return the current value for the parameter.

I would simply assume that it can't change during the lifetime of your program. If you assume it can change at any time you end up with race conditions where the value changes in between the time you read it and the time you use it. If you just explicitly state that your program assumes it never changes during the lifetime of the program, then system admins who run it will have to adopt the practice they should be adopting anyway and only change the kernel parameter at startup.

There are three POSIX specified calls that will interest you here:

  • pathconf and fpathconf
  • sysconf

I would recommend hunting down other sources as well to get a good feel for which variables are widely supported and which aren't.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜