1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
|
'\" t
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" 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
.\"
.\" 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.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Modified by Michael Haardt <michael@moria.de>
.\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
.\" Modified 1995-05-18 by Todd Larason <jtl@molehill.org>
.\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified 1995-01-09 by Richard Kettlewell <richard@greenend.org.uk>
.\" Modified 1998-05-13 by Michael Haardt <michael@cantor.informatik.rwth-aachen.de>
.\" Modified 1999-07-06 by aeb & Albert Cahalan
.\" Modified 2000-01-07 by aeb
.\" Modified 2004-06-23 by Michael Kerrisk <mtk-manpages@gmx.net>
.\"
.\" Japanese Version Copyright (c) 1998-1999 HANATAKA Shinya
.\" all rights reserved.
.\" Translated 1998-06-21, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Modified 1999-04-16, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated 2000-01-03, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2000-10-06, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2001-04-09, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2001-06-25, Kentaro Shirakata <argrath@ub32.org>
.\" Updated 2005-02-28, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\"
.\"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 2004-06-23 "Linux 2.6.7" "Linux Programmer's Manual"
.SH ̾
stat, fstat, lstat \- եξ֤
.SH
.B #include <sys/types.h>
.br
.B #include <sys/stat.h>
.br
.B #include <unistd.h>
.sp
.BI "int stat(const char *" file_name ", struct stat *" buf );
.br
.BI "int fstat(int " filedes ", struct stat *" buf );
.br
.BI "int lstat(const char *" file_name ", struct stat *" buf );
.SH
.PP
δؿϻꤵ줿եˤĤƤξ֤ξ
뤿ˤΥեФƤΥĤɬפȤʤ
Υեػǥ쥯ȥƤФ븡ĤɬפǤ롣
.PP
.B stat
.I file_name
ǻꤵ줿եξ֤
.I buf
سǼ롣
.B lstat
.B stat
ƱǤ뤬оݤܥåξ硢
ȤƤեǤϤʤȤξ֤ۤʤ롣
.B fstat
.B stat
Ʊ
.I file_name
ǤϤʤ
.RB ( open (2)
֤)
.I filedes
ˤäƻꤵ롢ץ줿եξ֤롣
.PP
δؿϡ̤
.I stat
¤Τ֤
.I stat
¤ΤˤϰʲΥեɤޤޤƤ:
.PP
.RS
.nf
struct stat {
dev_t st_dev; /* ǥХ */
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; /* ǥХ (inode ǥХξ) */
off_t st_size; /* ե륵 (Хȿ) */
blksize_t st_blksize; /* ե륷ƥ I/O ǤΥ֥å */
blkcnt_t st_blocks; /* Ƥ줿֥å */
time_t st_atime; /* ǽ */
time_t st_mtime; /* ǽѹ */
time_t st_ctime; /* ǽơѹ */
};
.fi
.RE
.PP
.I st_size
(̾Υե뤫ܥåξ)
ե礭Хȿ
ܥå礭ϡޤޤƤѥ̾Ĺ
(Ǹ NUL ʸϴޤޤʤ) Ǥ롣
.I st_blocks
ϥե礭 512 ХȤΥ֥åñ̤
(ե˷꤬褦ʾ硢ͤ
.IR st_size /512
꾮ʤ뤳Ȥ⤢)
.I st_blksize
ϸΨŪ˥ե롦ƥ I/O Ǥֹޤץ֥å
(äȾñ̤ǥե˽ߤԤȡ
ɤ߽Ф----ƽߤȤäΨưˤʤäƤޤ⤷ʤ)
.PP
Ƥ Linux Υե롦ƥबƤλ֥եɤ
Ƥ櫓ǤϤʤ
ե륢
.I st_atime
եɤʤ褦ʤǥޥȤǤե륷ƥ⤢롣
.RB ( mount (8)
`noatime' ץ)
.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
Ϲ뤳Ȥ⤢СǤʤ⤢롣
.I st_mtime
եɤϡե뤬줿ѹ
(㤨С
.BR mknod (2),
.BR truncate (2),
.BR utime (2)
Ѥ
.BR write (2)
1 ХȰʾߤʤ)
ˡǥ쥯ȥ
.I st_mtime
ϡΥǥ쥯ȥ
ե뤬줿줿ꤹѹ롣
.I st_mtime
եɤ
ͭԤ䥰롼פϡɡ⡼ɤѹǤѹ
.I ʤ
.I st_ctime
եɤϽߤ inode
(ͭԡ롼ס⡼ɤʤ)
ˤäѹ롣
.PP
ʲ POSIX ޥϡ
.I st_mode
ե
ǻѤե̤ΥåΤƤ :
.RS
.TP 1.2i
S_ISREG(m)
̾Υե뤫?
.TP
S_ISDIR(m)
ǥ쥯ȥ꤫?
.TP
S_ISCHR(m)
饯ǥХ?
.TP
S_ISBLK(m)
֥åǥХ?
.TP
S_ISFIFO(m)
fifo ?
.TP
S_ISLNK(m)
ܥå (POSIX.1-1996 ˤϤʤ)
.TP
S_ISSOCK(m)
åȤ? (POSIX.1-1996 ˤϤʤ)
.RE
.PP
ʲΥե饰
.I st_mode
եѤƤ:
.P
.TS
l 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 UID bit
S_ISGID 0002000 set GID 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 ¾ (others) ΥѤΥӥåȥޥ
S_IROTH 00004 ¾ͤɤ߹ߵ
S_IWOTH 00002 ¾ͤνߵ
S_IXOTH 00001 ¾ͤμ¹Ե
.TE
.P
set GID bit (S_ISGID) ˤϤĤüʻˡ:
ǥ쥯ȥꤷˤϡΥǥ쥯ȥ꤬ BSD ǻѤ
ȤĤޤꡢΥǥ쥯ȥ˺줿եΥ롼ID
ץμ¸ (effective) 롼ID ǤϤʤǥ쥯ȥ
롼ID Ѿ롣ޤΥǥ쥯ȥ˺줿ǥ쥯ȥˤ
S_ISGID ӥåȤꤵ롣롼¹ԥӥå (S_IXGRP) ꤵƤʤ
եꤵ줿ϡե/쥳ɤζŪ (mandatory)
åɽ
.P
ǥ쥯ȥˡ֥ƥåץӥå (S_ISVTX) ꤵ줿ϡ
Υǥ쥯ȥΥե̾ѹꡢǤΤϡ
ΥեνͭԤΥǥ쥯ȥνͭԤøץ
Ȥʤ롣
.SH ֤
0 ֤顼ξ \-1 ֤
.I errno
Ŭڤͤꤵ롣
.SH 顼
.TP
.B EACCES
.I file_name
°ǥ쥯ȥȤξ̤Υǥ쥯ȥΤ줫
Ф븡Ĥʤä
.RB ( path_resolution (2)
⻲ȤΤ)
.TP
.B EBADF
.I filedes
Ǥ롣
.TP
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O 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 Ĥ̾դüե
st_rdev 1,2 Ƕ̤:
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 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 Ѥʤ)
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 SysV ե롦å(S_ISGID ȶͭ)
0800 S_ISUID 004000 ¹Ի set user ID (V7)
0800 S_CDF 004000 ǥ쥯ȥ꤬¸ե (HP-UX)
.TE
ƥå ޥɤ Version 32V AT&T UNIX о줷
.SH Ϣ
.BR chmod (2),
.BR chown (2),
.BR readlink (2),
.BR utime (2),
.BR capabilities (7)
|