Scroll to navigation

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

名前

lseek64 - ファイルの 64 ビットの読み書きオフセットの位置を変える

書式

#define _LARGEFILE64_SOURCE /* feature_test_macros(7) 参照 */
#include <sys/types.h>
#include <unistd.h>

off64_t lseek64(int fd, off64_t offset, int whence);

説明

lseek() 関数ファミリーは、ファイルディスクリプター fd に関連するオープンされたファイルのオフセットを、 ファイルの開始位置・現在位置・終端から offset の位置へ変更する。 これは whence がそれぞれ SEEK_SET, SEEK_CUR, SEEK_END の場合に対応する。

更に詳しい説明・返り値・エラーは、 lseek(2) を参照すること。

4 つのインターフェースが使用可能である: lseek(), lseek64(), llseek(), llseek()

lseek()

プロトタイプ:


off_t lseek(int fd, off_t offset, int whence);

The C library's lseek() wrapper function uses the type off_t. This is a 32-bit signed type on 32-bit architectures, unless one compiles with


#define _FILE_OFFSET_BITS 64

を定義してコンパイルした場合は 64 ビット符号付き型である。

lseek64()

プロトタイプ:


off64_t lseek64(int fd, off64_t offset, int whence);

ライブラリ関数 lseek64() は off_t が 32 ビット型であっても 64 ビット型を使う。 このプロトタイプ (と型 off64_t) は、以下の定義をしてコンパイルした場合にのみ使用可能である。


#define _LARGEFILE64_SOURCE

関数 lseek64() は glibc 2.1 以降で使用可能である。

llseek()

プロトタイプ:


loff_t llseek(int fd, loff_t offset, int whence);

loff_t は 64 ビット符号付き型である。 ライブラリ関数 llseek() は glibc で利用可能であり、 特別な定義なしに動作する。 しかしながら、 glibc のヘッダーはプロトタイプを供していない。 ユーザーは上記のプロトタイプまたはそれと同等のものを、 自身のソースに追加しなければならない。 このデータがないことによって e2fsck(8) のコンパイルが失敗するという苦情がユーザーから出たので、 glibc 2.1.3 では以下のようなリンク時の警告が追加された。


"the `llseek´ function may be dangerous; use `lseek64´ instead."

これにより、警告なしでコンパイルしたい場合には、この関数を使用不可にできる。

Since glibc 2.28, this function symbol is no longer available to newly linked applications.

_llseek()

On 32-bit architectures, this is the system call that is used (by the C library wrapper functions) to implement all of the above functions. The prototype is:


int _llseek(int fd, off_t offset_hi, off_t offset_lo,
            loff_t *result, int whence);

更に詳しい情報は、 llseek(2) を参照すること。

64-bit systems don't need an _llseek() system call. Instead, they have an lseek(2) system call that supports 64-bit file offsets.

属性

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

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

注意

lseek64() is one of the functions that was specified in the Large File Summit (LFS) specification that was completed in 1996. The purpose of the specification was to provide transitional support that allowed applications on 32-bit systems to access files whose size exceeds that which can be represented with a 32-bit off_t type. As noted above, this symbol is exposed by header files if the _LARGEFILE64_SOURCE feature test macro is defined. ALternatively, on a 32-bit system, the symbol lseek is aliased to lseek64 if the macro _FILE_OFFSET_BITS is defined with the value 64.

関連項目

llseek(2), lseek(2)

この文書について

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

2020-11-01 Linux