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
26 @PRAGMA_SYSTEM_HEADER@
28 /* The include_next requires a split double-inclusion guard. */
29 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
31 #ifndef _GL_SYS_STAT_H
32 #define _GL_SYS_STAT_H
34 /* Before doing "#define mkdir rpl_mkdir" below, we need to include all
35 headers that may declare mkdir(). */
36 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
41 # define S_IFMT 0170000
44 #if STAT_MACROS_BROKEN
60 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
68 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
76 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
82 #ifndef S_ISDOOR /* Solaris 2.5 and up */
83 # define S_ISDOOR(m) 0
88 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
90 # define S_ISFIFO(m) 0
96 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
102 #ifndef S_ISMPB /* V7 */
104 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
105 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
107 # define S_ISMPB(m) 0
108 # define S_ISMPC(m) 0
112 #ifndef S_ISNAM /* Xenix */
114 # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
116 # define S_ISNAM(m) 0
120 #ifndef S_ISNWK /* HP/UX */
122 # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
124 # define S_ISNWK(m) 0
128 #ifndef S_ISPORT /* Solaris 10 and up */
129 # define S_ISPORT(m) 0
134 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
136 # define S_ISREG(m) 0
142 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
144 # define S_ISSOCK(m) 0
150 # define S_TYPEISMQ(p) 0
154 # define S_TYPEISTMO(p) 0
160 # define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
162 # define S_TYPEISSEM(p) 0
168 # define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
170 # define S_TYPEISSHM(p) 0
174 /* high performance ("contiguous data") */
176 # define S_ISCTG(p) 0
179 /* Cray DMF (data migration facility): off line, with data */
181 # define S_ISOFD(p) 0
184 /* Cray DMF (data migration facility): off line, with no data */
186 # define S_ISOFL(p) 0
189 /* 4.4BSD whiteout */
191 # define S_ISWHT(m) 0
194 /* If any of the following are undefined,
195 define them to their de facto standard values. */
197 # define S_ISUID 04000
200 # define S_ISGID 02000
203 /* S_ISVTX is a common extension to POSIX. */
205 # define S_ISVTX 01000
208 #if !S_IRUSR && S_IREAD
209 # define S_IRUSR S_IREAD
212 # define S_IRUSR 00400
215 # define S_IRGRP (S_IRUSR >> 3)
218 # define S_IROTH (S_IRUSR >> 6)
221 #if !S_IWUSR && S_IWRITE
222 # define S_IWUSR S_IWRITE
225 # define S_IWUSR 00200
228 # define S_IWGRP (S_IWUSR >> 3)
231 # define S_IWOTH (S_IWUSR >> 6)
234 #if !S_IXUSR && S_IEXEC
235 # define S_IXUSR S_IEXEC
238 # define S_IXUSR 00100
241 # define S_IXGRP (S_IXUSR >> 3)
244 # define S_IXOTH (S_IXUSR >> 6)
248 # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
251 # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
254 # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
257 /* S_IXUGO is a common extension to POSIX. */
259 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
263 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
266 /* mingw does not support symlinks, therefore it does not have lstat. But
267 without links, stat does just fine. */
274 # define mkdir rpl_mkdir
275 extern int mkdir (char const *name, mode_t mode);
277 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
278 Additionally, it declares _mkdir (and depending on compile flags, an
279 alias mkdir), only in the nonstandard <io.h>, which is included above. */
280 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
283 rpl_mkdir (char const *name, mode_t mode)
285 return _mkdir (name);
288 # define mkdir rpl_mkdir
292 #endif /* _GL_SYS_STAT_H */
293 #endif /* _GL_SYS_STAT_H */