1 | /* Test of <sys/stat.h> substitute.
|
---|
2 | Copyright (C) 2007-2022 Free Software Foundation, Inc.
|
---|
3 |
|
---|
4 | This program is free software: you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation, either version 3 of the License, or
|
---|
7 | (at your option) any later version.
|
---|
8 |
|
---|
9 | This program 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
|
---|
12 | GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License
|
---|
15 | along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
---|
16 |
|
---|
17 | /* Written by Bruno Haible <[email protected]>, 2007. */
|
---|
18 |
|
---|
19 | #include <config.h>
|
---|
20 |
|
---|
21 | #include <sys/stat.h>
|
---|
22 |
|
---|
23 | /* Check the existence of some macros. */
|
---|
24 | int a[] =
|
---|
25 | {
|
---|
26 | S_IFMT,
|
---|
27 | #ifdef S_IFBLK /* missing on MSVC */
|
---|
28 | S_IFBLK,
|
---|
29 | #endif
|
---|
30 | S_IFCHR, S_IFDIR, S_IFIFO, S_IFREG,
|
---|
31 | #ifdef S_IFLNK /* missing on native Windows and DJGPP */
|
---|
32 | S_IFLNK,
|
---|
33 | #endif
|
---|
34 | #ifdef S_IFSOCK /* missing on native Windows and DJGPP */
|
---|
35 | S_IFSOCK,
|
---|
36 | #endif
|
---|
37 | S_IRWXU, S_IRUSR, S_IWUSR, S_IXUSR,
|
---|
38 | S_IRWXG, S_IRGRP, S_IWGRP, S_IXGRP,
|
---|
39 | S_IRWXO, S_IROTH, S_IWOTH, S_IXOTH,
|
---|
40 | S_ISUID, S_ISGID, S_ISVTX,
|
---|
41 | S_ISBLK (S_IFREG),
|
---|
42 | S_ISCHR (S_IFREG),
|
---|
43 | S_ISDIR (S_IFREG),
|
---|
44 | S_ISFIFO (S_IFREG),
|
---|
45 | S_ISREG (S_IFREG),
|
---|
46 | S_ISLNK (S_IFREG),
|
---|
47 | S_ISSOCK (S_IFREG),
|
---|
48 | S_ISDOOR (S_IFREG),
|
---|
49 | S_ISMPB (S_IFREG),
|
---|
50 | S_ISMPX (S_IFREG),
|
---|
51 | S_ISNAM (S_IFREG),
|
---|
52 | S_ISNWK (S_IFREG),
|
---|
53 | S_ISPORT (S_IFREG),
|
---|
54 | S_ISCTG (S_IFREG),
|
---|
55 | S_ISOFD (S_IFREG),
|
---|
56 | S_ISOFL (S_IFREG),
|
---|
57 | S_ISWHT (S_IFREG)
|
---|
58 | };
|
---|
59 |
|
---|
60 | /* Sanity checks. */
|
---|
61 |
|
---|
62 | static_assert (S_IRWXU == (S_IRUSR | S_IWUSR | S_IXUSR));
|
---|
63 | static_assert (S_IRWXG == (S_IRGRP | S_IWGRP | S_IXGRP));
|
---|
64 | static_assert (S_IRWXO == (S_IROTH | S_IWOTH | S_IXOTH));
|
---|
65 |
|
---|
66 | #ifdef S_IFBLK
|
---|
67 | static_assert (S_ISBLK (S_IFBLK));
|
---|
68 | #endif
|
---|
69 | static_assert (!S_ISBLK (S_IFCHR));
|
---|
70 | static_assert (!S_ISBLK (S_IFDIR));
|
---|
71 | static_assert (!S_ISBLK (S_IFIFO));
|
---|
72 | static_assert (!S_ISBLK (S_IFREG));
|
---|
73 | #ifdef S_IFLNK
|
---|
74 | static_assert (!S_ISBLK (S_IFLNK));
|
---|
75 | #endif
|
---|
76 | #ifdef S_IFSOCK
|
---|
77 | static_assert (!S_ISBLK (S_IFSOCK));
|
---|
78 | #endif
|
---|
79 |
|
---|
80 | #ifdef S_IFBLK
|
---|
81 | static_assert (!S_ISCHR (S_IFBLK));
|
---|
82 | #endif
|
---|
83 | static_assert (S_ISCHR (S_IFCHR));
|
---|
84 | static_assert (!S_ISCHR (S_IFDIR));
|
---|
85 | static_assert (!S_ISCHR (S_IFIFO));
|
---|
86 | static_assert (!S_ISCHR (S_IFREG));
|
---|
87 | #ifdef S_IFLNK
|
---|
88 | static_assert (!S_ISCHR (S_IFLNK));
|
---|
89 | #endif
|
---|
90 | #ifdef S_IFSOCK
|
---|
91 | static_assert (!S_ISCHR (S_IFSOCK));
|
---|
92 | #endif
|
---|
93 |
|
---|
94 | #ifdef S_IFBLK
|
---|
95 | static_assert (!S_ISDIR (S_IFBLK));
|
---|
96 | #endif
|
---|
97 | static_assert (!S_ISDIR (S_IFCHR));
|
---|
98 | static_assert (S_ISDIR (S_IFDIR));
|
---|
99 | static_assert (!S_ISDIR (S_IFIFO));
|
---|
100 | static_assert (!S_ISDIR (S_IFREG));
|
---|
101 | #ifdef S_IFLNK
|
---|
102 | static_assert (!S_ISDIR (S_IFLNK));
|
---|
103 | #endif
|
---|
104 | #ifdef S_IFSOCK
|
---|
105 | static_assert (!S_ISDIR (S_IFSOCK));
|
---|
106 | #endif
|
---|
107 |
|
---|
108 | #ifdef S_IFBLK
|
---|
109 | static_assert (!S_ISFIFO (S_IFBLK));
|
---|
110 | #endif
|
---|
111 | static_assert (!S_ISFIFO (S_IFCHR));
|
---|
112 | static_assert (!S_ISFIFO (S_IFDIR));
|
---|
113 | static_assert (S_ISFIFO (S_IFIFO));
|
---|
114 | static_assert (!S_ISFIFO (S_IFREG));
|
---|
115 | #ifdef S_IFLNK
|
---|
116 | static_assert (!S_ISFIFO (S_IFLNK));
|
---|
117 | #endif
|
---|
118 | #ifdef S_IFSOCK
|
---|
119 | static_assert (!S_ISFIFO (S_IFSOCK));
|
---|
120 | #endif
|
---|
121 |
|
---|
122 | #ifdef S_IFBLK
|
---|
123 | static_assert (!S_ISREG (S_IFBLK));
|
---|
124 | #endif
|
---|
125 | static_assert (!S_ISREG (S_IFCHR));
|
---|
126 | static_assert (!S_ISREG (S_IFDIR));
|
---|
127 | static_assert (!S_ISREG (S_IFIFO));
|
---|
128 | static_assert (S_ISREG (S_IFREG));
|
---|
129 | #ifdef S_IFLNK
|
---|
130 | static_assert (!S_ISREG (S_IFLNK));
|
---|
131 | #endif
|
---|
132 | #ifdef S_IFSOCK
|
---|
133 | static_assert (!S_ISREG (S_IFSOCK));
|
---|
134 | #endif
|
---|
135 |
|
---|
136 | #ifdef S_IFBLK
|
---|
137 | static_assert (!S_ISLNK (S_IFBLK));
|
---|
138 | #endif
|
---|
139 | static_assert (!S_ISLNK (S_IFCHR));
|
---|
140 | static_assert (!S_ISLNK (S_IFDIR));
|
---|
141 | static_assert (!S_ISLNK (S_IFIFO));
|
---|
142 | static_assert (!S_ISLNK (S_IFREG));
|
---|
143 | #ifdef S_IFLNK
|
---|
144 | static_assert (S_ISLNK (S_IFLNK));
|
---|
145 | #endif
|
---|
146 | #ifdef S_IFSOCK
|
---|
147 | static_assert (!S_ISLNK (S_IFSOCK));
|
---|
148 | #endif
|
---|
149 |
|
---|
150 | #ifdef S_IFBLK
|
---|
151 | static_assert (!S_ISSOCK (S_IFBLK));
|
---|
152 | #endif
|
---|
153 | static_assert (!S_ISSOCK (S_IFCHR));
|
---|
154 | static_assert (!S_ISSOCK (S_IFDIR));
|
---|
155 | static_assert (!S_ISSOCK (S_IFIFO));
|
---|
156 | static_assert (!S_ISSOCK (S_IFREG));
|
---|
157 | #ifdef S_IFLNK
|
---|
158 | static_assert (!S_ISSOCK (S_IFLNK));
|
---|
159 | #endif
|
---|
160 | #ifdef S_IFSOCK
|
---|
161 | static_assert (S_ISSOCK (S_IFSOCK));
|
---|
162 | #endif
|
---|
163 |
|
---|
164 | #ifdef S_IFBLK
|
---|
165 | static_assert (!S_ISDOOR (S_IFBLK));
|
---|
166 | #endif
|
---|
167 | static_assert (!S_ISDOOR (S_IFCHR));
|
---|
168 | static_assert (!S_ISDOOR (S_IFDIR));
|
---|
169 | static_assert (!S_ISDOOR (S_IFIFO));
|
---|
170 | static_assert (!S_ISDOOR (S_IFREG));
|
---|
171 | #ifdef S_IFLNK
|
---|
172 | static_assert (!S_ISDOOR (S_IFLNK));
|
---|
173 | #endif
|
---|
174 | #ifdef S_IFSOCK
|
---|
175 | static_assert (!S_ISDOOR (S_IFSOCK));
|
---|
176 | #endif
|
---|
177 |
|
---|
178 | #ifdef S_IFBLK
|
---|
179 | static_assert (!S_ISMPB (S_IFBLK));
|
---|
180 | #endif
|
---|
181 | static_assert (!S_ISMPB (S_IFCHR));
|
---|
182 | static_assert (!S_ISMPB (S_IFDIR));
|
---|
183 | static_assert (!S_ISMPB (S_IFIFO));
|
---|
184 | static_assert (!S_ISMPB (S_IFREG));
|
---|
185 | #ifdef S_IFLNK
|
---|
186 | static_assert (!S_ISMPB (S_IFLNK));
|
---|
187 | #endif
|
---|
188 | #ifdef S_IFSOCK
|
---|
189 | static_assert (!S_ISMPB (S_IFSOCK));
|
---|
190 | #endif
|
---|
191 |
|
---|
192 | #ifdef S_IFBLK
|
---|
193 | static_assert (!S_ISMPX (S_IFBLK));
|
---|
194 | #endif
|
---|
195 | static_assert (!S_ISMPX (S_IFCHR));
|
---|
196 | static_assert (!S_ISMPX (S_IFDIR));
|
---|
197 | static_assert (!S_ISMPX (S_IFIFO));
|
---|
198 | static_assert (!S_ISMPX (S_IFREG));
|
---|
199 | #ifdef S_IFLNK
|
---|
200 | static_assert (!S_ISMPX (S_IFLNK));
|
---|
201 | #endif
|
---|
202 | #ifdef S_IFSOCK
|
---|
203 | static_assert (!S_ISMPX (S_IFSOCK));
|
---|
204 | #endif
|
---|
205 |
|
---|
206 | #ifdef S_IFBLK
|
---|
207 | static_assert (!S_ISNAM (S_IFBLK));
|
---|
208 | #endif
|
---|
209 | static_assert (!S_ISNAM (S_IFCHR));
|
---|
210 | static_assert (!S_ISNAM (S_IFDIR));
|
---|
211 | static_assert (!S_ISNAM (S_IFIFO));
|
---|
212 | static_assert (!S_ISNAM (S_IFREG));
|
---|
213 | #ifdef S_IFLNK
|
---|
214 | static_assert (!S_ISNAM (S_IFLNK));
|
---|
215 | #endif
|
---|
216 | #ifdef S_IFSOCK
|
---|
217 | static_assert (!S_ISNAM (S_IFSOCK));
|
---|
218 | #endif
|
---|
219 |
|
---|
220 | #ifdef S_IFBLK
|
---|
221 | static_assert (!S_ISNWK (S_IFBLK));
|
---|
222 | #endif
|
---|
223 | static_assert (!S_ISNWK (S_IFCHR));
|
---|
224 | static_assert (!S_ISNWK (S_IFDIR));
|
---|
225 | static_assert (!S_ISNWK (S_IFIFO));
|
---|
226 | static_assert (!S_ISNWK (S_IFREG));
|
---|
227 | #ifdef S_IFLNK
|
---|
228 | static_assert (!S_ISNWK (S_IFLNK));
|
---|
229 | #endif
|
---|
230 | #ifdef S_IFSOCK
|
---|
231 | static_assert (!S_ISNWK (S_IFSOCK));
|
---|
232 | #endif
|
---|
233 |
|
---|
234 | #ifdef S_IFBLK
|
---|
235 | static_assert (!S_ISPORT (S_IFBLK));
|
---|
236 | #endif
|
---|
237 | static_assert (!S_ISPORT (S_IFCHR));
|
---|
238 | static_assert (!S_ISPORT (S_IFDIR));
|
---|
239 | static_assert (!S_ISPORT (S_IFIFO));
|
---|
240 | static_assert (!S_ISPORT (S_IFREG));
|
---|
241 | #ifdef S_IFLNK
|
---|
242 | static_assert (!S_ISPORT (S_IFLNK));
|
---|
243 | #endif
|
---|
244 | #ifdef S_IFSOCK
|
---|
245 | static_assert (!S_ISPORT (S_IFSOCK));
|
---|
246 | #endif
|
---|
247 |
|
---|
248 | #ifdef S_IFBLK
|
---|
249 | static_assert (!S_ISCTG (S_IFBLK));
|
---|
250 | #endif
|
---|
251 | static_assert (!S_ISCTG (S_IFCHR));
|
---|
252 | static_assert (!S_ISCTG (S_IFDIR));
|
---|
253 | static_assert (!S_ISCTG (S_IFIFO));
|
---|
254 | static_assert (!S_ISCTG (S_IFREG));
|
---|
255 | #ifdef S_IFLNK
|
---|
256 | static_assert (!S_ISCTG (S_IFLNK));
|
---|
257 | #endif
|
---|
258 | #ifdef S_IFSOCK
|
---|
259 | static_assert (!S_ISCTG (S_IFSOCK));
|
---|
260 | #endif
|
---|
261 |
|
---|
262 | #ifdef S_IFBLK
|
---|
263 | static_assert (!S_ISOFD (S_IFBLK));
|
---|
264 | #endif
|
---|
265 | static_assert (!S_ISOFD (S_IFCHR));
|
---|
266 | static_assert (!S_ISOFD (S_IFDIR));
|
---|
267 | static_assert (!S_ISOFD (S_IFIFO));
|
---|
268 | static_assert (!S_ISOFD (S_IFREG));
|
---|
269 | #ifdef S_IFLNK
|
---|
270 | static_assert (!S_ISOFD (S_IFLNK));
|
---|
271 | #endif
|
---|
272 | #ifdef S_IFSOCK
|
---|
273 | static_assert (!S_ISOFD (S_IFSOCK));
|
---|
274 | #endif
|
---|
275 |
|
---|
276 | #ifdef S_IFBLK
|
---|
277 | static_assert (!S_ISOFL (S_IFBLK));
|
---|
278 | #endif
|
---|
279 | static_assert (!S_ISOFL (S_IFCHR));
|
---|
280 | static_assert (!S_ISOFL (S_IFDIR));
|
---|
281 | static_assert (!S_ISOFL (S_IFIFO));
|
---|
282 | static_assert (!S_ISOFL (S_IFREG));
|
---|
283 | #ifdef S_IFLNK
|
---|
284 | static_assert (!S_ISOFL (S_IFLNK));
|
---|
285 | #endif
|
---|
286 | #ifdef S_IFSOCK
|
---|
287 | static_assert (!S_ISOFL (S_IFSOCK));
|
---|
288 | #endif
|
---|
289 |
|
---|
290 | #ifdef S_IFBLK
|
---|
291 | static_assert (!S_ISWHT (S_IFBLK));
|
---|
292 | #endif
|
---|
293 | static_assert (!S_ISWHT (S_IFCHR));
|
---|
294 | static_assert (!S_ISWHT (S_IFDIR));
|
---|
295 | static_assert (!S_ISWHT (S_IFIFO));
|
---|
296 | static_assert (!S_ISWHT (S_IFREG));
|
---|
297 | #ifdef S_IFLNK
|
---|
298 | static_assert (!S_ISWHT (S_IFLNK));
|
---|
299 | #endif
|
---|
300 | #ifdef S_IFSOCK
|
---|
301 | static_assert (!S_ISWHT (S_IFSOCK));
|
---|
302 | #endif
|
---|
303 |
|
---|
304 | /* POSIX 2008 requires traditional encoding of permission constants. */
|
---|
305 | static_assert (S_IRWXU == 00700);
|
---|
306 | static_assert (S_IRUSR == 00400);
|
---|
307 | static_assert (S_IWUSR == 00200);
|
---|
308 | static_assert (S_IXUSR == 00100);
|
---|
309 | static_assert (S_IRWXG == 00070);
|
---|
310 | static_assert (S_IRGRP == 00040);
|
---|
311 | static_assert (S_IWGRP == 00020);
|
---|
312 | static_assert (S_IXGRP == 00010);
|
---|
313 | static_assert (S_IRWXO == 00007);
|
---|
314 | static_assert (S_IROTH == 00004);
|
---|
315 | static_assert (S_IWOTH == 00002);
|
---|
316 | static_assert (S_IXOTH == 00001);
|
---|
317 | static_assert (S_ISUID == 04000);
|
---|
318 | static_assert (S_ISGID == 02000);
|
---|
319 | static_assert (S_ISVTX == 01000);
|
---|
320 |
|
---|
321 | #if ((0 <= UTIME_NOW && UTIME_NOW < 1000000000) \
|
---|
322 | || (0 <= UTIME_OMIT && UTIME_OMIT < 1000000000) \
|
---|
323 | || UTIME_NOW == UTIME_OMIT)
|
---|
324 | invalid UTIME macros
|
---|
325 | #endif
|
---|
326 |
|
---|
327 | /* Check the existence of some types. */
|
---|
328 | nlink_t t1;
|
---|
329 | off_t t2;
|
---|
330 | mode_t t3;
|
---|
331 |
|
---|
332 | struct timespec st;
|
---|
333 |
|
---|
334 | int
|
---|
335 | main (void)
|
---|
336 | {
|
---|
337 | return 0;
|
---|
338 | }
|
---|