.\" Copyright (c) 2006, Michael Kerrisk .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 2006 Yuichi SATO .\" all rights reserved. .\" Translated 2006-07-13, Yuichi SATO . LDP v2.29 .\" Updated 2010-04-11, Akihiro MOTOKI , LDP v3.24 .\" .TH POSIX_FALLOCATE 3 2020\-11\-01 GNU "Linux Programmer's Manual" .SH 名前 posix_fallocate \- ファイルのスペースを確保する .SH 書式 .nf \fB#include \fP .PP \fBint posix_fallocate(int \fP\fIfd\fP\fB, off_t \fP\fIoffset\fP\fB, off_t \fP\fIlen\fP\fB);\fP .fi .PP .ad l .RS -4 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .RE .PP \fBposix_fallocate\fP(): .RS 4 _POSIX_C_SOURCE\ >=\ 200112L .RE .ad .SH 説明 関数 \fBposix_fallocate\fP() は、ファイルディスクリプター \fIfd\fP で参照されるファイルに対して、ディスクスペースを確実に確保する。 ディスクスペースは \fIoffset\fP から始まる \fIlen\fP バイトの範囲のバイトである。 \fBposix_fallocate\fP() の呼び出しが成功した後、指定された範囲のバイトに対する書き込みは、 ディスクスペースの不足で失敗しないことが保証される。 .PP ファイルのサイズが \fIoffset\fP+\fIlen\fP より小さい場合、ファイルはこのサイズになるように拡大される。 それ以外の場合、ファイルサイズは変わらない。 .SH 返り値 \fBposix_fallocate\fP() は成功した場合、0 を返す。 失敗した場合、エラー番号を返す。 \fIerrno\fP が設定されない点に注意すること。 .SH エラー .TP \fBEBADF\fP \fIfd\fP が有効なファイルディスクリプターでないか、 書き込み用としてオープンされていない。 .TP \fBEFBIG\fP \fIoffset+len\fP が最大ファイルサイズを超えている。 .TP \fBEINTR\fP 実行中にシグナルが捕捉された。 .TP \fBEINVAL\fP \fIoffset\fP was less than 0, or \fIlen\fP was less than or equal to 0, or the underlying filesystem does not support the operation. .TP \fBENODEV\fP \fIfd\fP が通常のファイルとして参照されていない。 .TP \fBENOSPC\fP \fIfd\fP が参照するファイルを含むデバイスに十分な空き領域がない。 .TP \fBEOPNOTSUPP\fP The filesystem containing the file referred to by \fIfd\fP 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. .TP \fBESPIPE\fP \fIfd\fP がパイプを参照している。 .SH バージョン \fBposix_fallocate\fP() は glibc 2.1.94 以降で利用可能である。 .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lb lb lb l l l. インターフェース 属性 値 T{ \fBposix_fallocate\fP() T} Thread safety MT\-Safe (ただし「注意」を参照) .TE .SH 準拠 POSIX.1\-2001. .PP POSIX.1\-2008 では、 \fIlen\fP が 0 の場合、もしくは \fIoffset\fP が 0 未満の場合、 \fBEINVAL\fP エラーを返すものとされている。 POSIX.1\-2001 では、 \fIlen\fP が 0 未満の場合、もしくは \fIoffset\fP が 0 未満の場合、 \fBEINVAL\fP エラーを返すものとされている。また、 \fIlen\fP が 0 の場合、 \fBEINVAL\fP エラーを返してもよいとされている。 .SH 注意 In the glibc implementation, \fBposix_fallocate\fP() is implemented using the \fBfallocate\fP(2) system call, which is MT\-safe. If the underlying filesystem does not support \fBfallocate\fP(2), then the operation is emulated with the following caveats: .IP * 2 The emulation is inefficient. .IP * There is a race condition where concurrent writes from another thread or process could be overwritten with null bytes. .IP * 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. .IP * If \fIfd\fP has been opened with the \fBO_APPEND\fP or \fBO_WRONLY\fP flags, the function fails with the error \fBEBADF\fP. .PP In general, the emulation is not MT\-safe. On Linux, applications may use \fBfallocate\fP(2) if they cannot tolerate the emulation caveats. In general, this is only recommended if the application plans to terminate the operation if \fBEOPNOTSUPP\fP is returned, otherwise the application itself will need to implement a fallback with all the same problems as the emulation provided by glibc. .SH 関連項目 \fBfallocate\fP(1), \fBfallocate\fP(2), \fBlseek\fP(2), \fBposix_fadvise\fP(2) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。