source: trunk/essentials/app-arch/cpio/lib/stat-macros.h

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

cpio 2.7

File size: 5.1 KB
Line 
1/* stat-related macros
2
3 Copyright (C) 1993, 1994, 2001, 2002, 2004, 2006 Free Software
4 Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
20/* Written by Paul Eggert and Jim Meyering. */
21
22#ifndef STAT_MACROS_H
23# define STAT_MACROS_H 1
24
25# if ! defined S_ISREG && ! defined S_IFREG
26# error "you must include <sys/stat.h> before including this file"
27# endif
28
29# ifndef S_IFMT
30# define S_IFMT 0170000
31# endif
32
33# if STAT_MACROS_BROKEN
34# undef S_ISBLK
35# undef S_ISCHR
36# undef S_ISDIR
37# undef S_ISFIFO
38# undef S_ISLNK
39# undef S_ISNAM
40# undef S_ISMPB
41# undef S_ISMPC
42# undef S_ISNWK
43# undef S_ISREG
44# undef S_ISSOCK
45# endif
46
47
48# ifndef S_ISBLK
49# ifdef S_IFBLK
50# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
51# else
52# define S_ISBLK(m) 0
53# endif
54# endif
55
56# ifndef S_ISCHR
57# ifdef S_IFCHR
58# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
59# else
60# define S_ISCHR(m) 0
61# endif
62# endif
63
64# ifndef S_ISDIR
65# ifdef S_IFDIR
66# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
67# else
68# define S_ISDIR(m) 0
69# endif
70# endif
71
72# ifndef S_ISDOOR /* Solaris 2.5 and up */
73# define S_ISDOOR(m) 0
74# endif
75
76# ifndef S_ISFIFO
77# ifdef S_IFIFO
78# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
79# else
80# define S_ISFIFO(m) 0
81# endif
82# endif
83
84# ifndef S_ISLNK
85# ifdef S_IFLNK
86# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
87# else
88# define S_ISLNK(m) 0
89# endif
90# endif
91
92# ifndef S_ISMPB /* V7 */
93# ifdef S_IFMPB
94# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
95# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
96# else
97# define S_ISMPB(m) 0
98# define S_ISMPC(m) 0
99# endif
100# endif
101
102# ifndef S_ISNAM /* Xenix */
103# ifdef S_IFNAM
104# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
105# else
106# define S_ISNAM(m) 0
107# endif
108# endif
109
110# ifndef S_ISNWK /* HP/UX */
111# ifdef S_IFNWK
112# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
113# else
114# define S_ISNWK(m) 0
115# endif
116# endif
117
118# ifndef S_ISPORT /* Solaris 10 and up */
119# define S_ISPORT(m) 0
120# endif
121
122# ifndef S_ISREG
123# ifdef S_IFREG
124# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
125# else
126# define S_ISREG(m) 0
127# endif
128# endif
129
130# ifndef S_ISSOCK
131# ifdef S_IFSOCK
132# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
133# else
134# define S_ISSOCK(m) 0
135# endif
136# endif
137
138
139# ifndef S_TYPEISMQ
140# define S_TYPEISMQ(p) 0
141# endif
142
143# ifndef S_TYPEISTMO
144# define S_TYPEISTMO(p) 0
145# endif
146
147
148# ifndef S_TYPEISSEM
149# ifdef S_INSEM
150# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
151# else
152# define S_TYPEISSEM(p) 0
153# endif
154# endif
155
156# ifndef S_TYPEISSHM
157# ifdef S_INSHD
158# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
159# else
160# define S_TYPEISSHM(p) 0
161# endif
162# endif
163
164/* high performance ("contiguous data") */
165# ifndef S_ISCTG
166# define S_ISCTG(p) 0
167# endif
168
169/* Cray DMF (data migration facility): off line, with data */
170# ifndef S_ISOFD
171# define S_ISOFD(p) 0
172# endif
173
174/* Cray DMF (data migration facility): off line, with no data */
175# ifndef S_ISOFL
176# define S_ISOFL(p) 0
177# endif
178
179/* 4.4BSD whiteout */
180# ifndef S_ISWHT
181# define S_ISWHT(m) 0
182# endif
183
184/* If any of the following are undefined,
185 define them to their de facto standard values. */
186# if !S_ISUID
187# define S_ISUID 04000
188# endif
189# if !S_ISGID
190# define S_ISGID 02000
191# endif
192
193/* S_ISVTX is a common extension to POSIX. */
194# ifndef S_ISVTX
195# define S_ISVTX 01000
196# endif
197
198# if !S_IRUSR && S_IREAD
199# define S_IRUSR S_IREAD
200# endif
201# if !S_IRUSR
202# define S_IRUSR 00400
203# endif
204# if !S_IRGRP
205# define S_IRGRP (S_IRUSR >> 3)
206# endif
207# if !S_IROTH
208# define S_IROTH (S_IRUSR >> 6)
209# endif
210
211# if !S_IWUSR && S_IWRITE
212# define S_IWUSR S_IWRITE
213# endif
214# if !S_IWUSR
215# define S_IWUSR 00200
216# endif
217# if !S_IWGRP
218# define S_IWGRP (S_IWUSR >> 3)
219# endif
220# if !S_IWOTH
221# define S_IWOTH (S_IWUSR >> 6)
222# endif
223
224# if !S_IXUSR && S_IEXEC
225# define S_IXUSR S_IEXEC
226# endif
227# if !S_IXUSR
228# define S_IXUSR 00100
229# endif
230# if !S_IXGRP
231# define S_IXGRP (S_IXUSR >> 3)
232# endif
233# if !S_IXOTH
234# define S_IXOTH (S_IXUSR >> 6)
235# endif
236
237# if !S_IRWXU
238# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
239# endif
240# if !S_IRWXG
241# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
242# endif
243# if !S_IRWXO
244# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
245# endif
246
247/* S_IXUGO is a common extension to POSIX. */
248# if !S_IXUGO
249# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
250# endif
251
252# ifndef S_IRWXUGO
253# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
254# endif
255
256/* All the mode bits that can be affected by chmod. */
257# define CHMOD_MODE_BITS \
258 (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
259
260#endif /* STAT_MACROS_H */
Note: See TracBrowser for help on using the repository browser.