OSDN Git Service

186abc479fdf6b64ef7869fe95bb4d72a3f26fb9
[linuxjm/LDP_man-pages.git] / draft / man2 / stat.2
1 '\" t
2 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\"
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>
7 .\"
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.
11 .\"
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.
16 .\"
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
23 .\" professionally.
24 .\"
25 .\" Formatted or processed versions of this manual, if unaccompanied by
26 .\" the source, must acknowledge the copyright and authors of this work.
27 .\"
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
39 .\"
40 .\" Japanese Version Copyright (c) 1998-1999 HANATAKA Shinya
41 .\" and Copyright (c) 2005-2008 Akihiro MOTOKI
42 .\"
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
55 .\"
56 .\"WORD:        status                  ¾õÂÖ
57 .\"WORD:        directory               ¥Ç¥£¥ì¥¯¥È¥ê
58 .\"WORD:        open                    ¥ª¡¼¥×¥ó
59 .\"WORD:        implement               ¼ÂÁõ
60 .\"WORD:        owner                   ½êÍ­¼Ô
61 .\"WORD:        group                   ¥°¥ë¡¼¥×
62 .\"WORD:        user                    ¥æ¡¼¥¶¡¼
63 .\"WORD:        other                   Â¾¿Í
64 .\"WORD:        hard link count         ¥Ï¡¼¥É¡¦¥ê¥ó¥¯¿ô
65 .\"WORD:        symbolic link           ¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯
66 .\"WORD:        socket                  ¥½¥±¥Ã¥È
67 .\"WORD:        device                  ¥Ç¥Ð¥¤¥¹
68 .\"WORD:        sticky bit              ¥¹¥Æ¥£¥Ã¥­¡¼¡¦¥Ó¥Ã¥È
69 .\"WORD:        mandatory locking       ¶¯À©¥í¥Ã¥¯
70 .\"
71 .TH STAT 2 2009-09-30 "Linux" "Linux Programmer's Manual"
72 .\"O .SH NAME
73 .SH Ì¾Á°
74 .\"O stat, fstat, lstat \- get file status
75 stat, fstat, lstat \- ¥Õ¥¡¥¤¥ë¤Î¾õÂÖ¤ò¼èÆÀ¤¹¤ë
76 .\"O .SH SYNOPSIS
77 .SH ½ñ¼°
78 .B #include <sys/types.h>
79 .br
80 .B #include <sys/stat.h>
81 .br
82 .B #include <unistd.h>
83 .sp
84 .BI "int stat(const char *" path ", struct stat *" buf );
85 .br
86 .BI "int fstat(int " fd ", struct stat *" buf );
87 .br
88 .BI "int lstat(const char *" path ", struct stat *" buf );
89 .sp
90 .in -4n
91 .\"O Feature Test Macro Requirements for glibc (see
92 .\"O .BR feature_test_macros (7)):
93 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
94 .RB ( feature_test_macros (7)
95 »²¾È):
96 .in
97 .sp
98 .BR lstat ():
99 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500
100 .\"O .SH DESCRIPTION
101 .SH ÀâÌÀ
102 .PP
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
105 .\"O .BR stat ()
106 .\"O and
107 .\"O .BR lstat ()
108 .\"O \(em
109 .\"O execute (search) permission is required on all of the directories in
110 .\"O .I path
111 .\"O that lead to the file.
112 ¤³¤ì¤é¤Î´Ø¿ô¤Ï¥Õ¥¡¥¤¥ë¤Ë¤Ä¤¤¤Æ¤Î¾ðÊó¤òÊÖ¤¹¡£
113 ¥Õ¥¡¥¤¥ë¤½¤Î¤â¤Î¤ËÂФ¹¤ë¥¢¥¯¥»¥¹µö²Ä¤ÏɬÍפȤ·¤Ê¤¤¤¬¡¢
114 \(em
115 .BR stat ()
116 ¤È
117 .BR lstat ()
118 ¤Î¾ì¹ç¤Ë¤Ï
119 \(em
120 ¤½¤Î¥Õ¥¡¥¤¥ë¤Ø»ê¤ë
121 .I path
122 ¤ò¹½À®¤¹¤ëÁ´¤Æ¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ËÂФ¹¤ë¼Â¹Ô (¸¡º÷) µö²Ä¤¬É¬ÍפǤ¢¤ë¡£
123 .PP
124 .\"O .BR stat ()
125 .\"O stats the file pointed to by
126 .\"O .I path
127 .\"O and fills in
128 .\"O .IR buf .
129 .BR stat ()
130 ¤Ï
131 .I path
132 ¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤Î¾õÂÖ¤ò¼èÆÀ¤·¤Æ
133 .I buf
134 ¤Ø³ÊǼ¤¹¤ë¡£
135
136 .\"O .BR lstat ()
137 .\"O is identical to
138 .\"O .BR stat (),
139 .\"O except that if
140 .\"O .I path
141 .\"O is a symbolic link, then the link itself is stat-ed,
142 .\"O not the file that it refers to.
143 .BR lstat ()
144 ¤Ï
145 .BR stat ()
146 ¤ÈƱ¤¸¤Ç¤¢¤ë¤¬¡¢
147 .I path
148 ¤¬¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Î¾ì¹ç¡¢¥ê¥ó¥¯¤¬»²¾È¤·¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤Ç¤Ï¤Ê¤¯¡¢
149 ¥ê¥ó¥¯¼«¿È¤Î¾õÂÖ¤ò¼èÆÀ¤¹¤ëÅÀ¤¬°Û¤Ê¤ë¡£
150
151 .\"O .BR fstat ()
152 .\"O is identical to
153 .\"O .BR stat (),
154 .\"O except that the file to be stat-ed is specified by the file descriptor
155 .\"O .IR fd .
156 .BR fstat ()
157 ¤Ï
158 .BR stat ()
159 ¤ÈƱ¤¸¤À¤¬¡¢
160 ¾õÂÖ¤ò¼èÆÀ¤¹¤ë¥Õ¥¡¥¤¥ë¤ò¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿
161 .I fd
162 ¤Ç»ØÄꤹ¤ë¡£
163 .PP
164 .\"O All of these system calls return a
165 .\"O .I stat
166 .\"O structure, which contains the following fields:
167 ¤³¤ì¤é¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¤¤¤º¤ì¤â¡¢·ë²Ì¤ò
168 .I stat
169 ¹½Â¤ÂΤËÆþ¤ì¤ÆÊÖ¤¹¡£
170 .I stat
171 ¹½Â¤ÂΤˤϰʲ¼¤Î¥Õ¥£¡¼¥ë¥É¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë:
172 .PP
173 .in +4n
174 .nf
175 struct stat {
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 ¤Ç¤Î
198                              ¥Ö¥í¥Ã¥¯¥µ¥¤¥º */
199     blkcnt_t  st_blocks;  /* ³ä¤êÅö¤Æ¤é¤ì¤¿ 512B ¤Î¥Ö¥í¥Ã¥¯¿ô */
200     time_t    st_atime;   /* ºÇ½ª¥¢¥¯¥»¥¹»þ¹ï */
201     time_t    st_mtime;   /* ºÇ½ª½¤Àµ»þ¹ï */
202     time_t    st_ctime;   /* ºÇ½ª¾õÂÖÊѹ¹»þ¹ï */
203 };
204 .fi
205 .in
206 .PP
207 .\"O The
208 .\"O .I st_dev
209 .\"O field describes the device on which this file resides.
210 .\"O (The
211 .\"O .BR major (3)
212 .\"O and
213 .\"O .BR minor (3)
214 .\"O macros may be useful to decompose the device ID in this field.)
215 .I st_dev
216 ¥Õ¥£¡¼¥ë¥É¤Ï¡¢¤³¤Î¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤¹¤ë¥Ç¥Ð¥¤¥¹¤ò¼¨¤¹
217 (¥Þ¥¯¥í
218 .BR major (3),
219 .BR minor (3)
220 ¤Ï¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤Î¥Ç¥Ð¥¤¥¹ ID ¤òʬ²ò¤¹¤ë¤Î¤ËÌòΩ¤Ä¤À¤í¤¦)¡£
221
222 .\"O The
223 .\"O .I st_rdev
224 .\"O field describes the device that this file (inode) represents.
225 .I st_rdev
226 ¥Õ¥£¡¼¥ë¥É¤Ï¡¢¤³¤Î¥Õ¥¡¥¤¥ë (inode) ¤¬É½¤¹¥Ç¥Ð¥¤¥¹¤ò¼¨¤¹¡£
227
228 .\"O The
229 .\"O .I st_size
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.
234 .I st_size
235 ¥Õ¥£¡¼¥ë¥É¤Ï¡¢(Ä̾ï¤Î¥Õ¥¡¥¤¥ë¤«¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Î¾ì¹ç¤Ë)
236 ¥Õ¥¡¥¤¥ë¤ÎÂ礭¤µ¤ò¥Ð¥¤¥Èñ°Ì¤Ç¼¨¤¹¡£
237 ¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤ÎÂ礭¤µ¤Ï¡¢¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë
238 ¥Ñ¥¹Ì¾¤ÎŤµ (ºÇ¸å¤Î NULL ¥Ð¥¤¥È¤Ï´Þ¤Þ¤Ê¤¤) ¤Ç¤¢¤ë¡£
239
240 .\"O The
241 .\"O .I st_blocks
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.)
246 .I st_blocks
247 ¥Õ¥£¡¼¥ë¥É¤Ï¡¢¥Õ¥¡¥¤¥ë¤ÎÂ礭¤µ¤ò 512 ¥Ð¥¤¥È¤Î¥Ö¥í¥Ã¥¯¥µ¥¤¥ºÃ±°Ì¤Ç¼¨¤¹
248 ¥Õ¥£¡¼¥ë¥É¤Ï¡¢¥Õ¥¡¥¤¥ë¤Ë³ä¤êÅö¤Æ¤µ¤ì¤¿¥Ö¥í¥Ã¥¯¿ô¤ò 512 ¥Ð¥¤¥Èñ°Ì¤Ç¼¨¤¹¡£
249 (¥Õ¥¡¥¤¥ë¤Ë·ê¤¬¤¢¤ë¤è¤¦¤Ê¾ì¹ç¡¢¤³¤ÎÃͤÏ
250 .IR st_size /512
251 ¤è¤ê¾®¤µ¤¯¤Ê¤ë¤³¤È¤â¤¢¤ë)¡£
252
253 .\"O The
254 .\"O .I st_blksize
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.)
258 .I st_blksize
259 ¥Õ¥£¡¼¥ë¥É¤Ï¡¢¸úΨŪ¤Ë¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à I/O ¤¬¤Ç¤­¤ë¡Ö¹¥¤Þ¤·¤¤¡×
260 ¥Ö¥í¥Ã¥¯¥µ¥¤¥º¤ò¼¨¤¹ (¤â¤Ã¤È¾®¤µ¤¤Ã±°Ì¤Ç¥Õ¥¡¥¤¥ë¤Ë½ñ¤­¹þ¤ß¤ò¹Ô¤¦¤È¡¢
261 Æɤ߽Ф·--½¤Àµ--ºÆ½ñ¤­¹þ¤ß¤È¤¤¤Ã¤¿Èó¸úΨ¤ÊÆ°ºî¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¦¤«¤â¤·¤ì¤Ê¤¤)¡£
262 .PP
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
266 .\"O .I st_atime
267 .\"O field.
268 .\"O (See
269 .\"O .IR noatime ,
270 .\"O .IR nodiratime ,
271 .\"O and
272 .\"O .I relatime
273 .\"O in
274 .\"O .BR mount (8),
275 .\"O and related information in
276 .\"O .BR mount (2).)
277 Á´¤Æ¤Î Linux ¤Î¥Õ¥¡¥¤¥ë¡¦¥·¥¹¥Æ¥à¤¬Á´¤Æ¤Î»þ´Ö¥Õ¥£¡¼¥ë¥É¤ò
278 ¼ÂÁõ¤·¤Æ¤¤¤ë¤ï¤±¤Ç¤Ï¤Ê¤¤¡£
279 ¥Õ¥¡¥¤¥ë¤ä¥Ç¥£¥ì¥¯¥È¥ê¤Î¥¢¥¯¥»¥¹¤¬
280 .I st_atime
281 ¥Õ¥£¡¼¥ë¥É¤ò¹¹¿·¤·¤Ê¤¤¤è¤¦¤Ê¤«¤¿¤Á¤Ç¥Þ¥¦¥ó¥È¤Ç¤­¤ë¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤â¤¢¤ë¡£
282 .RB ( mount (8)
283 ¤Î
284 .IR noatime ,
285 .IR nodiratime ,
286 .I relatime
287 ¤ä
288 .BR mount (2)
289 ¤Î´ØÏ¢¤¹¤ë¾ðÊó¤ò»²¾È)¡£
290 .\"O In addition,
291 .\"O .I st_atime
292 .\"O is not updated if a file is opened with the
293 .\"O .BR O_NOATIME ;
294 .\"O see
295 .\"O .BR open (2).
296 ¤Þ¤¿¡¢¥Õ¥¡¥¤¥ë¤¬
297 .B O_NOATIME
298 ÉÕ¤­¤Ç¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï
299 .I st_atime
300 ¤Ï¹¹¿·¤µ¤ì¤Ê¤¤¡£
301 .BR open (2)
302 »²¾È¡£
303
304 .\"O The field
305 .\"O .I st_atime
306 .\"O is changed by file accesses, for example, by
307 .\"O .BR execve (2),
308 .\"O .BR mknod (2),
309 .\"O .BR pipe (2),
310 .\"O .BR utime (2)
311 .\"O and
312 .\"O .BR read (2)
313 .\"O (of more than zero bytes).
314 .\"O Other routines, like
315 .\"O .BR mmap (2),
316 .\"O may or may not update
317 .\"O .IR st_atime .
318 .I st_atime
319 ¥Õ¥£¡¼¥ë¥É¤Ï¥Õ¥¡¥¤¥ë¥¢¥¯¥»¥¹¤¬¤¢¤Ã¤¿¾ì¹ç¤ËÊѹ¹¤µ¤ì¤ë
320 (Î㤨¤Ð¡¢
321 .BR execve (2),
322 .BR mknod (2),
323 .BR pipe (2),
324 .BR utime (2)
325 ¤ò»ÈÍѤ·¤¿¾ì¹ç¤ä
326 .BR read (2)
327 ¤Ç 1 ¥Ð¥¤¥È°Ê¾åÆɤ߹þ¤ó¤À¾ì¹ç¤Ê¤É)¡£
328 .BR mmap (2)
329 ¤Ê¤É¤Î¾¤Î¥ë¡¼¥Á¥ó¤Ç¤Ï¡¢
330 .I st_atime
331 ¤Ï¹¹¿·¤µ¤ì¤ë¤³¤È¤â¤¢¤ì¤Ð¡¢¤½¤¦¤Ç¤Ê¤¤¾ì¹ç¤â¤¢¤ë¡£
332
333 .\"O The field
334 .\"O .I st_mtime
335 .\"O is changed by file modifications, for example, by
336 .\"O .BR mknod (2),
337 .\"O .BR truncate (2),
338 .\"O .BR utime (2)
339 .\"O and
340 .\"O .BR write (2)
341 .\"O (of more than zero bytes).
342 .I st_mtime
343 ¥Õ¥£¡¼¥ë¥É¤Ï¡¢¥Õ¥¡¥¤¥ë¤¬½¤Àµ¤µ¤ì¤¿¾ì¹ç¤ËÊѹ¹¤µ¤ì¤ë
344 (Î㤨¤Ð¡¢
345 .BR mknod (2),
346 .BR truncate (2),
347 .BR utime (2)
348 ¤ò»ÈÍѤ·¤¿¾ì¹ç¤ä
349 .BR write (2)
350 ¤Ç 1 ¥Ð¥¤¥È°Ê¾å½ñ¤­¹þ¤ß¤ò¤·¤¿¾ì¹ç¤Ê¤É)¡£
351 .\"O Moreover,
352 .\"O .I st_mtime
353 .\"O of a directory is changed by the creation or deletion of files
354 .\"O in that directory.
355 ¤µ¤é¤Ë¡¢¥Ç¥£¥ì¥¯¥È¥ê¤Î
356 .I st_mtime
357 ¤Ï¡¢¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ç
358 ¥Õ¥¡¥¤¥ë¤¬ºîÀ®¤µ¤ì¤¿¤êºï½ü¤µ¤ì¤¿¤ê¤¹¤ë¤ÈÊѹ¹¤µ¤ì¤ë¡£
359 .\"O The
360 .\"O .I st_mtime
361 .\"O field is
362 .\"O .I not
363 .\"O changed for changes in owner, group, hard link count, or mode.
364 .I st_mtime
365 ¥Õ¥£¡¼¥ë¥É¤Ï
366 ½êÍ­¼Ô¤ä¥°¥ë¡¼¥×¤ä¥Ï¡¼¥É¡¦¥ê¥ó¥¯¿ô¤ä¥â¡¼¥É¤ÎÊѹ¹¤Ç¤ÏÊѹ¹
367 .I ¤µ¤ì¤Ê¤¤¡£
368
369 .\"O The field
370 .\"O .I st_ctime
371 .\"O is changed by writing or by setting inode information
372 .\"O (i.e., owner, group, link count, mode, etc.).
373 .I st_ctime
374 ¥Õ¥£¡¼¥ë¥É¤Ï½ñ¤­¹þ¤ß¤ä inode ¾ðÊó
375 (½êÍ­¼Ô¡¢¥°¥ë¡¼¥×¡¢¥ê¥ó¥¯¿ô¡¢¥â¡¼¥É¤Ê¤É) ¤Î
376 ÀßÄê¤Ë¤è¤Ã¤ÆÊѹ¹¤µ¤ì¤ë¡£
377 .PP
378 .\"O The following POSIX macros are defined to check the file type using the
379 .\"O .I st_mode
380 .\"O field:
381 °Ê²¼¤Î POSIX ¥Þ¥¯¥í¤Ï¡¢
382 .I st_mode
383 ¥Õ¥£¡¼¥ë¥É
384 ¤Ç»ÈÍѤµ¤ì¤ë¥Õ¥¡¥¤¥ë¼ïÊ̤ΥÁ¥§¥Ã¥¯¤Î¤¿¤á¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë :
385 .RS 4
386 .TP 1.2i
387 .BR S_ISREG (m)
388 .\"O is it a regular file?
389 Ä̾ï¤Î¥Õ¥¡¥¤¥ë¤«?
390 .TP
391 .BR S_ISDIR (m)
392 .\"O directory?
393 ¥Ç¥£¥ì¥¯¥È¥ê¤«?
394 .TP
395 .BR S_ISCHR (m)
396 .\"O character device?
397 ¥­¥ã¥é¥¯¥¿¡¼¡¦¥Ç¥Ð¥¤¥¹¤«?
398 .TP
399 .BR S_ISBLK (m)
400 .\"O block device?
401 ¥Ö¥í¥Ã¥¯¡¦¥Ç¥Ð¥¤¥¹¤«?
402 .TP
403 .BR S_ISFIFO (m)
404 .\"O FIFO (named pipe)?
405 FIFO (̾Á°ÉÕ¤­¥Ñ¥¤¥×) ¤«?
406 .TP
407 .BR S_ISLNK (m)
408 .\"O symbolic link? (Not in POSIX.1-1996.)
409 ¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤«? (POSIX.1-1996 ¤Ë¤Ï¤Ê¤¤)
410 .TP
411 .BR S_ISSOCK (m)
412 .\"O socket? (Not in POSIX.1-1996.)
413 ¥½¥±¥Ã¥È¤«? (POSIX.1-1996 ¤Ë¤Ï¤Ê¤¤)
414 .RE
415 .PP
416 .\"O The following flags are defined for the
417 .\"O .I st_mode
418 .\"O field:
419 °Ê²¼¤Î¥Õ¥é¥°¤¬
420 .I st_mode
421 ¥Õ¥£¡¼¥ë¥ÉÍѤËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
422 .in +4n
423 .TS
424 lB l l.
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 ¥­¥ã¥é¥¯¥¿¡¼¡¦¥Ç¥Ð¥¤¥¹
440 S_IFIFO 0010000 FIFO
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   Â¾¿Í¤Î¼Â¹Ôµö²Ä
471 .TE
472 .in
473 .P
474 .\"O The set-group-ID bit
475 .\"O .RB ( S_ISGID )
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
481 .\"O .B S_ISGID
482 .\"O bit set.
483 .\"O For a file that does not have the group execution bit
484 .\"O .RB ( S_IXGRP )
485 .\"O set,
486 .\"O the set-group-ID bit indicates mandatory file/record locking.
487 set-group-ID bit
488 .RB ( S_ISGID )
489 ¤Ë¤Ï¤¤¤¯¤Ä¤«¤ÎÆüì¤Ê»ÈÍÑË¡¤¬¤¢¤ë:
490 ¥Ç¥£¥ì¥¯¥È¥ê¤ËÀßÄꤷ¤¿¾ì¹ç¤Ë¤Ï¡¢¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤¬ BSD Êý¼°¤Ç»ÈÍѤµ¤ì¤ë
491 ¤³¤È¤ò¼¨¤¹¡£¤Ä¤Þ¤ê¡¢¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ËºîÀ®¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤Î¥°¥ë¡¼¥×ID ¤Ï
492 ºîÀ®¤·¤¿¥×¥í¥»¥¹¤Î¼Â¸ú (effective) ¥°¥ë¡¼¥×ID ¤Ç¤Ï¤Ê¤¯¡¢¥Ç¥£¥ì¥¯¥È¥ê¤Î
493 ¥°¥ë¡¼¥×ID ¤ò·Ñ¾µ¤¹¤ë¡£¤Þ¤¿¡¢¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ËºîÀ®¤µ¤ì¤¿¥Ç¥£¥ì¥¯¥È¥ê¤Ë¤â
494 .B S_ISGID
495 ¥Ó¥Ã¥È¤¬ÀßÄꤵ¤ì¤ë¡£¥°¥ë¡¼¥×¼Â¹Ô¥Ó¥Ã¥È
496 .RB ( S_IXGRP )
497 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¥Õ¥¡¥¤¥ë¤ËÀßÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢
498 set-group-ID ¥Ó¥Ã¥È¤Ï¥Õ¥¡¥¤¥ë/¥ì¥³¡¼¥É¤Î
499 ¶¯À©Åª¤Ê (mandatory) ¥í¥Ã¥¯¤òɽ¤¹¡£
500 .P
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
504 .\"O process.
505 ¥Ç¥£¥ì¥¯¥È¥ê¤Ë¥¹¥Æ¥£¥Ã¥­¡¼¥Ó¥Ã¥È (S_ISVTX) ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢
506 ¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î¥Õ¥¡¥¤¥ë¤Î̾Á°¤òÊѹ¹¤·¤¿¤ê¡¢ºï½ü¤·¤¿¤ê¤Ç¤­¤ë¤Î¤Ï¡¢
507 ¤½¤Î¥Õ¥¡¥¤¥ë¤Î½êÍ­¼Ô¤«¡¢¤½¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î½êÍ­¼Ô¤«¡¢Æø¢¥×¥í¥»¥¹
508 ¤À¤±¤È¤Ê¤ë¡£
509 .\"O .SH "RETURN VALUE"
510 .SH ÊÖ¤êÃÍ
511 .\"O On success, zero is returned.
512 .\"O On error, \-1 is returned, and
513 .\"O .I errno
514 .\"O is set appropriately.
515 À®¸ù¤·¤¿¾ì¹ç¤Ï 0 ¤òÊÖ¤¹¡£¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤òÊÖ¤·¡¢
516 .I errno
517 ¤ËŬÀÚ¤ÊÃͤ¬ÀßÄꤵ¤ì¤ë¡£
518 .\"O .SH ERRORS
519 .SH ¥¨¥é¡¼
520 .TP
521 .B EACCES
522 .\"O Search permission is denied for one of the directories
523 .\"O in the path prefix of
524 .\"O .IR path .
525 .\"O (See also
526 .\"O .BR path_resolution (7).)
527 .I path
528 ¤¬½ê°¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê¤È¤½¤Î¾å°Ì¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î¤¤¤º¤ì¤«¤Ë
529 ÂФ¹¤ë¸¡º÷µö²Ä¤¬¤Ê¤«¤Ã¤¿
530 .RB ( path_resolution (7)
531 ¤â»²¾È¤Î¤³¤È)¡£
532 .TP
533 .B EBADF
534 .\"O .I fd
535 .\"O is bad.
536 .I fd
537 ¤¬ÉÔÀµ¤Ç¤¢¤ë¡£
538 .TP
539 .B EFAULT
540 .\"O Bad address.
541 ¥¢¥É¥ì¥¹¤¬´Ö°ã¤Ã¤Æ¤¤¤ë¡£
542 .TP
543 .B ELOOP
544 .\"O Too many symbolic links encountered while traversing the path.
545 ¥Ñ¥¹¤òé¤ëºÝ¤Ë²ò·è¤¹¤Ù¤­¥·¥ó¥Ü¥ê¥Ã¥¯¡¦¥ê¥ó¥¯¤¬Â¿²á¤®¤¿¡£
546 .TP
547 .B ENAMETOOLONG
548 .\"O File name too long.
549 ¥Õ¥¡¥¤¥ë̾¤¬Ä¹²á¤®¤ë¡£
550 .TP
551 .B ENOENT
552 .\"O A component of
553 .\"O .I path
554 .\"O does not exist, or
555 .\"O .I path
556 .\"O is an empty string.
557 .I path
558 ¤Î¹½À®Í×ÁǤ¬Â¸ºß¤·¤Ê¤¤¤«¡¢
559 .I path
560 ¤¬¶õʸ»úÎó¤Ç¤¢¤ë¡£
561 .TP
562 .B ENOMEM
563 .\"O Out of memory (i.e., kernel memory).
564 ¥«¡¼¥Í¥ë¤Î¥á¥â¥ê¤¬Â­¤ê¤Ê¤¤¡£
565 .TP
566 .B ENOTDIR
567 .\"O A component of the path prefix of
568 .\"O .I path
569 .\"O is not a directory.
570 .I path
571 ¤ÎÁ°È¾Éôʬ (prefix) ¤Î¹½À®Í×ÁǤ¬¥Ç¥£¥ì¥¯¥È¥ê¤Ç¤Ï¤Ê¤¤¡£
572 .TP
573 .B EOVERFLOW
574 .\"O .RB ( stat ())
575 .\"O .I path
576 .\"O refers to a file whose size cannot be represented in the type
577 .\"O .IR off_t .
578 .\"O This can occur when an application compiled on a 32-bit platform without
579 .\"O .I -D_FILE_OFFSET_BITS=64
580 .\"O calls
581 .\"O .BR stat ()
582 .\"O on a file whose size exceeds
583 .\"O .I (2<<31)-1
584 .\"O bits.
585 .RB ( stat ())
586 .I path
587 ¤¬¡¢¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤ò
588 .I off_t
589 ·¿¤Çɽ¸½¤Ç¤­¤Ê¤¤¥Õ¥¡¥¤¥ë¤ò»²¾È¤·¤Æ¤¤¤ë¡£
590 ¤³¤Î¥¨¥é¡¼¤¬µ¯¤³¤ë¤Î¤Ï¡¢32 ¥Ó¥Ã¥È¥×¥é¥Ã¥È¥Õ¥©¡¼¥à¾å¤Ç
591 .I -D_FILE_OFFSET_BITS=64
592 ¤ò»ØÄꤻ¤º¤Ë¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬¡¢¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤¬
593 .I (2<31)-1
594 ¥Ó¥Ã¥È¤òĶ¤¨¤ë¥Õ¥¡¥¤¥ë¤ËÂФ·¤Æ
595 .BR stat ()
596 ¤ò¸Æ¤Ó½Ð¤·¤¿¾ì¹ç¤Ç¤¢¤ë¡£
597 .\"O .SH "CONFORMING TO"
598 .SH ½àµò
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
605 .\"O .\" .BR stat ()
606 .\"O .\" and
607 .\"O .\" .BR lstat ()
608 .\"O .\" error conditions EINTR, EMULTIHOP, ENOLINK, and EOVERFLOW.
609 .BR stat ()
610 ¤È
611 .BR fstat ()
612 ¥³¡¼¥ë¤Ï SVr4, SVID, POSIX, X/OPEN, 4.3BSD ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
613 .BR lstat ()
614 ¥³¡¼¥ë¤Ï 4.3BSD ¤È SVr4 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
615 .\" SVr4 ¤Ë¤Ï¾¤Ë
616 .\" .BR fstat ()
617 .\" ¤Î¥¨¥é¡¼¤È¤·¤Æ EINTR, ENOLINK, EOVERFLOW ¤¬µ­ºÜ¤µ¤ì¤Æ¤¤¤ë¡£
618 .\" SVr4 ¤Ë¤Ï¾¤Ë
619 .\" .BR stat ()
620 .\" ¤È
621 .\" .BR lstat ()
622 .\" ¤Î¥¨¥é¡¼¤È¤·¤Æ EINTR, EMULTIHOP, ENOLINK, EOVERFLOW ¤¬µ­ºÜ¤µ¤ì¤Æ¤¤¤ë¡£
623
624 .\"O Use of the
625 .\"O .I st_blocks
626 .\"O and
627 .\"O .I st_blksize
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.)
632 .I st_blocks
633 ¤È
634 .I st_blksize
635 ¥Õ¥£¡¼¥ë¥É¤Î»ÈÍѤϤ¢¤Þ¤ê°Ü¿¢À­¤¬¤Ê¤¤¡£
636 (¤³¤ì¤é¤Î¥Õ¥£¡¼¥ë¥É¤Ï BSD ¤Ë¤è¤Ã¤ÆƳÆþ¤µ¤ì¤¿¡£
637 ¥·¥¹¥Æ¥à¤´¤È¤Ë²ò¼á¤¬°Û¤Ê¤Ã¤Æ¤ª¤ê¡¢
638 NFS ¥Þ¥¦¥ó¥È¤Î¾ì¹ç¤Ë¤ÏƱ¤¸¥·¥¹¥Æ¥à¤Ç¤â°Û¤Ê¤ë²ÄǽÀ­¤¬¤¢¤ë)
639 .LP
640 .\"O POSIX does not describe the
641 .\"O .BR S_IFMT ,
642 .\"O .BR S_IFSOCK ,
643 .\"O .BR S_IFLNK ,
644 .\"O .BR S_IFREG ,
645 .\"O .BR S_IFBLK ,
646 .\"O .BR S_IFDIR ,
647 .\"O .BR S_IFCHR ,
648 .\"O .BR S_IFIFO ,
649 .\"O .B S_ISVTX
650 .\"O bits, but instead demands the use of
651 .\"O the macros
652 .\"O .BR S_ISDIR (),
653 .\"O etc.
654 .\"O The
655 .\"O .BR S_ISLNK ()
656 .\"O and
657 .\"O .BR S_ISSOCK ()
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.
661 POSIX ¤Ë¤Ï
662 .BR S_IFMT ,
663 .BR S_IFSOCK ,
664 .BR S_IFLNK ,
665 .BR S_IFREG ,
666 .BR S_IFBLK ,
667 .BR S_IFDIR ,
668 .BR S_IFCHR ,
669 .BR S_IFIFO ,
670 .B S_ISVTX
671 ¥Ó¥Ã¥È¤Ë¤Ä¤¤¤Æ¤Îµ­½Ò¤Ï¤Ê¤¤¡£¤«¤ï¤ê¤Ë
672 .BR S_ISDIR ()
673 ¤Î¤è¤¦¤Ê¥Þ¥¯¥í¤ò»ÈÍѤ¹¤ë¤è¤¦¤ËÍ׵ᤷ¤Æ¤¤¤ë¡£
674 ¥Þ¥¯¥í
675 .BR S_ISLNK ()
676 ¤È
677 .BR S_ISSOCK ()
678 ¤Ï POSIX.1-1996 ¤Ë¤Ï¤Ê¤¤¤¬¡¢
679 POSIX.1-2001 ¤Ë¤ÏξÊý¤È¤â¸ºß¤¹¤ë¡£
680 Á°¼Ô¤Ï SVID 4 ¤Ë¡¢¸å¼Ô¤Ï SUSv2 ¤ËͳÍ褷¤Æ¤¤¤ë¡£
681 .LP
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
685 .\"O .BR S_IREAD ,
686 .\"O .BR S_IWRITE ,
687 .\"O .BR S_IEXEC ,
688 .\"O where POSIX
689 .\"O prescribes the synonyms
690 .\"O .BR S_IRUSR ,
691 .\"O .BR S_IWUSR ,
692 .\"O .BR S_IXUSR .
693 Unix V7 (¤È¤½¤Î¸å¤Î¥·¥¹¥Æ¥à) ¤Ï
694 .BR S_IREAD ,
695 .BR S_IWRITE ,
696 .B S_IEXEC
697 ¤ò»ý¤Ã¤Æ¤ª¤ê¡¢
698 POSIX ¤Ï¤½¤ÎƱµÁ¸ì¤È¤·¤Æ
699 .BR S_IRUSR ,
700 .BR S_IWUSR ,
701 .B S_IXUSR
702 ¤òµ¬Äꤷ¤Æ¤¤¤ë¡£
703 .\"O .SS "Other Systems"
704 .SS Â¾¤Î¥·¥¹¥Æ¥à
705 .\"O Values that have been (or are) in use on various systems:
706 ³Æ¼ï¥·¥¹¥Æ¥à¤Ç»ÈÍѤµ¤ì¤Æ¤¤¤¿(¤¤¤ë)ÃÍ:
707 .TS
708 l l l l l.
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 ¤Î
719                                 Î¾Êý¤¬ÉáÄ̤Υե¡¥¤¥ë
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 Æó¤Ä¤ÎÉû·¿¤ò»ý¤Ä̾Á°ÉÕ¤­¤Î
734                                 Æüì¥Õ¥¡¥¤¥ë
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
761 .\"O                            after use (V7)
762 .\"O                            reserved (SVID-v2)
763 .\"O                            On nondirectories: don't cache this
764 .\"O                            file (SunOS)
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
771 .\"O                            with S_ISGID)
772 .\"O 0800       S_ISUID         004000  set-user-ID on execution (V7)
773 .\"O 0800       S_CDF           004000  directory is a context dependent
774 .\"O                            file (HP-UX)
775 0200    S_ISVTX         001000  `¥¹¥Æ¥£¥Ã¥­¡¼¡¦¥Ó¥Ã¥È':»ÈÍѸå¤â
776                                 ¥¹¥ï¥Ã¥×¤Ë»Ä¤¹ (V7)
777                                 Í½Ìó (SVID-v2)
778                                 ¥Ç¥£¥ì¥¯¥È¥ê°Ê³°: ¥Õ¥¡¥¤¥ë¤ò¥­¥ã¥Ã¥·¥å
779                                 ¤·¤Ê¤¤ (SunOS)
780                                 ¥Ç¥£¥ì¥¯¥È¥ê: ºï½üÀ©¸Â¥Õ¥é¥° (SVID-v4.2)
781 0400    S_ISGID         002000  ¼Â¹Ô»þ¤Î set-group-ID (V7)
782                                 ¥Ç¥£¥ì¥¯¥È¥ê¤ËÂФ·¤Æ¤Ï GID ¤ÎÅÁã¤Ë
783                                 BSD Êý¼°¤ò»ÈÍѤ¹¤ë
784 0400    S_ENFMT         002000  System V ¥Õ¥¡¥¤¥ë¡¦¥í¥Ã¥¯¤ò¶¯À©¤¹¤ë
785                                 (S_ISGID ¤È¶¦Í­)
786 0800    S_ISUID         004000  ¼Â¹Ô»þ¤Î set-user-ID (V7)
787 0800    S_CDF           004000  ¥Ç¥£¥ì¥¯¥È¥ê¤¬¾õ¶·°Í¸¥Õ¥¡¥¤¥ë (HP-UX)
788 .TE
789
790 .\"O A sticky command appeared in Version 32V AT&T UNIX.
791 ¥¹¥Æ¥£¥Ã¥­¡¼ ¥³¥Þ¥ó¥É¤Ï Version 32V AT&T UNIX ¤ÇÅо줷¤¿¡£
792 .\"O .SH NOTES
793 .SH Ãí°Õ
794 .\"O Since kernel 2.5.48, the
795 .\"O .I stat
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
799 .\"O of the form
800 .\"O .IR st_atim.tv_nsec ,
801 .\"O if the
802 .\"O .B _BSD_SOURCE
803 .\"O or
804 .\"O .B _SVID_SOURCE
805 .\"O feature test macro is defined,
806 .\"O or of the form
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 °Ê¹ß¤Ç¤Ï¡¢
812 .I stat
813 ¹½Â¤ÂΤϠ3¤Ä¤Î¥Õ¥¡¥¤¥ë¤Î¥¿¥¤¥à¥¹¥¿¥ó¥×´ØÏ¢¤Î¥Õ¥£¡¼¥ë¥É¤Ç
814 ¥Ê¥ÎÉÃñ°Ì¤ÎÀºÅÙ¤ËÂбþ¤·¤Æ¤¤¤ë¡£
815 glibc ¤Ç¤Ï¡¢³Æ¥Õ¥£¡¼¥ë¥É¤Î¥Ê¥ÎÉäξðÊó¤ò
816 .I st_atim.tv_nsec
817 ¤ä
818 .I st_atimensec
819 ¤È¤¤¤Ã¤¿·Á¤Ç»²¾È¤Ç¤­¤ë¡£
820 µ¡Ç½¸¡ºº¥Þ¥¯¥í
821 .B _BSD_SOURCE
822 ¤«
823 .B _SVID_SOURCE
824 ¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï
825 .I st_atim.tv_nsec
826 ¤Î·Á¼°¤Ç¡¢¤½¤ì°Ê³°¤Î¾ì¹ç¤Ë¤Ï
827 .I st_atimensec
828 ¤Î·Á¼°¤È¤Ê¤ë¡£
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.
834
835 .\"O On Linux,
836 .\"O .BR lstat ()
837 .\"O will generally not trigger automounter action, whereas
838 .\"O .BR stat ()
839 .\"O will.
840 Linux ¤Ç¤Ï¡¢
841 .BR lstat ()
842 ¤Ï°ìÈ̤ˤϼ«Æ°¥Þ¥¦¥ó¥ÈÆ°ºî (automounter action) ¤Î¤­¤Ã¤«¤±¤È¤Ê¤é¤Ê¤¤¤¬¡¢
843 .BR stat ()
844 ¤Ï¤­¤Ã¤«¤±¤È¤Ê¤ë¡£
845
846 .\"O For most files under the
847 .\"O .I /proc
848 .\"O directory,
849 .\"O .BR stat ()
850 .\"O does not return the file size in the
851 .\"O .I st_size
852 .\"O field; instead the field is returned with the value 0.
853 .I /proc
854 ¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤Ë¤¢¤ë¥Õ¥¡¥¤¥ë¤Î¤Û¤È¤ó¤É¤Ç¤Ï¡¢
855 .BR stat ()
856 ¤ò¸Æ¤Ó½Ð¤·¤¿ºÝ¤Ë¡¢
857 .I st_size
858 ¥Õ¥£¡¼¥ë¥É¤Ë¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤¬ÊÖ¤µ¤ì¤Ê¤¤¡£
859 Âå¤ï¤ê¤Ë
860 .I st_size
861 ¥Õ¥£¡¼¥ë¥É¤Ë¤Ï 0 ¤¬ÊÖ¤µ¤ì¤ë¡£
862 .\"O .SS Underlying kernel interface
863 .SS Çظå¤Î¥«¡¼¥Í¥ë¡¦¥¤¥ó¥¿¥Õ¥§¡¼¥¹
864 .\"O Over time, increases in the size of the
865 .\"O .I stat
866 .\"O structure have led to three successive versions of
867 .\"O .BR stat ():
868 »þ´Ö¤Î·Ð²á¤È¤È¤â¤Ë¡¢
869 .I stat
870 ¹½Â¤ÂΤΥµ¥¤¥º¤¬Â礭¤¯¤Ê¤ê¡¢¤³¤Î±Æ¶Á¤Ç
871 .BR stat ()
872 ¤Ë¤Ï 3¤Ä¤Î¥Ð¡¼¥¸¥ç¥ó¤¬Â¸ºß¤¹¤ë:
873 .\"O .IR sys_stat ()
874 .\"O (slot
875 .\"O .IR __NR_oldstat ),
876 .\"O .IR sys_newstat ()
877 .\"O (slot
878 .\"O .IR __NR_stat ),
879 .\"O and
880 .\"O .I sys_stat64()
881 .\"O (new in kernel 2.4; slot
882 .\"O .IR __NR_stat64 ).
883 .IR sys_stat ()
884 (¥¹¥í¥Ã¥È¤Ï
885 .IR __NR_oldstat )¡¢
886 .IR sys_newstat ()
887 (¥¹¥í¥Ã¥È¤Ï
888 .IR __NR_stat )¡¢
889 .IR sys_stat64 ()
890 (¥«¡¼¥Í¥ë 2.4 ¤ÇƳÆþ; ¥¹¥í¥Ã¥È¤Ï
891 .IR __NR_stat64 ).
892 .\"O The glibc
893 .\"O .BR stat ()
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.
897 glibc ¤Î
898 .BR stat ()
899 ¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï¤³¤ì¤é¤Î¾ÜºÙ¤ò¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤«¤é±£Ê䷤Ƥ¯¤ì¤ë¡£
900 ¶ñÂÎŪ¤Ë¤Ï¡¢¥«¡¼¥Í¥ë¤¬Ä󶡤·¤Æ¤¤¤ë¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î¤¦¤ÁºÇ¿·¤Î¥Ð¡¼¥¸¥ç¥ó¤ò
901 µ¯Æ°¤·¡¢¸Å¤¤¥Ð¥¤¥Ê¥ê¤Î¾ì¹ç¤Ë¤ÏɬÍפ˱þ¤¸¤ÆÊÖ¤µ¤ì¤¿¾ðÊó¤òºÆ¹½À® (repack) ¤¹¤ë¡£
902 .\"O Similar remarks apply for
903 .\"O .BR fstat ()
904 .\"O and
905 .\"O .BR lstat ().
906 .BR fstat ()
907 ¤È
908 .BR lstat ()
909 ¤Ë¤Ä¤¤¤Æ¤âƱÍͤǤ¢¤ë¡£
910 .\"
911 .\" A note from Andries Brouwer, July 2007
912 .\"
913 .\" > Is the story not rather more complicated for some calls like
914 .\" > stat(2)?
915 .\"
916 .\" Yes and no, mostly no. See /usr/include/sys/stat.h .
917 .\"
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.
929 .\"
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.
936 .\"
937 .\" (Note that the details depend on gcc being used as c compiler.)
938 .\"O .SH EXAMPLE
939 .SH Îã
940 .\"O The following program calls
941 .\"O .BR stat ()
942 .\"O and displays selected fields in the returned
943 .\"O .I stat
944 .\"O structure.
945 °Ê²¼¤Î¥×¥í¥°¥é¥à¤Ï
946 .BR stat ()
947 ¤ò¸Æ¤Ó½Ð¤·¡¢Ê֤äƤ­¤¿
948 .I stat
949 ¹½Â¤ÂΤΥե£¡¼¥ë¥É¤Î¤¤¤¯¤Ä¤«¤òɽ¼¨¤¹¤ë¡£
950 .nf
951
952 #include <sys/types.h>
953 #include <sys/stat.h>
954 #include <time.h>
955 #include <stdio.h>
956 #include <stdlib.h>
957
958 int
959 main(int argc, char *argv[])
960 {
961     struct stat sb;
962
963     if (argc != 2) {
964         fprintf(stderr, "Usage: %s <pathname>\\n", argv[0]);
965         exit(EXIT_FAILURE);
966     }
967
968     if (stat(argv[1], &sb) == \-1) {
969         perror("stat");
970         exit(EXIT_FAILURE);
971     }
972
973     printf("File type:                ");
974
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;
984     }
985
986     printf("I\-node number:            %ld\\n", (long) sb.st_ino);
987
988     printf("Mode:                     %lo (octal)\\n",
989             (unsigned long) sb.st_mode);
990
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);
994
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);
1001
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));
1005
1006     exit(EXIT_SUCCESS);
1007 }
1008 .fi
1009 .\"O .SH "SEE ALSO"
1010 .SH ´ØÏ¢¹àÌÜ
1011 .BR access (2),
1012 .BR chmod (2),
1013 .BR chown (2),
1014 .BR fstatat (2),
1015 .BR readlink (2),
1016 .BR utime (2),
1017 .BR capabilities (7),
1018 .BR symlink (7)