Back to index

glibc  2.9
stat.h
Go to the documentation of this file.
00001 /* Copyright (C) 1992, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004,
00002        2007 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef _SYS_STAT_H
00021 # error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
00022 #endif
00023 
00024 #include <sgidefs.h>
00025 
00026 /* Versions of the `struct stat' data structure.  */
00027 #define _STAT_VER_LINUX_OLD 1
00028 #define _STAT_VER_KERNEL    1
00029 #define _STAT_VER_SVR4             2
00030 #define _STAT_VER_LINUX            3
00031 #define _STAT_VER           _STAT_VER_LINUX /* The one defined below.  */
00032 
00033 /* Versions of the `xmknod' interface.  */
00034 #define _MKNOD_VER_LINUX    1
00035 #define _MKNOD_VER_SVR4            2
00036 #define _MKNOD_VER          _MKNOD_VER_LINUX /* The bits defined below.  */
00037 
00038 
00039 #if _MIPS_SIM == _ABIO32
00040 /* Structure describing file characteristics.  */
00041 struct stat
00042   {
00043     unsigned long int st_dev;
00044     long int st_pad1[3];
00045 #ifndef __USE_FILE_OFFSET64
00046     __ino_t st_ino;         /* File serial number.             */
00047 #else
00048     __ino64_t st_ino;              /* File serial number.             */
00049 #endif
00050     __mode_t st_mode;              /* File mode.  */
00051     __nlink_t st_nlink;            /* Link count.  */
00052     __uid_t st_uid;         /* User ID of the file's owner.    */
00053     __gid_t st_gid;         /* Group ID of the file's group.*/
00054     unsigned long int st_rdev;     /* Device number, if device.  */
00055 #ifndef __USE_FILE_OFFSET64
00056     long int st_pad2[2];
00057     __off_t st_size;        /* Size of file, in bytes.  */
00058     /* SVR4 added this extra long to allow for expansion of off_t.  */
00059     long int st_pad3;
00060 #else
00061     long int st_pad2[3];
00062     __off64_t st_size;             /* Size of file, in bytes.  */
00063 #endif
00064 #ifdef __USE_MISC
00065     /* Nanosecond resolution timestamps are stored in a format
00066        equivalent to 'struct timespec'.  This is the type used
00067        whenever possible but the Unix namespace rules do not allow the
00068        identifier 'timespec' to appear in the <sys/stat.h> header.
00069        Therefore we have to handle the use of this header in strictly
00070        standard-compliant sources special.  */
00071     struct timespec st_atim;            /* Time of last access.  */
00072     struct timespec st_mtim;            /* Time of last modification.  */
00073     struct timespec st_ctim;            /* Time of last status change.  */
00074 # define st_atime st_atim.tv_sec        /* Backward compatibility.  */
00075 # define st_mtime st_mtim.tv_sec
00076 # define st_ctime st_ctim.tv_sec
00077 #else
00078     __time_t st_atime;             /* Time of last access.  */
00079     long int __reserved0;
00080     __time_t st_mtime;             /* Time of last modification.  */
00081     long int __reserved1;
00082     __time_t st_ctime;             /* Time of last status change.  */
00083     long int __reserved2;
00084 #endif
00085     __blksize_t st_blksize; /* Optimal block size for I/O.  */
00086 #ifndef __USE_FILE_OFFSET64
00087     __blkcnt_t st_blocks;   /* Number of 512-byte blocks allocated.  */
00088 #else
00089     long int st_pad4;
00090     __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated.  */
00091 #endif
00092     long int st_pad5[14];
00093   };
00094 
00095 #ifdef __USE_LARGEFILE64
00096 struct stat64
00097   {
00098     unsigned long int st_dev;
00099     long int st_pad1[3];
00100     __ino64_t st_ino;              /* File serial number.             */
00101     __mode_t st_mode;              /* File mode.  */
00102     __nlink_t st_nlink;            /* Link count.  */
00103     __uid_t st_uid;         /* User ID of the file's owner.    */
00104     __gid_t st_gid;         /* Group ID of the file's group.*/
00105     unsigned long int st_rdev;     /* Device number, if device.  */
00106     long int st_pad2[3];
00107     __off64_t st_size;             /* Size of file, in bytes.  */
00108 #ifdef __USE_MISC
00109     /* Nanosecond resolution timestamps are stored in a format
00110        equivalent to 'struct timespec'.  This is the type used
00111        whenever possible but the Unix namespace rules do not allow the
00112        identifier 'timespec' to appear in the <sys/stat.h> header.
00113        Therefore we have to handle the use of this header in strictly
00114        standard-compliant sources special.  */
00115     struct timespec st_atim;            /* Time of last access.  */
00116     struct timespec st_mtim;            /* Time of last modification.  */
00117     struct timespec st_ctim;            /* Time of last status change.  */
00118 #else
00119     __time_t st_atime;             /* Time of last access.  */
00120     long int __reserved0;
00121     __time_t st_mtime;             /* Time of last modification.  */
00122     long int __reserved1;
00123     __time_t st_ctime;             /* Time of last status change.  */
00124     long int __reserved2;
00125 #endif
00126     __blksize_t st_blksize; /* Optimal block size for I/O.  */
00127     long int st_pad3;
00128     __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated.  */
00129     long int st_pad4[14];
00130   };
00131 #endif
00132 #else
00133 struct stat
00134   {
00135     __dev_t st_dev;
00136     int       st_pad1[3];          /* Reserved for st_dev expansion  */
00137 #ifndef __USE_FILE_OFFSET64
00138     __ino_t st_ino;
00139 #else
00140     __ino64_t st_ino;
00141 #endif
00142     __mode_t st_mode;
00143     __nlink_t st_nlink;
00144     __uid_t st_uid;
00145     __gid_t st_gid;
00146     __dev_t st_rdev;
00147 #if !defined __USE_FILE_OFFSET64
00148     unsigned int st_pad2[2];       /* Reserved for st_rdev expansion  */
00149     __off_t st_size;
00150     int st_pad3;
00151 #else
00152     unsigned int st_pad2[3];       /* Reserved for st_rdev expansion  */
00153     __off64_t st_size;
00154 #endif
00155 #ifdef __USE_MISC
00156     /* Nanosecond resolution timestamps are stored in a format
00157        equivalent to 'struct timespec'.  This is the type used
00158        whenever possible but the Unix namespace rules do not allow the
00159        identifier 'timespec' to appear in the <sys/stat.h> header.
00160        Therefore we have to handle the use of this header in strictly
00161        standard-compliant sources special.  */
00162     struct timespec st_atim;            /* Time of last access.  */
00163     struct timespec st_mtim;            /* Time of last modification.  */
00164     struct timespec st_ctim;            /* Time of last status change.  */
00165 # define st_atime st_atim.tv_sec        /* Backward compatibility.  */
00166 # define st_mtime st_mtim.tv_sec
00167 # define st_ctime st_ctim.tv_sec
00168 #else
00169     __time_t st_atime;
00170     int __reserved0;
00171     __time_t st_mtime;
00172     int __reserved1;
00173     __time_t st_ctime;
00174     int __reserved2;
00175 #endif
00176     __blksize_t st_blksize;
00177     unsigned int st_pad4;
00178 #ifndef __USE_FILE_OFFSET64
00179     __blkcnt_t st_blocks;
00180 #else
00181     __blkcnt64_t st_blocks;
00182 #endif
00183     int st_pad5[14];
00184   };
00185 
00186 #ifdef __USE_LARGEFILE64
00187 struct stat64
00188   {
00189     __dev_t st_dev;
00190     unsigned int st_pad1[3];       /* Reserved for st_dev expansion  */
00191     __ino64_t st_ino;
00192     __mode_t st_mode;
00193     __nlink_t st_nlink;
00194     __uid_t st_uid;
00195     __gid_t st_gid;
00196     __dev_t st_rdev;
00197     unsigned int st_pad2[3];       /* Reserved for st_rdev expansion  */
00198     __off64_t st_size;
00199 #ifdef __USE_MISC
00200     /* Nanosecond resolution timestamps are stored in a format
00201        equivalent to 'struct timespec'.  This is the type used
00202        whenever possible but the Unix namespace rules do not allow the
00203        identifier 'timespec' to appear in the <sys/stat.h> header.
00204        Therefore we have to handle the use of this header in strictly
00205        standard-compliant sources special.  */
00206     struct timespec st_atim;            /* Time of last access.  */
00207     struct timespec st_mtim;            /* Time of last modification.  */
00208     struct timespec st_ctim;            /* Time of last status change.  */
00209 #else
00210     __time_t st_atime;
00211     int __reserved0;
00212     __time_t st_mtime;
00213     int __reserved1;
00214     __time_t st_ctime;
00215     int __reserved2;
00216 #endif
00217     __blksize_t st_blksize;
00218     unsigned int st_pad3;
00219     __blkcnt64_t st_blocks;
00220     int st_pad4[14];
00221 };
00222 #endif
00223 #endif
00224 
00225 /* Tell code we have these members.  */
00226 #define       _STATBUF_ST_BLKSIZE
00227 #define       _STATBUF_ST_RDEV
00228 
00229 /* Encoding of the file mode.  */
00230 
00231 #define       __S_IFMT      0170000       /* These bits determine file type.  */
00232 
00233 /* File types.  */
00234 #define       __S_IFDIR     0040000       /* Directory.  */
00235 #define       __S_IFCHR     0020000       /* Character device.  */
00236 #define       __S_IFBLK     0060000       /* Block device.  */
00237 #define       __S_IFREG     0100000       /* Regular file.  */
00238 #define       __S_IFIFO     0010000       /* FIFO.  */
00239 #define       __S_IFLNK     0120000       /* Symbolic link.  */
00240 #define       __S_IFSOCK    0140000       /* Socket.  */
00241 
00242 /* POSIX.1b objects.  Note that these macros always evaluate to zero.  But
00243    they do it by enforcing the correct use of the macros.  */
00244 #define __S_TYPEISMQ(buf)  ((buf)->st_mode - (buf)->st_mode)
00245 #define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
00246 #define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
00247 
00248 /* Protection bits.  */
00249 
00250 #define       __S_ISUID     04000  /* Set user ID on execution.  */
00251 #define       __S_ISGID     02000  /* Set group ID on execution.  */
00252 #define       __S_ISVTX     01000  /* Save swapped text after use (sticky).  */
00253 #define       __S_IREAD     0400   /* Read by owner.  */
00254 #define       __S_IWRITE    0200   /* Write by owner.  */
00255 #define       __S_IEXEC     0100   /* Execute by owner.  */
00256 
00257 #if defined __USE_ATFILE || defined __USE_GNU
00258 /* XXX This will change to the macro for the next 2008 POSIX revision.  */
00259 # define UTIME_NOW   ((1l << 30) - 1l)
00260 # define UTIME_OMIT  ((1l << 30) - 2l)
00261 #endif