comparison lib/stat-macros.h @ 7581:45c727466eb8

Move stat.h-substitute stuff from lib/stat-macros.h to lib/stat_.h. stat-macros.h is now for our own macros, whereas stat_h is for macros in the <sys/stat.h> name space. * lib/stat-macros.h: Remove copyright notice, as this file is now tiny. (STAT_MACROS_H): Remove. (S_IFMT, S_ISBLK, S_ISCHR, S_ISDIR, S_ISFIFO, S_ISLNK, S_ISNAM): (S_ISMPB, S_ISMPC, S_ISNWK, S_ISREG, S_ISSOCK, S_ISDOOR, S_ISPORT): (S_TYPEISMQ, S_TYPEISTMO, S_TYPEISSEM, S_TYPEISSHM, S_ISCTG, S_ISOFD): (S_ISOFL, S_ISWHT, S_ISUID, S_ISGID, S_ISVTX, S_IRUSR, S_IRGRP): (S_IROTH, S_IWUSR, S_IWGRP, S_IWOTH, S_IXUSR, S_IXGRP, S_IXOTH): (S_IRWXU, S_IRWXG, S_IRWXO, S_IXUGO, S_IRWXUGO): Move these macros to ... * lib/stat_.h: here. Don't include stat-macros.h. * lib/canonicalize.c: Don't include stat-macros.h. * lib/chown.c: Likewise. * lib/euidaccess.c: Likewise. * lib/file-type.c: Likewise. * lib/filemode.c: Likewise. * lib/glob.c: Likewise. * lib/isapipe.c: Likewise. * lib/lchown.c: Likewise. * lib/lstat.c: Likewise. * lib/mkdir-p.c: Likewise. * lib/rmdir.c: Likewise. * m4/lchown.m4 (gl_FUNC_LCHOWN): Don't require gl_STAT_MACROS. * m4/sys_stat_h.m4 (gl_HEADER_SYS_STAT_H): Don't check for io.h unless mkdir isn't declared, to speed up 'configure'. Always create sys/stat.h, since it's unlikely any real sys/stat.h would define all the S_* symbols. * modules/canonicalize (Depends-on): Depend on sys_stat, not stat-macros. * modules/chown: Likewise. * modules/euidaccess: Likewise. * modules/filemode: Likewise. * modules/file-type: Likewise. * modules/glob: Likewise. * modules/isapipe: Likewise. * modules/lchown: Likewise. * modules/lstat: Likewise. * modules/mkancesdirs: Likewise. * modules/rmdir: Likewise. * modules/mkdir-p (Depends-on): Also depend on sys_stat. * modules/modechange: Likewise. * modules/stat-macros (Files): Remove m4/stat-macros.m4. (configure.ac): Remove gl_STAT_MACROS. * modules/sys_stat (Depends-on): Remove stat-macros.
author Paul Eggert <eggert@cs.ucla.edu>
date Fri, 27 Oct 2006 20:46:43 +0000
parents 314715e0260d
children
comparison
equal deleted inserted replaced
7580:fa32165fe92b 7581:45c727466eb8
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. */ 1 /* All the mode bits that can be affected by chmod. */
257 # define CHMOD_MODE_BITS \ 2 #define CHMOD_MODE_BITS \
258 (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) 3 (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
259
260 #endif /* STAT_MACROS_H */