Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / mach / hurd / bits / stat.h
blob6f9245742e0a4c691d060eeef1d903861ea9ce61
1 /* Copyright (C) 1992-2015 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #if !defined _SYS_STAT_H && !defined _FCNTL_H
19 # error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20 #endif
22 #ifndef _BITS_STAT_H
23 #define _BITS_STAT_H 1
25 #include <bits/types.h>
27 /* NOTE: The size of this structure (32 ints) is known in
28 <hurd/hurd_types.defs>, since it is used in the `io_stat' RPC. MiG
29 does not cope at all well with the passed C structure not being of
30 the expected size. There are some filler words at the end to allow
31 for future expansion. To increase the size of the structure used
32 in the RPC and retain binary compatibility, we would need to assign
33 a new message number. */
35 struct stat
37 int st_fstype; /* File system type. */
38 __fsid_t st_fsid; /* File system ID. */
39 #define st_dev st_fsid
41 #ifndef __USE_FILE_OFFSET64
42 __ino_t st_ino; /* File number. */
43 #else
44 __ino64_t st_ino; /* File number. */
45 #endif
46 unsigned int st_gen; /* To detect reuse of file numbers. */
47 __dev_t st_rdev; /* Device if special file. */
48 __mode_t st_mode; /* File mode. */
49 __nlink_t st_nlink; /* Number of links. */
51 __uid_t st_uid; /* Owner. */
52 __gid_t st_gid; /* Owning group. */
54 #ifndef __USE_FILE_OFFSET64
55 __off_t st_size; /* Size in bytes. */
56 #else
57 __off64_t st_size; /* Size in bytes. */
58 #endif
60 #ifdef __USE_XOPEN2K8
61 /* Nanosecond resolution timestamps are stored in a format
62 equivalent to 'struct timespec'. This is the type used
63 whenever possible but the Unix namespace rules do not allow the
64 identifier 'timespec' to appear in the <sys/stat.h> header.
65 Therefore we have to handle the use of this header in strictly
66 standard-compliant sources special. */
67 struct timespec st_atim; /* Time of last access. */
68 struct timespec st_mtim; /* Time of last modification. */
69 struct timespec st_ctim; /* Time of last status change. */
70 # define st_atime st_atim.tv_sec /* Backward compatibility. */
71 # define st_mtime st_mtim.tv_sec
72 # define st_ctime st_ctim.tv_sec
73 #else
74 __time_t st_atime; /* Time of last access. */
75 unsigned long int st_atimensec; /* Nscecs of last access. */
76 __time_t st_mtime; /* Time of last modification. */
77 unsigned long int st_mtimensec; /* Nsecs of last modification. */
78 __time_t st_ctime; /* Time of last status change. */
79 unsigned long int st_ctimensec; /* Nsecs of last status change. */
80 #endif
82 __blksize_t st_blksize; /* Optimal size for I/O. */
84 #ifndef __USE_FILE_OFFSET64
85 __blkcnt_t st_blocks; /* Number of 512-byte blocks allocated.
86 Not related to `st_blksize'. */
87 #else
88 __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated.
89 Not related to `st_blksize'. */
90 #endif
92 __uid_t st_author; /* File author. */
94 unsigned int st_flags; /* User-defined flags.
95 High 16 bits can be set only by root. */
97 #ifndef __USE_FILE_OFFSET64
98 # define _SPARE_SIZE ((sizeof (__fsid_t) == sizeof (int)) ? 12 : 11)
99 #else
100 # define _SPARE_SIZE ((sizeof (__fsid_t) == sizeof (int)) ? 9 : 8)
101 #endif
102 int st_spare[_SPARE_SIZE]; /* Room for future expansion. */
103 #undef _SPARE_SIZE
106 #ifdef __USE_LARGEFILE64
107 struct stat64
109 int st_fstype; /* File system type. */
110 __fsid_t st_fsid; /* File system ID. */
111 # define st_dev st_fsid
113 __ino64_t st_ino; /* File number. */
114 unsigned int st_gen; /* To detect reuse of file numbers. */
115 __dev_t st_rdev; /* Device if special file. */
116 __mode_t st_mode; /* File mode. */
117 __nlink_t st_nlink; /* Number of links. */
119 __uid_t st_uid; /* Owner. */
120 __gid_t st_gid; /* Owning group. */
122 __off64_t st_size; /* Size in bytes. */
124 #ifdef __USE_XOPEN2K8
125 /* Nanosecond resolution timestamps are stored in a format
126 equivalent to 'struct timespec'. This is the type used
127 whenever possible but the Unix namespace rules do not allow the
128 identifier 'timespec' to appear in the <sys/stat.h> header.
129 Therefore we have to handle the use of this header in strictly
130 standard-compliant sources special. */
131 struct timespec st_atim; /* Time of last access. */
132 struct timespec st_mtim; /* Time of last modification. */
133 struct timespec st_ctim; /* Time of last status change. */
134 #else
135 __time_t st_atime; /* Time of last access. */
136 unsigned long int st_atimensec; /* Nscecs of last access. */
137 __time_t st_mtime; /* Time of last modification. */
138 unsigned long int st_mtimensec; /* Nsecs of last modification. */
139 __time_t st_ctime; /* Time of last status change. */
140 unsigned long int st_ctimensec; /* Nsecs of last status change. */
141 #endif
143 __blksize_t st_blksize; /* Optimal size for I/O. */
145 __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated.
146 Not related to `st_blksize'. */
148 __uid_t st_author; /* File author. */
150 unsigned int st_flags; /* User-defined flags.
151 High 16 bits can be set only by root. */
153 #define _SPARE_SIZE ((sizeof (__fsid_t) == sizeof (int)) ? 9 : 8)
154 int st_spare[_SPARE_SIZE]; /* Room for future expansion. */
155 #undef _SPARE_SIZE
157 #endif
159 /* Tell code we have these members. */
160 #define _STATBUF_ST_BLKSIZE
161 /* Nanosecond resolution time values are supported. */
162 #define _STATBUF_ST_NSEC
164 /* Encoding of the file mode. */
166 #define __S_IFMT 0170000 /* These bits determine file type. */
168 /* File types. */
169 #define __S_IFDIR 0040000 /* Directory. */
170 #define __S_IFCHR 0020000 /* Character device. */
171 #define __S_IFBLK 0060000 /* Block device. */
172 #define __S_IFREG 0100000 /* Regular file. */
173 #define __S_IFLNK 0120000 /* Symbolic link. */
174 #define __S_IFSOCK 0140000 /* Socket. */
175 #define __S_IFIFO 0010000 /* FIFO. */
177 /* POSIX.1b objects. */
178 #define __S_TYPEISMQ(buf) (0)
179 #define __S_TYPEISSEM(buf) (0)
180 #define __S_TYPEISSHM(buf) (0)
182 /* Protection bits. */
184 #define __S_ISUID 04000 /* Set user ID on execution. */
185 #define __S_ISGID 02000 /* Set group ID on execution. */
186 #define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
187 #define __S_IREAD 00400 /* Read by owner. */
188 #define __S_IWRITE 00200 /* Write by owner. */
189 #define __S_IEXEC 00100 /* Execute by owner. */
192 #ifdef __USE_GNU
193 /* If set, there is no benefit in caching the contents of this file. */
194 #define S_INOCACHE 000000200000
196 /* If the S_IUSEUNK bit is set, then the S_IUNKNOWN bits (see below)
197 control access for unknown users. If S_IUSEUNK is clear, then unknown
198 users are treated as "others" for purposes of access control. */
199 #define S_IUSEUNK 000000400000
200 /* Mask of protection bits for unknown users (no effective IDs at all). */
201 #define S_IUNKNOWN 000007000000
202 /* Shift S_IREAD, S_IWRITE, S_IEXEC left this many bits to produce the
203 protection bits for unknown users. */
204 #define S_IUNKSHIFT 12
206 /* Read only bits: */
208 /* There is a passive translator set for this file */
209 #define S_IPTRANS 000010000000
210 /* There is an active translator running on this file */
211 #define S_IATRANS 000020000000
212 /* This is the root of a filesystem (or single node translator) */
213 #define S_IROOT 000040000000
214 /* All the bits relevant to translators */
215 #define S_ITRANS 000070000000
217 /* Definitely no mmaps to this. */
218 #define S_IMMAP0 000100000000
220 /* ALL the unused bits. */
221 #define S_ISPARE (~(S_IFMT|S_ITRANS|S_INOCACHE|S_IMMAP0| \
222 S_IUSEUNK|S_IUNKNOWN|07777))
223 #endif
225 /* Default file creation mask (umask). */
226 #ifdef __USE_MISC
227 # define CMASK 0022
228 #endif
230 #endif /* bits/stat.h */