fpathconf函数介绍

函数原型

       #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

在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值