1*53ee8cc1Swenshuai.xi /* Copyright (C) 1992, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2*53ee8cc1Swenshuai.xi 2007 Free Software Foundation, Inc. 3*53ee8cc1Swenshuai.xi This file is part of the GNU C Library. 4*53ee8cc1Swenshuai.xi 5*53ee8cc1Swenshuai.xi The GNU C Library is free software; you can redistribute it and/or 6*53ee8cc1Swenshuai.xi modify it under the terms of the GNU Lesser General Public 7*53ee8cc1Swenshuai.xi License as published by the Free Software Foundation; either 8*53ee8cc1Swenshuai.xi version 2.1 of the License, or (at your option) any later version. 9*53ee8cc1Swenshuai.xi 10*53ee8cc1Swenshuai.xi The GNU C Library is distributed in the hope that it will be useful, 11*53ee8cc1Swenshuai.xi but WITHOUT ANY WARRANTY; without even the implied warranty of 12*53ee8cc1Swenshuai.xi MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13*53ee8cc1Swenshuai.xi Lesser General Public License for more details. 14*53ee8cc1Swenshuai.xi 15*53ee8cc1Swenshuai.xi You should have received a copy of the GNU Lesser General Public 16*53ee8cc1Swenshuai.xi License along with the GNU C Library; if not, write to the Free 17*53ee8cc1Swenshuai.xi Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18*53ee8cc1Swenshuai.xi 02111-1307 USA. */ 19*53ee8cc1Swenshuai.xi 20*53ee8cc1Swenshuai.xi #ifndef _SYS_STAT_H 21*53ee8cc1Swenshuai.xi # error "Never include <bits/stat.h> directly; use <sys/stat.h> instead." 22*53ee8cc1Swenshuai.xi #endif 23*53ee8cc1Swenshuai.xi 24*53ee8cc1Swenshuai.xi #include <sgidefs.h> 25*53ee8cc1Swenshuai.xi 26*53ee8cc1Swenshuai.xi /* Versions of the `struct stat' data structure. */ 27*53ee8cc1Swenshuai.xi #define _STAT_VER_LINUX_OLD 1 28*53ee8cc1Swenshuai.xi #define _STAT_VER_KERNEL 1 29*53ee8cc1Swenshuai.xi #define _STAT_VER_SVR4 2 30*53ee8cc1Swenshuai.xi #define _STAT_VER_LINUX 3 31*53ee8cc1Swenshuai.xi #define _STAT_VER _STAT_VER_LINUX /* The one defined below. */ 32*53ee8cc1Swenshuai.xi 33*53ee8cc1Swenshuai.xi /* Versions of the `xmknod' interface. */ 34*53ee8cc1Swenshuai.xi #define _MKNOD_VER_LINUX 1 35*53ee8cc1Swenshuai.xi #define _MKNOD_VER_SVR4 2 36*53ee8cc1Swenshuai.xi #define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */ 37*53ee8cc1Swenshuai.xi 38*53ee8cc1Swenshuai.xi 39*53ee8cc1Swenshuai.xi #if _MIPS_SIM == _ABIO32 40*53ee8cc1Swenshuai.xi /* Structure describing file characteristics. */ 41*53ee8cc1Swenshuai.xi struct stat 42*53ee8cc1Swenshuai.xi { 43*53ee8cc1Swenshuai.xi unsigned long int st_dev; 44*53ee8cc1Swenshuai.xi long int st_pad1[3]; 45*53ee8cc1Swenshuai.xi #ifndef __USE_FILE_OFFSET64 46*53ee8cc1Swenshuai.xi __ino_t st_ino; /* File serial number. */ 47*53ee8cc1Swenshuai.xi #else 48*53ee8cc1Swenshuai.xi __ino64_t st_ino; /* File serial number. */ 49*53ee8cc1Swenshuai.xi #endif 50*53ee8cc1Swenshuai.xi __mode_t st_mode; /* File mode. */ 51*53ee8cc1Swenshuai.xi __nlink_t st_nlink; /* Link count. */ 52*53ee8cc1Swenshuai.xi __uid_t st_uid; /* User ID of the file's owner. */ 53*53ee8cc1Swenshuai.xi __gid_t st_gid; /* Group ID of the file's group.*/ 54*53ee8cc1Swenshuai.xi unsigned long int st_rdev; /* Device number, if device. */ 55*53ee8cc1Swenshuai.xi #ifndef __USE_FILE_OFFSET64 56*53ee8cc1Swenshuai.xi long int st_pad2[2]; 57*53ee8cc1Swenshuai.xi __off_t st_size; /* Size of file, in bytes. */ 58*53ee8cc1Swenshuai.xi /* SVR4 added this extra long to allow for expansion of off_t. */ 59*53ee8cc1Swenshuai.xi long int st_pad3; 60*53ee8cc1Swenshuai.xi #else 61*53ee8cc1Swenshuai.xi long int st_pad2[3]; 62*53ee8cc1Swenshuai.xi __off64_t st_size; /* Size of file, in bytes. */ 63*53ee8cc1Swenshuai.xi #endif 64*53ee8cc1Swenshuai.xi #ifdef __USE_MISC 65*53ee8cc1Swenshuai.xi /* Nanosecond resolution timestamps are stored in a format 66*53ee8cc1Swenshuai.xi equivalent to 'struct timespec'. This is the type used 67*53ee8cc1Swenshuai.xi whenever possible but the Unix namespace rules do not allow the 68*53ee8cc1Swenshuai.xi identifier 'timespec' to appear in the <sys/stat.h> header. 69*53ee8cc1Swenshuai.xi Therefore we have to handle the use of this header in strictly 70*53ee8cc1Swenshuai.xi standard-compliant sources special. */ 71*53ee8cc1Swenshuai.xi struct timespec st_atim; /* Time of last access. */ 72*53ee8cc1Swenshuai.xi struct timespec st_mtim; /* Time of last modification. */ 73*53ee8cc1Swenshuai.xi struct timespec st_ctim; /* Time of last status change. */ 74*53ee8cc1Swenshuai.xi # define st_atime st_atim.tv_sec /* Backward compatibility. */ 75*53ee8cc1Swenshuai.xi # define st_mtime st_mtim.tv_sec 76*53ee8cc1Swenshuai.xi # define st_ctime st_ctim.tv_sec 77*53ee8cc1Swenshuai.xi #else 78*53ee8cc1Swenshuai.xi __time_t st_atime; /* Time of last access. */ 79*53ee8cc1Swenshuai.xi long int __reserved0; 80*53ee8cc1Swenshuai.xi __time_t st_mtime; /* Time of last modification. */ 81*53ee8cc1Swenshuai.xi long int __reserved1; 82*53ee8cc1Swenshuai.xi __time_t st_ctime; /* Time of last status change. */ 83*53ee8cc1Swenshuai.xi long int __reserved2; 84*53ee8cc1Swenshuai.xi #endif 85*53ee8cc1Swenshuai.xi __blksize_t st_blksize; /* Optimal block size for I/O. */ 86*53ee8cc1Swenshuai.xi #ifndef __USE_FILE_OFFSET64 87*53ee8cc1Swenshuai.xi __blkcnt_t st_blocks; /* Number of 512-byte blocks allocated. */ 88*53ee8cc1Swenshuai.xi #else 89*53ee8cc1Swenshuai.xi long int st_pad4; 90*53ee8cc1Swenshuai.xi __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated. */ 91*53ee8cc1Swenshuai.xi #endif 92*53ee8cc1Swenshuai.xi long int st_pad5[14]; 93*53ee8cc1Swenshuai.xi }; 94*53ee8cc1Swenshuai.xi 95*53ee8cc1Swenshuai.xi #ifdef __USE_LARGEFILE64 96*53ee8cc1Swenshuai.xi struct stat64 97*53ee8cc1Swenshuai.xi { 98*53ee8cc1Swenshuai.xi unsigned long int st_dev; 99*53ee8cc1Swenshuai.xi long int st_pad1[3]; 100*53ee8cc1Swenshuai.xi __ino64_t st_ino; /* File serial number. */ 101*53ee8cc1Swenshuai.xi __mode_t st_mode; /* File mode. */ 102*53ee8cc1Swenshuai.xi __nlink_t st_nlink; /* Link count. */ 103*53ee8cc1Swenshuai.xi __uid_t st_uid; /* User ID of the file's owner. */ 104*53ee8cc1Swenshuai.xi __gid_t st_gid; /* Group ID of the file's group.*/ 105*53ee8cc1Swenshuai.xi unsigned long int st_rdev; /* Device number, if device. */ 106*53ee8cc1Swenshuai.xi long int st_pad2[3]; 107*53ee8cc1Swenshuai.xi __off64_t st_size; /* Size of file, in bytes. */ 108*53ee8cc1Swenshuai.xi #ifdef __USE_MISC 109*53ee8cc1Swenshuai.xi /* Nanosecond resolution timestamps are stored in a format 110*53ee8cc1Swenshuai.xi equivalent to 'struct timespec'. This is the type used 111*53ee8cc1Swenshuai.xi whenever possible but the Unix namespace rules do not allow the 112*53ee8cc1Swenshuai.xi identifier 'timespec' to appear in the <sys/stat.h> header. 113*53ee8cc1Swenshuai.xi Therefore we have to handle the use of this header in strictly 114*53ee8cc1Swenshuai.xi standard-compliant sources special. */ 115*53ee8cc1Swenshuai.xi struct timespec st_atim; /* Time of last access. */ 116*53ee8cc1Swenshuai.xi struct timespec st_mtim; /* Time of last modification. */ 117*53ee8cc1Swenshuai.xi struct timespec st_ctim; /* Time of last status change. */ 118*53ee8cc1Swenshuai.xi #else 119*53ee8cc1Swenshuai.xi __time_t st_atime; /* Time of last access. */ 120*53ee8cc1Swenshuai.xi long int __reserved0; 121*53ee8cc1Swenshuai.xi __time_t st_mtime; /* Time of last modification. */ 122*53ee8cc1Swenshuai.xi long int __reserved1; 123*53ee8cc1Swenshuai.xi __time_t st_ctime; /* Time of last status change. */ 124*53ee8cc1Swenshuai.xi long int __reserved2; 125*53ee8cc1Swenshuai.xi #endif 126*53ee8cc1Swenshuai.xi __blksize_t st_blksize; /* Optimal block size for I/O. */ 127*53ee8cc1Swenshuai.xi long int st_pad3; 128*53ee8cc1Swenshuai.xi __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated. */ 129*53ee8cc1Swenshuai.xi long int st_pad4[14]; 130*53ee8cc1Swenshuai.xi }; 131*53ee8cc1Swenshuai.xi #endif 132*53ee8cc1Swenshuai.xi #else 133*53ee8cc1Swenshuai.xi struct stat 134*53ee8cc1Swenshuai.xi { 135*53ee8cc1Swenshuai.xi __dev_t st_dev; 136*53ee8cc1Swenshuai.xi int st_pad1[3]; /* Reserved for st_dev expansion */ 137*53ee8cc1Swenshuai.xi #ifndef __USE_FILE_OFFSET64 138*53ee8cc1Swenshuai.xi __ino_t st_ino; 139*53ee8cc1Swenshuai.xi #else 140*53ee8cc1Swenshuai.xi __ino64_t st_ino; 141*53ee8cc1Swenshuai.xi #endif 142*53ee8cc1Swenshuai.xi __mode_t st_mode; 143*53ee8cc1Swenshuai.xi __nlink_t st_nlink; 144*53ee8cc1Swenshuai.xi __uid_t st_uid; 145*53ee8cc1Swenshuai.xi __gid_t st_gid; 146*53ee8cc1Swenshuai.xi __dev_t st_rdev; 147*53ee8cc1Swenshuai.xi #if !defined __USE_FILE_OFFSET64 148*53ee8cc1Swenshuai.xi unsigned int st_pad2[2]; /* Reserved for st_rdev expansion */ 149*53ee8cc1Swenshuai.xi __off_t st_size; 150*53ee8cc1Swenshuai.xi int st_pad3; 151*53ee8cc1Swenshuai.xi #else 152*53ee8cc1Swenshuai.xi unsigned int st_pad2[3]; /* Reserved for st_rdev expansion */ 153*53ee8cc1Swenshuai.xi __off64_t st_size; 154*53ee8cc1Swenshuai.xi #endif 155*53ee8cc1Swenshuai.xi #ifdef __USE_MISC 156*53ee8cc1Swenshuai.xi /* Nanosecond resolution timestamps are stored in a format 157*53ee8cc1Swenshuai.xi equivalent to 'struct timespec'. This is the type used 158*53ee8cc1Swenshuai.xi whenever possible but the Unix namespace rules do not allow the 159*53ee8cc1Swenshuai.xi identifier 'timespec' to appear in the <sys/stat.h> header. 160*53ee8cc1Swenshuai.xi Therefore we have to handle the use of this header in strictly 161*53ee8cc1Swenshuai.xi standard-compliant sources special. */ 162*53ee8cc1Swenshuai.xi struct timespec st_atim; /* Time of last access. */ 163*53ee8cc1Swenshuai.xi struct timespec st_mtim; /* Time of last modification. */ 164*53ee8cc1Swenshuai.xi struct timespec st_ctim; /* Time of last status change. */ 165*53ee8cc1Swenshuai.xi # define st_atime st_atim.tv_sec /* Backward compatibility. */ 166*53ee8cc1Swenshuai.xi # define st_mtime st_mtim.tv_sec 167*53ee8cc1Swenshuai.xi # define st_ctime st_ctim.tv_sec 168*53ee8cc1Swenshuai.xi #else 169*53ee8cc1Swenshuai.xi __time_t st_atime; 170*53ee8cc1Swenshuai.xi int __reserved0; 171*53ee8cc1Swenshuai.xi __time_t st_mtime; 172*53ee8cc1Swenshuai.xi int __reserved1; 173*53ee8cc1Swenshuai.xi __time_t st_ctime; 174*53ee8cc1Swenshuai.xi int __reserved2; 175*53ee8cc1Swenshuai.xi #endif 176*53ee8cc1Swenshuai.xi __blksize_t st_blksize; 177*53ee8cc1Swenshuai.xi unsigned int st_pad4; 178*53ee8cc1Swenshuai.xi #ifndef __USE_FILE_OFFSET64 179*53ee8cc1Swenshuai.xi __blkcnt_t st_blocks; 180*53ee8cc1Swenshuai.xi #else 181*53ee8cc1Swenshuai.xi __blkcnt64_t st_blocks; 182*53ee8cc1Swenshuai.xi #endif 183*53ee8cc1Swenshuai.xi int st_pad5[14]; 184*53ee8cc1Swenshuai.xi }; 185*53ee8cc1Swenshuai.xi 186*53ee8cc1Swenshuai.xi #ifdef __USE_LARGEFILE64 187*53ee8cc1Swenshuai.xi struct stat64 188*53ee8cc1Swenshuai.xi { 189*53ee8cc1Swenshuai.xi __dev_t st_dev; 190*53ee8cc1Swenshuai.xi unsigned int st_pad1[3]; /* Reserved for st_dev expansion */ 191*53ee8cc1Swenshuai.xi __ino64_t st_ino; 192*53ee8cc1Swenshuai.xi __mode_t st_mode; 193*53ee8cc1Swenshuai.xi __nlink_t st_nlink; 194*53ee8cc1Swenshuai.xi __uid_t st_uid; 195*53ee8cc1Swenshuai.xi __gid_t st_gid; 196*53ee8cc1Swenshuai.xi __dev_t st_rdev; 197*53ee8cc1Swenshuai.xi unsigned int st_pad2[3]; /* Reserved for st_rdev expansion */ 198*53ee8cc1Swenshuai.xi __off64_t st_size; 199*53ee8cc1Swenshuai.xi #ifdef __USE_MISC 200*53ee8cc1Swenshuai.xi /* Nanosecond resolution timestamps are stored in a format 201*53ee8cc1Swenshuai.xi equivalent to 'struct timespec'. This is the type used 202*53ee8cc1Swenshuai.xi whenever possible but the Unix namespace rules do not allow the 203*53ee8cc1Swenshuai.xi identifier 'timespec' to appear in the <sys/stat.h> header. 204*53ee8cc1Swenshuai.xi Therefore we have to handle the use of this header in strictly 205*53ee8cc1Swenshuai.xi standard-compliant sources special. */ 206*53ee8cc1Swenshuai.xi struct timespec st_atim; /* Time of last access. */ 207*53ee8cc1Swenshuai.xi struct timespec st_mtim; /* Time of last modification. */ 208*53ee8cc1Swenshuai.xi struct timespec st_ctim; /* Time of last status change. */ 209*53ee8cc1Swenshuai.xi #else 210*53ee8cc1Swenshuai.xi __time_t st_atime; 211*53ee8cc1Swenshuai.xi int __reserved0; 212*53ee8cc1Swenshuai.xi __time_t st_mtime; 213*53ee8cc1Swenshuai.xi int __reserved1; 214*53ee8cc1Swenshuai.xi __time_t st_ctime; 215*53ee8cc1Swenshuai.xi int __reserved2; 216*53ee8cc1Swenshuai.xi #endif 217*53ee8cc1Swenshuai.xi __blksize_t st_blksize; 218*53ee8cc1Swenshuai.xi unsigned int st_pad3; 219*53ee8cc1Swenshuai.xi __blkcnt64_t st_blocks; 220*53ee8cc1Swenshuai.xi int st_pad4[14]; 221*53ee8cc1Swenshuai.xi }; 222*53ee8cc1Swenshuai.xi #endif 223*53ee8cc1Swenshuai.xi #endif 224*53ee8cc1Swenshuai.xi 225*53ee8cc1Swenshuai.xi /* Tell code we have these members. */ 226*53ee8cc1Swenshuai.xi #define _STATBUF_ST_BLKSIZE 227*53ee8cc1Swenshuai.xi #define _STATBUF_ST_RDEV 228*53ee8cc1Swenshuai.xi 229*53ee8cc1Swenshuai.xi /* Encoding of the file mode. */ 230*53ee8cc1Swenshuai.xi 231*53ee8cc1Swenshuai.xi #define __S_IFMT 0170000 /* These bits determine file type. */ 232*53ee8cc1Swenshuai.xi 233*53ee8cc1Swenshuai.xi /* File types. */ 234*53ee8cc1Swenshuai.xi #define __S_IFDIR 0040000 /* Directory. */ 235*53ee8cc1Swenshuai.xi #define __S_IFCHR 0020000 /* Character device. */ 236*53ee8cc1Swenshuai.xi #define __S_IFBLK 0060000 /* Block device. */ 237*53ee8cc1Swenshuai.xi #define __S_IFREG 0100000 /* Regular file. */ 238*53ee8cc1Swenshuai.xi #define __S_IFIFO 0010000 /* FIFO. */ 239*53ee8cc1Swenshuai.xi #define __S_IFLNK 0120000 /* Symbolic link. */ 240*53ee8cc1Swenshuai.xi #define __S_IFSOCK 0140000 /* Socket. */ 241*53ee8cc1Swenshuai.xi 242*53ee8cc1Swenshuai.xi /* POSIX.1b objects. Note that these macros always evaluate to zero. But 243*53ee8cc1Swenshuai.xi they do it by enforcing the correct use of the macros. */ 244*53ee8cc1Swenshuai.xi #define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode) 245*53ee8cc1Swenshuai.xi #define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode) 246*53ee8cc1Swenshuai.xi #define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode) 247*53ee8cc1Swenshuai.xi 248*53ee8cc1Swenshuai.xi /* Protection bits. */ 249*53ee8cc1Swenshuai.xi 250*53ee8cc1Swenshuai.xi #define __S_ISUID 04000 /* Set user ID on execution. */ 251*53ee8cc1Swenshuai.xi #define __S_ISGID 02000 /* Set group ID on execution. */ 252*53ee8cc1Swenshuai.xi #define __S_ISVTX 01000 /* Save swapped text after use (sticky). */ 253*53ee8cc1Swenshuai.xi #define __S_IREAD 0400 /* Read by owner. */ 254*53ee8cc1Swenshuai.xi #define __S_IWRITE 0200 /* Write by owner. */ 255*53ee8cc1Swenshuai.xi #define __S_IEXEC 0100 /* Execute by owner. */ 256*53ee8cc1Swenshuai.xi 257*53ee8cc1Swenshuai.xi #if defined __USE_ATFILE || defined __USE_GNU 258*53ee8cc1Swenshuai.xi /* XXX This will change to the macro for the next 2008 POSIX revision. */ 259*53ee8cc1Swenshuai.xi # define UTIME_NOW ((1l << 30) - 1l) 260*53ee8cc1Swenshuai.xi # define UTIME_OMIT ((1l << 30) - 2l) 261*53ee8cc1Swenshuai.xi #endif 262