plucky (3) posix_fallocate.3.gz

Provided by: manpages-ja-dev_0.5.0.0.20221215+dfsg-1_all bug

名前

       posix_fallocate - ファイルのスペースを確保する

書式

       #include <fcntl.h>

       int posix_fallocate(int fd, off_t offset, off_t len);

   glibc 向けの機能検査マクロの要件 (feature_test_macros(7)  参照):

       posix_fallocate():
           _POSIX_C_SOURCE >= 200112L

説明

       関数  posix_fallocate()  は、ファイルディスクリプター fd で参照されるファイルに対して、ディスクスペースを
       確実に確保する。 ディスクスペースは offset から始まる len バイトの範囲のバイトである。  posix_fallocate()
       の呼び出しが成功した後、指定された範囲のバイトに対する書き込みは、 ディスクスペースの不足で失敗しないこと
       が保証される。

       ファイルのサイズが offset+len  より小さい場合、ファイルはこのサイズになるように拡大される。  それ以外の場
       合、ファイルサイズは変わらない。

返り値

       posix_fallocate()  は成功した場合、0 を返す。 失敗した場合、エラー番号を返す。 errno が設定されない点に注
       意すること。

エラー

       EBADF  fd が有効なファイルディスクリプターでないか、 書き込み用としてオープンされていない。

       EFBIG  offset+len が最大ファイルサイズを超えている。

       EINTR  実行中にシグナルが捕捉された。

       EINVAL offset was less than 0, or len was less than or equal to 0, or the underlying filesystem does  not
              support the operation.

       ENODEV fd が通常のファイルとして参照されていない。

       ENOSPC fd が参照するファイルを含むデバイスに十分な空き領域がない。

       EOPNOTSUPP
              The  filesystem containing the file referred to by fd does not support this operation.  This error
              code can be returned by C libraries that don't perform the emulation shown in NOTES, such as  musl
              libc.

       ESPIPE fd がパイプを参照している。

バージョン

       posix_fallocate()  は glibc 2.1.94 以降で利用可能である。

属性

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

       ┌──────────────────┬───────────────┬────────────────────────────────┐
       │インターフェース属性                             │
       ├──────────────────┼───────────────┼────────────────────────────────┤
       │posix_fallocate() │ Thread safety │ MT-Safe (ただし「注意」を参照) │
       └──────────────────┴───────────────┴────────────────────────────────┘

準拠

       POSIX.1-2001.

       POSIX.1-2008  では、 len が 0 の場合、もしくは offset が 0 未満の場合、 EINVAL エラーを返すものとされてい
       る。 POSIX.1-2001 では、 len が 0 未満の場合、もしくは offset が 0 未満の場合、 EINVAL エラーを返すものと
       されている。また、 len が 0 の場合、 EINVAL エラーを返してもよいとされている。

注意

       In the glibc implementation, posix_fallocate()  is implemented using the fallocate(2)  system call, which
       is MT-safe.  If the underlying filesystem does not support fallocate(2), then the operation  is  emulated
       with the following caveats:

       * The emulation is inefficient.

       * There  is  a race condition where concurrent writes from another thread or process could be overwritten
         with null bytes.

       * There is a race condition where concurrent file size increases  by  another  thread  or  process  could
         result in a file whose size is smaller than expected.

       * If fd has been opened with the O_APPEND or O_WRONLY flags, the function fails with the error EBADF.

       In  general,  the  emulation is not MT-safe.  On Linux, applications may use fallocate(2)  if they cannot
       tolerate the emulation caveats.  In general, this  is  only  recommended  if  the  application  plans  to
       terminate  the  operation  if  EOPNOTSUPP  is  returned,  otherwise  the  application itself will need to
       implement a fallback with all the same problems as the emulation provided by glibc.

関連項目

       fallocate(1), fallocate(2), lseek(2), posix_fadvise(2)

この文書について

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