OSDN Git Service

Update draft for LDP 3.67
[linuxjm/LDP_man-pages.git] / draft / man2 / stat.2
index cc939b4..232e342 100644 (file)
@@ -61,7 +61,7 @@
 .\" Updated 2012-05-29, Akihiro MOTOKI <amotoki@gmail.com>
 .\" Updated 2013-03-26, Akihiro MOTOKI <amotoki@gmail.com>
 .\"
-.TH STAT 2 2014\-03\-19 Linux "Linux Programmer's Manual"
+.TH STAT 2 2014\-05\-10 Linux "Linux Programmer's Manual"
 .SH 名前
 stat, fstat, lstat, fstatat \- ファイルの状態を取得する
 .SH 書式
@@ -93,7 +93,11 @@ glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参
 .sp
 \fBlstat\fP():
 .RS 4
-_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
+/* glibc 2.19 and earlier */ _BSD_SOURCE ||
+.br
+/* Since glibc 2.20 */_DEFAULT_SOURCE ||
+.br
+_XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
 .br
 || /* glibc 2.10 以降: */ _POSIX_C_SOURCE\ >=\ 200112L
 .RE
@@ -195,7 +199,37 @@ glibc とカーネルのソースを調べてほしい。
 
 \fIst_ctime\fP フィールドは書き込みや inode 情報 (所有者、グループ、リンク数、モードなど) の 設定によって変更される。
 .PP
-以下の POSIX マクロは、 \fIst_mode\fP フィールド で使用されるファイル種別のチェックのために定義されている :
+The following mask values are defined for the file type component of the
+\fIst_mode\fP field:
+.in +4n
+.TS
+lB l l.
+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
+.TE
+.in
+.PP
+Thus, to test for a regular file (for example), one could write:
+
+.nf
+.in +4n
+stat(pathname, &sb);
+if ((sb.st_mode & S_IFMT) == S_IFREG) {
+    /* Handle regular file */
+}
+.in
+.fi
+.PP
+Because tests of the above form are common, additional macros are defined by
+POSIX to allow the test of the file type in \fIst_mode\fP to be written more
+concisely:
 .RS 4
 .TP  1.2i
 \fBS_ISREG\fP(m)
@@ -220,43 +254,65 @@ FIFO (名前付きパイプ) か?
 ソケットか? (POSIX.1\-1996 にはない)
 .RE
 .PP
-以下のフラグが \fIst_mode\fP フィールド用に定義されている:
+The preceding code snippet could thus be rewritten as:
+
+.nf
+.in +4n
+stat(pathname, &sb);
+if (S_ISREG(sb.st_mode)) {
+    /* Handle regular file */
+}
+.in
+.fi
+.PP
+The definitions of most of the above file type test macros are provided if
+any of the following feature test macros are defined: \fB_BSD_SOURCE\fP (in
+glibc 2.19 and earlier), \fB_SVID_SOURCE\fP (in glibc 2.19 and earlier), or
+\fB_DEFAULT_SOURCE\fP (in glibc 2.20 and later).  In addition, definitions of
+all of the above macros except \fBS_IFSOCK\fP and \fBS_ISSOCK\fP()  are provided
+if \fB_XOPEN_SOURCE\fP is defined.  The definition of \fBS_IFSOCK\fP can also be
+exposed by defining \fB_XOPEN_SOURCE\fP with a value of 500 or greater.
+
+The definition of \fBS_ISSOCK\fP()  is exposed if any of the following feature
+test macros is defined: \fB_BSD_SOURCE\fP (in glibc 2.19 and earlier),
+\fB_DEFAULT_SOURCE\fP (in glibc 2.20 and later), \fB_XOPEN_SOURCE\fP with a value
+of 500 or greater, or \fB_POSIX_C_SOURCE\fP with a value of 200112L or greater.
+.PP
+The following mask values are defined for the file permissions component of
+the \fIst_mode\fP field:
 .in +4n
 .TS
 lB l l.
