Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | pj | 1 | /* Copyright (C) 1991, 92, 95, 96, 97, 98 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 Library General Public License as |
||
6 | published by the Free Software Foundation; either version 2 of the |
||
7 | 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 | Library General Public License for more details. |
||
13 | |||
14 | You should have received a copy of the GNU Library General Public |
||
15 | License along with the GNU C Library; see the file COPYING.LIB. If not, |
||
16 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
||
17 | Boston, MA 02111-1307, USA. */ |
||
18 | |||
19 | /* |
||
20 | * POSIX Standard: 5.6 File Characteristics <sys/stat.h> |
||
21 | */ |
||
22 | |||
23 | #ifndef _SYS_STAT_H |
||
24 | #define _SYS_STAT_H 1 |
||
25 | |||
26 | #include <features.h> |
||
27 | |||
28 | #include <bits/types.h> /* For __mode_t and __dev_t. */ |
||
29 | #include <sys/htypes.h> |
||
30 | |||
31 | #ifdef __USE_XOPEN |
||
32 | # define __need_time_t |
||
33 | # include <time.h> /* For time_t. */ |
||
34 | #endif |
||
35 | |||
36 | /* The Single Unix specification says that some more types are |
||
37 | available here. */ |
||
38 | __DJ_dev_t |
||
39 | #undef __DJ_dev_t |
||
40 | #define __DJ_dev_t |
||
41 | |||
42 | __DJ_gid_t |
||
43 | #undef __DJ_gid_t |
||
44 | #define __DJ_gid_t |
||
45 | |||
46 | # ifndef ino_t |
||
47 | # ifndef __USE_FILE_OFFSET64 |
||
48 | __DJ_ino_t |
||
49 | #undef __DJ_ino_t |
||
50 | #define __DJ_ino_t |
||
51 | # else |
||
52 | typedef __ino64_t ino_t; |
||
53 | # endif |
||
54 | # define ino_t ino_t |
||
55 | # endif |
||
56 | |||
57 | __DJ_mode_t |
||
58 | #undef __DJ_mode_t |
||
59 | #define __DJ_mode_t |
||
60 | |||
61 | __DJ_nlink_t |
||
62 | #undef __DJ_nlink_t |
||
63 | #define __DJ_nlink_t |
||
64 | |||
65 | # ifndef off_t |
||
66 | # ifndef __USE_FILE_OFFSET64 |
||
67 | __DJ_off_t |
||
68 | #undef __DJ_off_t |
||
69 | #define __DJ_off_t |
||
70 | # else |
||
71 | typedef __off64_t off_t; |
||
72 | # endif |
||
73 | # define off_t off_t |
||
74 | # endif |
||
75 | |||
76 | __DJ_uid_t |
||
77 | #undef __DJ_uid_t |
||
78 | #define __DJ_uid_t |
||
79 | |||
80 | #ifdef __USE_UNIX98 |
||
81 | __DJ_pid_t |
||
82 | #undef __DJ_pid_t |
||
83 | #define __DJ_pid_t |
||
84 | #endif /* Unix98 */ |
||
85 | |||
86 | __BEGIN_DECLS |
||
87 | |||
88 | #include <bits/stat.h> |
||
89 | |||
90 | #if defined __USE_BSD || defined __USE_MISC || defined __USE_XOPEN |
||
91 | # define S_IFMT __S_IFMT |
||
92 | # define S_IFDIR __S_IFDIR |
||
93 | # define S_IFCHR __S_IFCHR |
||
94 | # define S_IFBLK __S_IFBLK |
||
95 | # define S_IFREG __S_IFREG |
||
96 | # ifdef __S_IFIFO |
||
97 | # define S_IFIFO __S_IFIFO |
||
98 | # endif |
||
99 | # if defined __USE_BSD || defined __USE_MISC |
||
100 | # ifdef __S_IFLNK |
||
101 | # define S_IFLNK __S_IFLNK |
||
102 | # endif |
||
103 | # ifdef __S_IFSOCK |
||
104 | # define S_IFSOCK __S_IFSOCK |
||
105 | # endif |
||
106 | # endif |
||
107 | #endif |
||
108 | |||
109 | /* Test macros for file types. */ |
||
110 | |||
111 | #define __S_ISTYPE(mode, mask) (((mode) & __S_IFMT) == (mask)) |
||
112 | |||
113 | #define S_ISDIR(mode) __S_ISTYPE((mode), __S_IFDIR) |
||
114 | #define S_ISCHR(mode) __S_ISTYPE((mode), __S_IFCHR) |
||
115 | #define S_ISBLK(mode) __S_ISTYPE((mode), __S_IFBLK) |
||
116 | #define S_ISREG(mode) __S_ISTYPE((mode), __S_IFREG) |
||
117 | #ifdef __S_IFIFO |
||
118 | # define S_ISFIFO(mode) __S_ISTYPE((mode), __S_IFIFO) |
||
119 | #endif |
||
120 | |||
121 | #ifdef __USE_BSD |
||
122 | # ifdef __S_IFLNK |
||
123 | # define S_ISLNK(mode) __S_ISTYPE((mode), __S_IFLNK) |
||
124 | # else |
||
125 | # define S_ISLNK(mode) 0 |
||
126 | # endif |
||
127 | # ifdef __S_IFSOCK |
||
128 | # define S_ISSOCK(mode) __S_ISTYPE((mode), __S_IFSOCK) |
||
129 | # endif |
||
130 | #endif |
||
131 | |||
132 | |||
133 | /* Protection bits. */ |
||
134 | |||
135 | #define S_ISUID __S_ISUID /* Set user ID on execution. */ |
||
136 | #define S_ISGID __S_ISGID /* Set group ID on execution. */ |
||
137 | |||
138 | #if defined __USE_BSD || defined __USE_MISC |
||
139 | /* Save swapped text after use (sticky bit). This is pretty well obsolete. */ |
||
140 | # define S_ISVTX __S_ISVTX |
||
141 | #endif |
||
142 | |||
143 | #define S_IRUSR __S_IREAD /* Read by owner. */ |
||
144 | #define S_IWUSR __S_IWRITE /* Write by owner. */ |
||
145 | #define S_IXUSR __S_IEXEC /* Execute by owner. */ |
||
146 | /* Read, write, and execute by owner. */ |
||
147 | #define S_IRWXU (__S_IREAD|__S_IWRITE|__S_IEXEC) |
||
148 | |||
149 | #if defined __USE_MISC && defined __USE_BSD |
||
150 | # define S_IREAD S_IRUSR |
||
151 | # define S_IWRITE S_IWUSR |
||
152 | # define S_IEXEC S_IXUSR |
||
153 | #endif |
||
154 | |||
155 | #define S_IRGRP (S_IRUSR >> 3) /* Read by group. */ |
||
156 | #define S_IWGRP (S_IWUSR >> 3) /* Write by group. */ |
||
157 | #define S_IXGRP (S_IXUSR >> 3) /* Execute by group. */ |
||
158 | /* Read, write, and execute by group. */ |
||
159 | #define S_IRWXG (S_IRWXU >> 3) |
||
160 | |||
161 | #define S_IROTH (S_IRGRP >> 3) /* Read by others. */ |
||
162 | #define S_IWOTH (S_IWGRP >> 3) /* Write by others. */ |
||
163 | #define S_IXOTH (S_IXGRP >> 3) /* Execute by others. */ |
||
164 | /* Read, write, and execute by others. */ |
||
165 | #define S_IRWXO (S_IRWXG >> 3) |
||
166 | |||
167 | |||
168 | #ifdef __USE_BSD |
||
169 | /* Macros for common mode bit masks. */ |
||
170 | # define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */ |
||
171 | # define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)/* 07777 */ |
||
172 | # define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/ |
||
173 | |||
174 | # define S_BLKSIZE 512 /* Block size for `st_blocks'. */ |
||
175 | #endif |
||
176 | |||
177 | |||
178 | #ifndef __USE_FILE_OFFSET64 |
||
179 | /* Get file attributes for FILE and put them in BUF. */ |
||
180 | extern int stat __P ((__const char *__file, struct stat *__buf)); |
||
181 | |||
182 | /* Get file attributes for the file, device, pipe, or socket |
||
183 | that file descriptor FD is open on and put them in BUF. */ |
||
184 | extern int fstat __P ((int __fd, struct stat *__buf)); |
||
185 | #else |
||
186 | # ifdef __REDIRECT |
||
187 | extern int __REDIRECT (stat, __P ((__const char *__file, struct stat *__buf)), |
||
188 | stat64); |
||
189 | extern int __REDIRECT (fstat, __P ((int __fd, struct stat *__buf)), fstat64); |
||
190 | # else |
||
191 | # define stat stat64 |
||
192 | # define fstat fstat64 |
||
193 | # endif |
||
194 | #endif |
||
195 | #ifdef __USE_LARGEFILE64 |
||
196 | extern int stat64 __P ((__const char *__file, struct stat64 *__buf)); |
||
197 | extern int fstat64 __P ((int __fd, struct stat64 *__buf)); |
||
198 | #endif |
||
199 | |||
200 | #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED |
||
201 | # ifndef __USE_FILE_OFFSET64 |
||
202 | /* Get file attributes about FILE and put them in BUF. |
||
203 | If FILE is a symbolic link, do not follow it. */ |
||
204 | extern int lstat __P ((__const char *__file, struct stat *__buf)); |
||
205 | # else |
||
206 | # ifdef __REDIRECT |
||
207 | extern int __REDIRECT (lstat, __P ((__const char *__file, struct stat *__buf)), |
||
208 | lstat64); |
||
209 | # else |
||
210 | # define lstat lstat64 |
||
211 | # endif |
||
212 | # endif |
||
213 | # ifdef __USE_LARGEFILE64 |
||
214 | extern int lstat64 __P ((__const char *__file, struct stat64 *__buf)); |
||
215 | # endif |
||
216 | #endif |
||
217 | |||
218 | /* Set file access permissions for FILE to MODE. |
||
219 | This takes an `int' MODE argument because that |
||
220 | is what `mode_t's get widened to. */ |
||
221 | extern int chmod __P ((__const char *__file, __mode_t __mode)); |
||
222 | |||
223 | /* Set file access permissions of the file FD is open on to MODE. */ |
||
224 | #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED |
||
225 | extern int fchmod __P ((int __fd, __mode_t __mode)); |
||
226 | #endif |
||
227 | |||
228 | |||
229 | /* Set the file creation mask of the current process to MASK, |
||
230 | and return the old creation mask. */ |
||
231 | extern __mode_t umask __P ((__mode_t __mask)); |
||
232 | |||
233 | #ifdef __USE_GNU |
||
234 | /* Get the current `umask' value without changing it. |
||
235 | This function is only available under the GNU Hurd. */ |
||
236 | extern __mode_t getumask __P ((void)); |
||
237 | #endif |
||
238 | |||
239 | /* Create a new directory named PATH, with permission bits MODE. */ |
||
240 | extern int mkdir __P ((__const char *__path, __mode_t __mode)); |
||
241 | |||
242 | /* Create a device file named PATH, with permission and special bits MODE |
||
243 | and device number DEV (which can be constructed from major and minor |
||
244 | device numbers with the `makedev' macro above). */ |
||
245 | #if defined __USE_MISC || defined __USE_BSD || defined __USE_XOPEN_EXTENDED |
||
246 | extern int mknod __P ((__const char *__path, |
||
247 | __mode_t __mode, __dev_t __dev)); |
||
248 | #endif |
||
249 | |||
250 | |||
251 | /* Create a new FIFO named PATH, with permission bits MODE. */ |
||
252 | extern int mkfifo __P ((__const char *__path, __mode_t __mode)); |
||
253 | |||
254 | /* To allow the `struct stat' structure and the file type `mode_t' |
||
255 | bits to vary without changing shared library major version number, |
||
256 | the `stat' family of functions and `mknod' are in fact inline |
||
257 | wrappers around calls to `xstat', `fxstat', `lxstat', and `xmknod', |
||
258 | which all take a leading version-number argument designating the |
||
259 | data structure and bits used. <bits/stat.h> defines _STAT_VER with |
||
260 | the version number corresponding to `struct stat' as defined in |
||
261 | that file; and _MKNOD_VER with the version number corresponding to |
||
262 | the S_IF* macros defined therein. It is arranged that when not |
||
263 | inlined these function are always statically linked; that way a |
||
264 | dynamically-linked executable always encodes the version number |
||
265 | corresponding to the data structures it uses, so the `x' functions |
||
266 | in the shared library can adapt without needing to recompile all |
||
267 | callers. */ |
||
268 | |||
269 | #ifndef _STAT_VER |
||
270 | # define _STAT_VER 0 |
||
271 | #endif |
||
272 | #ifndef _MKNOD_VER |
||
273 | # define _MKNOD_VER 0 |
||
274 | #endif |
||
275 | |||
276 | /* Wrappers for stat and mknod system calls. */ |
||
277 | #ifndef __USE_FILE_OFFSET64 |
||
278 | extern int __fxstat __P ((int __ver, int __fildes, |
||
279 | struct stat *__stat_buf)); |
||
280 | extern int __xstat __P ((int __ver, __const char *__filename, |
||
281 | struct stat *__stat_buf)); |
||
282 | extern int __lxstat __P ((int __ver, __const char *__filename, |
||
283 | struct stat *__stat_buf)); |
||
284 | #else |
||
285 | # ifdef __REDIRECT |
||
286 | extern int __REDIRECT (__fxstat, __P ((int __ver, int __fildes, |
||
287 | struct stat *__stat_buf)), __fxstat64); |
||
288 | extern int __REDIRECT (__xstat, __P ((int __ver, __const char *__filename, |
||
289 | struct stat *__stat_buf)), __xstat64); |
||
290 | extern int __REDIRECT (__lxstat, __P ((int __ver, __const char *__filename, |
||
291 | struct stat *__stat_buf)), __lxstat64); |
||
292 | |||
293 | # else |
||
294 | # define __fxstat __fxstat64 |
||
295 | # define __xstat __xstat64 |
||
296 | # define __lxstat __lxstat64 |
||
297 | # endif |
||
298 | #endif |
||
299 | |||
300 | #ifdef __USE_LARGEFILE64 |
||
301 | extern int __fxstat64 __P ((int __ver, int __fildes, |
||
302 | struct stat64 *__stat_buf)); |
||
303 | extern int __xstat64 __P ((int __ver, __const char *__filename, |
||
304 | struct stat64 *__stat_buf)); |
||
305 | extern int __lxstat64 __P ((int __ver, __const char *__filename, |
||
306 | struct stat64 *__stat_buf)); |
||
307 | #endif |
||
308 | extern int __xmknod __P ((int __ver, __const char *__path, |
||
309 | __mode_t __mode, __dev_t *__dev)); |
||
310 | |||
311 | #if defined __GNUC__ && __GNUC__ >= 2 |
||
312 | /* Inlined versions of the real stat and mknod functions. */ |
||
313 | |||
314 | extern __inline__ int stat (__const char *__path, |
||
315 | struct stat *__statbuf) __THROW |
||
316 | { |
||
317 | return __xstat (_STAT_VER, __path, __statbuf); |
||
318 | } |
||
319 | |||
320 | # if defined __USE_BSD || defined __USE_XOPEN_EXTENDED |
||
321 | extern __inline__ int lstat (__const char *__path, |
||
322 | struct stat *__statbuf) __THROW |
||
323 | { |
||
324 | return __lxstat (_STAT_VER, __path, __statbuf); |
||
325 | } |
||
326 | # endif |
||
327 | |||
328 | extern __inline__ int fstat (int __fd, struct stat *__statbuf) __THROW |
||
329 | { |
||
330 | return __fxstat (_STAT_VER, __fd, __statbuf); |
||
331 | } |
||
332 | |||
333 | # if defined __USE_MISC || defined __USE_BSD |
||
334 | extern __inline__ int mknod (__const char *__path, __mode_t __mode, |
||
335 | __dev_t __dev) __THROW |
||
336 | { |
||
337 | return __xmknod (_MKNOD_VER, __path, __mode, &__dev); |
||
338 | } |
||
339 | # endif |
||
340 | |||
341 | # ifdef __USE_LARGEFILE64 |
||
342 | extern __inline__ int stat64 (__const char *__path, |
||
343 | struct stat64 *__statbuf) __THROW |
||
344 | { |
||
345 | return __xstat64 (_STAT_VER, __path, __statbuf); |
||
346 | } |
||
347 | |||
348 | # if defined __USE_BSD || defined __USE_XOPEN_EXTENDED |
||
349 | extern __inline__ int lstat64 (__const char *__path, |
||
350 | struct stat64 *__statbuf) __THROW |
||
351 | { |
||
352 | return __lxstat64 (_STAT_VER, __path, __statbuf); |
||
353 | } |
||
354 | # endif |
||
355 | |||
356 | extern __inline__ int fstat64 (int __fd, struct stat64 *__statbuf) __THROW |
||
357 | { |
||
358 | return __fxstat64 (_STAT_VER, __fd, __statbuf); |
||
359 | } |
||
360 | # endif |
||
361 | |||
362 | #endif |
||
363 | |||
364 | __END_DECLS |
||
365 | |||
366 | |||
367 | #endif /* sys/stat.h */ |