3 Copyright (C) 1993, 1994, 2001, 2002, 2004 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19 /* Written by Paul Eggert and Jim Meyering. */
22 # define STAT_MACROS_H 1
24 # if ! defined S_ISREG && ! defined S_IFREG
25 # error "you must include <sys/stat.h> before including this file"
29 # define S_IFMT 0170000
32 # 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 */
74 # define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
76 # define S_ISDOOR(m) 0
82 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
84 # define S_ISFIFO(m) 0
90 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
96 # ifndef S_ISMPB /* V7 */
98 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
99 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
101 # define S_ISMPB(m) 0
102 # define S_ISMPC(m) 0
106 # ifndef S_ISNAM /* Xenix */
108 # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
110 # define S_ISNAM(m) 0
114 # ifndef S_ISNWK /* HP/UX */
116 # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
118 # define S_ISNWK(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
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 /* If any of the following are undefined,
180 define them to their de facto standard values. */
182 # define S_ISUID 04000
185 # define S_ISGID 02000
188 /* S_ISVTX is a common extension to POSIX. */
190 # define S_ISVTX 01000
193 # if !S_IRUSR && S_IREAD
194 # define S_IRUSR S_IREAD
197 # define S_IRUSR 00400
200 # define S_IRGRP (S_IRUSR >> 3)
203 # define S_IROTH (S_IRUSR >> 6)
206 # if !S_IWUSR && S_IWRITE
207 # define S_IWUSR S_IWRITE
210 # define S_IWUSR 00200
213 # define S_IWGRP (S_IWUSR >> 3)
216 # define S_IWOTH (S_IWUSR >> 6)
219 # if !S_IXUSR && S_IEXEC
220 # define S_IXUSR S_IEXEC
223 # define S_IXUSR 00100
226 # define S_IXGRP (S_IXUSR >> 3)
229 # define S_IXOTH (S_IXUSR >> 6)
233 # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
236 # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
239 # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
242 /* S_IXUGO is a common extension to POSIX. */
244 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
248 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
251 /* All the mode bits that can be affected by chmod. */
252 # define CHMOD_MODE_BITS \
253 (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
255 #endif /* STAT_MACROS_H */