Scroll to navigation

FPATHCONF(3) Linux Programmer's Manual FPATHCONF(3)

名前

fpathconf, pathconf - ファイルの設定値を取得する

書式

#include <unistd.h>

long fpathconf(int fd, int name); long pathconf(const char *path, int name);

説明

fpathconf() はオープンされているファイルディスクリプター fd に対して設定されているオプション name の値を取得する。

pathconf() はファイル名 path に対して設定されているオプション name の値を取得する。

対応するマクロのうち <unistd.h> で定義されているものは最小値である。アプリケーションによってはこれらの 値を変更してより有利な動作を行おうとするものがある。この場合でも fpathconf() または pathconf() は呼び出すことができる。この場合はより大きな値が返ることになろう。

name を以下の定数のどれかにすると、対応する設定オプションが返される。

_PC_LINK_MAX
ファイルへのリンクの最大数。 fd または path がディレクトリの場合は、この値はディレクトリ全体に適用される。対応する マクロは _POSIX_LINK_MAX である。
_PC_MAX_CANON
フォーマット付き入力行の最大長。このとき fd または path は端末を参照していなければならない。 対応するマクロは _POSIX_MAX_CANON である。
_PC_MAX_INPUT
入力行の最大長。このとき fd または path は端末を参照していなければならない。 対応するマクロは _POSIX_MAX_INPUT である。
_PC_NAME_MAX
ディレクトリ path または fd 内に、そのプロセスが作成することができるファイル名の最大長。 対応するマクロは _POSIX_NAME_MAX である。
_PC_PATH_MAX
path または fd がカレントディレクトリの場合、相対パス名の最大長。 対応するマクロは _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
アクセス中のファイル名が _POSIX_NAME_MAX よりも長く、エラーとなる場合には 0 以外の値を返す。 対応するマクロは _POSIX_NAME_MAX である。
_PC_VDISABLE
特殊文字 (special character) の処理が許されていない場合は 0 以外の値を 返す。このとき fd または path は端末を参照していなければならない。

返り値

The return value of these functions is one of the following:

  • On error, -1 is returned and errno is set to indicate the cause of the error (for example, EINVAL, indicating that name is invalid).
  • If name corresponds to a maximum or minimum limit, and that limit is indeterminate, -1 is returned and errno is not changed. (To distinguish an indeterminate limit from an error, set errno to zero before the call, and then check whether errno is nonzero when -1 is returned.)
  • If name corresponds to an option, a positive value is returned if the option is supported, and -1 is returned if the option is not supported.
  • Otherwise, the current value of the option or limit is returned. This value will not be more restrictive than the corresponding value that was described to the application in <unistd.h> or <limits.h> when the application was compiled.

エラー

(pathconf()) Search permission is denied for one of the directories in the path prefix of path.
(fpathconf()) fd が適切なファイルディスクリプターでない。
name が無効である。
The implementation does not support an association of name with the specified file.
(pathconf()) path を解決する際に遭遇したシンボリックリンクが多過ぎる。
(pathconf()) path が長過ぎる。
(pathconf()) A component of path does not exist, or path is an empty string.
(pathconf()) path のディレクトリ部分が実際にはディレクトリでない。

属性

この節で使用されている用語の説明については、 attributes(7) を参照。

インターフェース 属性
fpathconf(), pathconf() Thread safety MT-Safe

準拠

POSIX.1-2001, POSIX.1-2008.

注意

name_PC_NAME_MAX を入れて返された値よりも長いファイル名を持つファイルが、与えられたディ レクトリに存在するかもしれない。

いくつかの返り値はとても大きくなることがある。これらを使って メモリーの割り当てを行うのは適当ではない。

関連項目

getconf(1), open(2), statfs(2), confstr(3), sysconf(3)

この文書について

この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。

2017-07-13 GNU