函数原型
#include <unistd.h>
long fpathconf(int fd, int name);
功能:对文件的相关参数进行配置。
参数:fd:打开的文件描述符
name:在下面进行选择
_PC_LINK_MAX
The maximum number of links to the file. If fd or path refer to a directory, then the value applies to the whole directory. The corresponding macro is _POSIX_LINK_MAX.
_PC_MAX_CANON
The maximum length of a formatted input line, where fd or path must refer to a terminal. The corresponding macro is _POSIX_MAX_CANON.
_PC_MAX_INPUT
The maximum length of an input line, where fd or path must refer to a terminal. The corresponding macro is _POSIX_MAX_INPUT.
_PC_NAME_MAX
The maximum length of a filename in the directory path or fd that the process is allowed to create. The corresponding macro is _POSIX_NAME_MAX.
_PC_PATH_MAX
The maximum length of a relative pathname when path or fd is the current working directory. The corresponding macro is _POSIX_PATH_MAX.
_PC_PIPE_BUF
The maximum number of bytes that can be written atomically to a pipe of FIFO. For fpathconf(), fd should refer to a pipe or FIFO. For fpathconf(), path should refer to a FIFO or a directory; in the latter
case, the returned value corresponds to FIFOs created in that directory. The corresponding macro is _POSIX_PIPE_BUF.
_PC_CHOWN_RESTRICTED
This returns a positive value if the use of chown(2) and fchown(2) for changing a file's user ID is restricted to a process with appropriate privileges, and changing a file's group ID to a value other than the
process's effective group ID or one of its supplementary group IDs is restricted to a process with appropriate privileges. According to POSIX.1, this variable shall always be defined with a value other than
-1. The corresponding macro is _POSIX_CHOWN_RESTRICTED.
If fd or path refers to a directory, then the return value applies to all files in that directory.
_PC_NO_TRUNC
This returns nonzero if accessing filenames longer than _POSIX_NAME_MAX generates an error. The corresponding macro is _POSIX_NO_TRUNC.
_PC_VDISABLE
测试源码
测试当前系统管道中的缓存为多少
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
int main(int argc, const char* argv[])
{
int fd[2];
int ret = pipe(fd);
if(ret == -1)
{
perror("pipe error");
exit(1);
}
long num = fpathconf(fd[0], _PC_PIPE_BUF);
printf("num = %ld\n", num);
return 0;
}
测试结果:
也可以使用如下命令进行查看
ulimit -a