3 Copyright (C) 1993, 1994, 2001, 2002, 2004, 2006 Free Software
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)
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.
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. */
20 /* Written by Paul Eggert and Jim Meyering. */
23 # define STAT_MACROS_H 1
25 # if ! defined S_ISREG && ! defined S_IFREG
26 # error "you must include <sys/stat.h> before including this file"
30 # define S_IFMT 0170000
33 # if STAT_MACROS_BROKEN
50 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
58 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
66 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
72 # ifndef S_ISDOOR /* Solaris 2.5 and up */
73 # define S_ISDOOR(m) 0
78 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
80 # define S_ISFIFO(m) 0
86 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
92 # ifndef S_ISMPB /* V7 */
94 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
95 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
102 # ifndef S_ISNAM /* Xenix */
104 # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
106 # define S_ISNAM(m) 0
110 # ifndef S_ISNWK /* HP/UX */
112 # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
114 # define S_ISNWK(m) 0
118 # ifndef S_ISPORT /* Solaris 10 and up */
119 # define S_ISPORT(m) 0
124 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
126 # define S_ISREG(m) 0
132 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
134 # define S_ISSOCK(m) 0
140 # define S_TYPEISMQ(p) 0
144 # define S_TYPEISTMO(p) 0
150 # define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
152 # define S_TYPEISSEM(p) 0
158 # define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
160 # define S_TYPEISSHM(p) 0
164 /* high performance ("contiguous data") */
166 # define S_ISCTG(p) 0
169 /* Cray DMF (data migration facility): off line, with data */
171 # define S_ISOFD(p) 0
174 /* Cray DMF (data migration facility): off line, with no data */
176 # define S_ISOFL(p) 0
179 /* 4.4BSD whiteout */
181 # define S_ISWHT(m) 0
184 /* If any of the following are undefined,
185 define them to their de facto standard values. */
187 # define S_ISUID 04000
190 # define S_ISGID 02000
193 /* S_ISVTX is a common extension to POSIX. */
195 # define S_ISVTX 01000
198 # if !S_IRUSR && S_IREAD
199 # define S_IRUSR S_IREAD
202 # define S_IRUSR 00400
205 # define S_IRGRP (S_IRUSR >> 3)
208 # define S_IROTH (S_IRUSR >> 6)
211 # if !S_IWUSR && S_IWRITE
212 # define S_IWUSR S_IWRITE
215 # define S_IWUSR 00200
218 # define S_IWGRP (S_IWUSR >> 3)
221 # define S_IWOTH (S_IWUSR >> 6)
224 # if !S_IXUSR && S_IEXEC
225 # define S_IXUSR S_IEXEC
228 # define S_IXUSR 00100
231 # define S_IXGRP (S_IXUSR >> 3)
234 # define S_IXOTH (S_IXUSR >> 6)
238 # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
241 # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
244 # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
247 /* S_IXUGO is a common extension to POSIX. */
249 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
253 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
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)
260 #endif /* STAT_MACROS_H */