Man page - posix_fallocate(3)

Packages contains this manual

Available languages:

en fr ja ru ro

Manual

POSIX_FALLOCATE

名 前
書 式
説 明
返 り 値
エ ラ ー
バ ー ジ ョ ン
属 性
準 拠
注 意
関 連 項 目
こ の 文 書 に つ い て

名 前

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) を 参 照 。

Image grohtml-41338-1.png

準 拠

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/ に 書 か れ て い る 。