source: trunk/essentials/app-arch/tar/lib/stat_.h

Last change on this file was 3342, checked in by bird, 18 years ago

tar 1.16.1

File size: 5.5 KB
Line 
1/* Provide a more complete sys/stat header file.
2 Copyright (C) 2006 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 2, or (at your option)
7 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, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17
18/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */
19
20#ifndef _gl_SYS_STAT_H
21#define _gl_SYS_STAT_H
22
23/* This file is supposed to be used on platforms where <sys/stat.h> is
24 incomplete. It is intended to provide definitions and prototypes
25 needed by an application. Start with what the system provides. */
26#include @ABSOLUTE_SYS_STAT_H@
27
28#ifndef S_IFMT
29# define S_IFMT 0170000
30#endif
31
32#if STAT_MACROS_BROKEN
33# undef S_ISBLK
34# undef S_ISCHR
35# undef S_ISDIR
36# undef S_ISFIFO
37# undef S_ISLNK
38# undef S_ISNAM
39# undef S_ISMPB
40# undef S_ISMPC
41# undef S_ISNWK
42# undef S_ISREG
43# undef S_ISSOCK
44#endif
45
46#ifndef S_ISBLK
47# ifdef S_IFBLK
48# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
49# else
50# define S_ISBLK(m) 0
51# endif
52#endif
53
54#ifndef S_ISCHR
55# ifdef S_IFCHR
56# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
57# else
58# define S_ISCHR(m) 0
59# endif
60#endif
61
62#ifndef S_ISDIR
63# ifdef S_IFDIR
64# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
65# else
66# define S_ISDIR(m) 0
67# endif
68#endif
69
70#ifndef S_ISDOOR /* Solaris 2.5 and up */
71# define S_ISDOOR(m) 0
72#endif
73
74#ifndef S_ISFIFO
75# ifdef S_IFIFO
76# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
77# else
78# define S_ISFIFO(m) 0
79# endif
80#endif
81
82#ifndef S_ISLNK
83# ifdef S_IFLNK
84# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
85# else
86# define S_ISLNK(m) 0
87# endif
88#endif
89
90#ifndef S_ISMPB /* V7 */
91# ifdef S_IFMPB
92# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
93# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
94# else
95# define S_ISMPB(m) 0
96# define S_ISMPC(m) 0
97# endif
98#endif
99
100#ifndef S_ISNAM /* Xenix */
101# ifdef S_IFNAM
102# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
103# else
104# define S_ISNAM(m) 0
105# endif
106#endif
107
108#ifndef S_ISNWK /* HP/UX */
109# ifdef S_IFNWK
110# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
111# else
112# define S_ISNWK(m) 0
113# endif
114#endif
115
116#ifndef S_ISPORT /* Solaris 10 and up */
117# define S_ISPORT(m) 0
118#endif
119
120#ifndef S_ISREG
121# ifdef S_IFREG
122# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
123# else
124# define S_ISREG(m) 0
125# endif
126#endif
127
128#ifndef S_ISSOCK
129# ifdef S_IFSOCK
130# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
131# else
132# define S_ISSOCK(m) 0
133# endif
134#endif
135
136
137#ifndef S_TYPEISMQ
138# define S_TYPEISMQ(p) 0
139#endif
140
141#ifndef S_TYPEISTMO
142# define S_TYPEISTMO(p) 0
143#endif
144
145
146#ifndef S_TYPEISSEM
147# ifdef S_INSEM
148# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
149# else
150# define S_TYPEISSEM(p) 0
151# endif
152#endif
153
154#ifndef S_TYPEISSHM
155# ifdef S_INSHD
156# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
157# else
158# define S_TYPEISSHM(p) 0
159# endif
160#endif
161
162/* high performance ("contiguous data") */
163#ifndef S_ISCTG
164# define S_ISCTG(p) 0
165#endif
166
167/* Cray DMF (data migration facility): off line, with data */
168#ifndef S_ISOFD
169# define S_ISOFD(p) 0
170#endif
171
172/* Cray DMF (data migration facility): off line, with no data */
173#ifndef S_ISOFL
174# define S_ISOFL(p) 0
175#endif
176
177/* 4.4BSD whiteout */
178#ifndef S_ISWHT
179# define S_ISWHT(m) 0
180#endif
181
182/* If any of the following are undefined,
183 define them to their de facto standard values. */
184#if !S_ISUID
185# define S_ISUID 04000
186#endif
187#if !S_ISGID
188# define S_ISGID 02000
189#endif
190
191/* S_ISVTX is a common extension to POSIX. */
192#ifndef S_ISVTX
193# define S_ISVTX 01000
194#endif
195
196#if !S_IRUSR && S_IREAD
197# define S_IRUSR S_IREAD
198#endif
199#if !S_IRUSR
200# define S_IRUSR 00400
201#endif
202#if !S_IRGRP
203# define S_IRGRP (S_IRUSR >> 3)
204#endif
205#if !S_IROTH
206# define S_IROTH (S_IRUSR >> 6)
207#endif
208
209#if !S_IWUSR && S_IWRITE
210# define S_IWUSR S_IWRITE
211#endif
212#if !S_IWUSR
213# define S_IWUSR 00200
214#endif
215#if !S_IWGRP
216# define S_IWGRP (S_IWUSR >> 3)
217#endif
218#if !S_IWOTH
219# define S_IWOTH (S_IWUSR >> 6)
220#endif
221
222#if !S_IXUSR && S_IEXEC
223# define S_IXUSR S_IEXEC
224#endif
225#if !S_IXUSR
226# define S_IXUSR 00100
227#endif
228#if !S_IXGRP
229# define S_IXGRP (S_IXUSR >> 3)
230#endif
231#if !S_IXOTH
232# define S_IXOTH (S_IXUSR >> 6)
233#endif
234
235#if !S_IRWXU
236# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
237#endif
238#if !S_IRWXG
239# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
240#endif
241#if !S_IRWXO
242# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
243#endif
244
245/* S_IXUGO is a common extension to POSIX. */
246#if !S_IXUGO
247# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
248#endif
249
250#ifndef S_IRWXUGO
251# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
252#endif
253
254/* mingw does not support symlinks, therefore it does not have lstat. But
255 without links, stat does just fine. */
256#if ! HAVE_LSTAT
257# define lstat stat
258#endif
259
260/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
261 Additionally, it declares _mkdir (and depending on compile flags, an
262 alias mkdir), only in the nonstandard io.h. */
263#if ! HAVE_DECL_MKDIR && HAVE_IO_H
264# include <io.h>
265
266static inline int
267rpl_mkdir (char const *name, mode_t mode)
268{
269 return _mkdir (name);
270}
271
272# define mkdir rpl_mkdir
273#endif
274
275#endif /* _gl_SYS_STAT_H */
Note: See TracBrowser for help on using the repository browser.