-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
 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{
+
+S_IRWXU          00700 mask for file owner permissions
+S_IRUSR          00400 owner has read permission
+S_IWUSR          00200 owner has write permission
+S_IXUSR          00100 owner has execute permission
+
+S_IRWXG          00070 mask for group permissions
+S_IRGRP          00040 group has read permission
+S_IWGRP          00020 group has write permission
+S_IXGRP          00010 group has execute permission
+
+S_IRWXO          00007 T{
 他人 (others) のアクセス許可用のビットマスク
 T}
-S_IROTH        00004   他人の読み込み許可
-S_IWOTH        00002   他人の書き込み許可
-S_IXOTH        00001   他人の実行許可
+S_IROTH          00004 others have read permission
+S_IWOTH          00002 others have write permission
+S_IXOTH          00001 others have execute permission
 .TE
 .in
 .P
-set\-group\-ID bit (\fBS_ISGID\fP)  にはいくつかの特殊な使用法がある: ディレクトリに設定した場合には、そのディレクトリが
-BSD 方式で使用される ことを示す。つまり、そのディレクトリに作成されたファイルのグループID は 作成したプロセスの実効 (effective)
-グループID ではなく、ディレクトリの グループID を継承する。また、そのディレクトリに作成されたディレクトリにも \fBS_ISGID\fP
-ビットが設定される。グループ実行ビット (\fBS_IXGRP\fP)  が設定されていないファイルに設定された場合は、 set\-group\-ID
-ビットはファイル/レコードの 強制的な (mandatory) ロックを表す。
+The set\-group\-ID bit (\fBS_ISGID\fP)  has several special uses.  For a
+directory, it indicates that BSD semantics is to be used for that directory:
+files created there inherit their group ID from the directory, not from the
+effective group ID of the creating process, and directories created there
+will also get the \fBS_ISGID\fP bit set.  For a file that does not have the
+group execution bit (\fBS_IXGRP\fP)  set, the set\-group\-ID bit indicates
+mandatory file/record locking.
 .P
 .\"
 .\"
@@ -383,7 +439,7 @@ POSIX.1\-1990 には \fBS_IFMT\fP, \fBS_IFSOCK\fP, \fBS_IFLNK\fP, \fBS_IFREG\fP,
 POSIX.1\-2001 には両方とも存在する。 前者は SVID 4 に、後者は SUSv2 に
 由来している。
 .LP
-UNIX V7 (とその後のシステム) は \fBS_IREAD\fP, \fBS_IWRITE\fP, \fBS_IEXEC\fP を持っており、
+UNIX\ V7 (とその後のシステム) は \fBS_IREAD\fP, \fBS_IWRITE\fP, \fBS_IEXEC\fP を持っており、
 POSIX はその同義語として \fBS_IRUSR\fP, \fBS_IWUSR\fP, \fBS_IXUSR\fP を規定している。
 .SS 他のシステム
 各種システムで使用されていた(いる)値:
@@ -463,7 +519,7 @@ Linux では、 \fBlstat\fP() は一般には自動マウント動作 (automount
 
 .\" commit ef7f38359ea8b3e9c7f2cae9a4d4935f55ca9e80
 ナノ秒のタイムスタンプは XFS, JFS, Btrfs, ext4 でサポートされている (Linux 2.6.23 以降)。
-ナノ秒のタイムスタンプは ext2, ext3, Resierfs ではサポートされていない。
+ナノ秒のタイムスタンプは ext2, ext3, Reiserfs ではサポートされていない。
 サブ秒のタイムスタンプをサポートしていないファイルシステムでは、 ナノ秒のフィールドには値 0 が入る。
 .SS 背後のカーネル・インタフェース
 .\"
@@ -567,6 +623,6 @@ main(int argc, char *argv[])
 \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 の一部
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.67 の一部
 である。プロジェクトの説明とバグ報告に関する情報は
 http://www.kernel.org/doc/man\-pages/ に書かれている。