Subversion Repositories shark

Rev

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