1 /* Provide a more complete sys/stat header file.
2 Copyright (C) 2006, 2007 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 /* The include_next requires a split double-inclusion guard. */
27 #if @HAVE_INCLUDE_NEXT@
28 # include_next <sys/stat.h>
30 # include @ABSOLUTE_SYS_STAT_H@
33 #ifndef _GL_SYS_STAT_H
34 #define _GL_SYS_STAT_H
37 # define S_IFMT 0170000
40 #if STAT_MACROS_BROKEN
56 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
64 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
72 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
78 #ifndef S_ISDOOR /* Solaris 2.5 and up */
79 # define S_ISDOOR(m) 0
84 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
86 # define S_ISFIFO(m) 0
92 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
98 #ifndef S_ISMPB /* V7 */
100 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
101 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
103 # define S_ISMPB(m) 0
104 # define S_ISMPC(m) 0
108 #ifndef S_ISNAM /* Xenix */
110 # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
112 # define S_ISNAM(m) 0
116 #ifndef S_ISNWK /* HP/UX */
118 # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
120 # define S_ISNWK(m) 0
124 #ifndef S_ISPORT /* Solaris 10 and up */
125 # define S_ISPORT(m) 0
130 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
132 # define S_ISREG(m) 0
138 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
140 # define S_ISSOCK(m) 0
146 # define S_TYPEISMQ(p) 0
150 # define S_TYPEISTMO(p) 0
156 # define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
158 # define S_TYPEISSEM(p) 0
164 # define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
166 # define S_TYPEISSHM(p) 0
170 /* high performance ("contiguous data") */
172 # define S_ISCTG(p) 0
175 /* Cray DMF (data migration facility): off line, with data */
177 # define S_ISOFD(p) 0
180 /* Cray DMF (data migration facility): off line, with no data */
182 # define S_ISOFL(p) 0
185 /* 4.4BSD whiteout */
187 # define S_ISWHT(m) 0
190 /* If any of the following are undefined,
191 define them to their de facto standard values. */
193 # define S_ISUID 04000
196 # define S_ISGID 02000
199 /* S_ISVTX is a common extension to POSIX. */
201 # define S_ISVTX 01000
204 #if !S_IRUSR && S_IREAD
205 # define S_IRUSR S_IREAD
208 # define S_IRUSR 00400
211 # define S_IRGRP (S_IRUSR >> 3)
214 # define S_IROTH (S_IRUSR >> 6)
217 #if !S_IWUSR && S_IWRITE
218 # define S_IWUSR S_IWRITE
221 # define S_IWUSR 00200
224 # define S_IWGRP (S_IWUSR >> 3)
227 # define S_IWOTH (S_IWUSR >> 6)
230 #if !S_IXUSR && S_IEXEC
231 # define S_IXUSR S_IEXEC
234 # define S_IXUSR 00100
237 # define S_IXGRP (S_IXUSR >> 3)
240 # define S_IXOTH (S_IXUSR >> 6)
244 # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
247 # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
250 # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
253 /* S_IXUGO is a common extension to POSIX. */
255 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
259 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
262 /* mingw does not support symlinks, therefore it does not have lstat. But
263 without links, stat does just fine. */
268 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
269 Additionally, it declares _mkdir (and depending on compile flags, an
270 alias mkdir), only in the nonstandard io.h. */
271 #if ! @HAVE_DECL_MKDIR@ && @HAVE_IO_H@
275 rpl_mkdir (char const *name, mode_t mode)
277 return _mkdir (name);
280 # define mkdir rpl_mkdir
283 #endif /* _GL_SYS_STAT_H */
284 #endif /* _GL_SYS_STAT_H */