1 /* Provide a more complete sys/stat header file.
2 Copyright (C) 2006-2008 Free Software Foundation, Inc.
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)
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.
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. */
18 /* Written by Eric Blake, Paul Eggert, and Jim Meyering. */
20 /* This file is supposed to be used on platforms where <sys/stat.h> is
21 incomplete. It is intended to provide definitions and prototypes
22 needed by an application. Start with what the system provides. */
24 #ifndef _GL_SYS_STAT_H
27 @PRAGMA_SYSTEM_HEADER@
30 /* The include_next requires a split double-inclusion guard. */
31 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
33 #ifndef _GL_SYS_STAT_H
34 #define _GL_SYS_STAT_H
36 /* Before doing "#define mkdir rpl_mkdir" below, we need to include all
37 headers that may declare mkdir(). */
38 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
43 # define S_IFMT 0170000
46 #if STAT_MACROS_BROKEN
62 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
70 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
78 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
84 #ifndef S_ISDOOR /* Solaris 2.5 and up */
85 # define S_ISDOOR(m) 0
90 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
92 # define S_ISFIFO(m) 0
98 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
100 # define S_ISLNK(m) 0
104 #ifndef S_ISMPB /* V7 */
106 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
107 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
109 # define S_ISMPB(m) 0
110 # define S_ISMPC(m) 0
114 #ifndef S_ISNAM /* Xenix */
116 # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
118 # define S_ISNAM(m) 0
122 #ifndef S_ISNWK /* HP/UX */
124 # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
126 # define S_ISNWK(m) 0
130 #ifndef S_ISPORT /* Solaris 10 and up */
131 # define S_ISPORT(m) 0
136 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
138 # define S_ISREG(m) 0
144 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
146 # define S_ISSOCK(m) 0
152 # define S_TYPEISMQ(p) 0
156 # define S_TYPEISTMO(p) 0
162 # define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
164 # define S_TYPEISSEM(p) 0
170 # define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
172 # define S_TYPEISSHM(p) 0
176 /* high performance ("contiguous data") */
178 # define S_ISCTG(p) 0
181 /* Cray DMF (data migration facility): off line, with data */
183 # define S_ISOFD(p) 0
186 /* Cray DMF (data migration facility): off line, with no data */
188 # define S_ISOFL(p) 0
191 /* 4.4BSD whiteout */
193 # define S_ISWHT(m) 0
196 /* If any of the following are undefined,
197 define them to their de facto standard values. */
199 # define S_ISUID 04000
202 # define S_ISGID 02000
205 /* S_ISVTX is a common extension to POSIX. */
207 # define S_ISVTX 01000
210 #if !S_IRUSR && S_IREAD
211 # define S_IRUSR S_IREAD
214 # define S_IRUSR 00400
217 # define S_IRGRP (S_IRUSR >> 3)
220 # define S_IROTH (S_IRUSR >> 6)
223 #if !S_IWUSR && S_IWRITE
224 # define S_IWUSR S_IWRITE
227 # define S_IWUSR 00200
230 # define S_IWGRP (S_IWUSR >> 3)
233 # define S_IWOTH (S_IWUSR >> 6)
236 #if !S_IXUSR && S_IEXEC
237 # define S_IXUSR S_IEXEC
240 # define S_IXUSR 00100
243 # define S_IXGRP (S_IXUSR >> 3)
246 # define S_IXOTH (S_IXUSR >> 6)
250 # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
253 # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
256 # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
259 /* S_IXUGO is a common extension to POSIX. */
261 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
265 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
268 /* mingw does not support symlinks, therefore it does not have lstat. But
269 without links, stat does just fine. */
276 # define mkdir rpl_mkdir
277 extern int mkdir (char const *name, mode_t mode);
279 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
280 Additionally, it declares _mkdir (and depending on compile flags, an
281 alias mkdir), only in the nonstandard <io.h>, which is included above. */
282 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
285 rpl_mkdir (char const *name, mode_t mode)
287 return _mkdir (name);
290 # define mkdir rpl_mkdir
294 #endif /* _GL_SYS_STAT_H */
295 #endif /* _GL_SYS_STAT_H */