-'\" t
-.\" Hey Emacs! This file is -*- nroff -*- source.
-.\"
+.\" t
.\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
.\" Parts Copyright (c) 1995 Nicolai Langfeldt (janl@ifi.uio.no), 1/1/95
-.\" and Copyright (c) 2007 Michael Kerrisk <mtk.manpages@gmail.com>
+.\" and Copyright (c) 2006, 2007, 2014 Michael Kerrisk <mtk.manpages@gmail.com>
.\"
+.\" %%%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.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
.\"
.\" Modified by Michael Haardt <michael@moria.de>
.\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
.\" 2007-06-08 mtk: Added example program
.\" 2007-07-05 mtk: Added details on underlying system call interfaces
.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
.\" Japanese Version Copyright (c) 1998-1999 HANATAKA Shinya
.\" and Copyright (c) 2005-2008 Akihiro MOTOKI
-.\"
.\" Translated 1998-06-21, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Modified 1999-04-16, HANATAKA Shinya
.\" Updated 2000-01-03, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2006-07-21, Akihiro MOTOKI, LDP v2.36
.\" Updated 2007-06-13, Akihiro MOTOKI, LDP v2.55
.\" Updated 2008-09-19, Akihiro MOTOKI, LDP v3.08
+.\" Updated 2012-04-30, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2012-05-29, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-03-26, Akihiro MOTOKI <amotoki@gmail.com>
.\"
-.\"WORD: status ¾õÂÖ
-.\"WORD: directory ¥Ç¥£¥ì¥¯¥È¥ê
-.\"WORD: open ¥ª¡¼¥×¥ó
-.\"WORD: implement ¼ÂÁõ
-.\"WORD: owner ½êͼÔ
-.\"WORD: group ¥°¥ë¡¼¥×
-.\"WORD: user ¥æ¡¼¥¶¡¼
-.\"WORD: other ¾¿Í
-.\"WORD: hard link count ¥Ï¡¼¥É¡¦¥ê¥ó¥¯¿ô
-.\"WORD: symbolic link ¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯
-.\"WORD: socket ¥½¥±¥Ã¥È
-.\"WORD: device ¥Ç¥Ð¥¤¥¹
-.\"WORD: sticky bit ¥¹¥Æ¥£¥Ã¥¡¼¡¦¥Ó¥Ã¥È
-.\"WORD: mandatory locking ¶¯À©¥í¥Ã¥¯
-.\"
-.TH STAT 2 2010-12-03 "Linux" "Linux Programmer's Manual"
-.\"O .SH NAME
-.SH ̾Á°
-.\"O stat, fstat, lstat \- get file status
-stat, fstat, lstat \- ¥Õ¥¡¥¤¥ë¤Î¾õÂÖ¤ò¼èÆÀ¤¹¤ë
-.\"O .SH SYNOPSIS
-.SH ½ñ¼°
-.B #include <sys/types.h>
+.TH STAT 2 2014\-03\-19 Linux "Linux Programmer's Manual"
+.SH 名前
+stat, fstat, lstat, fstatat \- ファイルの状態を取得する
+.SH 書式
+.nf
+\fB#include <sys/types.h>\fP
.br
-.B #include <sys/stat.h>
+\fB#include <sys/stat.h>\fP
.br
-.B #include <unistd.h>
+\fB#include <unistd.h>\fP
.sp
-.BI "int stat(const char *" path ", struct stat *" buf );
+\fBint stat(const char *\fP\fIpathname\fP\fB, struct stat *\fP\fIbuf\fP\fB);\fP
.br
-.BI "int fstat(int " fd ", struct stat *" buf );
+\fBint fstat(int \fP\fIfd\fP\fB, struct stat *\fP\fIbuf\fP\fB);\fP
.br
-.BI "int lstat(const char *" path ", struct stat *" buf );
+\fBint lstat(const char *\fP\fIpathname\fP\fB, struct stat *\fP\fIbuf\fP\fB);\fP
+.sp
+\fB#include <fcntl.h> \fP/* AT_* 定数の定義 */
+\fB#include <sys/stat.h>\fP
+.sp
+\fBint fstatat(int \fP\fIdirfd\fP\fB, const char *\fP\fIpathname\fP\fB, struct stat *\fP\fIbuf\fP\fB,\fP
+\fB int \fP\fIflags\fP\fB);\fP
+.fi
.sp
.in -4n
-.\"O Feature Test Macro Requirements for glibc (see
-.\"O .BR feature_test_macros (7)):
-glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
-.RB ( feature_test_macros (7)
-»²¾È):
+glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照):
.in
+.ad l
+.PD 0
+.sp
+\fBlstat\fP():
+.RS 4
+_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
+.br
+|| /* glibc 2.10 以降: */ _POSIX_C_SOURCE\ >=\ 200112L
+.RE
.sp
-.BR lstat ():
-_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
-.\"O .SH DESCRIPTION
-.SH ÀâÌÀ
+\fBfstatat\fP():
+.PD 0
+.ad l
+.RS 4
+.TP 4
+glibc 2.10 以降:
+_XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
+.TP
+glibc 2.10 より前:
+_ATFILE_SOURCE
+.RE
+.PD
+.ad
+.SH 説明
.PP
-.\"O These functions return information about a file.
-.\"O No permissions are required on the file itself, but \(em in the case of
-.\"O .BR stat ()
-.\"O and
-.\"O .BR lstat ()
-.\"O \(em
-.\"O execute (search) permission is required on all of the directories in
-.\"O .I path
-.\"O that lead to the file.
-¤³¤ì¤é¤Î´Ø¿ô¤Ï¥Õ¥¡¥¤¥ë¤Ë¤Ä¤¤¤Æ¤Î¾ðÊó¤òÊÖ¤¹¡£
-¥Õ¥¡¥¤¥ë¤½¤Î¤â¤Î¤ËÂФ¹¤ë¥¢¥¯¥»¥¹µö²Ä¤ÏɬÍפȤ·¤Ê¤¤¤¬¡¢
-\(em
-.BR stat ()
-¤È
-.BR lstat ()
-¤Î¾ì¹ç¤Ë¤Ï
-\(em
-¤½¤Î¥Õ¥¡¥¤¥ë¤Ø»ê¤ë
-.I path
-¤ò¹½À®¤¹¤ëÁ´¤Æ¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ËÂФ¹¤ë¼Â¹Ô (¸¡º÷) µö²Ä¤¬É¬ÍפǤ¢¤ë¡£
+これらの関数は、ファイルについての情報を \fIstat\fP が指すバッファに格納して返す。 ファイルそのものに対するアクセス許可は必要としないが、
+\(em\fBstat\fP(), \fBfstatat\fP(), \fBlstat\fP() の場合には \(emそのファイルへ至る \fIpathname\fP
+を構成する全てのディレクトリに対する実行 (検索) 許可が必要である。
.PP
-.\"O .BR stat ()
-.\"O stats the file pointed to by
-.\"O .I path
-.\"O and fills in
-.\"O .IR buf .
-.BR stat ()
-¤Ï
-.I path
-¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤Î¾õÂÖ¤ò¼èÆÀ¤·¤Æ
-.I buf
-¤Ø³ÊǼ¤¹¤ë¡£
-
-.\"O .BR lstat ()
-.\"O is identical to
-.\"O .BR stat (),
-.\"O except that if
-.\"O .I path
-.\"O is a symbolic link, then the link itself is stat-ed,
-.\"O not the file that it refers to.
-.BR lstat ()
-¤Ï
-.BR stat ()
-¤ÈƱ¤¸¤Ç¤¢¤ë¤¬¡¢
-.I path
-¤¬¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Î¾ì¹ç¡¢¥ê¥ó¥¯¤¬»²¾È¤·¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤Ç¤Ï¤Ê¤¯¡¢
-¥ê¥ó¥¯¼«¿È¤Î¾õÂÖ¤ò¼èÆÀ¤¹¤ëÅÀ¤¬°Û¤Ê¤ë¡£
-
-.\"O .BR fstat ()
-.\"O is identical to
-.\"O .BR stat (),
-.\"O except that the file to be stat-ed is specified by the file descriptor
-.\"O .IR fd .
-.BR fstat ()
-¤Ï
-.BR stat ()
-¤ÈƱ¤¸¤À¤¬¡¢
-¾õÂÖ¤ò¼èÆÀ¤¹¤ë¥Õ¥¡¥¤¥ë¤ò¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿
-.I fd
-¤Ç»ØÄꤹ¤ë¡£
+\fBstat\fP() and \fBfstatat\fP() retrieve information about the file pointed to
+by \fIpathname\fP; the differences for \fBfstatat\fP() are described below.
+
+\fBlstat\fP() は \fBstat\fP() と同じであるが、 \fIpathnames\fP
+がシンボリックリンクの場合、リンクが参照しているファイルではなく、 リンク自身の状態を返す点が異なる。
+
+\fBfstat\fP() は \fBstat\fP() と同じだが、 状態を取得するファイルをファイルディスクリプタ \fIfd\fP で指定する点が異なる。
.PP
-.\"O All of these system calls return a
-.\"O .I stat
-.\"O structure, which contains the following fields:
-¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¤¤¤º¤ì¤â¡¢·ë²Ì¤ò
-.I stat
-¹½Â¤ÂΤËÆþ¤ì¤ÆÊÖ¤¹¡£
-.I stat
-¹½Â¤ÂΤˤϰʲ¼¤Î¥Õ¥£¡¼¥ë¥É¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë:
+これらのシステムコールはいずれも、結果を \fIstat\fP 構造体に入れて返す。 \fIstat\fP 構造体には以下のフィールドが含まれている:
.PP
.in +4n
.nf
struct stat {
-.\"O dev_t st_dev; /* ID of device containing file */
-.\"O ino_t st_ino; /* inode number */
-.\"O mode_t st_mode; /* protection */
-.\"O nlink_t st_nlink; /* number of hard links */
-.\"O uid_t st_uid; /* user ID of owner */
-.\"O gid_t st_gid; /* group ID of owner */
-.\"O dev_t st_rdev; /* device ID (if special file) */
-.\"O off_t st_size; /* total size, in bytes */
-.\"O blksize_t st_blksize; /* blocksize for file system I/O */
-.\"O blkcnt_t st_blocks; /* number of 512B blocks allocated */
-.\"O time_t st_atime; /* time of last access */
-.\"O time_t st_mtime; /* time of last modification */
-.\"O time_t st_ctime; /* time of last status change */
- dev_t st_dev; /* ¥Õ¥¡¥¤¥ë¤¬¤¢¤ë¥Ç¥Ð¥¤¥¹¤Î ID */
- ino_t st_ino; /* inode ÈÖ¹æ */
- mode_t st_mode; /* ¥¢¥¯¥»¥¹Êݸî */
- nlink_t st_nlink; /* ¥Ï¡¼¥É¥ê¥ó¥¯¤Î¿ô */
- uid_t st_uid; /* ½êͼԤΥ桼¥¶ ID */
- gid_t st_gid; /* ½êͼԤΥ°¥ë¡¼¥× ID */
- dev_t st_rdev; /* ¥Ç¥Ð¥¤¥¹ ID (Æüì¥Õ¥¡¥¤¥ë¤Î¾ì¹ç) */
- off_t st_size; /* Á´ÂΤΥµ¥¤¥º (¥Ð¥¤¥Èñ°Ì) */
- blksize_t st_blksize; /* ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à I/O ¤Ç¤Î
- ¥Ö¥í¥Ã¥¯¥µ¥¤¥º */
- blkcnt_t st_blocks; /* ³ä¤êÅö¤Æ¤é¤ì¤¿ 512B ¤Î¥Ö¥í¥Ã¥¯¿ô */
- time_t st_atime; /* ºÇ½ª¥¢¥¯¥»¥¹»þ¹ï */
- time_t st_mtime; /* ºÇ½ª½¤Àµ»þ¹ï */
- time_t st_ctime; /* ºÇ½ª¾õÂÖÊѹ¹»þ¹ï */
+ dev_t st_dev; /* ファイルがあるデバイスの ID */
+ ino_t st_ino; /* inode 番号 */
+ mode_t st_mode; /* アクセス保護 */
+ nlink_t st_nlink; /* ハードリンクの数 */
+ uid_t st_uid; /* 所有者のユーザ ID */
+ gid_t st_gid; /* 所有者のグループ ID */
+ dev_t st_rdev; /* デバイス ID (特殊ファイルの場合) */
+ off_t st_size; /* 全体のサイズ (バイト単位) */
+ blksize_t st_blksize; /* ファイルシステム I/O での
+ ブロックサイズ */
+ blkcnt_t st_blocks; /* 割り当てられた 512B のブロック数 */
+};
+
+ /* Since Linux 2.6, the kernel supports nanosecond
+ precision for the following timestamp fields.
+ For the details before Linux 2.6, see NOTES. */
+
+ struct timespec st_atim; /* 最終アクセス時刻 */
+ struct timespec st_mtim; /* 最終修正時刻 */
+ struct timespec st_ctim; /* 最終状態変更時刻 */
+
+#define st_atime st_atim.tv_sec /* Backward compatibility */
+#define st_mtime st_mtim.tv_sec
+#define st_ctime st_ctim.tv_sec
};
.fi
.in
+
+\fINote:\fP the order of fields in the \fIstat\fP structure varies somewhat across
+architectures. In addition, the definition above does not show the padding
+bytes that may be present between some fields on various architectures.
+Consult the the glibc and kernel source code if you need to know the
+details.
+
+\fIst_dev\fP フィールドは、このファイルが存在するデバイスを示す (マクロ \fBmajor\fP(3), \fBminor\fP(3)
+は、このフィールドのデバイス ID を分解するのに役立つだろう)。
+
+\fIst_rdev\fP フィールドは、このファイル (inode) が表すデバイスを示す。
+
+\fIst_size\fP フィールドは、(通常のファイルかシンボリックリンクの場合に)
+ファイルの大きさをバイト単位で示す。 シンボリックリンクの大きさは、
+シンボリックリンクに含まれている パス名の長さ (終端の NULL バイトは含まない)
+である。
+
+\fIst_blocks\fP フィールドは、ファイルの大きさを 512 バイトのブロックサイズ単位で示す フィールドは、ファイルに割り当てされたブロック数を
+512 バイト単位で示す。 (ファイルに穴があるような場合、この値は \fIst_size\fP/512 より小さくなることもある)。
+
+\fIst_blksize\fP フィールドは、効率的にファイルシステム I/O ができる「好ましい」 ブロックサイズを示す
+(もっと小さい単位でファイルに書き込みを行うと、 読み出し\-\-修正\-\-再書き込みといった非効率な動作になってしまうかもしれない)。
.PP
-.\"O The
-.\"O .I st_dev
-.\"O field describes the device on which this file resides.
-.\"O (The
-.\"O .BR major (3)
-.\"O and
-.\"O .BR minor (3)
-.\"O macros may be useful to decompose the device ID in this field.)
-.I st_dev
-¥Õ¥£¡¼¥ë¥É¤Ï¡¢¤³¤Î¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤¹¤ë¥Ç¥Ð¥¤¥¹¤ò¼¨¤¹
-(¥Þ¥¯¥í
-.BR major (3),
-.BR minor (3)
-¤Ï¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤Î¥Ç¥Ð¥¤¥¹ ID ¤òʬ²ò¤¹¤ë¤Î¤ËÌòΩ¤Ä¤À¤í¤¦)¡£
-
-.\"O The
-.\"O .I st_rdev
-.\"O field describes the device that this file (inode) represents.
-.I st_rdev
-¥Õ¥£¡¼¥ë¥É¤Ï¡¢¤³¤Î¥Õ¥¡¥¤¥ë (inode) ¤¬É½¤¹¥Ç¥Ð¥¤¥¹¤ò¼¨¤¹¡£
-
-.\"O The
-.\"O .I st_size
-.\"O field gives the size of the file (if it is a regular
-.\"O file or a symbolic link) in bytes.
-.\"O The size of a symlink is the length of the pathname
-.\"O it contains, without a trailing null byte.
-.I st_size
-¥Õ¥£¡¼¥ë¥É¤Ï¡¢(Ä̾ï¤Î¥Õ¥¡¥¤¥ë¤«¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Î¾ì¹ç¤Ë)
-¥Õ¥¡¥¤¥ë¤ÎÂ礤µ¤ò¥Ð¥¤¥Èñ°Ì¤Ç¼¨¤¹¡£
-¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤ÎÂ礤µ¤Ï¡¢¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë
-¥Ñ¥¹Ì¾¤ÎŤµ (ºÇ¸å¤Î NULL ¥Ð¥¤¥È¤Ï´Þ¤Þ¤Ê¤¤) ¤Ç¤¢¤ë¡£
-
-.\"O The
-.\"O .I st_blocks
-.\"O field indicates the number of blocks allocated to the file, 512-byte units.
-.\"O (This may be smaller than
-.\"O .IR st_size /512
-.\"O when the file has holes.)
-.I st_blocks
-¥Õ¥£¡¼¥ë¥É¤Ï¡¢¥Õ¥¡¥¤¥ë¤ÎÂ礤µ¤ò 512 ¥Ð¥¤¥È¤Î¥Ö¥í¥Ã¥¯¥µ¥¤¥ºÃ±°Ì¤Ç¼¨¤¹
-¥Õ¥£¡¼¥ë¥É¤Ï¡¢¥Õ¥¡¥¤¥ë¤Ë³ä¤êÅö¤Æ¤µ¤ì¤¿¥Ö¥í¥Ã¥¯¿ô¤ò 512 ¥Ð¥¤¥Èñ°Ì¤Ç¼¨¤¹¡£
-(¥Õ¥¡¥¤¥ë¤Ë·ê¤¬¤¢¤ë¤è¤¦¤Ê¾ì¹ç¡¢¤³¤ÎÃͤÏ
-.IR st_size /512
-¤è¤ê¾®¤µ¤¯¤Ê¤ë¤³¤È¤â¤¢¤ë)¡£
-
-.\"O The
-.\"O .I st_blksize
-.\"O field gives the "preferred" blocksize for efficient file system I/O.
-.\"O (Writing to a file in smaller chunks may cause
-.\"O an inefficient read-modify-rewrite.)
-.I st_blksize
-¥Õ¥£¡¼¥ë¥É¤Ï¡¢¸úΨŪ¤Ë¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à I/O ¤¬¤Ç¤¤ë¡Ö¹¥¤Þ¤·¤¤¡×
-¥Ö¥í¥Ã¥¯¥µ¥¤¥º¤ò¼¨¤¹ (¤â¤Ã¤È¾®¤µ¤¤Ã±°Ì¤Ç¥Õ¥¡¥¤¥ë¤Ë½ñ¤¹þ¤ß¤ò¹Ô¤¦¤È¡¢
-Æɤ߽Ф·--½¤Àµ--ºÆ½ñ¤¹þ¤ß¤È¤¤¤Ã¤¿Èó¸úΨ¤ÊÆ°ºî¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¦¤«¤â¤·¤ì¤Ê¤¤)¡£
-.PP
-.\"O Not all of the Linux file systems implement all of the time fields.
-.\"O Some file system types allow mounting in such a way that file
-.\"O and/or directory accesses do not cause an update of the
-.\"O .I st_atime
-.\"O field.
-.\"O (See
-.\"O .IR noatime ,
-.\"O .IR nodiratime ,
-.\"O and
-.\"O .I relatime
-.\"O in
-.\"O .BR mount (8),
-.\"O and related information in
-.\"O .BR mount (2).)
-Á´¤Æ¤Î Linux ¤Î¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à¤¬Á´¤Æ¤Î»þ´Ö¥Õ¥£¡¼¥ë¥É¤ò
-¼ÂÁõ¤·¤Æ¤¤¤ë¤ï¤±¤Ç¤Ï¤Ê¤¤¡£
-¥Õ¥¡¥¤¥ë¤ä¥Ç¥£¥ì¥¯¥È¥ê¤Î¥¢¥¯¥»¥¹¤¬
-.I st_atime
-¥Õ¥£¡¼¥ë¥É¤ò¹¹¿·¤·¤Ê¤¤¤è¤¦¤Ê¤«¤¿¤Á¤Ç¥Þ¥¦¥ó¥È¤Ç¤¤ë¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤â¤¢¤ë¡£
-.RB ( mount (8)
-¤Î
-.IR noatime ,
-.IR nodiratime ,
-.I relatime
-¤ä
-.BR mount (2)
-¤Î´ØÏ¢¤¹¤ë¾ðÊó¤ò»²¾È)¡£
-.\"O In addition,
-.\"O .I st_atime
-.\"O is not updated if a file is opened with the
-.\"O .BR O_NOATIME ;
-.\"O see
-.\"O .BR open (2).
-¤Þ¤¿¡¢¥Õ¥¡¥¤¥ë¤¬
-.B O_NOATIME
-ÉÕ¤¤Ç¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï
-.I st_atime
-¤Ï¹¹¿·¤µ¤ì¤Ê¤¤¡£
-.BR open (2)
-»²¾È¡£
-
-.\"O The field
-.\"O .I st_atime
-.\"O is changed by file accesses, for example, by
-.\"O .BR execve (2),
-.\"O .BR mknod (2),
-.\"O .BR pipe (2),
-.\"O .BR utime (2)
-.\"O and
-.\"O .BR read (2)
-.\"O (of more than zero bytes).
-.\"O Other routines, like
-.\"O .BR mmap (2),
-.\"O may or may not update
-.\"O .IR st_atime .
-.I st_atime
-¥Õ¥£¡¼¥ë¥É¤Ï¥Õ¥¡¥¤¥ë¥¢¥¯¥»¥¹¤¬¤¢¤Ã¤¿¾ì¹ç¤ËÊѹ¹¤µ¤ì¤ë
-(Î㤨¤Ð¡¢
-.BR execve (2),
-.BR mknod (2),
-.BR pipe (2),
-.BR utime (2)
-¤ò»ÈÍѤ·¤¿¾ì¹ç¤ä
-.BR read (2)
-¤Ç 1 ¥Ð¥¤¥È°Ê¾åÆɤ߹þ¤ó¤À¾ì¹ç¤Ê¤É)¡£
-.BR mmap (2)
-¤Ê¤É¤Î¾¤Î¥ë¡¼¥Á¥ó¤Ç¤Ï¡¢
-.I st_atime
-¤Ï¹¹¿·¤µ¤ì¤ë¤³¤È¤â¤¢¤ì¤Ð¡¢¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤â¤¢¤ë¡£
-
-.\"O The field
-.\"O .I st_mtime
-.\"O is changed by file modifications, for example, by
-.\"O .BR mknod (2),
-.\"O .BR truncate (2),
-.\"O .BR utime (2)
-.\"O and
-.\"O .BR write (2)
-.\"O (of more than zero bytes).
-.I st_mtime
-¥Õ¥£¡¼¥ë¥É¤Ï¡¢¥Õ¥¡¥¤¥ë¤¬½¤Àµ¤µ¤ì¤¿¾ì¹ç¤ËÊѹ¹¤µ¤ì¤ë
-(Î㤨¤Ð¡¢
-.BR mknod (2),
-.BR truncate (2),
-.BR utime (2)
-¤ò»ÈÍѤ·¤¿¾ì¹ç¤ä
-.BR write (2)
-¤Ç 1 ¥Ð¥¤¥È°Ê¾å½ñ¤¹þ¤ß¤ò¤·¤¿¾ì¹ç¤Ê¤É)¡£
-.\"O Moreover,
-.\"O .I st_mtime
-.\"O of a directory is changed by the creation or deletion of files
-.\"O in that directory.
-¤µ¤é¤Ë¡¢¥Ç¥£¥ì¥¯¥È¥ê¤Î
-.I st_mtime
-¤Ï¡¢¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ç
-¥Õ¥¡¥¤¥ë¤¬ºîÀ®¤µ¤ì¤¿¤êºï½ü¤µ¤ì¤¿¤ê¤¹¤ë¤ÈÊѹ¹¤µ¤ì¤ë¡£
-.\"O The
-.\"O .I st_mtime
-.\"O field is
-.\"O .I not
-.\"O changed for changes in owner, group, hard link count, or mode.
-.I st_mtime
-¥Õ¥£¡¼¥ë¥É¤Ï
-½êͼԤ䥰¥ë¡¼¥×¤ä¥Ï¡¼¥É¡¦¥ê¥ó¥¯¿ô¤ä¥â¡¼¥É¤ÎÊѹ¹¤Ç¤ÏÊѹ¹
-.I ¤µ¤ì¤Ê¤¤¡£
-
-.\"O The field
-.\"O .I st_ctime
-.\"O is changed by writing or by setting inode information
-.\"O (i.e., owner, group, link count, mode, etc.).
-.I st_ctime
-¥Õ¥£¡¼¥ë¥É¤Ï½ñ¤¹þ¤ß¤ä inode ¾ðÊó
-(½êͼԡ¢¥°¥ë¡¼¥×¡¢¥ê¥ó¥¯¿ô¡¢¥â¡¼¥É¤Ê¤É) ¤Î
-ÀßÄê¤Ë¤è¤Ã¤ÆÊѹ¹¤µ¤ì¤ë¡£
+全ての Linux のファイルシステムが全ての時間フィールドを 実装しているわけではない。 ファイルやディレクトリのアクセスが \fIst_atime\fP
+フィールドを更新しないようなかたちでマウントできるファイルシステムもある。 (\fBmount\fP(8) の \fInoatime\fP,
+\fInodiratime\fP, \fIrelatime\fP や \fBmount\fP(2) の関連する情報を参照)。 また、ファイルが \fBO_NOATIME\fP
+付きでオープンされている場合には \fIst_atime\fP は更新されない。 \fBopen\fP(2) 参照。
+
+\fIst_atime\fP フィールドはファイルアクセスがあった場合に変更される (例えば、 \fBexecve\fP(2), \fBmknod\fP(2),
+\fBpipe\fP(2), \fButime\fP(2) を使用した場合や \fBread\fP(2) で 1 バイト以上読み込んだ場合など)。
+\fBmmap\fP(2) などの他のルーチンでは、 \fIst_atime\fP は更新されることもあれば、そうでない場合もある。
+
+\fIst_mtime\fP フィールドは、ファイルが修正された場合に変更される (例えば、 \fBmknod\fP(2), \fBtruncate\fP(2),
+\fButime\fP(2) を使用した場合や \fBwrite\fP(2) で 1 バイト以上書き込みをした場合など)。 さらに、ディレクトリの
+\fIst_mtime\fP は、そのディレクトリで ファイルが作成されたり削除されたりすると変更される。 \fIst_mtime\fP フィールドは
+所有者やグループやハード・リンク数やモードの変更では変更 \fIされない。\fP
+
+\fIst_ctime\fP フィールドは書き込みや inode 情報 (所有者、グループ、リンク数、モードなど) の 設定によって変更される。
.PP
-.\"O The following POSIX macros are defined to check the file type using the
-.\"O .I st_mode
-.\"O field:
-°Ê²¼¤Î POSIX ¥Þ¥¯¥í¤Ï¡¢
-.I st_mode
-¥Õ¥£¡¼¥ë¥É
-¤Ç»ÈÍѤµ¤ì¤ë¥Õ¥¡¥¤¥ë¼ïÊ̤ΥÁ¥§¥Ã¥¯¤Î¤¿¤á¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë :
+以下の POSIX マクロは、 \fIst_mode\fP フィールド で使用されるファイル種別のチェックのために定義されている :
.RS 4
-.TP 1.2i
-.BR S_ISREG (m)
-.\"O is it a regular file?
-Ä̾ï¤Î¥Õ¥¡¥¤¥ë¤«?
-.TP
-.BR S_ISDIR (m)
-.\"O directory?
-¥Ç¥£¥ì¥¯¥È¥ê¤«?
-.TP
-.BR S_ISCHR (m)
-.\"O character device?
-¥¥ã¥é¥¯¥¿¡¼¡¦¥Ç¥Ð¥¤¥¹¤«?
-.TP
-.BR S_ISBLK (m)
-.\"O block device?
-¥Ö¥í¥Ã¥¯¡¦¥Ç¥Ð¥¤¥¹¤«?
-.TP
-.BR S_ISFIFO (m)
-.\"O FIFO (named pipe)?
-FIFO (̾Á°ÉÕ¤¥Ñ¥¤¥×) ¤«?
-.TP
-.BR S_ISLNK (m)
-.\"O symbolic link? (Not in POSIX.1-1996.)
-¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤«? (POSIX.1-1996 ¤Ë¤Ï¤Ê¤¤)
-.TP
-.BR S_ISSOCK (m)
-.\"O socket? (Not in POSIX.1-1996.)
-¥½¥±¥Ã¥È¤«? (POSIX.1-1996 ¤Ë¤Ï¤Ê¤¤)
+.TP 1.2i
+\fBS_ISREG\fP(m)
+通常のファイルか?
+.TP
+\fBS_ISDIR\fP(m)
+ディレクトリか?
+.TP
+\fBS_ISCHR\fP(m)
+キャラクター・デバイスか?
+.TP
+\fBS_ISBLK\fP(m)
+ブロック・デバイスか?
+.TP
+\fBS_ISFIFO\fP(m)
+FIFO (名前付きパイプ) か?
+.TP
+\fBS_ISLNK\fP(m)
+シンボリックリンクか? (POSIX.1\-1996 にはない)
+.TP
+\fBS_ISSOCK\fP(m)
+ソケットか? (POSIX.1\-1996 にはない)
.RE
.PP
-.\"O The following flags are defined for the
-.\"O .I st_mode
-.\"O field:
-°Ê²¼¤Î¥Õ¥é¥°¤¬
-.I st_mode
-¥Õ¥£¡¼¥ë¥ÉÍѤËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
+以下のフラグが \fIst_mode\fP フィールド用に定義されている:
.in +4n
.TS
lB l l.
-.\"O S_IFMT 0170000 bit mask for the file type bit fields
-.\"O S_IFSOCK 0140000 socket
-.\"O S_IFLNK 0120000 symbolic link
-.\"O S_IFREG 0100000 regular file
-.\"O S_IFBLK 0060000 block device
-.\"O S_IFDIR 0040000 directory
-.\"O S_IFCHR 0020000 character device
-.\"O S_IFIFO 0010000 FIFO
-S_IFMT 0170000 ¥Õ¥¡¥¤¥ë¼ïÊ̤ò¼¨¤¹¥Ó¥Ã¥ÈÎΰè¤òɽ¤¹¥Ó¥Ã¥È¥Þ¥¹¥¯
-S_IFSOCK 0140000 ¥½¥±¥Ã¥È
-S_IFLNK 0120000 ¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯
-S_IFREG 0100000 Ä̾ï¤Î¥Õ¥¡¥¤¥ë
-S_IFBLK 0060000 ¥Ö¥í¥Ã¥¯¡¦¥Ç¥Ð¥¤¥¹
-S_IFDIR 0040000 ¥Ç¥£¥ì¥¯¥È¥ê
-S_IFCHR 0020000 ¥¥ã¥é¥¯¥¿¡¼¡¦¥Ç¥Ð¥¤¥¹
+S_IFMT 0170000 ファイル種別を示すビット領域を表すビットマスク
+S_IFSOCK 0140000 ソケット
+S_IFLNK 0120000 シンボリックリンク
+S_IFREG 0100000 通常のファイル
+S_IFBLK 0060000 ブロック・デバイス
+S_IFDIR 0040000 ディレクトリ
+S_IFCHR 0020000 キャラクター・デバイス
S_IFIFO 0010000 FIFO
-.\"O S_ISUID 0004000 set-user-ID bit
-.\"O S_ISGID 0002000 set-group-ID bit (see below)
-.\"O S_ISVTX 0001000 sticky bit (see below)
-S_ISUID 0004000 set-user-ID bit
-S_ISGID 0002000 set-group-ID bit (²¼µ»²¾È)
-S_ISVTX 0001000 ¥¹¥Æ¥£¥Ã¥¡¼¡¦¥Ó¥Ã¥È (²¼µ»²¾È)
-.\"O S_IRWXU 00700 mask for file owner permissions
-.\"O S_IRUSR 00400 owner has read permission
-.\"O S_IWUSR 00200 owner has write permission
-.\"O S_IXUSR 00100 owner has execute permission
-S_IRWXU 00700 ¥Õ¥¡¥¤¥ë½êͼԤΥ¢¥¯¥»¥¹µö²ÄÍѤΥӥåȥޥ¹¥¯
-S_IRUSR 00400 ½êͼԤÎÆɤ߹þ¤ßµö²Ä
-S_IWUSR 00200 ½êͼԤνñ¤¹þ¤ßµö²Ä
-S_IXUSR 00100 ½êͼԤμ¹Եö²Ä
-.\"O S_IRWXG 00070 mask for group permissions
-.\"O S_IRGRP 00040 group has read permission
-.\"O S_IWGRP 00020 group has write permission
-.\"O S_IXGRP 00010 group has execute permission
-S_IRWXG 00070 ¥°¥ë¡¼¥×¤Î¥¢¥¯¥»¥¹µö²ÄÍѤΥӥåȥޥ¹¥¯
-S_IRGRP 00040 ¥°¥ë¡¼¥×¤ÎÆɤ߹þ¤ßµö²Ä
-S_IWGRP 00020 ¥°¥ë¡¼¥×¤Î½ñ¤¹þ¤ßµö²Ä
-S_IXGRP 00010 ¥°¥ë¡¼¥×¤Î¼Â¹Ôµö²Ä
-.\"O S_IRWXO 00007 mask for permissions for others (not in group)
-.\"O S_IROTH 00004 others have read permission
-.\"O S_IWOTH 00002 others have write permission
-.\"O S_IXOTH 00001 others have execute permission
-S_IRWXO 00007 ¾¿Í (others) ¤Î¥¢¥¯¥»¥¹µö²ÄÍѤΥӥåȥޥ¹¥¯
-S_IROTH 00004 ¾¿Í¤ÎÆɤ߹þ¤ßµö²Ä
-S_IWOTH 00002 ¾¿Í¤Î½ñ¤¹þ¤ßµö²Ä
-S_IXOTH 00001 ¾¿Í¤Î¼Â¹Ôµö²Ä
+S_ISUID 0004000 set\-user\-ID bit
+S_ISGID 0002000 set\-group\-ID bit (下記参照)
+S_ISVTX 0001000 スティッキー・ビット (下記参照)
+S_IRWXU 00700 ファイル所有者のアクセス許可用のビットマスク
+S_IRUSR 00400 所有者の読み込み許可
+S_IWUSR 00200 所有者の書き込み許可
+S_IXUSR 00100 所有者の実行許可
+S_IRWXG 00070 グループのアクセス許可用のビットマスク
+S_IRGRP 00040 グループの読み込み許可
+S_IWGRP 00020 グループの書き込み許可
+S_IXGRP 00010 グループの実行許可
+S_IRWXO 00007 T{
+他人 (others) のアクセス許可用のビットマスク
+T}
+S_IROTH 00004 他人の読み込み許可
+S_IWOTH 00002 他人の書き込み許可
+S_IXOTH 00001 他人の実行許可
.TE
.in
.P
-.\"O The set-group-ID bit
-.\"O .RB ( S_ISGID )
-.\"O has several special uses.
-.\"O For a directory it indicates that BSD semantics is to be used
-.\"O for that directory: files created there inherit their group ID from
-.\"O the directory, not from the effective group ID of the creating process,
-.\"O and directories created there will also get the
-.\"O .B S_ISGID
-.\"O bit set.
-.\"O For a file that does not have the group execution bit
-.\"O .RB ( S_IXGRP )
-.\"O set,
-.\"O the set-group-ID bit indicates mandatory file/record locking.
-set-group-ID bit
-.RB ( S_ISGID )
-¤Ë¤Ï¤¤¤¯¤Ä¤«¤ÎÆüì¤Ê»ÈÍÑË¡¤¬¤¢¤ë:
-¥Ç¥£¥ì¥¯¥È¥ê¤ËÀßÄꤷ¤¿¾ì¹ç¤Ë¤Ï¡¢¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤¬ BSD Êý¼°¤Ç»ÈÍѤµ¤ì¤ë
-¤³¤È¤ò¼¨¤¹¡£¤Ä¤Þ¤ê¡¢¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ËºîÀ®¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤Î¥°¥ë¡¼¥×ID ¤Ï
-ºîÀ®¤·¤¿¥×¥í¥»¥¹¤Î¼Â¸ú (effective) ¥°¥ë¡¼¥×ID ¤Ç¤Ï¤Ê¤¯¡¢¥Ç¥£¥ì¥¯¥È¥ê¤Î
-¥°¥ë¡¼¥×ID ¤ò·Ñ¾µ¤¹¤ë¡£¤Þ¤¿¡¢¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ËºîÀ®¤µ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤Ë¤â
-.B S_ISGID
-¥Ó¥Ã¥È¤¬ÀßÄꤵ¤ì¤ë¡£¥°¥ë¡¼¥×¼Â¹Ô¥Ó¥Ã¥È
-.RB ( S_IXGRP )
-¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¥Õ¥¡¥¤¥ë¤ËÀßÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢
-set-group-ID ¥Ó¥Ã¥È¤Ï¥Õ¥¡¥¤¥ë/¥ì¥³¡¼¥É¤Î
-¶¯À©Åª¤Ê (mandatory) ¥í¥Ã¥¯¤òɽ¤¹¡£
+set\-group\-ID bit (\fBS_ISGID\fP) にはいくつかの特殊な使用法がある: ディレクトリに設定した場合には、そのディレクトリが
+BSD 方式で使用される ことを示す。つまり、そのディレクトリに作成されたファイルのグループID は 作成したプロセスの実効 (effective)
+グループID ではなく、ディレクトリの グループID を継承する。また、そのディレクトリに作成されたディレクトリにも \fBS_ISGID\fP
+ビットが設定される。グループ実行ビット (\fBS_IXGRP\fP) が設定されていないファイルに設定された場合は、 set\-group\-ID
+ビットはファイル/レコードの 強制的な (mandatory) ロックを表す。
.P
-.\"O The sticky bit (S_ISVTX) on a directory means that a file
-.\"O in that directory can be renamed or deleted only by the owner
-.\"O of the file, by the owner of the directory, and by a privileged
-.\"O process.
-¥Ç¥£¥ì¥¯¥È¥ê¤Ë¥¹¥Æ¥£¥Ã¥¡¼¥Ó¥Ã¥È (S_ISVTX) ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢
-¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Õ¥¡¥¤¥ë¤Î̾Á°¤òÊѹ¹¤·¤¿¤ê¡¢ºï½ü¤·¤¿¤ê¤Ç¤¤ë¤Î¤Ï¡¢
-¤½¤Î¥Õ¥¡¥¤¥ë¤Î½êͼԤ«¡¢¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î½êͼԤ«¡¢Æø¢¥×¥í¥»¥¹
-¤À¤±¤È¤Ê¤ë¡£
-.\"O .SH "RETURN VALUE"
-.SH ÊÖ¤êÃÍ
-.\"O On success, zero is returned.
-.\"O On error, \-1 is returned, and
-.\"O .I errno
-.\"O is set appropriately.
-À®¸ù¤·¤¿¾ì¹ç¤Ï 0 ¤òÊÖ¤¹¡£¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤òÊÖ¤·¡¢
-.I errno
-¤ËŬÀÚ¤ÊÃͤ¬ÀßÄꤵ¤ì¤ë¡£
-.\"O .SH ERRORS
-.SH ¥¨¥é¡¼
-.TP
-.B EACCES
-.\"O Search permission is denied for one of the directories
-.\"O in the path prefix of
-.\"O .IR path .
-.\"O (See also
-.\"O .BR path_resolution (7).)
-.I path
-¤¬½ê°¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¤È¤½¤Î¾å°Ì¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î¤¤¤º¤ì¤«¤Ë
-ÂФ¹¤ë¸¡º÷µö²Ä¤¬¤Ê¤«¤Ã¤¿
-.RB ( path_resolution (7)
-¤â»²¾È¤Î¤³¤È)¡£
-.TP
-.B EBADF
-.\"O .I fd
-.\"O is bad.
-.I fd
-¤¬ÉÔÀµ¤Ç¤¢¤ë¡£
-.TP
-.B EFAULT
-.\"O Bad address.
-¥¢¥É¥ì¥¹¤¬´Ö°ã¤Ã¤Æ¤¤¤ë¡£
-.TP
-.B ELOOP
-.\"O Too many symbolic links encountered while traversing the path.
-¥Ñ¥¹¤òé¤ëºÝ¤Ë²ò·è¤¹¤Ù¤¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤¬Â¿²á¤®¤¿¡£
-.TP
-.B ENAMETOOLONG
-.\"O .I path
-.\"O is too long.
-.I path
-¤¬Ä¹²á¤®¤ë¡£
-.TP
-.B ENOENT
-.\"O A component of
-.\"O .I path
-.\"O does not exist, or
-.\"O .I path
-.\"O is an empty string.
-.I path
-¤Î¹½À®Í×ÁǤ¬Â¸ºß¤·¤Ê¤¤¤«¡¢
-.I path
-¤¬¶õʸ»úÎó¤Ç¤¢¤ë¡£
-.TP
-.B ENOMEM
-.\"O Out of memory (i.e., kernel memory).
-¥«¡¼¥Í¥ë¤Î¥á¥â¥ê¤¬Â¤ê¤Ê¤¤¡£
-.TP
-.B ENOTDIR
-.\"O A component of the path prefix of
-.\"O .I path
-.\"O is not a directory.
-.I path
-¤ÎÁ°È¾Éôʬ (prefix) ¤Î¹½À®Í×ÁǤ¬¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ï¤Ê¤¤¡£
-.TP
-.B EOVERFLOW
-.\"O .RB ( stat ())
-.\"O .I path
-.\"O refers to a file whose size cannot be represented in the type
-.\"O .IR off_t .
-.\"O This can occur when an application compiled on a 32-bit platform without
-.\"O .I -D_FILE_OFFSET_BITS=64
-.\"O calls
-.\"O .BR stat ()
-.\"O on a file whose size exceeds
-.\"O .I (1<<31)-1
-.\"O bits.
-.RB ( stat ())
-.I path
-¤¬¡¢¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤ò
-.I off_t
-·¿¤Çɽ¸½¤Ç¤¤Ê¤¤¥Õ¥¡¥¤¥ë¤ò»²¾È¤·¤Æ¤¤¤ë¡£
-¤³¤Î¥¨¥é¡¼¤¬µ¯¤³¤ë¤Î¤Ï¡¢32 ¥Ó¥Ã¥È¥×¥é¥Ã¥È¥Õ¥©¡¼¥à¾å¤Ç
-.I -D_FILE_OFFSET_BITS=64
-¤ò»ØÄꤻ¤º¤Ë¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬¡¢¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤¬
-.I (1<31)-1
-¥Ó¥Ã¥È¤òĶ¤¨¤ë¥Õ¥¡¥¤¥ë¤ËÂФ·¤Æ
-.BR stat ()
-¤ò¸Æ¤Ó½Ð¤·¤¿¾ì¹ç¤Ç¤¢¤ë¡£
-.\"O .SH "CONFORMING TO"
-.SH ½àµò
-.\"O These system calls conform to SVr4, 4.3BSD, POSIX.1-2001.
-¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï SVr4, 4.3BSD, POSIX.1-2001 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
-.\"O .\" SVr4 documents additional
-.\"O .\" .BR fstat ()
-.\"O .\" error conditions EINTR, ENOLINK, and EOVERFLOW. SVr4
-.\"O .\" documents additional
-.\"O .\" .BR stat ()
-.\"O .\" and
-.\"O .\" .BR lstat ()
-.\"O .\" error conditions EINTR, EMULTIHOP, ENOLINK, and EOVERFLOW.
-.BR stat ()
-¤È
-.BR fstat ()
-¥³¡¼¥ë¤Ï SVr4, SVID, POSIX, X/OPEN, 4.3BSD ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
-.BR lstat ()
-¥³¡¼¥ë¤Ï 4.3BSD ¤È SVr4 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
-.\" SVr4 ¤Ë¤Ï¾¤Ë
+.\"
+.\"
+ディレクトリにスティッキービット (S_ISVTX) が設定された場合は、 そのディレクトリのファイルの名前を変更したり、削除したりできるのは、
+そのファイルの所有者か、そのディレクトリの所有者か、特権プロセス だけとなる。
+.SS fstatat()
+\fBfstatat\fP() システムコールは \fBstat\fP() と全く同様に動作するが、以下で説明する点が異なる。
+
+If the pathname given in \fIpathname\fP is relative, then it is interpreted
+relative to the directory referred to by the file descriptor \fIdirfd\fP
+(rather than relative to the current working directory of the calling
+process, as is done by \fBstat\fP() for a relative pathname).
+
+If \fIpathname\fP is relative and \fIdirfd\fP is the special value \fBAT_FDCWD\fP,
+then \fIpathname\fP is interpreted relative to the current working directory of
+the calling process (like \fBstat\fP()).
+
+If \fIpathname\fP is absolute, then \fIdirfd\fP is ignored.
+
+この \fIflags\fP 引き数は下記のフラグの 0 個以上の論理和を取ったものである:
+.TP
+\fBAT_EMPTY_PATH\fP (Linux 2.6.39 以降)
+.\" commit 65cfc6722361570bfe255698d9cd4dccaf47570d
+.\" Before glibc 2.16, defining _ATFILE_SOURCE sufficed
+If \fIpathname\fP is an empty string, operate on the file referred to by
+\fIdirfd\fP (which may have been obtained using the \fBopen\fP(2) \fBO_PATH\fP
+flag). If \fIdirfd\fP is \fBAT_FDCWD\fP, the call operates on the current working
+directory. In this case, \fIdirfd\fP can refer to any type of file, not just a
+directory. This flag is Linux\-specific; define \fB_GNU_SOURCE\fP to obtain its
+definition.
+.TP
+\fBAT_NO_AUTOMOUNT\fP (Linux 2.6.38 以降)
+.\" Before glibc 2.16, defining _ATFILE_SOURCE sufficed
+Don't automount the terminal ("basename") component of \fIpathname\fP if it is
+a directory that is an automount point. This allows the caller to gather
+attributes of an automount point (rather than the location it would mount).
+This flag can be used in tools that scan directories to prevent
+mass\-automounting of a directory of automount points. The
+\fBAT_NO_AUTOMOUNT\fP flag has no effect if the mount point has already been
+mounted over. This flag is Linux\-specific; define \fB_GNU_SOURCE\fP to obtain
+its definition.
+.TP
+\fBAT_SYMLINK_NOFOLLOW\fP
+If \fIpathname\fP is a symbolic link, do not dereference it: instead return
+information about the link itself, like \fBlstat\fP(). (By default,
+\fBfstatat\fP() dereferences symbolic links, like \fBstat\fP().)
+.PP
+See \fBopenat\fP(2) for an explanation of the need for \fBfstatat\fP().
+.SH 返り値
+成功した場合、0 が返される。 失敗した場合、 \-1 が返され、 \fIerrno\fP に適切な値がセットされる。
+.SH エラー
+.TP
+\fBEACCES\fP
+\fIpathname\fP が所属するディレクトリとその上位のディレクトリのいずれかに 対する検索許可がなかった
+(\fBpath_resolution\fP(7) も参照のこと)。
+.TP
+\fBEBADF\fP
+\fIfd\fP が不正である。
+.TP
+\fBEFAULT\fP
+アドレスが間違っている。
+.TP
+\fBELOOP\fP
+パスを辿る際に解決すべきシンボリックリンクが多過ぎた。
+.TP
+\fBENAMETOOLONG\fP
+\fIpathname\fP が長過ぎる。
+.TP
+\fBENOENT\fP
+\fIpathname\fP の構成要素が存在しないか、 \fIpathname\fP が空文字列である。
+.TP
+\fBENOMEM\fP
+カーネルのメモリが足りない。
+.TP
+\fBENOTDIR\fP
+\fIpathname\fP の前半部分 (prefix) の構成要素がディレクトリではない。
+.TP
+\fBEOVERFLOW\fP
+\fIpathname\fP または \fIfd\fP が、ファイルサイズ、inode 番号、ブロック数が
+それぞれ \fIoff_t\fP 型、 \fIino_t\fP 型、 \fIblkcnt_t\fP 型で表現できないファイルを
+参照している。このエラーが起こるのは、例えば、32 ビットプラットフォーム上で
+\fI\-D_FILE_OFFSET_BITS=64\fP を指定せずにコンパイルされたアプリケーションが、
+ファイルサイズが \fI(1<<31)\-1\fP バイトを超えるファイルに対して
+\fBstat\fP() を呼び出した場合である。
+.PP
+The following additional errors can occur for \fBfstatat\fP():
+.TP
+\fBEBADF\fP
+\fIdirfd\fP が有効なファイルディスクリプタでない。
+.TP
+\fBEINVAL\fP
+\fIflags\fP に無効なフラグが指定された。
+.TP
+\fBENOTDIR\fP
+\fIpathname\fP is relative and \fIdirfd\fP is a file descriptor referring to a
+file other than a directory.
+.SH バージョン
+\fBfstatat\fP() はカーネル 2.6.16 で Linux に追加された。 ライブラリによるサポートはバージョン 2.4 で glibc
+に追加された。
+.SH 準拠
+.\" SVr4 documents additional
.\" .BR fstat ()
-.\" ¤Î¥¨¥é¡¼¤È¤·¤Æ EINTR, ENOLINK, EOVERFLOW ¤¬µºÜ¤µ¤ì¤Æ¤¤¤ë¡£
-.\" SVr4 ¤Ë¤Ï¾¤Ë
+.\" error conditions EINTR, ENOLINK, and EOVERFLOW. SVr4
+.\" documents additional
.\" .BR stat ()
-.\" ¤È
+.\" and
.\" .BR lstat ()
-.\" ¤Î¥¨¥é¡¼¤È¤·¤Æ EINTR, EMULTIHOP, ENOLINK, EOVERFLOW ¤¬µºÜ¤µ¤ì¤Æ¤¤¤ë¡£
-
-.\"O Use of the
-.\"O .I st_blocks
-.\"O and
-.\"O .I st_blksize
-.\"O fields may be less portable.
-.\"O (They were introduced in BSD.
-.\"O The interpretation differs between systems,
-.\"O and possibly on a single system when NFS mounts are involved.)
-.I st_blocks
-¤È
-.I st_blksize
-¥Õ¥£¡¼¥ë¥É¤Î»ÈÍѤϤ¢¤Þ¤ê°Ü¿¢À¤¬¤Ê¤¤¡£
-(¤³¤ì¤é¤Î¥Õ¥£¡¼¥ë¥É¤Ï BSD ¤Ë¤è¤Ã¤ÆƳÆþ¤µ¤ì¤¿¡£
-¥·¥¹¥Æ¥à¤´¤È¤Ë²ò¼á¤¬°Û¤Ê¤Ã¤Æ¤ª¤ê¡¢
-NFS ¥Þ¥¦¥ó¥È¤Î¾ì¹ç¤Ë¤ÏƱ¤¸¥·¥¹¥Æ¥à¤Ç¤â°Û¤Ê¤ë²ÄǽÀ¤¬¤¢¤ë)
+.\" error conditions EINTR, EMULTIHOP, ENOLINK, and EOVERFLOW.
+\fBstat\fP(), \fBfstat\fP(), \fBlstat\fP(): SVr4, 4.3BSD, POSIX.1\-2001, POSIX.1.2008.
+
+\fBfstatat\fP(): POSIX.1\-2008.
+
+POSIX.1\-2001 では、シンボリックリンクに対する \fBlstat\fP() で
+有効な情報を返すように求められていたのは、 \fIstat\fP 構造体の \fIst_size\fP
+と \fIst_mode\fP のファイル種別要素だけであった。
+POSIX.1\-2008 では規定が厳しくなり、 \fBlstat\fP() は \fIst_mode\fP の
+アクセス許可ビット以外の全てのフィールドに有効な情報を返すことが
+求められるようになっている。
+
+\fIst_blocks\fP と \fIst_blksize\fP フィールドの使用はあまり移植性がない
+(これらのフィールドは BSD によって導入された。 システムごとに解釈が
+異なっており、 NFS マウントの場合には同じシステムでも異なる可能性がある)。
+\fI<sys/stat.h>\fP から \fIblkcnt_t\fP の \fIblksize_t\fP 型定義を
+読み込みたい場合は、(\fIどの\fPヘッダファイルをインクルードするよりも前に)
+\fB_XOPEN_SOURCE\fP を 500 以上の値で定義すること。
.LP
-.\"O POSIX does not describe the
-.\"O .BR S_IFMT ,
-.\"O .BR S_IFSOCK ,
-.\"O .BR S_IFLNK ,
-.\"O .BR S_IFREG ,
-.\"O .BR S_IFBLK ,
-.\"O .BR S_IFDIR ,
-.\"O .BR S_IFCHR ,
-.\"O .BR S_IFIFO ,
-.\"O .B S_ISVTX
-.\"O bits, but instead demands the use of
-.\"O the macros
-.\"O .BR S_ISDIR (),
-.\"O etc.
-.\"O The
-.\"O .BR S_ISLNK ()
-.\"O and
-.\"O .BR S_ISSOCK ()
-.\"O macros are not in
-.\"O POSIX.1-1996, but both are present in POSIX.1-2001;
-.\"O the former is from SVID 4, the latter from SUSv2.
-POSIX ¤Ë¤Ï
-.BR S_IFMT ,
-.BR S_IFSOCK ,
-.BR S_IFLNK ,
-.BR S_IFREG ,
-.BR S_IFBLK ,
-.BR S_IFDIR ,
-.BR S_IFCHR ,
-.BR S_IFIFO ,
-.B S_ISVTX
-¥Ó¥Ã¥È¤Ë¤Ä¤¤¤Æ¤Îµ½Ò¤Ï¤Ê¤¤¡£¤«¤ï¤ê¤Ë
-.BR S_ISDIR ()
-¤Î¤è¤¦¤Ê¥Þ¥¯¥í¤ò»ÈÍѤ¹¤ë¤è¤¦¤ËÍ׵ᤷ¤Æ¤¤¤ë¡£
-¥Þ¥¯¥í
-.BR S_ISLNK ()
-¤È
-.BR S_ISSOCK ()
-¤Ï POSIX.1-1996 ¤Ë¤Ï¤Ê¤¤¤¬¡¢
-POSIX.1-2001 ¤Ë¤ÏξÊý¤È¤â¸ºß¤¹¤ë¡£
-Á°¼Ô¤Ï SVID 4 ¤Ë¡¢¸å¼Ô¤Ï SUSv2 ¤ËͳÍ褷¤Æ¤¤¤ë¡£
+POSIX.1\-1990 には \fBS_IFMT\fP, \fBS_IFSOCK\fP, \fBS_IFLNK\fP, \fBS_IFREG\fP,
+\fBS_IFBLK\fP, \fBS_IFDIR\fP, \fBS_IFCHR\fP, \fBS_IFIFO\fP, \fBS_ISVTX\fP 定数に関する
+記述はなかったが、代わりに \fBS_ISDIR\fP() のようなマクロを使用するように
+要求していた。 \fBS_IF*\fP 定数は POSIX.1\-2001 以降には存在する。
+
+マクロ \fBS_ISLNK\fP() と \fBS_ISSOCK\fP() は POSIX.1\-1996 にはないが、
+POSIX.1\-2001 には両方とも存在する。 前者は SVID 4 に、後者は SUSv2 に
+由来している。
.LP
-.\"O Unix V7 (and later systems) had S_IREAD, S_IWRITE, S_IEXEC, where POSIX
-.\"O prescribes the synonyms S_IRUSR, S_IWUSR, S_IXUSR.
-.\"O Unix V7 (and later systems) had
-.\"O .BR S_IREAD ,
-.\"O .BR S_IWRITE ,
-.\"O .BR S_IEXEC ,
-.\"O where POSIX
-.\"O prescribes the synonyms
-.\"O .BR S_IRUSR ,
-.\"O .BR S_IWUSR ,
-.\"O .BR S_IXUSR .
-Unix V7 (¤È¤½¤Î¸å¤Î¥·¥¹¥Æ¥à) ¤Ï
-.BR S_IREAD ,
-.BR S_IWRITE ,
-.B S_IEXEC
-¤ò»ý¤Ã¤Æ¤ª¤ê¡¢
-POSIX ¤Ï¤½¤ÎƱµÁ¸ì¤È¤·¤Æ
-.BR S_IRUSR ,
-.BR S_IWUSR ,
-.B S_IXUSR
-¤òµ¬Äꤷ¤Æ¤¤¤ë¡£
-.\"O .SS "Other Systems"
-.SS ¾¤Î¥·¥¹¥Æ¥à
-.\"O Values that have been (or are) in use on various systems:
-³Æ¼ï¥·¥¹¥Æ¥à¤Ç»ÈÍѤµ¤ì¤Æ¤¤¤¿(¤¤¤ë)ÃÍ:
+UNIX V7 (とその後のシステム) は \fBS_IREAD\fP, \fBS_IWRITE\fP, \fBS_IEXEC\fP を持っており、
+POSIX はその同義語として \fBS_IRUSR\fP, \fBS_IWUSR\fP, \fBS_IXUSR\fP を規定している。
+.SS 他のシステム
+各種システムで使用されていた(いる)値:
+.ad l
.TS
l l l l l.
-.\"O hex name ls octal description
-16¿Ê ̾Á° ls 8¿Ê¿ô ÀâÌÀ
-.\"O f000 S_IFMT 170000 mask for file type
-.\"O 0000 000000 SCO out-of-service inode, BSD unknown
-.\"O type; SVID-v2 and XPG2 have both
-.\"O 0 and 0100000 for ordinary file
-f000 S_IFMT 170000 ¥Õ¥¡¥¤¥ë¼ïÊÌ¥Õ¥£¡¼¥ë¥É¤Î¥Ó¥Ã¥È¥Þ¥¹¥¯
-0000 000000 SCO ¤Ç¤Ï »ÈÍÑÉÔǽ inode;
- BSD ¤Ç¤Ï̤ÃΤΥե¡¥¤¥ë¼ïÊÌ;
- SVID-v2 ¤È XPG2 ¤Ç¤Ï 0 ¤È 0100000 ¤Î
- ξÊý¤¬ÉáÄ̤Υե¡¥¤¥ë
-.\"O 1000 S_IFIFO p| 010000 FIFO (named pipe)
-.\"O 2000 S_IFCHR c 020000 character special (V7)
-.\"O 3000 S_IFMPC 030000 multiplexed character special (V7)
-.\"O 4000 S_IFDIR d/ 040000 directory (V7)
-.\"O 5000 S_IFNAM 050000 XENIX named special file
-.\"O with two subtypes, distinguished by
-.\"O \fIst_rdev\fP values 1, 2
-.\"O 0001 S_INSEM s 000001 XENIX semaphore subtype of IFNAM
-.\"O 0002 S_INSHD m 000002 XENIX shared data subtype of IFNAM
-1000 S_IFIFO p| 010000 FIFO (̾Á°ÉÕ¤¥Ñ¥¤¥×)
-2000 S_IFCHR c 020000 ¥¥ã¥é¥¯¥¿Æüì¥Õ¥¡¥¤¥ë (V7)
-3000 S_IFMPC 030000 ¿½Å²½¤µ¤ì¤¿¥¥ã¥é¥¯¥¿Æüì¥Õ¥¡¥¤¥ë (V7)
-4000 S_IFDIR d/ 040000 ¥Ç¥£¥ì¥¯¥È¥ê (V7)
-5000 S_IFNAM 050000 XENIX Æó¤Ä¤ÎÉû·¿¤ò»ý¤Ä̾Á°ÉÕ¤¤Î
- Æüì¥Õ¥¡¥¤¥ë
- Éû·¿¤Ï \fIst_rdev\fP ¤ÎÃÍ 1,2 ¤Ç¶èÊ̤µ¤ì¤ë:
-0001 S_INSEM s 000001 XENIX IFNAM¤Î¥»¥Þ¥Õ¥©¡¼Éû·¿
-0002 S_INSHD m 000002 XENIX IFNAM¤Î¶¦Í¥Ç¡¼¥¿Éû·¿
-.\"O 6000 S_IFBLK b 060000 block special (V7)
-.\"O 7000 S_IFMPB 070000 multiplexed block special (V7)
-.\"O 8000 S_IFREG - 100000 regular (V7)
-.\"O 9000 S_IFCMP 110000 VxFS compressed
-.\"O 9000 S_IFNWK n 110000 network special (HP-UX)
-.\"O a000 S_IFLNK l@ 120000 symbolic link (BSD)
-6000 S_IFBLK b 060000 ¥Ö¥í¥Ã¥¯Æüì¥Õ¥¡¥¤¥ë (V7)
-7000 S_IFMPB 070000 ¿½Å²½¤µ¤ì¤¿¥Ö¥í¥Ã¥¯Æüì¥Õ¥¡¥¤¥ë (V7)
-8000 S_IFREG - 100000 Ä̾ï¥Õ¥¡¥¤¥ë (V7)
-9000 S_IFCMP 110000 VxFS °µ½Ì¥Õ¥¡¥¤¥ë
-9000 S_IFNWK n 110000 ¥Í¥Ã¥È¥ï¡¼¥¯Æüì¥Õ¥¡¥¤¥ë (HP-UX)
-a000 S_IFLNK l@ 120000 ¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯ (BSD)
-.\"O b000 S_IFSHAD 130000 Solaris shadow inode for ACL
-.\"O (not seen by userspace)
-.\"O c000 S_IFSOCK s= 140000 socket (BSD; also "S_IFSOC" on VxFS)
-.\"O d000 S_IFDOOR D> 150000 Solaris door
-.\"O e000 S_IFWHT w% 160000 BSD whiteout (not used for inode)
-b000 S_IFSHAD 130000 Solaris ACL ¤Î¤¿¤á¤Î±£¤µ¤ì¤¿ inode
- (¥æ¡¼¥¶¶õ´Ö¤«¤é¤Ï¸«¤¨¤Ê¤¤)
-c000 S_IFSOCK s= 140000 ¥½¥±¥Ã¥È (BSD; VxFS ¤Î "S_IFSOC")
-d000 S_IFDOOR D> 150000 Solaris ¥É¥¢¡¦¥Õ¥¡¥¤¥ë
-e000 S_IFWHT w% 160000 BSD ¶õÇò¥Õ¥¡¥¤¥ë (inode ¤ò»ÈÍѤ·¤Ê¤¤)
-.\"O 0200 S_ISVTX 001000 sticky bit: save swapped text even
-.\"O after use (V7)
-.\"O reserved (SVID-v2)
-.\"O On nondirectories: don't cache this
-.\"O file (SunOS)
-.\"O On directories: restricted deletion
-.\"O flag (SVID-v4.2)
-.\"O 0400 S_ISGID 002000 set-group-ID on execution (V7)
-.\"O for directories: use BSD semantics for
-.\"O propagation of GID
-.\"O 0400 S_ENFMT 002000 System V file locking enforcement (shared
-.\"O with S_ISGID)
-.\"O 0800 S_ISUID 004000 set-user-ID on execution (V7)
-.\"O 0800 S_CDF 004000 directory is a context dependent
-.\"O file (HP-UX)
-0200 S_ISVTX 001000 `¥¹¥Æ¥£¥Ã¥¡¼¡¦¥Ó¥Ã¥È':»ÈÍѸå¤â
- ¥¹¥ï¥Ã¥×¤Ë»Ä¤¹ (V7)
- ͽÌó (SVID-v2)
- ¥Ç¥£¥ì¥¯¥È¥ê°Ê³°: ¥Õ¥¡¥¤¥ë¤ò¥¥ã¥Ã¥·¥å
- ¤·¤Ê¤¤ (SunOS)
- ¥Ç¥£¥ì¥¯¥È¥ê: ºï½üÀ©¸Â¥Õ¥é¥° (SVID-v4.2)
-0400 S_ISGID 002000 ¼Â¹Ô»þ¤Î set-group-ID (V7)
- ¥Ç¥£¥ì¥¯¥È¥ê¤ËÂФ·¤Æ¤Ï GID ¤ÎÅÁã¤Ë
- BSD Êý¼°¤ò»ÈÍѤ¹¤ë
-0400 S_ENFMT 002000 System V ¥Õ¥¡¥¤¥ë¡¦¥í¥Ã¥¯¤ò¶¯À©¤¹¤ë
- (S_ISGID ¤È¶¦Í)
-0800 S_ISUID 004000 ¼Â¹Ô»þ¤Î set-user-ID (V7)
-0800 S_CDF 004000 ¥Ç¥£¥ì¥¯¥È¥ê¤¬¾õ¶·°Í¸¥Õ¥¡¥¤¥ë (HP-UX)
+16進 名前 ls 8進数 説明
+f000 S_IFMT 170000 ファイル種別フィールドのビットマスク
+0000 000000 T{
+SCO では 使用不能 inode; BSD では不明なファイル種別;
+SVID\-v2 と XPG2 では 0 と 0100000 の両方が通常のファイル
+T}
+1000 S_IFIFO p| 010000 FIFO (名前付きパイプ)
+2000 S_IFCHR c 020000 キャラクタ特殊ファイル (V7)
+3000 S_IFMPC 030000 多重化されたキャラクタ特殊ファイル (V7)
+4000 S_IFDIR d/ 040000 ディレクトリ (V7)
+5000 S_IFNAM 050000 T{
+XENIX の二つの副型を持つ名前付きの特殊ファイル
+副型は \fIst_rdev\fP の値 1, 2 で区別される
+T}
+0001 S_INSEM s 000001 XENIX の IFNAM セマフォ副型
+0002 S_INSHD m 000002 XENIX の IFNAM 共有データ副型
+6000 S_IFBLK b 060000 ブロック特殊ファイル (V7)
+7000 S_IFMPB 070000 多重化されたブロック特殊ファイル (V7)
+8000 S_IFREG \- 100000 通常ファイル (V7)
+9000 S_IFCMP 110000 VxFS 圧縮ファイル
+9000 S_IFNWK n 110000 ネットワーク特殊ファイル (HP\-UX)
+a000 S_IFLNK l@ 120000 シンボリックリンク (BSD)
+b000 S_IFSHAD 130000 T{
+Solaris の ACL 用の隠し inode (ユーザ空間からは見えない)
+T}
+c000 S_IFSOCK s= 140000 ソケット (BSD; VxFS の "S_IFSOC")
+d000 S_IFDOOR D> 150000 Solaris の door ファイル
+e000 S_IFWHT w% 160000 BSD の空白ファイル (inode を使用しない)
+0200 S_ISVTX 001000 T{
+スティッキービット: 使用後もスワップに残す (V7)
+.br
+予約 (SVID\-v2)
+.br
+ディレクトリ以外: ファイルをキャッシュしない (SunOS)
+.br
+ディレクトリの場合: 削除制限フラグ (SVID\-v4.2)
+T}
+0400 S_ISGID 002000 T{
+実行時の set\-group\-ID (V7)
+.br
+ディレクトリの場合: GID の伝搬に BSD 方式を使用する
+T}
+0400 S_ENFMT 002000 T{
+System V ファイルロックを強制する (S_ISGID と共有)
+T}
+0800 S_ISUID 004000 実行時の set\-user\-ID (V7)
+0800 S_CDF 004000 T{
+ディレクトリがコンテキスト依存ファイル (HP\-UX)
+T}
.TE
+.ad
+
+スティッキー コマンドは Version 32V AT&T UNIX で登場した。
+.SH 注意
+Linux では、 \fBlstat\fP() は一般には自動マウント動作 (automounter action) の
+きっかけとならないが、 \fBstat\fP() はきっかけとなる (\fBfstatat\fP(2) を参照)。
-.\"O A sticky command appeared in Version 32V AT&T UNIX.
-¥¹¥Æ¥£¥Ã¥¡¼ ¥³¥Þ¥ó¥É¤Ï Version 32V AT&T UNIX ¤ÇÅо줷¤¿¡£
-.\"O .SH NOTES
-.SH Ãí°Õ
-.\"O Since kernel 2.5.48, the
-.\"O .I stat
-.\"O structure supports nanosecond resolution for the three
-.\"O file timestamp fields.
-.\"O Glibc exposes the nanosecond component of each field using names either
-.\"O of the form
-.\"O .IR st_atim.tv_nsec ,
-.\"O if the
-.\"O .B _BSD_SOURCE
-.\"O or
-.\"O .B _SVID_SOURCE
-.\"O feature test macro is defined,
-.\"O or of the form
-.\"O .IR st_atimensec ,
-.\"O if neither of these macros is defined.
-.\"O On file systems that do not support subsecond timestamps,
-.\"O these nanosecond fields are returned with the value 0.
-¥«¡¼¥Í¥ë 2.5.48 °Ê¹ß¤Ç¤Ï¡¢
-.I stat
-¹½Â¤ÂÎ¤Ï 3¤Ä¤Î¥Õ¥¡¥¤¥ë¤Î¥¿¥¤¥à¥¹¥¿¥ó¥×´ØÏ¢¤Î¥Õ¥£¡¼¥ë¥É¤Ç
-¥Ê¥ÎÉÃñ°Ì¤ÎÀºÅÙ¤ËÂбþ¤·¤Æ¤¤¤ë¡£
-glibc ¤Ç¤Ï¡¢³Æ¥Õ¥£¡¼¥ë¥É¤Î¥Ê¥ÎÉäξðÊó¤ò
-.I st_atim.tv_nsec
-¤ä
-.I st_atimensec
-¤È¤¤¤Ã¤¿·Á¤Ç»²¾È¤Ç¤¤ë¡£
-µ¡Ç½¸¡ºº¥Þ¥¯¥í
-.B _BSD_SOURCE
-¤«
-.B _SVID_SOURCE
-¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï
-.I st_atim.tv_nsec
-¤Î·Á¼°¤Ç¡¢¤½¤ì°Ê³°¤Î¾ì¹ç¤Ë¤Ï
-.I st_atimensec
-¤Î·Á¼°¤È¤Ê¤ë¡£
-Éäè¤êºÙ¤«¤¤¥¿¥¤¥à¥¹¥¿¥ó¥×¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ç¤Ï¡¢
-¤³¤ì¤é¤Î¥Ê¥ÎÉäΥե£¡¼¥ë¥É¤Ï 0 ¤ËÀßÄꤵ¤ì¤ë¡£
-.\" As at kernel 2.6.25, XFS and JFS support nanosecond timestamps,
-.\" but ext2, ext3, and Reiserfs do not.
-.\" FIXME . SUSv4 specifies nanosecond timestamps.
-
-.\"O On Linux,
-.\"O .BR lstat ()
-.\"O will generally not trigger automounter action, whereas
-.\"O .BR stat ()
-.\"O will.
-Linux ¤Ç¤Ï¡¢
-.BR lstat ()
-¤Ï°ìÈ̤ˤϼ«Æ°¥Þ¥¦¥ó¥ÈÆ°ºî (automounter action) ¤Î¤¤Ã¤«¤±¤È¤Ê¤é¤Ê¤¤¤¬¡¢
-.BR stat ()
-¤Ï¤¤Ã¤«¤±¤È¤Ê¤ë¡£
-
-.\"O For most files under the
-.\"O .I /proc
-.\"O directory,
-.\"O .BR stat ()
-.\"O does not return the file size in the
-.\"O .I st_size
-.\"O field; instead the field is returned with the value 0.
-.I /proc
-¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤Ë¤¢¤ë¥Õ¥¡¥¤¥ë¤Î¤Û¤È¤ó¤É¤Ç¤Ï¡¢
-.BR stat ()
-¤ò¸Æ¤Ó½Ð¤·¤¿ºÝ¤Ë¡¢
-.I st_size
-¥Õ¥£¡¼¥ë¥É¤Ë¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤¬ÊÖ¤µ¤ì¤Ê¤¤¡£
-Âå¤ï¤ê¤Ë
-.I st_size
-¥Õ¥£¡¼¥ë¥É¤Ë¤Ï 0 ¤¬ÊÖ¤µ¤ì¤ë¡£
-.\"O .SS Underlying kernel interface
-.SS Çظå¤Î¥«¡¼¥Í¥ë¡¦¥¤¥ó¥¿¥Õ¥§¡¼¥¹
-.\"O Over time, increases in the size of the
-.\"O .I stat
-.\"O structure have led to three successive versions of
-.\"O .BR stat ():
-»þ´Ö¤Î·Ð²á¤È¤È¤â¤Ë¡¢
-.I stat
-¹½Â¤ÂΤΥµ¥¤¥º¤¬Â礤¯¤Ê¤ê¡¢¤³¤Î±Æ¶Á¤Ç
-.BR stat ()
-¤Ë¤Ï 3¤Ä¤Î¥Ð¡¼¥¸¥ç¥ó¤¬Â¸ºß¤¹¤ë:
-.\"O .IR sys_stat ()
-.\"O (slot
-.\"O .IR __NR_oldstat ),
-.\"O .IR sys_newstat ()
-.\"O (slot
-.\"O .IR __NR_stat ),
-.\"O and
-.\"O .I sys_stat64()
-.\"O (new in kernel 2.4; slot
-.\"O .IR __NR_stat64 ).
-.IR sys_stat ()
-(¥¹¥í¥Ã¥È¤Ï
-.IR __NR_oldstat )¡¢
-.IR sys_newstat ()
-(¥¹¥í¥Ã¥È¤Ï
-.IR __NR_stat )¡¢
-.IR sys_stat64 ()
-(¥«¡¼¥Í¥ë 2.4 ¤ÇƳÆþ; ¥¹¥í¥Ã¥È¤Ï
-.IR __NR_stat64 ).
-.\"O The glibc
-.\"O .BR stat ()
-.\"O wrapper function hides these details from applications,
-.\"O invoking the most recent version of the system call provided by the kernel,
-.\"O and repacking the returned information if required for old binaries.
-glibc ¤Î
-.BR stat ()
-¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï¤³¤ì¤é¤Î¾ÜºÙ¤ò¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤«¤é±£Ê䷤Ƥ¯¤ì¤ë¡£
-¶ñÂÎŪ¤Ë¤Ï¡¢¥«¡¼¥Í¥ë¤¬Ä󶡤·¤Æ¤¤¤ë¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î¤¦¤ÁºÇ¿·¤Î¥Ð¡¼¥¸¥ç¥ó¤ò
-µ¯Æ°¤·¡¢¸Å¤¤¥Ð¥¤¥Ê¥ê¤Î¾ì¹ç¤Ë¤ÏɬÍפ˱þ¤¸¤ÆÊÖ¤µ¤ì¤¿¾ðÊó¤òºÆ¹½À® (repack) ¤¹¤ë¡£
-.\"O Similar remarks apply for
-.\"O .BR fstat ()
-.\"O and
-.\"O .BR lstat ().
-.BR fstat ()
-¤È
-.BR lstat ()
-¤Ë¤Ä¤¤¤Æ¤âƱÍͤǤ¢¤ë¡£
+\fI/proc\fP ディレクトリ以下にあるファイルのほとんどでは、 \fBstat\fP() を呼び出した際に、 \fIst_size\fP
+フィールドにファイルサイズが返されない。 代わりに \fIst_size\fP フィールドには 0 が返される。
+.SS タイムスタンプフィールド
+Older kernels and older standards did not support nanosecond timestamp
+fields. Instead, there were three timestamp fields\(em\fIst_atime\fP,
+\fIst_mtime\fP, and \fIst_ctime\fP\(emtyped as \fItime_t\fP that recorded timestamps
+with one\-second precision.
+
+カーネル 2.5.48 以降では、 \fIstat\fP 構造体は 3 つのファイルのタイムスタンプ関連のフィールドでナノ秒単位の精度に対応している。
+機能検査マクロ \fB_BSD_SOURCE\fP か \fB_SVID_SOURCE\fP が定義された場合に、各タイムスタンプのナノ秒の情報は
+\fIst_atim.tv_nsec\fP という形式の名前で参照できる。 ナノ秒のタイムスタンプは現在では標準化されており、 POSIX.1\-2008
+からである。 バージョン 2.12 以降の glibc では、 \fB_POSIX_C_SOURCE\fP が 200809L 以上の値で定義されるか、
+\fB_XOPEN_SOURCE\fP が 700 以上の値で定義された場合にも、 このナノ秒のタイムスタンプが公開される。
+上記のマクロのいずれも定義されていない場合、ナノ秒の値は \fIst_atimensec\fP という形式の名前で公開される。
+
+.\" commit ef7f38359ea8b3e9c7f2cae9a4d4935f55ca9e80
+Nanosecond timestamps are supported on XFS, JFS, Btrfs, and ext4 (since
+Linux 2.6.23). Nanosecond timestamps are not supported in ext2, ext3, and
+Resierfs. On filesystems that do not support subsecond timestamps, the
+nanosecond fields are returned with the value 0.
+.SS 背後のカーネル・インタフェース
.\"
.\" A note from Andries Brouwer, July 2007
.\"
.\" interface, rather than the libc-kernel interface.
.\"
.\" (Note that the details depend on gcc being used as c compiler.)
-.\"O .SH EXAMPLE
-.SH Îã
-.\"O The following program calls
-.\"O .BR stat ()
-.\"O and displays selected fields in the returned
-.\"O .I stat
-.\"O structure.
-°Ê²¼¤Î¥×¥í¥°¥é¥à¤Ï
-.BR stat ()
-¤ò¸Æ¤Ó½Ð¤·¡¢Ê֤äƤ¤¿
-.I stat
-¹½Â¤ÂΤΥե£¡¼¥ë¥É¤Î¤¤¤¯¤Ä¤«¤òɽ¼¨¤¹¤ë¡£
+時間の経過とともに、 \fIstat\fP 構造体のサイズが大きくなり、この影響で \fBstat\fP() には 3つのバージョンが存在する:
+\fIsys_stat\fP() (スロットは \fI__NR_oldstat\fP)、 \fIsys_newstat\fP() (スロットは
+\fI__NR_stat\fP)、 \fIsys_stat64\fP() (カーネル 2.4 で導入; スロットは \fI__NR_stat64\fP). glibc
+の \fBstat\fP() ラッパー関数はこれらの詳細をアプリケーションから隠蔽してくれる。
+具体的には、カーネルが提供しているシステムコールのうち最新のバージョンを 起動し、古いバイナリの場合には必要に応じて返された情報を再構成
+(repack) する。 \fBfstat\fP() と \fBlstat\fP() についても同様である。
+
+glibc の \fBfstatat\fP() ラッパー関数が内部で利用するシステムコールは、実際には \fBfstatat64\fP() である。
+.SH 例
+以下のプログラムは \fBstat\fP() を呼び出し、返ってきた \fIstat\fP 構造体のフィールドのいくつかを表示する。
.nf
#include <sys/types.h>
struct stat sb;
if (argc != 2) {
- fprintf(stderr, "Usage: %s <pathname>\\n", argv[0]);
+ fprintf(stderr, "Usage: %s <pathname>\en", argv[0]);
exit(EXIT_FAILURE);
}
printf("File type: ");
switch (sb.st_mode & S_IFMT) {
- case S_IFBLK: printf("block device\\n"); break;
- case S_IFCHR: printf("character device\\n"); break;
- case S_IFDIR: printf("directory\\n"); break;
- case S_IFIFO: printf("FIFO/pipe\\n"); break;
- case S_IFLNK: printf("symlink\\n"); break;
- case S_IFREG: printf("regular file\\n"); break;
- case S_IFSOCK: printf("socket\\n"); break;
- default: printf("unknown?\\n"); break;
+ case S_IFBLK: printf("block device\en"); break;
+ case S_IFCHR: printf("character device\en"); break;
+ case S_IFDIR: printf("directory\en"); break;
+ case S_IFIFO: printf("FIFO/pipe\en"); break;
+ case S_IFLNK: printf("symlink\en"); break;
+ case S_IFREG: printf("regular file\en"); break;
+ case S_IFSOCK: printf("socket\en"); break;
+ default: printf("unknown?\en"); break;
}
- printf("I\-node number: %ld\\n", (long) sb.st_ino);
+ printf("I\-node number: %ld\en", (long) sb.st_ino);
- printf("Mode: %lo (octal)\\n",
+ printf("Mode: %lo (octal)\en",
(unsigned long) sb.st_mode);
- printf("Link count: %ld\\n", (long) sb.st_nlink);
- printf("Ownership: UID=%ld GID=%ld\\n",
+ printf("Link count: %ld\en", (long) sb.st_nlink);
+ printf("Ownership: UID=%ld GID=%ld\en",
(long) sb.st_uid, (long) sb.st_gid);
- printf("Preferred I/O block size: %ld bytes\\n",
+ printf("Preferred I/O block size: %ld bytes\en",
(long) sb.st_blksize);
- printf("File size: %lld bytes\\n",
+ printf("File size: %lld bytes\en",
(long long) sb.st_size);
- printf("Blocks allocated: %lld\\n",
+ printf("Blocks allocated: %lld\en",
(long long) sb.st_blocks);
printf("Last status change: %s", ctime(&sb.st_ctime));
exit(EXIT_SUCCESS);
}
.fi
-.\"O .SH "SEE ALSO"
-.SH ´ØÏ¢¹àÌÜ
-.BR access (2),
-.BR chmod (2),
-.BR chown (2),
-.BR fstatat (2),
-.BR readlink (2),
-.BR utime (2),
-.BR capabilities (7),
-.BR symlink (7)
+.SH 関連項目
+\fBls\fP(1), \fBstat\fP(1), \fBaccess\fP(2), \fBchmod\fP(2), \fBchown\fP(2),
+\fBreadlink\fP(2), \fButime\fP(2), \fBcapabilities\fP(7), \fBsymlink\fP(7)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.65 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。