1STAT(2) System Calls Manual STAT(2)
2
3
4
6 stat, fstat - get file status
7
9 #include <sys/types.h>
10 #include <sys/stat.h>
11
12 stat(name, buf)
13 char *name;
14 struct stat *buf;
15
16 fstat(fildes, buf)
17 struct stat *buf;
18
20 Stat obtains detailed information about a named file. Fstat obtains
21 the same information about an open file known by the file descriptor
22 from a successful open, creat, dup or pipe(2) call.
23
24 Name points to a null-terminated string naming a file; buf is the
25 address of a buffer into which information is placed concerning the
26 file. It is unnecessary to have any permissions at all with respect to
27 the file, but all directories leading to the file must be searchable.
28 The layout of the structure pointed to by buf as defined in <stat.h> is
29 given below. St_mode is encoded according to the `#define' statements.
30
31 /* Copyright (C) 1991, 1992, 1995-2007, 2009, 2010, 2012
32 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
34
35 The GNU C Library is free software; you can redistribute it and/or
36 modify it under the terms of the GNU Lesser General Public
37 License as published by the Free Software Foundation; either
38 version 2.1 of the License, or (at your option) any later version.
39
40 The GNU C Library is distributed in the hope that it will be useful,
41 but WITHOUT ANY WARRANTY; without even the implied warranty of
42 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
43 Lesser General Public License for more details.
44
45 You should have received a copy of the GNU Lesser General Public
46 License along with the GNU C Library; if not, see
47 <http://www.gnu.org/licenses/>. */
48
49 /*
50 * POSIX Standard: 5.6 File Characteristics <sys/stat.h>
51 */
52
53 #ifndef _SYS_STAT_H
54 #define _SYS_STAT_H 1
55
56 #include <features.h>
57
58 #include <bits/types.h> /* For __mode_t and __dev_t. */
59
60 #if defined __USE_XOPEN || defined __USE_XOPEN2K || defined __USE_MISC || defined __USE_ATFILE
61 # if defined __USE_XOPEN || defined __USE_XOPEN2K
62 # define __need_time_t
63 # endif
64 # if defined __USE_MISC || defined __USE_ATFILE
65 # define __need_timespec
66 # endif
67 # include <time.h> /* For time_t resp. timespec. */
68 #endif
69
70 #if defined __USE_XOPEN || defined __USE_XOPEN2K
71 /* The Single Unix specification says that some more types are
72 available here. */
73 # ifndef __dev_t_defined
74 typedef __dev_t dev_t;
75 # define __dev_t_defined
76 # endif
77
78 # ifndef __gid_t_defined