1/* Provide a more complete sys/stat header file. 2 Copyright (C) 2006, 2007 Free Software Foundation, Inc. 3 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) 7 any later version. 8 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. 13 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. */ 17 18/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */ 19 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. */ 23 24#ifndef _GL_SYS_STAT_H 25 26/* The include_next requires a split double-inclusion guard. */ 27#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@ 28 29#ifndef _GL_SYS_STAT_H 30#define _GL_SYS_STAT_H 31 32#ifndef S_IFMT 33# define S_IFMT 0170000 34#endif 35 36#if STAT_MACROS_BROKEN 37# undef S_ISBLK 38# undef S_ISCHR 39# undef S_ISDIR 40# undef S_ISFIFO 41# undef S_ISLNK 42# undef S_ISNAM 43# undef S_ISMPB 44# undef S_ISMPC 45# undef S_ISNWK 46# undef S_ISREG 47# undef S_ISSOCK 48#endif 49 50#ifndef S_ISBLK 51# ifdef S_IFBLK 52# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) 53# else 54# define S_ISBLK(m) 0 55# endif 56#endif 57 58#ifndef S_ISCHR 59# ifdef S_IFCHR 60# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) 61# else 62# define S_ISCHR(m) 0 63# endif 64#endif 65 66#ifndef S_ISDIR 67# ifdef S_IFDIR 68# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 69# else 70# define S_ISDIR(m) 0 71# endif 72#endif 73 74#ifndef S_ISDOOR /* Solaris 2.5 and up */ 75# define S_ISDOOR(m) 0 76#endif 77 78#ifndef S_ISFIFO 79# ifdef S_IFIFO 80# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) 81# else 82# define S_ISFIFO(m) 0 83# endif 84#endif 85 86#ifndef S_ISLNK 87# ifdef S_IFLNK 88# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) 89# else 90# define S_ISLNK(m) 0 91# endif 92#endif 93 94#ifndef S_ISMPB /* V7 */ 95# ifdef S_IFMPB 96# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) 97# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) 98# else 99# define S_ISMPB(m) 0 100# define S_ISMPC(m) 0 101# endif 102#endif 103 104#ifndef S_ISNAM /* Xenix */ 105# ifdef S_IFNAM 106# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM) 107# else 108# define S_ISNAM(m) 0 109# endif 110#endif 111 112#ifndef S_ISNWK /* HP/UX */ 113# ifdef S_IFNWK 114# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) 115# else 116# define S_ISNWK(m) 0 117# endif 118#endif 119 120#ifndef S_ISPORT /* Solaris 10 and up */ 121# define S_ISPORT(m) 0 122#endif 123 124#ifndef S_ISREG 125# ifdef S_IFREG 126# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 127# else 128# define S_ISREG(m) 0 129# endif 130#endif 131 132#ifndef S_ISSOCK 133# ifdef S_IFSOCK 134# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) 135# else 136# define S_ISSOCK(m) 0 137# endif 138#endif 139 140 141#ifndef S_TYPEISMQ 142# define S_TYPEISMQ(p) 0 143#endif 144 145#ifndef S_TYPEISTMO 146# define S_TYPEISTMO(p) 0 147#endif 148 149 150#ifndef S_TYPEISSEM 151# ifdef S_INSEM 152# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM) 153# else 154# define S_TYPEISSEM(p) 0 155# endif 156#endif 157 158#ifndef S_TYPEISSHM 159# ifdef S_INSHD 160# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD) 161# else 162# define S_TYPEISSHM(p) 0 163# endif 164#endif 165 166/* high performance ("contiguous data") */ 167#ifndef S_ISCTG 168# define S_ISCTG(p) 0 169#endif 170 171/* Cray DMF (data migration facility): off line, with data */ 172#ifndef S_ISOFD 173# define S_ISOFD(p) 0 174#endif 175 176/* Cray DMF (data migration facility): off line, with no data */ 177#ifndef S_ISOFL 178# define S_ISOFL(p) 0 179#endif 180 181/* 4.4BSD whiteout */ 182#ifndef S_ISWHT 183# define S_ISWHT(m) 0 184#endif 185 186/* If any of the following are undefined, 187 define them to their de facto standard values. */ 188#if !S_ISUID 189# define S_ISUID 04000 190#endif 191#if !S_ISGID 192# define S_ISGID 02000 193#endif 194 195/* S_ISVTX is a common extension to POSIX. */ 196#ifndef S_ISVTX 197# define S_ISVTX 01000 198#endif 199 200#if !S_IRUSR && S_IREAD 201# define S_IRUSR S_IREAD 202#endif 203#if !S_IRUSR 204# define S_IRUSR 00400 205#endif 206#if !S_IRGRP 207# define S_IRGRP (S_IRUSR >> 3) 208#endif 209#if !S_IROTH 210# define S_IROTH (S_IRUSR >> 6) 211#endif 212 213#if !S_IWUSR && S_IWRITE 214# define S_IWUSR S_IWRITE 215#endif 216#if !S_IWUSR 217# define S_IWUSR 00200 218#endif 219#if !S_IWGRP 220# define S_IWGRP (S_IWUSR >> 3) 221#endif 222#if !S_IWOTH 223# define S_IWOTH (S_IWUSR >> 6) 224#endif 225 226#if !S_IXUSR && S_IEXEC 227# define S_IXUSR S_IEXEC 228#endif 229#if !S_IXUSR 230# define S_IXUSR 00100 231#endif 232#if !S_IXGRP 233# define S_IXGRP (S_IXUSR >> 3) 234#endif 235#if !S_IXOTH 236# define S_IXOTH (S_IXUSR >> 6) 237#endif 238 239#if !S_IRWXU 240# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) 241#endif 242#if !S_IRWXG 243# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) 244#endif 245#if !S_IRWXO 246# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) 247#endif 248 249/* S_IXUGO is a common extension to POSIX. */ 250#if !S_IXUGO 251# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) 252#endif 253 254#ifndef S_IRWXUGO 255# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) 256#endif 257 258/* mingw does not support symlinks, therefore it does not have lstat. But 259 without links, stat does just fine. */ 260#if ! @HAVE_LSTAT@ 261# define lstat stat 262#endif 263 264/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. 265 Additionally, it declares _mkdir (and depending on compile flags, an 266 alias mkdir), only in the nonstandard io.h. */ 267#if ! @HAVE_DECL_MKDIR@ && @HAVE_IO_H@ 268# include <io.h> 269 270static inline int 271rpl_mkdir (char const *name, mode_t mode) 272{ 273 return _mkdir (name); 274} 275 276# define mkdir rpl_mkdir 277#endif 278 279#endif /* _GL_SYS_STAT_H */ 280#endif /* _GL_SYS_STAT_H */ 281