2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* @(#)statdefs.h 1.9 03/06/15 Copyright 1998 J. Schilling */
15 * Definitions for stat() file mode
17 * Copyright (c) 1998 J. Schilling
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License version 2
22 * as published by the Free Software Foundation.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License along with
30 * this program; see the file COPYING. If not, write to the Free Software
31 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
41 #ifndef _INCL_SYS_TYPES_H
42 #include <sys/types.h> /* Needed for sys/stat.h */
43 #define _INCL_SYS_TYPES_H
45 #ifndef _INCL_SYS_STAT_H
46 #include <sys/stat.h> /* For S_IS* and S_IF* */
47 #define _INCL_SYS_STAT_H
51 * Apollo Domain/OS has a broken sys/stat.h that defines
52 * S_IFIFO == S_IFSOCK and creates trouble if the constants
53 * are used as case labels.
55 #if S_IFIFO == S_IFSOCK
59 #ifdef STAT_MACROS_BROKEN
60 #undef S_ISFIFO /* Named pipe */
61 #undef S_ISCHR /* Character special */
62 #undef S_ISMPC /* UNUSED multiplexed c */
63 #undef S_ISDIR /* Directory */
64 #undef S_ISNAM /* Named file (XENIX) */
65 #undef S_ISBLK /* Block special */
66 #undef S_ISMPB /* UNUSED multiplexed b */
67 #undef S_ISREG /* Regular file */
68 #undef S_ISCNT /* Contiguous file */
69 #undef S_ISLNK /* Symbolic link */
70 #undef S_ISSHAD /* Solaris shadow inode */
71 #undef S_ISSOCK /* UNIX domain socket */
72 #undef S_ISDOOR /* Solaris DOOR */
73 #undef S_ISWHT /* BSD whiteout */
74 #undef S_ISEVC /* UNOS eventcount */
77 #ifndef S_ISFIFO /* 1 Named pipe */
79 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
81 # define S_ISFIFO(m) (0)
84 #ifndef S_ISCHR /* 2 Character special */
86 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
88 # define S_ISCHR(m) (0)
91 #ifndef S_ISMPC /* 3 UNUSED multiplexed char */
93 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
95 # define S_ISMPC(m) (0)
98 #ifndef S_ISDIR /* 4 Directory */
100 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
102 # define S_ISDIR(m) (0)
105 #ifndef S_ISNAM /* 5 Named file (XENIX) */
107 # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
109 # define S_ISNAM(m) (0)
112 #ifndef S_ISBLK /* 6 Block special */
114 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
116 # define S_ISBLK(m) (0)
119 #ifndef S_ISMPB /* 7 UNUSED multiplexed block */
121 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
123 # define S_ISMPB(m) (0)
126 #ifndef S_ISREG /* 8 Regular file */
128 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
130 # define S_ISREG(m) (0)
133 #ifndef S_ISCNT /* 9 Contiguous file */
135 # define S_ISCNT(m) (((m) & S_IFMT) == S_IFCNT)
137 # define S_ISCNT(m) (0)
140 #ifndef S_ISLNK /* 10 Symbolic link */
142 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
144 # define S_ISLNK(m) (0)
147 #ifndef S_ISSHAD /* 11 Solaris shadow inode */
149 # define S_ISSHAD(m) (((m) & S_IFMT) == S_IFSHAD)
151 # define S_ISSHAD(m) (0)
154 #ifndef S_ISSOCK /* 12 UNIX domain socket */
156 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
158 # define S_ISSOCK(m) (0)
161 #ifndef S_ISDOOR /* 13 Solaris DOOR */
163 # define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
165 # define S_ISDOOR(m) (0)
168 #ifndef S_ISWHT /* 14 BSD whiteout */
170 # define S_ISWHT(m) (((m) & S_IFMT) == S_ISWHT)
172 # define S_ISWHT(m) (0)
175 #ifndef S_IFEVC /* 15 UNOS eventcount */
177 # define S_ISEVC(m) (((m) & S_IFMT) == S_IFEVC)
179 # define S_ISEVC(m) (0)
185 * XXX ??? where is a definition of a message queue ???
187 # define S_TYPEISMQ(_stbuf) (0)
191 # define S_TYPEISSEM(_stbuf) (S_ISNAM((_stbuf)->st_mode) && (_stbuf)->st_rdev == S_INSEM)
193 # define S_TYPEISSEM(_stbuf) (0)
198 # define S_TYPEISSHM(_stbuf) (S_ISNAM((_stbuf)->st_mode) && (_stbuf)->st_rdev == S_INSHD)
200 # define S_TYPEISSHM(_stbuf) (0)
205 * Mode permission bits.
206 * UNIX V.7 has only S_ISUID/S_ISGID/S_ISVTX and S_IREAD/S_IWRITE/S_IEXEC
208 #ifndef S_ISUID /* Set-user-ID on execution */
209 #define S_ISUID 0 /* If it is not defined, it is not supported */
211 #ifndef S_ISGID /* Set-group-ID on execution */
212 #define S_ISGID 0 /* If it is not defined, it is not supported */
214 #ifndef S_ISVTX /* On directories, restricted deletion flag */
215 #define S_ISVTX 0 /* If it is not defined, it is not supported */
218 #ifndef S_IRUSR /* Read permission, owner */
220 #define S_IRUSR S_IREAD /* Needed on old UNIX systems */
225 #ifndef S_IWUSR /* Write permission, owner */
227 #define S_IWUSR S_IWRITE /* Needed on old UNIX systems */
232 #ifndef S_IXUSR /* Execute/search permission, owner */
234 #define S_IXUSR S_IEXEC /* Needed on old UNIX systems */
239 #ifndef S_IRGRP /* Read permission, group */
241 #define S_IRGRP (S_IREAD >> 3) /* Needed on old UNIX systems */
246 #ifndef S_IWGRP /* Write permission, group */
248 #define S_IWGRP (S_IWRITE >> 3) /* Needed on old UNIX systems */
253 #ifndef S_IXGRP /* Execute/search permission, group */
255 #define S_IXGRP (S_IEXEC >> 3) /* Needed on old UNIX systems */
260 #ifndef S_IROTH /* Read permission, others */
262 #define S_IROTH (S_IREAD >> 6) /* Needed on old UNIX systems */
267 #ifndef S_IWOTH /* Write permission, others */
269 #define S_IWOTH (S_IWRITE >> 6) /* Needed on old UNIX systems */
274 #ifndef S_IXOTH /* Execute/search permission, others */
276 #define S_IXOTH (S_IEXEC >> 6) /* Needed on old UNIX systems */
282 #ifndef S_IRWXU /* Read, write, execute/search by owner */
283 #define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
285 #ifndef S_IRWXG /* Read, write, execute/search by group */
286 #define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
288 #ifndef S_IRWXO /* Read, write, execute/search by others */
289 #define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
293 * SCO UnixWare has st_atim.st__tim.tv_nsec but the st_atim.tv_nsec tests also
294 * succeeds. If we use st_atim.tv_nsec on UnixWare, we get a warning about
295 * illegal structure usage. For this reason, our code needs to have
296 * #ifdef HAVE_ST__TIM before #ifdef HAVE_ST_NSEC.
298 #if defined(HAVE_ST_ATIMENSEC)
300 #define stat_ansecs(s) ((s)->st_atimensec)
301 #define stat_mnsecs(s) ((s)->st_mtimensec)
302 #define stat_cnsecs(s) ((s)->st_ctimensec)
304 #define _FOUND_STAT_NSECS_
307 #if defined(HAVE_ST_SPARE1) && !defined(_FOUND_STAT_NSECS_)
309 #define stat_ansecs(s) ((s)->st_spare1 * 1000)
310 #define stat_mnsecs(s) ((s)->st_spare2 * 1000)
311 #define stat_cnsecs(s) ((s)->st_spare3 * 1000)
313 #define _FOUND_STAT_USECS_
314 #define _FOUND_STAT_NSECS_
317 #if defined(HAVE_ST__TIM) && !defined(_FOUND_STAT_NSECS_)
319 #define stat_ansecs(s) ((s)->st_atim.st__tim.tv_nsec)
320 #define stat_mnsecs(s) ((s)->st_mtim.st__tim.tv_nsec)
321 #define stat_cnsecs(s) ((s)->st_ctim.st__tim.tv_nsec)
323 #define _FOUND_STAT_NSECS_
326 #if defined(HAVE_ST_NSEC) && !defined(_FOUND_STAT_NSECS_)
328 #define stat_ansecs(s) ((s)->st_atim.tv_nsec)
329 #define stat_mnsecs(s) ((s)->st_mtim.tv_nsec)
330 #define stat_cnsecs(s) ((s)->st_ctim.tv_nsec)
332 #define _FOUND_STAT_NSECS_
335 #if defined(HAVE_ST_ATIMESPEC) && !defined(_FOUND_STAT_NSECS_)
337 #define stat_ansecs(s) ((s)->st_atimespec.tv_nsec)
338 #define stat_mnsecs(s) ((s)->st_mtimespec.tv_nsec)
339 #define stat_cnsecs(s) ((s)->st_ctimespec.tv_nsec)
341 #define _FOUND_STAT_NSECS_
344 #if !defined(_FOUND_STAT_NSECS_)
345 #define stat_ansecs(s) (0)
346 #define stat_mnsecs(s) (0)
347 #define stat_cnsecs(s) (0)
350 #endif /* _STATDEFS_H */