Warning: This file is not a C or C++ file. It does not have highlighting.
1 | /* Copyright (C) 1992-2024 Free Software Foundation, Inc. |
---|---|
2 | This file is part of the GNU C Library. |
3 | |
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. |
8 | |
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. |
13 | |
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 | <https://www.gnu.org/licenses/>. */ |
17 | |
18 | #if !defined _SYS_STAT_H && !defined _FCNTL_H |
19 | # error "Never include <bits/stat.h> directly; use <sys/stat.h> instead." |
20 | #endif |
21 | |
22 | #ifndef _BITS_STAT_H |
23 | #define _BITS_STAT_H 1 |
24 | |
25 | #include <bits/types.h> |
26 | |
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. */ |
34 | |
35 | struct stat |
36 | { |
37 | int st_fstype; /* File system type. */ |
38 | __fsid_t st_fsid; /* File system ID. */ |
39 | #define st_dev st_fsid |
40 | |
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. */ |
50 | |
51 | __uid_t st_uid; /* Owner. */ |
52 | __gid_t st_gid; /* Owning group. */ |
53 | |
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 |
59 | |
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 |
81 | |
82 | __blksize_t st_blksize; /* Optimal size for I/O. */ |
83 | |
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 |
91 | |
92 | __uid_t st_author; /* File author. */ |
93 | |
94 | unsigned int st_flags; /* User-defined flags. |
95 | High 16 bits can be set only by root. */ |
96 | |
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 |
104 | }; |
105 | |
106 | #ifdef __USE_LARGEFILE64 |
107 | struct stat64 |
108 | { |
109 | int st_fstype; /* File system type. */ |
110 | __fsid_t st_fsid; /* File system ID. */ |
111 | # define st_dev st_fsid |
112 | |
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. */ |
118 | |
119 | __uid_t st_uid; /* Owner. */ |
120 | __gid_t st_gid; /* Owning group. */ |
121 | |
122 | __off64_t st_size; /* Size in bytes. */ |
123 | |
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 |
142 | |
143 | __blksize_t st_blksize; /* Optimal size for I/O. */ |
144 | |
145 | __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated. |
146 | Not related to `st_blksize'. */ |
147 | |
148 | __uid_t st_author; /* File author. */ |
149 | |
150 | unsigned int st_flags; /* User-defined flags. |
151 | High 16 bits can be set only by root. */ |
152 | |
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 |
156 | }; |
157 | #endif |
158 | |
159 | /* Tell code we have these members. */ |
160 | #define _STATBUF_ST_BLKSIZE |
161 | /* Nanosecond resolution time values are supported. */ |
162 | #define _STATBUF_ST_NSEC |
163 | |
164 | /* Encoding of the file mode. */ |
165 | |
166 | #define __S_IFMT 0170000 /* These bits determine file type. */ |
167 | |
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. */ |
176 | |
177 | /* POSIX.1b objects. */ |
178 | #define __S_TYPEISMQ(buf) (0) |
179 | #define __S_TYPEISSEM(buf) (0) |
180 | #define __S_TYPEISSHM(buf) (0) |
181 | |
182 | /* Protection bits. */ |
183 | |
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. */ |
190 | |
191 | |
192 | #ifdef __USE_GNU |
193 | /* If set, there is no benefit in caching the contents of this file. */ |
194 | #define S_INOCACHE 000000200000 |
195 | |
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 |
205 | |
206 | /* Read only bits: */ |
207 | |
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 |
216 | |
217 | /* Definitely no mmaps to this. */ |
218 | #define S_IMMAP0 000100000000 |
219 | |
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 |
224 | |
225 | #ifdef __USE_MISC |
226 | /* Default file creation mask (umask). */ |
227 | # define CMASK 0022 |
228 | |
229 | /* Definitions of flags stored in file flags word. */ |
230 | |
231 | /* Super-user and owner changeable flags. */ |
232 | # define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */ |
233 | # define UF_NODUMP 0x00000001 /* do not dump file */ |
234 | # define UF_IMMUTABLE 0x00000002 /* file may not be changed */ |
235 | # define UF_APPEND 0x00000004 /* writes to file may only append */ |
236 | # define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */ |
237 | # define UF_NOUNLINK 0x00000010 /* file may not be removed or renamed */ |
238 | |
239 | /* Super-user changeable flags. */ |
240 | # define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */ |
241 | # define SF_ARCHIVED 0x00010000 /* file is archived */ |
242 | # define SF_IMMUTABLE 0x00020000 /* file may not be changed */ |
243 | # define SF_APPEND 0x00040000 /* writes to file may only append */ |
244 | # define SF_NOUNLINK 0x00100000 /* file may not be removed or renamed */ |
245 | # define SF_SNAPSHOT 0x00200000 /* snapshot inode */ |
246 | |
247 | __BEGIN_DECLS |
248 | |
249 | /* Set file flags for FILE to FLAGS. */ |
250 | extern int chflags (__const char *__file, unsigned long int __flags) __THROW; |
251 | |
252 | /* Set file flags of the file referred to by FD to FLAGS. */ |
253 | extern int fchflags (int __fd, unsigned long int __flags) __THROW; |
254 | |
255 | __END_DECLS |
256 | #endif |
257 | |
258 | #ifdef __USE_ATFILE |
259 | # define UTIME_NOW -1 /* corresponds to the current time */ |
260 | # define UTIME_OMIT -2 /* target time is omitted */ |
261 | #endif |
262 | |
263 | #endif /* bits/stat.h */ |
264 |
Warning: This file is not a C or C++ file. It does not have highlighting.