POSIX_FALLOCATE(3) | Linux Programmer's Manual | POSIX_FALLOCATE(3) |
posix_fallocate - ファイルのスペースを確保する
#include <fcntl.h>
int posix_fallocate(int fd, off_t offset, off_t len);
posix_fallocate():
関数 posix_fallocate() は、ファイルディスクリプター fd で参照されるファイルに対して、ディスクスペースを確実に確保する。 ディスクスペースは offset から始まる len バイトの範囲のバイトである。 posix_fallocate() の呼び出しが成功した後、指定された範囲のバイトに対する書き込みは、 ディスクスペースの不足で失敗しないことが保証される。
ファイルのサイズが offset+len より小さい場合、ファイルはこのサイズになるように拡大される。 それ以外の場合、ファイルサイズは変わらない。
posix_fallocate() は成功した場合、0 を返す。 失敗した場合、エラー番号を返す。 errno が設定されない点に注意すること。
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:
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.
この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。
2020-11-01 | GNU |