2 .\" Hey Emacs! This file is -*- nroff -*- source.
4 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
5 .\" Parts Copyright (c) 1995 Nicolai Langfeldt (janl@ifi.uio.no), 1/1/95
6 .\" and Copyright (c) 2007 Michael Kerrisk <mtk.manpages@gmail.com>
8 .\" Permission is granted to make and distribute verbatim copies of this
9 .\" manual provided the copyright notice and this permission notice are
10 .\" preserved on all copies.
12 .\" Permission is granted to copy and distribute modified versions of this
13 .\" manual under the conditions for verbatim copying, provided that the
14 .\" entire resulting derived work is distributed under the terms of a
15 .\" permission notice identical to this one.
17 .\" Since the Linux kernel and libraries are constantly changing, this
18 .\" manual page may be incorrect or out-of-date. The author(s) assume no
19 .\" responsibility for errors or omissions, or for damages resulting from
20 .\" the use of the information contained herein. The author(s) may not
21 .\" have taken the same level of care in the production of this manual,
22 .\" which is licensed free of charge, as they might when working
25 .\" Formatted or processed versions of this manual, if unaccompanied by
26 .\" the source, must acknowledge the copyright and authors of this work.
28 .\" Modified by Michael Haardt <michael@moria.de>
29 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
30 .\" Modified 1995-05-18 by Todd Larason <jtl@molehill.org>
31 .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
32 .\" Modified 1995-01-09 by Richard Kettlewell <richard@greenend.org.uk>
33 .\" Modified 1998-05-13 by Michael Haardt <michael@cantor.informatik.rwth-aachen.de>
34 .\" Modified 1999-07-06 by aeb & Albert Cahalan
35 .\" Modified 2000-01-07 by aeb
36 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
37 .\" 2007-06-08 mtk: Added example program
38 .\" 2007-07-05 mtk: Added details on underlying system call interfaces
40 .\" Japanese Version Copyright (c) 1998-1999 HANATAKA Shinya
41 .\" and Copyright (c) 2005-2008 Akihiro MOTOKI
43 .\" Translated 1998-06-21, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
44 .\" Modified 1999-04-16, HANATAKA Shinya
45 .\" Updated 2000-01-03, Kentaro Shirakata <argrath@ub32.org>
46 .\" Updated 2000-10-06, Kentaro Shirakata
47 .\" Updated 2001-04-09, Kentaro Shirakata
48 .\" Updated 2001-06-25, Kentaro Shirakata
49 .\" Updated 2005-02-28, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
50 .\" Updated 2005-09-06, Akihiro MOTOKI
51 .\" Updated 2005-11-19, Akihiro MOTOKI, catch up to LDP v2.14
52 .\" Updated 2006-07-21, Akihiro MOTOKI, LDP v2.36
53 .\" Updated 2007-06-13, Akihiro MOTOKI, LDP v2.55
54 .\" Updated 2008-09-19, Akihiro MOTOKI, LDP v3.08
57 .\"WORD: directory ディレクトリ
64 .\"WORD: hard link count ハード・リンク数
65 .\"WORD: symbolic link シンボリック・リンク
68 .\"WORD: sticky bit スティッキー・ビット
69 .\"WORD: mandatory locking 強制ロック
71 .TH STAT 2 2010-12-03 "Linux" "Linux Programmer's Manual"
74 .\"O stat, fstat, lstat \- get file status
75 stat, fstat, lstat \- ファイルの状態を取得する
78 .B #include <sys/types.h>
80 .B #include <sys/stat.h>
82 .B #include <unistd.h>
84 .BI "int stat(const char *" path ", struct stat *" buf );
86 .BI "int fstat(int " fd ", struct stat *" buf );
88 .BI "int lstat(const char *" path ", struct stat *" buf );
91 .\"O Feature Test Macro Requirements for glibc (see
92 .\"O .BR feature_test_macros (7)):
94 .RB ( feature_test_macros (7)
99 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
103 .\"O These functions return information about a file.
104 .\"O No permissions are required on the file itself, but \(em in the case of
109 .\"O execute (search) permission is required on all of the directories in
111 .\"O that lead to the file.
112 これらの関数はファイルについての情報を返す。
113 ファイルそのものに対するアクセス許可は必要としないが、
122 を構成する全てのディレクトリに対する実行 (検索) 許可が必要である。
125 .\"O stats the file pointed to by
141 .\"O is a symbolic link, then the link itself is stat-ed,
142 .\"O not the file that it refers to.
148 がシンボリックリンクの場合、リンクが参照しているファイルではなく、
154 .\"O except that the file to be stat-ed is specified by the file descriptor
160 状態を取得するファイルをファイル・ディスクリプタ
164 .\"O All of these system calls return a
166 .\"O structure, which contains the following fields:
171 構造体には以下のフィールドが含まれている:
176 .\"O dev_t st_dev; /* ID of device containing file */
177 .\"O ino_t st_ino; /* inode number */
178 .\"O mode_t st_mode; /* protection */
179 .\"O nlink_t st_nlink; /* number of hard links */
180 .\"O uid_t st_uid; /* user ID of owner */
181 .\"O gid_t st_gid; /* group ID of owner */
182 .\"O dev_t st_rdev; /* device ID (if special file) */
183 .\"O off_t st_size; /* total size, in bytes */
184 .\"O blksize_t st_blksize; /* blocksize for file system I/O */
185 .\"O blkcnt_t st_blocks; /* number of 512B blocks allocated */
186 .\"O time_t st_atime; /* time of last access */
187 .\"O time_t st_mtime; /* time of last modification */
188 .\"O time_t st_ctime; /* time of last status change */
189 dev_t st_dev; /* ファイルがあるデバイスの ID */
190 ino_t st_ino; /* inode 番号 */
191 mode_t st_mode; /* アクセス保護 */
192 nlink_t st_nlink; /* ハードリンクの数 */
193 uid_t st_uid; /* 所有者のユーザ ID */
194 gid_t st_gid; /* 所有者のグループ ID */
195 dev_t st_rdev; /* デバイス ID (特殊ファイルの場合) */
196 off_t st_size; /* 全体のサイズ (バイト単位) */
197 blksize_t st_blksize; /* ファイルシステム I/O での
199 blkcnt_t st_blocks; /* 割り当てられた 512B のブロック数 */
200 time_t st_atime; /* 最終アクセス時刻 */
201 time_t st_mtime; /* 最終修正時刻 */
202 time_t st_ctime; /* 最終状態変更時刻 */
209 .\"O field describes the device on which this file resides.
214 .\"O macros may be useful to decompose the device ID in this field.)
216 フィールドは、このファイルが存在するデバイスを示す
220 は、このフィールドのデバイス ID を分解するのに役立つだろう)。
224 .\"O field describes the device that this file (inode) represents.
226 フィールドは、このファイル (inode) が表すデバイスを示す。
230 .\"O field gives the size of the file (if it is a regular
231 .\"O file or a symbolic link) in bytes.
232 .\"O The size of a symlink is the length of the pathname
233 .\"O it contains, without a trailing null byte.
235 フィールドは、(通常のファイルかシンボリックリンクの場合に)
237 シンボリックリンクの大きさは、シンボリックリンクに含まれている
238 パス名の長さ (最後の NULL バイトは含まない) である。
242 .\"O field indicates the number of blocks allocated to the file, 512-byte units.
243 .\"O (This may be smaller than
244 .\"O .IR st_size /512
245 .\"O when the file has holes.)
247 フィールドは、ファイルの大きさを 512 バイトのブロックサイズ単位で示す
248 フィールドは、ファイルに割り当てされたブロック数を 512 バイト単位で示す。
255 .\"O field gives the "preferred" blocksize for efficient file system I/O.
256 .\"O (Writing to a file in smaller chunks may cause
257 .\"O an inefficient read-modify-rewrite.)
259 フィールドは、効率的にファイル・システム I/O ができる「好ましい」
260 ブロックサイズを示す (もっと小さい単位でファイルに書き込みを行うと、
261 読み出し--修正--再書き込みといった非効率な動作になってしまうかもしれない)。
263 .\"O Not all of the Linux file systems implement all of the time fields.
264 .\"O Some file system types allow mounting in such a way that file
265 .\"O and/or directory accesses do not cause an update of the
270 .\"O .IR nodiratime ,
275 .\"O and related information in
277 全ての Linux のファイル・システムが全ての時間フィールドを
281 フィールドを更新しないようなかたちでマウントできるファイルシステムもある。
292 .\"O is not updated if a file is opened with the
306 .\"O is changed by file accesses, for example, by
313 .\"O (of more than zero bytes).
314 .\"O Other routines, like
316 .\"O may or may not update
319 フィールドはファイルアクセスがあった場合に変更される
331 は更新されることもあれば、そうでない場合もある。
335 .\"O is changed by file modifications, for example, by
337 .\"O .BR truncate (2),
341 .\"O (of more than zero bytes).
343 フィールドは、ファイルが修正された場合に変更される
350 で 1 バイト以上書き込みをした場合など)。
353 .\"O of a directory is changed by the creation or deletion of files
354 .\"O in that directory.
358 ファイルが作成されたり削除されたりすると変更される。
363 .\"O changed for changes in owner, group, hard link count, or mode.
366 所有者やグループやハード・リンク数やモードの変更では変更
371 .\"O is changed by writing or by setting inode information
372 .\"O (i.e., owner, group, link count, mode, etc.).
375 (所有者、グループ、リンク数、モードなど) の
378 .\"O The following POSIX macros are defined to check the file type using the
384 で使用されるファイル種別のチェックのために定義されている :
388 .\"O is it a regular file?
396 .\"O character device?
404 .\"O FIFO (named pipe)?
408 .\"O symbolic link? (Not in POSIX.1-1996.)
409 シンボリック・リンクか? (POSIX.1-1996 にはない)
412 .\"O socket? (Not in POSIX.1-1996.)
413 ソケットか? (POSIX.1-1996 にはない)
416 .\"O The following flags are defined for the
425 .\"O S_IFMT 0170000 bit mask for the file type bit fields
426 .\"O S_IFSOCK 0140000 socket
427 .\"O S_IFLNK 0120000 symbolic link
428 .\"O S_IFREG 0100000 regular file
429 .\"O S_IFBLK 0060000 block device
430 .\"O S_IFDIR 0040000 directory
431 .\"O S_IFCHR 0020000 character device
432 .\"O S_IFIFO 0010000 FIFO
433 S_IFMT 0170000 ファイル種別を示すビット領域を表すビットマスク
434 S_IFSOCK 0140000 ソケット
435 S_IFLNK 0120000 シンボリック・リンク
436 S_IFREG 0100000 通常のファイル
437 S_IFBLK 0060000 ブロック・デバイス
438 S_IFDIR 0040000 ディレクトリ
439 S_IFCHR 0020000 キャラクター・デバイス
441 .\"O S_ISUID 0004000 set-user-ID bit
442 .\"O S_ISGID 0002000 set-group-ID bit (see below)
443 .\"O S_ISVTX 0001000 sticky bit (see below)
444 S_ISUID 0004000 set-user-ID bit
445 S_ISGID 0002000 set-group-ID bit (下記参照)
446 S_ISVTX 0001000 スティッキー・ビット (下記参照)
447 .\"O S_IRWXU 00700 mask for file owner permissions
448 .\"O S_IRUSR 00400 owner has read permission
449 .\"O S_IWUSR 00200 owner has write permission
450 .\"O S_IXUSR 00100 owner has execute permission
451 S_IRWXU 00700 ファイル所有者のアクセス許可用のビットマスク
452 S_IRUSR 00400 所有者の読み込み許可
453 S_IWUSR 00200 所有者の書き込み許可
454 S_IXUSR 00100 所有者の実行許可
455 .\"O S_IRWXG 00070 mask for group permissions
456 .\"O S_IRGRP 00040 group has read permission
457 .\"O S_IWGRP 00020 group has write permission
458 .\"O S_IXGRP 00010 group has execute permission
459 S_IRWXG 00070 グループのアクセス許可用のビットマスク
460 S_IRGRP 00040 グループの読み込み許可
461 S_IWGRP 00020 グループの書き込み許可
462 S_IXGRP 00010 グループの実行許可
463 .\"O S_IRWXO 00007 mask for permissions for others (not in group)
464 .\"O S_IROTH 00004 others have read permission
465 .\"O S_IWOTH 00002 others have write permission
466 .\"O S_IXOTH 00001 others have execute permission
467 S_IRWXO 00007 他人 (others) のアクセス許可用のビットマスク
468 S_IROTH 00004 他人の読み込み許可
469 S_IWOTH 00002 他人の書き込み許可
470 S_IXOTH 00001 他人の実行許可
474 .\"O The set-group-ID bit
476 .\"O has several special uses.
477 .\"O For a directory it indicates that BSD semantics is to be used
478 .\"O for that directory: files created there inherit their group ID from
479 .\"O the directory, not from the effective group ID of the creating process,
480 .\"O and directories created there will also get the
483 .\"O For a file that does not have the group execution bit
486 .\"O the set-group-ID bit indicates mandatory file/record locking.
490 ディレクトリに設定した場合には、そのディレクトリが BSD 方式で使用される
491 ことを示す。つまり、そのディレクトリに作成されたファイルのグループID は
492 作成したプロセスの実効 (effective) グループID ではなく、ディレクトリの
493 グループID を継承する。また、そのディレクトリに作成されたディレクトリにも
497 が設定されていないファイルに設定された場合は、
498 set-group-ID ビットはファイル/レコードの
499 強制的な (mandatory) ロックを表す。
501 .\"O The sticky bit (S_ISVTX) on a directory means that a file
502 .\"O in that directory can be renamed or deleted only by the owner
503 .\"O of the file, by the owner of the directory, and by a privileged
505 ディレクトリにスティッキービット (S_ISVTX) が設定された場合は、
506 そのディレクトリのファイルの名前を変更したり、削除したりできるのは、
507 そのファイルの所有者か、そのディレクトリの所有者か、特権プロセス
509 .\"O .SH "RETURN VALUE"
511 .\"O On success, zero is returned.
512 .\"O On error, \-1 is returned, and
514 .\"O is set appropriately.
515 成功した場合は 0 を返す。エラーの場合は \-1 を返し、
522 .\"O Search permission is denied for one of the directories
523 .\"O in the path prefix of
526 .\"O .BR path_resolution (7).)
528 が所属するディレクトリとその上位のディレクトリのいずれかに
530 .RB ( path_resolution (7)
544 .\"O Too many symbolic links encountered while traversing the path.
545 パスを辿る際に解決すべきシンボリック・リンクが多過ぎた。
556 .\"O does not exist, or
558 .\"O is an empty string.
565 .\"O Out of memory (i.e., kernel memory).
569 .\"O A component of the path prefix of
571 .\"O is not a directory.
573 の前半部分 (prefix) の構成要素がディレクトリではない。
578 .\"O refers to a file whose size cannot be represented in the type
580 .\"O This can occur when an application compiled on a 32-bit platform without
581 .\"O .I -D_FILE_OFFSET_BITS=64
584 .\"O on a file whose size exceeds
592 このエラーが起こるのは、32 ビットプラットフォーム上で
593 .I -D_FILE_OFFSET_BITS=64
594 を指定せずにコンパイルされたアプリケーションが、ファイルサイズが
599 .\"O .SH "CONFORMING TO"
601 .\"O These system calls conform to SVr4, 4.3BSD, POSIX.1-2001.
602 これらのシステムコールは SVr4, 4.3BSD, POSIX.1-2001 に準拠している。
603 .\"O .\" SVr4 documents additional
604 .\"O .\" .BR fstat ()
605 .\"O .\" error conditions EINTR, ENOLINK, and EOVERFLOW. SVr4
606 .\"O .\" documents additional
609 .\"O .\" .BR lstat ()
610 .\"O .\" error conditions EINTR, EMULTIHOP, ENOLINK, and EOVERFLOW.
614 コールは SVr4, SVID, POSIX, X/OPEN, 4.3BSD に準拠している。
616 コールは 4.3BSD と SVr4 に準拠している。
619 .\" のエラーとして EINTR, ENOLINK, EOVERFLOW が記載されている。
624 .\" のエラーとして EINTR, EMULTIHOP, ENOLINK, EOVERFLOW が記載されている。
630 .\"O fields may be less portable.
631 .\"O (They were introduced in BSD.
632 .\"O The interpretation differs between systems,
633 .\"O and possibly on a single system when NFS mounts are involved.)
638 (これらのフィールドは BSD によって導入された。
640 NFS マウントの場合には同じシステムでも異なる可能性がある)
642 .\"O POSIX does not describe the
652 .\"O bits, but instead demands the use of
660 .\"O macros are not in
661 .\"O POSIX.1-1996, but both are present in POSIX.1-2001;
662 .\"O the former is from SVID 4, the latter from SUSv2.
675 のようなマクロを使用するように要求している。
680 は POSIX.1-1996 にはないが、
681 POSIX.1-2001 には両方とも存在する。
682 前者は SVID 4 に、後者は SUSv2 に由来している。
684 .\"O Unix V7 (and later systems) had S_IREAD, S_IWRITE, S_IEXEC, where POSIX
685 .\"O prescribes the synonyms S_IRUSR, S_IWUSR, S_IXUSR.
686 .\"O Unix V7 (and later systems) had
691 .\"O prescribes the synonyms
695 Unix V7 (とその後のシステム) は
705 .\"O .SS "Other Systems"
707 .\"O Values that have been (or are) in use on various systems:
711 .\"O hex name ls octal description
713 .\"O f000 S_IFMT 170000 mask for file type
714 .\"O 0000 000000 SCO out-of-service inode, BSD unknown
715 .\"O type; SVID-v2 and XPG2 have both
716 .\"O 0 and 0100000 for ordinary file
717 f000 S_IFMT 170000 ファイル種別フィールドのビットマスク
718 0000 000000 SCO では 使用不能 inode;
720 SVID-v2 と XPG2 では 0 と 0100000 の
722 .\"O 1000 S_IFIFO p| 010000 FIFO (named pipe)
723 .\"O 2000 S_IFCHR c 020000 character special (V7)
724 .\"O 3000 S_IFMPC 030000 multiplexed character special (V7)
725 .\"O 4000 S_IFDIR d/ 040000 directory (V7)
726 .\"O 5000 S_IFNAM 050000 XENIX named special file
727 .\"O with two subtypes, distinguished by
728 .\"O \fIst_rdev\fP values 1, 2
729 .\"O 0001 S_INSEM s 000001 XENIX semaphore subtype of IFNAM
730 .\"O 0002 S_INSHD m 000002 XENIX shared data subtype of IFNAM
731 1000 S_IFIFO p| 010000 FIFO (名前付きパイプ)
732 2000 S_IFCHR c 020000 キャラクタ特殊ファイル (V7)
733 3000 S_IFMPC 030000 多重化されたキャラクタ特殊ファイル (V7)
734 4000 S_IFDIR d/ 040000 ディレクトリ (V7)
735 5000 S_IFNAM 050000 XENIX 二つの副型を持つ名前付きの
737 副型は \fIst_rdev\fP の値 1,2 で区別される:
738 0001 S_INSEM s 000001 XENIX IFNAMのセマフォー副型
739 0002 S_INSHD m 000002 XENIX IFNAMの共有データ副型
740 .\"O 6000 S_IFBLK b 060000 block special (V7)
741 .\"O 7000 S_IFMPB 070000 multiplexed block special (V7)
742 .\"O 8000 S_IFREG - 100000 regular (V7)
743 .\"O 9000 S_IFCMP 110000 VxFS compressed
744 .\"O 9000 S_IFNWK n 110000 network special (HP-UX)
745 .\"O a000 S_IFLNK l@ 120000 symbolic link (BSD)
746 6000 S_IFBLK b 060000 ブロック特殊ファイル (V7)
747 7000 S_IFMPB 070000 多重化されたブロック特殊ファイル (V7)
748 8000 S_IFREG - 100000 通常ファイル (V7)
749 9000 S_IFCMP 110000 VxFS 圧縮ファイル
750 9000 S_IFNWK n 110000 ネットワーク特殊ファイル (HP-UX)
751 a000 S_IFLNK l@ 120000 シンボリック・リンク (BSD)
752 .\"O b000 S_IFSHAD 130000 Solaris shadow inode for ACL
753 .\"O (not seen by userspace)
754 .\"O c000 S_IFSOCK s= 140000 socket (BSD; also "S_IFSOC" on VxFS)
755 .\"O d000 S_IFDOOR D> 150000 Solaris door
756 .\"O e000 S_IFWHT w% 160000 BSD whiteout (not used for inode)
757 b000 S_IFSHAD 130000 Solaris ACL のための隠された inode
759 c000 S_IFSOCK s= 140000 ソケット (BSD; VxFS の "S_IFSOC")
760 d000 S_IFDOOR D> 150000 Solaris ドア・ファイル
761 e000 S_IFWHT w% 160000 BSD 空白ファイル (inode を使用しない)
762 .\"O 0200 S_ISVTX 001000 sticky bit: save swapped text even
764 .\"O reserved (SVID-v2)
765 .\"O On nondirectories: don't cache this
767 .\"O On directories: restricted deletion
768 .\"O flag (SVID-v4.2)
769 .\"O 0400 S_ISGID 002000 set-group-ID on execution (V7)
770 .\"O for directories: use BSD semantics for
771 .\"O propagation of GID
772 .\"O 0400 S_ENFMT 002000 System V file locking enforcement (shared
774 .\"O 0800 S_ISUID 004000 set-user-ID on execution (V7)
775 .\"O 0800 S_CDF 004000 directory is a context dependent
777 0200 S_ISVTX 001000 `スティッキー・ビット':使用後も
782 ディレクトリ: 削除制限フラグ (SVID-v4.2)
783 0400 S_ISGID 002000 実行時の set-group-ID (V7)
786 0400 S_ENFMT 002000 System V ファイル・ロックを強制する
788 0800 S_ISUID 004000 実行時の set-user-ID (V7)
789 0800 S_CDF 004000 ディレクトリが状況依存ファイル (HP-UX)
792 .\"O A sticky command appeared in Version 32V AT&T UNIX.
793 スティッキー コマンドは Version 32V AT&T UNIX で登場した。
796 .\"O Since kernel 2.5.48, the
798 .\"O structure supports nanosecond resolution for the three
799 .\"O file timestamp fields.
800 .\"O Glibc exposes the nanosecond component of each field using names either
802 .\"O .IR st_atim.tv_nsec ,
807 .\"O feature test macro is defined,
809 .\"O .IR st_atimensec ,
810 .\"O if neither of these macros is defined.
811 .\"O On file systems that do not support subsecond timestamps,
812 .\"O these nanosecond fields are returned with the value 0.
815 構造体は 3つのファイルのタイムスタンプ関連のフィールドで
817 glibc では、各フィールドのナノ秒の情報を
831 秒より細かいタイムスタンプをサポートしていないファイルシステムでは、
832 これらのナノ秒のフィールドは 0 に設定される。
833 .\" As at kernel 2.6.25, XFS and JFS support nanosecond timestamps,
834 .\" but ext2, ext3, and Reiserfs do not.
835 .\" FIXME . SUSv4 specifies nanosecond timestamps.
839 .\"O will generally not trigger automounter action, whereas
844 は一般には自動マウント動作 (automounter action) のきっかけとならないが、
848 .\"O For most files under the
852 .\"O does not return the file size in the
854 .\"O field; instead the field is returned with the value 0.
856 ディレクトリ以下にあるファイルのほとんどでは、
864 .\"O .SS Underlying kernel interface
866 .\"O Over time, increases in the size of the
868 .\"O structure have led to three successive versions of
877 .\"O .IR __NR_oldstat ),
878 .\"O .IR sys_newstat ()
880 .\"O .IR __NR_stat ),
883 .\"O (new in kernel 2.4; slot
884 .\"O .IR __NR_stat64 ).
896 .\"O wrapper function hides these details from applications,
897 .\"O invoking the most recent version of the system call provided by the kernel,
898 .\"O and repacking the returned information if required for old binaries.
901 ラッパー関数はこれらの詳細をアプリケーションから隠蔽してくれる。
902 具体的には、カーネルが提供しているシステムコールのうち最新のバージョンを
903 起動し、古いバイナリの場合には必要に応じて返された情報を再構成 (repack) する。
904 .\"O Similar remarks apply for
913 .\" A note from Andries Brouwer, July 2007
915 .\" > Is the story not rather more complicated for some calls like
918 .\" Yes and no, mostly no. See /usr/include/sys/stat.h .
920 .\" The idea is here not so much that syscalls change, but that
921 .\" the definitions of struct stat and of the types dev_t and mode_t change.
922 .\" This means that libc (even if it does not call the kernel
923 .\" but only calls some internal function) must know what the
924 .\" format of dev_t or of struct stat is.
925 .\" The communication between the application and libc goes via
926 .\" the include file <sys/stat.h> that defines a _STAT_VER and
927 .\" _MKNOD_VER describing the layout of the data that user space
928 .\" uses. Each (almost each) occurrence of stat() is replaced by
929 .\" an occurrence of xstat() where the first parameter of xstat()
930 .\" is this version number _STAT_VER.
932 .\" Now, also the definitions used by the kernel change.
933 .\" But glibc copes with this in the standard way, and the
934 .\" struct stat as returned by the kernel is repacked into
935 .\" the struct stat as expected by the application.
936 .\" Thus, _STAT_VER and this setup cater for the application-libc
937 .\" interface, rather than the libc-kernel interface.
939 .\" (Note that the details depend on gcc being used as c compiler.)
942 .\"O The following program calls
944 .\"O and displays selected fields in the returned
954 #include <sys/types.h>
955 #include <sys/stat.h>
961 main(int argc, char *argv[])
966 fprintf(stderr, "Usage: %s <pathname>\\n", argv[0]);
970 if (stat(argv[1], &sb) == \-1) {
975 printf("File type: ");
977 switch (sb.st_mode & S_IFMT) {
978 case S_IFBLK: printf("block device\\n"); break;
979 case S_IFCHR: printf("character device\\n"); break;
980 case S_IFDIR: printf("directory\\n"); break;
981 case S_IFIFO: printf("FIFO/pipe\\n"); break;
982 case S_IFLNK: printf("symlink\\n"); break;
983 case S_IFREG: printf("regular file\\n"); break;
984 case S_IFSOCK: printf("socket\\n"); break;
985 default: printf("unknown?\\n"); break;
988 printf("I\-node number: %ld\\n", (long) sb.st_ino);
990 printf("Mode: %lo (octal)\\n",
991 (unsigned long) sb.st_mode);
993 printf("Link count: %ld\\n", (long) sb.st_nlink);
994 printf("Ownership: UID=%ld GID=%ld\\n",
995 (long) sb.st_uid, (long) sb.st_gid);
997 printf("Preferred I/O block size: %ld bytes\\n",
998 (long) sb.st_blksize);
999 printf("File size: %lld bytes\\n",
1000 (long long) sb.st_size);
1001 printf("Blocks allocated: %lld\\n",
1002 (long long) sb.st_blocks);
1004 printf("Last status change: %s", ctime(&sb.st_ctime));
1005 printf("Last file access: %s", ctime(&sb.st_atime));
1006 printf("Last file modification: %s", ctime(&sb.st_mtime));
1019 .BR capabilities (7),