OSDN Git Service

(split) LDP: Release pages with over 80% translations.
[linuxjm/LDP_man-pages.git] / release / man2 / lseek.2
index 48388ca..36ac7be 100644 (file)
@@ -1,4 +1,6 @@
+.\" t
 .\" Copyright (c) 1980, 1991 Regents of the University of California.
+.\" and Copyright (c) 2011, Michael Kerrisk <mtk.manpages@gmail.com>
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
 .\"
 .\"     @(#)lseek.2    6.5 (Berkeley) 3/10/91
 .\"
-.\" Modified Fri Jul 23 22:17:00 1993 by Rik Faith <faith@cs.unc.edu>
-.\" Modified 10 June 1995 by Andries Brouwer <aeb@cwi.nl>
-.\" Modified Thu Oct 31 15:18:33 1996 by Eric S. Raymond <esr@thyrsus.com>
-.\" Modified Sat Jan 17 13:00:32 MET 1998 by Michael Haardt
+.\" Modified 1993-07-23 by Rik Faith <faith@cs.unc.edu>
+.\" Modified 1995-06-10 by Andries Brouwer <aeb@cwi.nl>
+.\" Modified 1996-10-31 by Eric S. Raymond <esr@thyrsus.com>
+.\" Modified 1998-01-17 by Michael Haardt
 .\"   <michael@cantor.informatik.rwth-aachen.de>
-.\" Modified Mon Sep 24 16:18:02 CEST 2001 by Michael Haardt <michael@moria.de>
+.\" Modified 2001-09-24 by Michael Haardt <michael@moria.de>
+.\" Modified 2003-08-21 by Andries Brouwer <aeb@cwi.nl>
+.\" 2011-09-18, mtk, Added SEEK_DATA + SEEK_HOLE
 .\"
-.\" Japanese Version Copyright (c) 1997-1998 HANATAKA Shinya
-.\"         all rights reserved.
-.\" Translated 1997-02-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
-.\" Modified 1998-05-11, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
-.\" Updated 2001-12-14, Kentaro Shirakata <argrath@ub32.org>
-.\" Updated 2003-09-08, Kentaro Shirakata <argrath@ub32.org>
-.\" Updated 2005-02-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
-.\" Updated 2006-03-05, Akihiro MOTOKI, catch up to LDP v2.25
+.\"*******************************************************************
 .\"
-.\"WORD:       end-of-file             ¥Õ¥¡¥¤¥ë¤Î½ªÃ¼(end-of-file)
+.\" This file was generated with po4a. Translate the source file.
 .\"
-.TH LSEEK 2 2010-09-11 "Linux" "Linux Programmer's Manual"
-.SH Ì¾Á°
-lseek \- ¥Õ¥¡¥¤¥ë¤ÎÆɤ߽ñ¤­¥ª¥Õ¥»¥Ã¥È¤Î°ÌÃÖ¤òÊѤ¨¤ë
-.SH ½ñ¼°
-.B #include <sys/types.h>
+.\"*******************************************************************
+.TH LSEEK 2 2011\-09\-25 Linux "Linux Programmer's Manual"
+.SH 名前
+lseek \- ファイルの読み書きオフセットの位置を変える
+.SH 書式
+\fB#include <sys/types.h>\fP
 .br
-.B #include <unistd.h>
+\fB#include <unistd.h>\fP
 .sp
-.BI "off_t lseek(int " fd ", off_t " offset ", int " whence );
-.SH ÀâÌÀ
-.BR lseek ()
-´Ø¿ô¤Ï¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿ (descriptor)
-.I fd
-¤ËÂбþ¤¹¤ë¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤Î¥ª¥Õ¥»¥Ã¥È¤ò¡¢
-.IR  whence
-¤Ë´ð¤Å¤­
-.I offset
-°ú¤­¿ô¤Î°ÌÃ֤ذʲ¼¤Î¤è¤¦¤ËÊѹ¹¤¹¤ë:
-.TP
-.B SEEK_SET
-¥ª¥Õ¥»¥Ã¥È¤Ï
-.I offset
-¥Ð¥¤¥È¤ËÀßÄꤵ¤ì¤ë¡£
-.TP
-.B SEEK_CUR
-¥ª¥Õ¥»¥Ã¥È¤Ï¸½ºß°ÌÃÖ¤Ë
-.I offset
-¥Ð¥¤¥È¤ò­¤·¤¿°ÌÃ֤ˤʤ롣
-.TP
-.B SEEK_END
-¥ª¥Õ¥»¥Ã¥È¤Ï¥Õ¥¡¥¤¥ë¤Î¥µ¥¤¥º¤Ë
-.I offset
-¥Ð¥¤¥È¤ò­¤·¤¿°ÌÃ֤ˤʤ롣
+\fBoff_t lseek(int \fP\fIfd\fP\fB, off_t \fP\fIoffset\fP\fB, int \fP\fIwhence\fP\fB);\fP
+.SH 説明
+\fBlseek\fP()  関数は、ファイルディスクリプタ (descriptor)  \fIfd\fP に対応するオープンされたファイルのオフセットを、
+\fIwhence\fP に基づき \fIoffset\fP 引き数の位置へ以下のように変更する:
+.TP 
+\fBSEEK_SET\fP
+オフセットは \fIoffset\fP バイトに設定される。
+.TP 
+\fBSEEK_CUR\fP
+オフセットは現在位置に \fIoffset\fP バイトを足した位置になる。
+.TP 
+\fBSEEK_END\fP
+オフセットはファイルのサイズに \fIoffset\fP バイトを足した位置になる。
 .PP
