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 ¥Ç¥£¥ì¥¯¥È¥ê
58 .\"WORD: open ¥ª¡¼¥×¥ó
59 .\"WORD: implement ¼ÂÁõ
61 .\"WORD: group ¥°¥ë¡¼¥×
62 .\"WORD: user ¥æ¡¼¥¶¡¼
64 .\"WORD: hard link count ¥Ï¡¼¥É¡¦¥ê¥ó¥¯¿ô
65 .\"WORD: symbolic link ¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯
66 .\"WORD: socket ¥½¥±¥Ã¥È
67 .\"WORD: device ¥Ç¥Ð¥¤¥¹
68 .\"WORD: sticky bit ¥¹¥Æ¥£¥Ã¥¡¼¡¦¥Ó¥Ã¥È
69 .\"WORD: mandatory locking ¶¯À©¥í¥Ã¥¯
71 .TH STAT 2 2009-09-30 "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)):
93 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
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
132 ¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤Î¾õÂÖ¤ò¼èÆÀ¤·¤Æ
141 .\"O is a symbolic link, then the link itself is stat-ed,
142 .\"O not the file that it refers to.
148 ¤¬¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Î¾ì¹ç¡¢¥ê¥ó¥¯¤¬»²¾È¤·¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤Ç¤Ï¤Ê¤¯¡¢
149 ¥ê¥ó¥¯¼«¿È¤Î¾õÂÖ¤ò¼èÆÀ¤¹¤ëÅÀ¤¬°Û¤Ê¤ë¡£
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:
167 ¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¤¤¤º¤ì¤â¡¢·ë²Ì¤ò
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 ¥Õ¥£¡¼¥ë¥É¤Ï¡¢(Ä̾ï¤Î¥Õ¥¡¥¤¥ë¤«¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Î¾ì¹ç¤Ë)
236 ¥Õ¥¡¥¤¥ë¤ÎÂ礤µ¤ò¥Ð¥¤¥Èñ°Ì¤Ç¼¨¤¹¡£
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 ¥Ð¥¤¥Èñ°Ì¤Ç¼¨¤¹¡£
249 (¥Õ¥¡¥¤¥ë¤Ë·ê¤¬¤¢¤ë¤è¤¦¤Ê¾ì¹ç¡¢¤³¤ÎÃͤÏ
251 ¤è¤ê¾®¤µ¤¯¤Ê¤ë¤³¤È¤â¤¢¤ë)¡£
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 ¤Î¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à¤¬Á´¤Æ¤Î»þ´Ö¥Õ¥£¡¼¥ë¥É¤ò
278 ¼ÂÁõ¤·¤Æ¤¤¤ë¤ï¤±¤Ç¤Ï¤Ê¤¤¡£
279 ¥Õ¥¡¥¤¥ë¤ä¥Ç¥£¥ì¥¯¥È¥ê¤Î¥¢¥¯¥»¥¹¤¬
281 ¥Õ¥£¡¼¥ë¥É¤ò¹¹¿·¤·¤Ê¤¤¤è¤¦¤Ê¤«¤¿¤Á¤Ç¥Þ¥¦¥ó¥È¤Ç¤¤ë¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤â¤¢¤ë¡£
289 ¤Î´ØÏ¢¤¹¤ë¾ðÊó¤ò»²¾È)¡£
292 .\"O is not updated if a file is opened with the
298 ÉÕ¤¤Ç¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï
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 ¥Õ¥£¡¼¥ë¥É¤Ï¥Õ¥¡¥¤¥ë¥¢¥¯¥»¥¹¤¬¤¢¤Ã¤¿¾ì¹ç¤ËÊѹ¹¤µ¤ì¤ë
327 ¤Ç 1 ¥Ð¥¤¥È°Ê¾åÆɤ߹þ¤ó¤À¾ì¹ç¤Ê¤É)¡£
329 ¤Ê¤É¤Î¾¤Î¥ë¡¼¥Á¥ó¤Ç¤Ï¡¢
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.
355 ¤µ¤é¤Ë¡¢¥Ç¥£¥ì¥¯¥È¥ê¤Î
357 ¤Ï¡¢¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ç
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.).
374 ¥Õ¥£¡¼¥ë¥É¤Ï½ñ¤¹þ¤ß¤ä inode ¾ðÊó
375 (½êͼԡ¢¥°¥ë¡¼¥×¡¢¥ê¥ó¥¯¿ô¡¢¥â¡¼¥É¤Ê¤É) ¤Î
376 ÀßÄê¤Ë¤è¤Ã¤ÆÊѹ¹¤µ¤ì¤ë¡£
378 .\"O The following POSIX macros are defined to check the file type using the
381 °Ê²¼¤Î POSIX ¥Þ¥¯¥í¤Ï¡¢
384 ¤Ç»ÈÍѤµ¤ì¤ë¥Õ¥¡¥¤¥ë¼ïÊ̤ΥÁ¥§¥Ã¥¯¤Î¤¿¤á¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë :
388 .\"O is it a regular file?
396 .\"O character device?
397 ¥¥ã¥é¥¯¥¿¡¼¡¦¥Ç¥Ð¥¤¥¹¤«?
401 ¥Ö¥í¥Ã¥¯¡¦¥Ç¥Ð¥¤¥¹¤«?
404 .\"O FIFO (named pipe)?
405 FIFO (̾Á°ÉÕ¤¥Ñ¥¤¥×) ¤«?
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
421 ¥Õ¥£¡¼¥ë¥ÉÍѤËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
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.
489 ¤Ë¤Ï¤¤¤¯¤Ä¤«¤ÎÆüì¤Ê»ÈÍÑË¡¤¬¤¢¤ë:
490 ¥Ç¥£¥ì¥¯¥È¥ê¤ËÀßÄꤷ¤¿¾ì¹ç¤Ë¤Ï¡¢¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤¬ BSD Êý¼°¤Ç»ÈÍѤµ¤ì¤ë
491 ¤³¤È¤ò¼¨¤¹¡£¤Ä¤Þ¤ê¡¢¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ËºîÀ®¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤Î¥°¥ë¡¼¥×ID ¤Ï
492 ºîÀ®¤·¤¿¥×¥í¥»¥¹¤Î¼Â¸ú (effective) ¥°¥ë¡¼¥×ID ¤Ç¤Ï¤Ê¤¯¡¢¥Ç¥£¥ì¥¯¥È¥ê¤Î
493 ¥°¥ë¡¼¥×ID ¤ò·Ñ¾µ¤¹¤ë¡£¤Þ¤¿¡¢¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ËºîÀ®¤µ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤Ë¤â
495 ¥Ó¥Ã¥È¤¬ÀßÄꤵ¤ì¤ë¡£¥°¥ë¡¼¥×¼Â¹Ô¥Ó¥Ã¥È
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 ¤òÊÖ¤·¡¢
517 ¤ËŬÀÚ¤ÊÃͤ¬ÀßÄꤵ¤ì¤ë¡£
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 ¤¬½ê°¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¤È¤½¤Î¾å°Ì¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î¤¤¤º¤ì¤«¤Ë
529 ÂФ¹¤ë¸¡º÷µö²Ä¤¬¤Ê¤«¤Ã¤¿
530 .RB ( path_resolution (7)
541 ¥¢¥É¥ì¥¹¤¬´Ö°ã¤Ã¤Æ¤¤¤ë¡£
544 .\"O Too many symbolic links encountered while traversing the path.
545 ¥Ñ¥¹¤òé¤ëºÝ¤Ë²ò·è¤¹¤Ù¤¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤¬Â¿²á¤®¤¿¡£
548 .\"O File name too long.
549 ¥Õ¥¡¥¤¥ë̾¤¬Ä¹²á¤®¤ë¡£
554 .\"O does not exist, or
556 .\"O is an empty string.
558 ¤Î¹½À®Í×ÁǤ¬Â¸ºß¤·¤Ê¤¤¤«¡¢
563 .\"O Out of memory (i.e., kernel memory).
564 ¥«¡¼¥Í¥ë¤Î¥á¥â¥ê¤¬Â¤ê¤Ê¤¤¡£
567 .\"O A component of the path prefix of
569 .\"O is not a directory.
571 ¤ÎÁ°È¾Éôʬ (prefix) ¤Î¹½À®Í×ÁǤ¬¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ï¤Ê¤¤¡£
576 .\"O refers to a file whose size cannot be represented in the type
578 .\"O This can occur when an application compiled on a 32-bit platform without
579 .\"O .I -D_FILE_OFFSET_BITS=64
582 .\"O on a file whose size exceeds
589 ·¿¤Çɽ¸½¤Ç¤¤Ê¤¤¥Õ¥¡¥¤¥ë¤ò»²¾È¤·¤Æ¤¤¤ë¡£
590 ¤³¤Î¥¨¥é¡¼¤¬µ¯¤³¤ë¤Î¤Ï¡¢32 ¥Ó¥Ã¥È¥×¥é¥Ã¥È¥Õ¥©¡¼¥à¾å¤Ç
591 .I -D_FILE_OFFSET_BITS=64
592 ¤ò»ØÄꤻ¤º¤Ë¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬¡¢¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤¬
594 ¥Ó¥Ã¥È¤òĶ¤¨¤ë¥Õ¥¡¥¤¥ë¤ËÂФ·¤Æ
596 ¤ò¸Æ¤Ó½Ð¤·¤¿¾ì¹ç¤Ç¤¢¤ë¡£
597 .\"O .SH "CONFORMING TO"
599 .\"O These system calls conform to SVr4, 4.3BSD, POSIX.1-2001.
600 ¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï SVr4, 4.3BSD, POSIX.1-2001 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
601 .\"O .\" SVr4 documents additional
602 .\"O .\" .BR fstat ()
603 .\"O .\" error conditions EINTR, ENOLINK, and EOVERFLOW. SVr4
604 .\"O .\" documents additional
607 .\"O .\" .BR lstat ()
608 .\"O .\" error conditions EINTR, EMULTIHOP, ENOLINK, and EOVERFLOW.
612 ¥³¡¼¥ë¤Ï SVr4, SVID, POSIX, X/OPEN, 4.3BSD ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
614 ¥³¡¼¥ë¤Ï 4.3BSD ¤È SVr4 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
617 .\" ¤Î¥¨¥é¡¼¤È¤·¤Æ EINTR, ENOLINK, EOVERFLOW ¤¬µºÜ¤µ¤ì¤Æ¤¤¤ë¡£
622 .\" ¤Î¥¨¥é¡¼¤È¤·¤Æ EINTR, EMULTIHOP, ENOLINK, EOVERFLOW ¤¬µºÜ¤µ¤ì¤Æ¤¤¤ë¡£
628 .\"O fields may be less portable.
629 .\"O (They were introduced in BSD.
630 .\"O The interpretation differs between systems,
631 .\"O and possibly on a single system when NFS mounts are involved.)
635 ¥Õ¥£¡¼¥ë¥É¤Î»ÈÍѤϤ¢¤Þ¤ê°Ü¿¢À¤¬¤Ê¤¤¡£
636 (¤³¤ì¤é¤Î¥Õ¥£¡¼¥ë¥É¤Ï BSD ¤Ë¤è¤Ã¤ÆƳÆþ¤µ¤ì¤¿¡£
637 ¥·¥¹¥Æ¥à¤´¤È¤Ë²ò¼á¤¬°Û¤Ê¤Ã¤Æ¤ª¤ê¡¢
638 NFS ¥Þ¥¦¥ó¥È¤Î¾ì¹ç¤Ë¤ÏƱ¤¸¥·¥¹¥Æ¥à¤Ç¤â°Û¤Ê¤ë²ÄǽÀ¤¬¤¢¤ë)
640 .\"O POSIX does not describe the
650 .\"O bits, but instead demands the use of
658 .\"O macros are not in
659 .\"O POSIX.1-1996, but both are present in POSIX.1-2001;
660 .\"O the former is from SVID 4, the latter from SUSv2.
671 ¥Ó¥Ã¥È¤Ë¤Ä¤¤¤Æ¤Îµ½Ò¤Ï¤Ê¤¤¡£¤«¤ï¤ê¤Ë
673 ¤Î¤è¤¦¤Ê¥Þ¥¯¥í¤ò»ÈÍѤ¹¤ë¤è¤¦¤ËÍ׵ᤷ¤Æ¤¤¤ë¡£
678 ¤Ï POSIX.1-1996 ¤Ë¤Ï¤Ê¤¤¤¬¡¢
679 POSIX.1-2001 ¤Ë¤ÏξÊý¤È¤â¸ºß¤¹¤ë¡£
680 Á°¼Ô¤Ï SVID 4 ¤Ë¡¢¸å¼Ô¤Ï SUSv2 ¤ËͳÍ褷¤Æ¤¤¤ë¡£
682 .\"O Unix V7 (and later systems) had S_IREAD, S_IWRITE, S_IEXEC, where POSIX
683 .\"O prescribes the synonyms S_IRUSR, S_IWUSR, S_IXUSR.
684 .\"O Unix V7 (and later systems) had
689 .\"O prescribes the synonyms
693 Unix V7 (¤È¤½¤Î¸å¤Î¥·¥¹¥Æ¥à) ¤Ï
698 POSIX ¤Ï¤½¤ÎƱµÁ¸ì¤È¤·¤Æ
703 .\"O .SS "Other Systems"
705 .\"O Values that have been (or are) in use on various systems:
706 ³Æ¼ï¥·¥¹¥Æ¥à¤Ç»ÈÍѤµ¤ì¤Æ¤¤¤¿(¤¤¤ë)ÃÍ:
709 .\"O hex name ls octal description
710 16¿Ê ̾Á° ls 8¿Ê¿ô ÀâÌÀ
711 .\"O f000 S_IFMT 170000 mask for file type
712 .\"O 0000 000000 SCO out-of-service inode, BSD unknown
713 .\"O type; SVID-v2 and XPG2 have both
714 .\"O 0 and 0100000 for ordinary file
715 f000 S_IFMT 170000 ¥Õ¥¡¥¤¥ë¼ïÊÌ¥Õ¥£¡¼¥ë¥É¤Î¥Ó¥Ã¥È¥Þ¥¹¥¯
716 0000 000000 SCO ¤Ç¤Ï »ÈÍÑÉÔǽ inode;
717 BSD ¤Ç¤Ï̤ÃΤΥե¡¥¤¥ë¼ïÊÌ;
718 SVID-v2 ¤È XPG2 ¤Ç¤Ï 0 ¤È 0100000 ¤Î
720 .\"O 1000 S_IFIFO p| 010000 FIFO (named pipe)
721 .\"O 2000 S_IFCHR c 020000 character special (V7)
722 .\"O 3000 S_IFMPC 030000 multiplexed character special (V7)
723 .\"O 4000 S_IFDIR d/ 040000 directory (V7)
724 .\"O 5000 S_IFNAM 050000 XENIX named special file
725 .\"O with two subtypes, distinguished by
726 .\"O \fIst_rdev\fP values 1, 2
727 .\"O 0001 S_INSEM s 000001 XENIX semaphore subtype of IFNAM
728 .\"O 0002 S_INSHD m 000002 XENIX shared data subtype of IFNAM
729 1000 S_IFIFO p| 010000 FIFO (̾Á°ÉÕ¤¥Ñ¥¤¥×)
730 2000 S_IFCHR c 020000 ¥¥ã¥é¥¯¥¿Æüì¥Õ¥¡¥¤¥ë (V7)
731 3000 S_IFMPC 030000 ¿½Å²½¤µ¤ì¤¿¥¥ã¥é¥¯¥¿Æüì¥Õ¥¡¥¤¥ë (V7)
732 4000 S_IFDIR d/ 040000 ¥Ç¥£¥ì¥¯¥È¥ê (V7)
733 5000 S_IFNAM 050000 XENIX Æó¤Ä¤ÎÉû·¿¤ò»ý¤Ä̾Á°ÉÕ¤¤Î
735 Éû·¿¤Ï \fIst_rdev\fP ¤ÎÃÍ 1,2 ¤Ç¶èÊ̤µ¤ì¤ë:
736 0001 S_INSEM s 000001 XENIX IFNAM¤Î¥»¥Þ¥Õ¥©¡¼Éû·¿
737 0002 S_INSHD m 000002 XENIX IFNAM¤Î¶¦Í¥Ç¡¼¥¿Éû·¿
738 .\"O 6000 S_IFBLK b 060000 block special (V7)
739 .\"O 7000 S_IFMPB 070000 multiplexed block special (V7)
740 .\"O 8000 S_IFREG - 100000 regular (V7)
741 .\"O 9000 S_IFCMP 110000 VxFS compressed
742 .\"O 9000 S_IFNWK n 110000 network special (HP-UX)
743 .\"O a000 S_IFLNK l@ 120000 symbolic link (BSD)
744 6000 S_IFBLK b 060000 ¥Ö¥í¥Ã¥¯Æüì¥Õ¥¡¥¤¥ë (V7)
745 7000 S_IFMPB 070000 ¿½Å²½¤µ¤ì¤¿¥Ö¥í¥Ã¥¯Æüì¥Õ¥¡¥¤¥ë (V7)
746 8000 S_IFREG - 100000 Ä̾ï¥Õ¥¡¥¤¥ë (V7)
747 9000 S_IFCMP 110000 VxFS °µ½Ì¥Õ¥¡¥¤¥ë
748 9000 S_IFNWK n 110000 ¥Í¥Ã¥È¥ï¡¼¥¯Æüì¥Õ¥¡¥¤¥ë (HP-UX)
749 a000 S_IFLNK l@ 120000 ¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯ (BSD)
750 .\"O b000 S_IFSHAD 130000 Solaris shadow inode for ACL
751 .\"O (not seen by userspace)
752 .\"O c000 S_IFSOCK s= 140000 socket (BSD; also "S_IFSOC" on VxFS)
753 .\"O d000 S_IFDOOR D> 150000 Solaris door
754 .\"O e000 S_IFWHT w% 160000 BSD whiteout (not used for inode)
755 b000 S_IFSHAD 130000 Solaris ACL ¤Î¤¿¤á¤Î±£¤µ¤ì¤¿ inode
756 (¥æ¡¼¥¶¶õ´Ö¤«¤é¤Ï¸«¤¨¤Ê¤¤)
757 c000 S_IFSOCK s= 140000 ¥½¥±¥Ã¥È (BSD; VxFS ¤Î "S_IFSOC")
758 d000 S_IFDOOR D> 150000 Solaris ¥É¥¢¡¦¥Õ¥¡¥¤¥ë
759 e000 S_IFWHT w% 160000 BSD ¶õÇò¥Õ¥¡¥¤¥ë (inode ¤ò»ÈÍѤ·¤Ê¤¤)
760 .\"O 0200 S_ISVTX 001000 sticky bit: save swapped text even
762 .\"O reserved (SVID-v2)
763 .\"O On nondirectories: don't cache this
765 .\"O On directories: restricted deletion
766 .\"O flag (SVID-v4.2)
767 .\"O 0400 S_ISGID 002000 set-group-ID on execution (V7)
768 .\"O for directories: use BSD semantics for
769 .\"O propagation of GID
770 .\"O 0400 S_ENFMT 002000 System V file locking enforcement (shared
772 .\"O 0800 S_ISUID 004000 set-user-ID on execution (V7)
773 .\"O 0800 S_CDF 004000 directory is a context dependent
775 0200 S_ISVTX 001000 `¥¹¥Æ¥£¥Ã¥¡¼¡¦¥Ó¥Ã¥È':»ÈÍѸå¤â
778 ¥Ç¥£¥ì¥¯¥È¥ê°Ê³°: ¥Õ¥¡¥¤¥ë¤ò¥¥ã¥Ã¥·¥å
780 ¥Ç¥£¥ì¥¯¥È¥ê: ºï½üÀ©¸Â¥Õ¥é¥° (SVID-v4.2)
781 0400 S_ISGID 002000 ¼Â¹Ô»þ¤Î set-group-ID (V7)
782 ¥Ç¥£¥ì¥¯¥È¥ê¤ËÂФ·¤Æ¤Ï GID ¤ÎÅÁã¤Ë
784 0400 S_ENFMT 002000 System V ¥Õ¥¡¥¤¥ë¡¦¥í¥Ã¥¯¤ò¶¯À©¤¹¤ë
786 0800 S_ISUID 004000 ¼Â¹Ô»þ¤Î set-user-ID (V7)
787 0800 S_CDF 004000 ¥Ç¥£¥ì¥¯¥È¥ê¤¬¾õ¶·°Í¸¥Õ¥¡¥¤¥ë (HP-UX)
790 .\"O A sticky command appeared in Version 32V AT&T UNIX.
791 ¥¹¥Æ¥£¥Ã¥¡¼ ¥³¥Þ¥ó¥É¤Ï Version 32V AT&T UNIX ¤ÇÅо줷¤¿¡£
794 .\"O Since kernel 2.5.48, the
796 .\"O structure supports nanosecond resolution for the three
797 .\"O file timestamp fields.
798 .\"O Glibc exposes the nanosecond component of each field using names either
800 .\"O .IR st_atim.tv_nsec ,
805 .\"O feature test macro is defined,
807 .\"O .IR st_atimensec ,
808 .\"O if neither of these macros is defined.
809 .\"O On file systems that do not support subsecond timestamps,
810 .\"O these nanosecond fields are returned with the value 0.
811 ¥«¡¼¥Í¥ë 2.5.48 °Ê¹ß¤Ç¤Ï¡¢
813 ¹½Â¤ÂÎ¤Ï 3¤Ä¤Î¥Õ¥¡¥¤¥ë¤Î¥¿¥¤¥à¥¹¥¿¥ó¥×´ØÏ¢¤Î¥Õ¥£¡¼¥ë¥É¤Ç
814 ¥Ê¥ÎÉÃñ°Ì¤ÎÀºÅÙ¤ËÂбþ¤·¤Æ¤¤¤ë¡£
815 glibc ¤Ç¤Ï¡¢³Æ¥Õ¥£¡¼¥ë¥É¤Î¥Ê¥ÎÉäξðÊó¤ò
819 ¤È¤¤¤Ã¤¿·Á¤Ç»²¾È¤Ç¤¤ë¡£
824 ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï
826 ¤Î·Á¼°¤Ç¡¢¤½¤ì°Ê³°¤Î¾ì¹ç¤Ë¤Ï
829 Éäè¤êºÙ¤«¤¤¥¿¥¤¥à¥¹¥¿¥ó¥×¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ç¤Ï¡¢
830 ¤³¤ì¤é¤Î¥Ê¥ÎÉäΥե£¡¼¥ë¥É¤Ï 0 ¤ËÀßÄꤵ¤ì¤ë¡£
831 .\" As at kernel 2.6.25, XFS and JFS support nanosecond timestamps,
832 .\" but ext2, ext3, and Reiserfs do not.
833 .\" FIXME . SUSv4 specifies nanosecond timestamps.
837 .\"O will generally not trigger automounter action, whereas
842 ¤Ï°ìÈ̤ˤϼ«Æ°¥Þ¥¦¥ó¥ÈÆ°ºî (automounter action) ¤Î¤¤Ã¤«¤±¤È¤Ê¤é¤Ê¤¤¤¬¡¢
846 .\"O For most files under the
850 .\"O does not return the file size in the
852 .\"O field; instead the field is returned with the value 0.
854 ¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤Ë¤¢¤ë¥Õ¥¡¥¤¥ë¤Î¤Û¤È¤ó¤É¤Ç¤Ï¡¢
858 ¥Õ¥£¡¼¥ë¥É¤Ë¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤¬ÊÖ¤µ¤ì¤Ê¤¤¡£
861 ¥Õ¥£¡¼¥ë¥É¤Ë¤Ï 0 ¤¬ÊÖ¤µ¤ì¤ë¡£
862 .\"O .SS Underlying kernel interface
863 .SS Çظå¤Î¥«¡¼¥Í¥ë¡¦¥¤¥ó¥¿¥Õ¥§¡¼¥¹
864 .\"O Over time, increases in the size of the
866 .\"O structure have led to three successive versions of
870 ¹½Â¤ÂΤΥµ¥¤¥º¤¬Â礤¯¤Ê¤ê¡¢¤³¤Î±Æ¶Á¤Ç
872 ¤Ë¤Ï 3¤Ä¤Î¥Ð¡¼¥¸¥ç¥ó¤¬Â¸ºß¤¹¤ë:
875 .\"O .IR __NR_oldstat ),
876 .\"O .IR sys_newstat ()
878 .\"O .IR __NR_stat ),
881 .\"O (new in kernel 2.4; slot
882 .\"O .IR __NR_stat64 ).
890 (¥«¡¼¥Í¥ë 2.4 ¤ÇƳÆþ; ¥¹¥í¥Ã¥È¤Ï
894 .\"O wrapper function hides these details from applications,
895 .\"O invoking the most recent version of the system call provided by the kernel,
896 .\"O and repacking the returned information if required for old binaries.
899 ¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï¤³¤ì¤é¤Î¾ÜºÙ¤ò¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤«¤é±£Ê䷤Ƥ¯¤ì¤ë¡£
900 ¶ñÂÎŪ¤Ë¤Ï¡¢¥«¡¼¥Í¥ë¤¬Ä󶡤·¤Æ¤¤¤ë¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î¤¦¤ÁºÇ¿·¤Î¥Ð¡¼¥¸¥ç¥ó¤ò
901 µ¯Æ°¤·¡¢¸Å¤¤¥Ð¥¤¥Ê¥ê¤Î¾ì¹ç¤Ë¤ÏɬÍפ˱þ¤¸¤ÆÊÖ¤µ¤ì¤¿¾ðÊó¤òºÆ¹½À® (repack) ¤¹¤ë¡£
902 .\"O Similar remarks apply for
909 ¤Ë¤Ä¤¤¤Æ¤âƱÍͤǤ¢¤ë¡£
911 .\" A note from Andries Brouwer, July 2007
913 .\" > Is the story not rather more complicated for some calls like
916 .\" Yes and no, mostly no. See /usr/include/sys/stat.h .
918 .\" The idea is here not so much that syscalls change, but that
919 .\" the definitions of struct stat and of the types dev_t and mode_t change.
920 .\" This means that libc (even if it does not call the kernel
921 .\" but only calls some internal function) must know what the
922 .\" format of dev_t or of struct stat is.
923 .\" The communication between the application and libc goes via
924 .\" the include file <sys/stat.h> that defines a _STAT_VER and
925 .\" _MKNOD_VER describing the layout of the data that user space
926 .\" uses. Each (almost each) occurrence of stat() is replaced by
927 .\" an occurrence of xstat() where the first parameter of xstat()
928 .\" is this version number _STAT_VER.
930 .\" Now, also the definitions used by the kernel change.
931 .\" But glibc copes with this in the standard way, and the
932 .\" struct stat as returned by the kernel is repacked into
933 .\" the struct stat as expected by the application.
934 .\" Thus, _STAT_VER and this setup cater for the application-libc
935 .\" interface, rather than the libc-kernel interface.
937 .\" (Note that the details depend on gcc being used as c compiler.)
940 .\"O The following program calls
942 .\"O and displays selected fields in the returned
947 ¤ò¸Æ¤Ó½Ð¤·¡¢Ê֤äƤ¤¿
949 ¹½Â¤ÂΤΥե£¡¼¥ë¥É¤Î¤¤¤¯¤Ä¤«¤òɽ¼¨¤¹¤ë¡£
952 #include <sys/types.h>
953 #include <sys/stat.h>
959 main(int argc, char *argv[])
964 fprintf(stderr, "Usage: %s <pathname>\\n", argv[0]);
968 if (stat(argv[1], &sb) == \-1) {
973 printf("File type: ");
975 switch (sb.st_mode & S_IFMT) {
976 case S_IFBLK: printf("block device\\n"); break;
977 case S_IFCHR: printf("character device\\n"); break;
978 case S_IFDIR: printf("directory\\n"); break;
979 case S_IFIFO: printf("FIFO/pipe\\n"); break;
980 case S_IFLNK: printf("symlink\\n"); break;
981 case S_IFREG: printf("regular file\\n"); break;
982 case S_IFSOCK: printf("socket\\n"); break;
983 default: printf("unknown?\\n"); break;
986 printf("I\-node number: %ld\\n", (long) sb.st_ino);
988 printf("Mode: %lo (octal)\\n",
989 (unsigned long) sb.st_mode);
991 printf("Link count: %ld\\n", (long) sb.st_nlink);
992 printf("Ownership: UID=%ld GID=%ld\\n",
993 (long) sb.st_uid, (long) sb.st_gid);
995 printf("Preferred I/O block size: %ld bytes\\n",
996 (long) sb.st_blksize);
997 printf("File size: %lld bytes\\n",
998 (long long) sb.st_size);
999 printf("Blocks allocated: %lld\\n",
1000 (long long) sb.st_blocks);
1002 printf("Last status change: %s", ctime(&sb.st_ctime));
1003 printf("Last file access: %s", ctime(&sb.st_atime));
1004 printf("Last file modification: %s", ctime(&sb.st_mtime));
1017 .BR capabilities (7),