-.BR lseek ()
-´Ø¿ô¤Ï¡¢¥ª¥Õ¥»¥Ã¥È¤ò¥Õ¥¡¥¤¥ë¤ÎËöÈø¤ò±Û¤¨¤¿°ÌÃÖ¤ËÀßÄê¤Ç¤­¤ë
-(⤷¡¢¤³¤ì¤Ë¤è¤ê¥Õ¥¡¥¤¥ë¤Î¥µ¥¤¥º¤¬ÊѤï¤é¤Ê¤¤)¡£
-¤â¤·¥Ç¡¼¥¿¤¬¤³¤Î¥ª¥Õ¥»¥Ã¥È°ÌÃְʹߤ˽ñ¤­¹þ¤Þ¤ì¤¿¾ì¹ç¡¢
-´Ö¤Î¶õ·ä¤ÎÉôʬ ("·ê (hole)") ¤ÎÆɤ߽Ф·¤¬¤¢¤ë¤È¡¢
-¼ÂºÝ¤Ë¤½¤³¤Ë¥Ç¡¼¥¿¤ò½ñ¤­¹þ¤Þ¤ì¤ë¤Þ¤Ç¤Ï
-NULL ¥Ð¥¤¥È (\(aq\\0\(aq) ¤ÎÎó¤¬ÊÖ¤µ¤ì¤ë¡£
-.SH ÊÖ¤êÃÍ
-À®¸ù¤·¤¿¾ì¹ç¡¢
-.BR lseek ()
-¤Ï·ë²Ì¤Î¥Õ¥¡¥¤¥ë°ÌÃÖ¤ò¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤«¤é¤Î¥Ð¥¤¥È¿ô¤ÇÊÖ¤¹¡£
-¥¨¥é¡¼¤Î¾ì¹ç¡¢ÃÍ \fI(off_t)\ \-1\fP ¤¬ÊÖ¤µ¤ì¡¢
-.I errno
-¤Ë¥¨¥é¡¼¤¬»Ø¼¨¤µ¤ì¤ë¡£
-.SH ¥¨¥é¡¼
-.TP
-.B EBADF
-.I fd
-¤¬¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ê¤¤¡£
-.TP
-.B EINVAL
-.I whence
-¤¬
-.BR SEEK_SET ,
-.BR SEEK_CUR ,
-.B SEEK_END
-¤Î¤É¤ì¤Ç¤â¤Ê¤¤¡£
-¤Þ¤¿¤Ï¡¢seek ¤Î·ë²Ì¡¢¥Õ¥¡¥¤¥ë¡¦¥ª¥Õ¥»¥Ã¥È¤¬Éé¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¦¤«¡¢
-seek ²Äǽ¤Ê¥Ç¥Ð¥¤¥¹¤ÎËöÈø¤ò±Û¤¨¤Æ¤·¤Þ¤¦¡£
-.\" ¥·¥¹¥Æ¥à¤Ë¤è¤Ã¤Æ¤Ï¥­¥ã¥é¥¯¥¿¥Ç¥Ð¥¤¥¹¤ä¥ê¥â¡¼¥È¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤ËÂФ·¤Æ
-.\" Éé¤Î¥ª¥Õ¥»¥Ã¥È¤¬µö¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
-.B EOVERFLOW
-.\" ¤³¤Î¾ì¹ç HP-UX 11 ¤Ï EINVAL ¤òÊÖ¤¹ (°ìÊý¡¢POSIX.1 ¤Ï EOVERFLOW ¤òÊÖ¤¹)
-·ë²Ì¤Î¥Õ¥¡¥¤¥ë¡¦¥ª¥Õ¥»¥Ã¥È¤ò
-.I off_t
-·¿¤Çɽ¸½¤¹¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤¡£
-.TP
-.B ESPIPE
-.I fd
-¤¬¥Ñ¥¤¥×¡¢¥½¥±¥Ã¥È¡¢FIFO ¤ò»²¾È¤·¤Æ¤¤¤ë¡£
-.SH ½àµò
-SVr4, 4.3BSD, POSIX.1-2001.
-.SH Ãí°Õ
-¤³¤Îʸ¾Ï¤Ç»ÈÍѤ·¤¿
-.I whence
-¤Ï±Ñ¸ì¤È¤·¤ÆÀµ¤·¤¯¤Ê¤¤¤¬¡¢
-Îò»ËŪÍýͳ¤Ë¤è¤ê¤½¤Î¤Þ¤Þ»È¤ï¤ì¤Æ¤¤¤ë¡£
+\fBlseek\fP()  関数は、オフセットをファイルの末尾を越えた位置に設定できる (但し、これによりファイルのサイズが変わらない)。
+もしデータがこのオフセット位置以降に書き込まれた場合、 間の空隙の部分 ("穴 (hole)") の読み出しがあると、
+実際にそこにデータを書き込まれるまでは NULL バイト (\(aq\e0\(aq) の列が返される。
+.SS "Seeking file data and holes"
+Linux バージョン 3.1 以降では、
+\fIwhence\fP に以下の値も指定することができる。
+.TP 
+\fBSEEK_DATA\fP
+Adjust the file offset to the next location in the file greater than or
+equal to \fIoffset\fP containing data.  If \fIoffset\fP points to data, then the
+file offset is set to \fIoffset\fP.
+.TP 
+\fBSEEK_HOLE\fP
+Adjust the file offset to the next hole in the file greater than or equal to
+\fIoffset\fP.  If \fIoffset\fP points into the middle of a hole, then the file
+offset is set to \fIoffset\fP.  If there is no hole past \fIoffset\fP, then the
+file offset is adjusted to the end of the file (i.e., there is an implicit
+hole at the end of any file).
+.PP
+In both of the above cases, \fBlseek\fP()  fails if \fIoffset\fP points past the
+end of the file.
+
+These operations allow applications to map holes in a sparsely allocated
+file.  This can be useful for applications such as file backup tools, which
+can save space when creating backups and preserve holes, if they have a
+mechanism for discovering holes.
+
+.\" https://lkml.org/lkml/2011/4/22/79
+.\" http://lwn.net/Articles/440255/
+.\" http://blogs.oracle.com/bonwick/entry/seek_hole_and_seek_data
+For the purposes of these operations, a hole is a sequence of zeros that
+(normally) has not been allocated in the underlying file storage.  However,
+a file system is not obliged to report holes, so these operations are not a
+guaranteed mechanism for mapping the storage space actually allocated to a
+file.  (Furthermore, a sequence of zeros that actually has been written to
+the underlying storage may not be reported as a hole.)  In the simplest
+implementation, a file system can support the operations by making
+\fBSEEK_HOLE\fP always return the offset of the end of the file, and making
+\fBSEEK_DATA\fP always return \fIoffset\fP (i.e., even if the location referred to
+by \fIoffset\fP is a hole, it can be considered to consist of data that is a
+sequence of zeros).
+.SH 返り値
+成功した場合、 \fBlseek\fP()  は結果のファイル位置をファイルの先頭からのバイト数で返す。 エラーの場合、値 \fI(off_t)\ \-1\fP
+が返され、 \fIerrno\fP にエラーが指示される。
+.SH エラー
+.TP 
+\fBEBADF\fP
+\fIfd\fP がオープンされたファイルディスクリプタでない。
+.TP 
+\fBEINVAL\fP
+.\" Some systems may allow negative offsets for character devices
+.\" and/or for remote file systems.
+\fIwhence\fP が有効な値ではない。または、seek の結果、ファイルオフセットが負に
+なってしまうか、 seek 可能なデバイスの末尾を越えてしまう。
+.TP 
+\fBEOVERFLOW\fP
+.\" HP-UX 11 says EINVAL for this case (but POSIX.1 says EOVERFLOW)
+結果のファイルオフセットを \fIoff_t\fP 型で表現することができない。
+.TP 
+\fBESPIPE\fP
+\fIfd\fP がパイプ、ソケット、FIFO を参照している。
+.TP 
+\fBENXIO\fP
+\fIwhence\fP が \fBSEEK_DATA\fP か \fBSEEK_HOLE\fP で、
+現在のファイルオフセットがファイルの末尾を超えた位置である。
+.SH 準拠
+SVr4, 4.3BSD, POSIX.1\-2001.
 
-¤¤¤¯¤Ä¤«¤Î¥Ç¥Ð¥¤¥¹¤Ç¤Ï seek ¤¬¤Ç¤­¤Ê¤¤¡£
-POSIX ¤Ï¤É¤Î¥Ç¥Ð¥¤¥¹¤¬
-.BR lseek ()
-¤ËÂбþ¤¹¤Ù¤­¤«¤Ïµ¬Äꤷ¤Æ¤¤¤Ê¤¤¡£
+.\" FIXME . Review http://austingroupbugs.net/view.php?id=415 in the future
+\fBSEEK_DATA\fP and \fBSEEK_HOLE\fP are nonstandard extensions also present in
+Solaris, FreeBSD, and DragonFly BSD; they are proposed for inclusion in the
+next POSIX revision (Issue 8).
+.SH 注意
+いくつかのデバイスでは seek ができない。 POSIX はどのデバイスが \fBlseek\fP()  に対応すべきかは規定していない。
 
-Linux ¤Ç¤Ï¡¢ tty ¥Ç¥Ð¥¤¥¹¤Ë
-.BR lseek ()
-¤ò»ÈÍѤ¹¤ë¤È
-\fBESPIPE\fP ¤òÊÖ¤¹¡£
-.\" Â¾¤Î¥·¥¹¥Æ¥à¤Ç¤Ï½ñ¤­¹þ¤Þ¤ì¤¿Ê¸»ú¤Î¿ô¤òÊÖ¤·¡¢
-.\" SEEK_SET ¤òÍѤ¤¤Æ¥«¥¦¥ó¥¿¤òÀßÄꤹ¤ë¡£ (½ñ¤­¹þ¤Þ¤ì¤¿Ê¸»ú¤Î¡£)
+.\" Other systems return the number of written characters,
+.\" using SEEK_SET to set the counter. (Of written characters.)
+Linux では、 tty デバイスに \fBlseek\fP()  を使用すると \fBESPIPE\fP を返す。
 
-¸Å¤¤¥³¡¼¥É¤òÊÑ´¹¤¹¤ë»þ¤Ï \fIwhence\fP ¤ÎÃͤò°Ê²¼¤Î¥Þ¥¯¥í¤ËÃÖ¤­´¹¤¨¤ë¤³¤È:
+古いコードを変換する時は \fIwhence\fP の値を以下のマクロに置き換えること:
 .TS
 c c
 l l.
@@ -156,21 +161,15 @@ L_INCR    SEEK_CUR
 L_XTND SEEK_END
 .TE
 .\" .PP
-.\" .\"O SVr1-3 returns \fIlong\fP instead of \fIoff_t\fP,
-.\" .\"O (ancient) BSD returns \fIint\fP.
-.\" ÊÖ¤êÃͤη¿¤Ï¡¢SVr1-3 ¤Ç¤Ï \fIoff_t\fP ¤Ç¤Ï¤Ê¤¯ \fIlong\fP ¤Ç¤¢¤ê¡¢
-.\" (¸Å¤¤) BSD ¤Ç¤Ï \fIint\fP ¤Ç¤¢¤ë¡£
+.\" SVr1-3 returns \fIlong\fP instead of \fIoff_t\fP,
+.\" (ancient) BSD returns \fIint\fP.
 .PP
-.BR dup (2)
-¤ä
-.BR fork (2)
-¤ÇºîÀ®¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¡¢¸½ºß¤Î¥Õ¥¡¥¤¥ë°ÌÃ֥ݥ¤¥ó¥¿
-(current file position pointer) ¤ò¶¦Í­¤·¤Æ¤¤¤ë¤Î¤Ç¡¢
-¤³¤Î¤è¤¦¤Ê¥Õ¥¡¥¤¥ë¤Ç°ÜÆ°¤ò¹Ô¤¦¤È¶¥¹ç¾õÂÖ¤ò°ú¤­µ¯¤³¤¹²ÄǽÀ­¤¬¤¢¤ë¡£
-.SH ´ØÏ¢¹àÌÜ
-.BR dup (2),
-.BR fork (2),
-.BR open (2),
-.BR fseek (3),
-.BR lseek64 (3),
-.BR posix_fallocate (3)
+\fBdup\fP(2)  や \fBfork\fP(2)  で作成されたファイルディスクリプタは、現在のファイル位置ポインタ (current file
+position pointer) を共有しているので、 このようなファイルで移動を行うと競合状態を引き起こす可能性がある。
+.SH 関連項目
+\fBdup\fP(2), \fBfork\fP(2), \fBopen\fP(2), \fBfseek\fP(3), \fBlseek64\fP(3),
+\fBposix_fallocate\fP(3)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.40 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。