Back to index

glibc  2.9
stat.h
Go to the documentation of this file.
00001 /* Copyright (C) 1992,93,94,96,97,99,2000,2005 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #ifndef _SYS_STAT_H
00020 # error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
00021 #endif
00022 
00023 #include <bits/types.h>
00024 
00025 /* NOTE: The size of this structure (32 ints) is known in
00026    <hurd/hurd_types.defs>, since it is used in the `io_stat' RPC.  MiG
00027    does not cope at all well with the passed C structure not being of
00028    the expected size.  There are some filler words at the end to allow
00029    for future expansion.  To increase the size of the structure used
00030    in the RPC and retain binary compatibility, we would need to assign
00031    a new message number.  */
00032 
00033 struct stat
00034   {
00035     int st_fstype;          /* File system type.  */
00036     __fsid_t st_fsid;              /* File system ID.  */
00037 #define       st_dev st_fsid
00038 
00039 #ifndef __USE_FILE_OFFSET64
00040     __ino_t st_ino;         /* File number.  */
00041 #else
00042     __ino64_t st_ino;              /* File number.  */
00043 #endif
00044     unsigned int st_gen;    /* To detect reuse of file numbers.  */
00045     __dev_t st_rdev;        /* Device if special file.  */
00046     __mode_t st_mode;              /* File mode.  */
00047     __nlink_t st_nlink;            /* Number of links.  */
00048 
00049     __uid_t st_uid;         /* Owner.  */
00050     __gid_t st_gid;         /* Owning group.  */
00051 
00052 #ifndef __USE_FILE_OFFSET64
00053     __off_t st_size;        /* Size in bytes.  */
00054 #else
00055     __off64_t st_size;             /* Size in bytes.  */
00056 #endif
00057 
00058     __time_t st_atime;             /* Access time, seconds */
00059     unsigned long int st_atime_usec; /* and microseconds.  */
00060     __time_t st_mtime;             /* Modification time, seconds */
00061     unsigned long int st_mtime_usec; /* and microseconds.  */
00062     __time_t st_ctime;             /* Status change time, seconds */
00063     unsigned long int st_ctime_usec; /* and microseconds.  */
00064 
00065     __blksize_t st_blksize; /* Optimal size for I/O.  */
00066 
00067 #ifndef __USE_FILE_OFFSET64
00068     __blkcnt_t st_blocks;   /* Number of 512-byte blocks allocated.
00069                                Not related to `st_blksize'.  */
00070 #else
00071     __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated.
00072                                Not related to `st_blksize'.  */
00073 #endif
00074 
00075     __uid_t st_author;             /* File author.  */
00076 
00077     unsigned int st_flags;  /* User-defined flags.
00078                                High 16 bits can be set only by root.  */
00079 
00080 #ifndef __USE_FILE_OFFSET64
00081 # define _SPARE_SIZE ((sizeof (__fsid_t) == sizeof (int)) ? 12 : 11)
00082 #else
00083 # define _SPARE_SIZE ((sizeof (__fsid_t) == sizeof (int)) ? 9 : 8)
00084 #endif
00085     int st_spare[_SPARE_SIZE];     /* Room for future expansion.  */
00086 #undef _SPARE_SIZE
00087   };
00088 
00089 #ifdef __USE_LARGEFILE64
00090 struct stat64
00091   {
00092     int st_fstype;          /* File system type.  */
00093     __fsid_t st_fsid;              /* File system ID.  */
00094 # define st_dev      st_fsid
00095 
00096     __ino64_t st_ino;              /* File number.  */
00097     unsigned int st_gen;    /* To detect reuse of file numbers.  */
00098     __dev_t st_rdev;        /* Device if special file.  */
00099     __mode_t st_mode;              /* File mode.  */
00100     __nlink_t st_nlink;            /* Number of links.  */
00101 
00102     __uid_t st_uid;         /* Owner.  */
00103     __gid_t st_gid;         /* Owning group.  */
00104 
00105     __off64_t st_size;             /* Size in bytes.  */
00106 
00107     __time_t st_atime;             /* Access time, seconds */
00108     unsigned long int st_atime_usec; /* and microseconds.  */
00109     __time_t st_mtime;             /* Modification time, seconds */
00110     unsigned long int st_mtime_usec; /* and microseconds.  */
00111     __time_t st_ctime;             /* Status change time, seconds */
00112     unsigned long int st_ctime_usec; /* and microseconds.  */
00113 
00114     __blksize_t st_blksize; /* Optimal size for I/O.  */
00115 
00116     __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated.
00117                                Not related to `st_blksize'.  */
00118 
00119     __uid_t st_author;             /* File author.  */
00120 
00121     unsigned int st_flags;  /* User-defined flags.
00122                                High 16 bits can be set only by root.  */
00123 
00124 #define _SPARE_SIZE  ((sizeof (__fsid_t) == sizeof (int)) ? 9 : 8)
00125     int st_spare[_SPARE_SIZE];     /* Room for future expansion.  */
00126 #undef _SPARE_SIZE
00127   };
00128 #endif
00129 
00130 #define       _STATBUF_ST_BLKSIZE  /* Tell code we have this member.  */
00131 
00132 /* Encoding of the file mode.  */
00133 
00134 #define       __S_IFMT      0170000       /* These bits determine file type.  */
00135 
00136 /* File types.  */
00137 #define       __S_IFDIR     0040000       /* Directory.  */
00138 #define       __S_IFCHR     0020000       /* Character device.  */
00139 #define       __S_IFBLK     0060000       /* Block device.  */
00140 #define       __S_IFREG     0100000       /* Regular file.  */
00141 #define       __S_IFLNK     0120000       /* Symbolic link.  */
00142 #define       __S_IFSOCK    0140000       /* Socket.  */
00143 #define       __S_IFIFO     0010000       /* FIFO.  */
00144 
00145 /* POSIX.1b objects.  */
00146 #define __S_TYPEISMQ(buf) (0)
00147 #define __S_TYPEISSEM(buf) (0)
00148 #define __S_TYPEISSHM(buf) (0)
00149 
00150 /* Protection bits.  */
00151 
00152 #define       __S_ISUID     04000  /* Set user ID on execution.  */
00153 #define       __S_ISGID     02000  /* Set group ID on execution.  */
00154 #define       __S_ISVTX     01000  /* Save swapped text after use (sticky).  */
00155 #define       __S_IREAD     00400  /* Read by owner.  */
00156 #define       __S_IWRITE    00200  /* Write by owner.  */
00157 #define       __S_IEXEC     00100  /* Execute by owner.  */
00158 
00159 
00160 #ifdef __USE_GNU
00161 /* If set, there is no benefit in caching the contents of this file.  */
00162 #define S_INOCACHE   000000200000
00163 
00164 /* If the S_IUSEUNK bit is set, then the S_IUNKNOWN bits (see below)
00165    control access for unknown users.  If S_IUSEUNK is clear, then unknown
00166    users are treated as "others" for purposes of access control.  */
00167 #define S_IUSEUNK    000000400000
00168 /* Mask of protection bits for unknown users (no effective IDs at all).  */
00169 #define S_IUNKNOWN      000007000000
00170 /* Shift S_IREAD, S_IWRITE, S_IEXEC left this many bits to produce the
00171    protection bits for unknown users.  */
00172 #define S_IUNKSHIFT  12
00173 
00174 /* Read only bits: */
00175 
00176 /* There is a passive translator set for this file */
00177 #define S_IPTRANS    000010000000
00178 /* There is an active translator running on this file */
00179 #define S_IATRANS    000020000000
00180 /* This is the root of a filesystem (or single node translator) */
00181 #define S_IROOT             000040000000
00182 /* All the bits relevant to translators */
00183 #define S_ITRANS     000070000000
00184 
00185 /* Definitely no mmaps to this.  */
00186 #define S_IMMAP0     000100000000
00187 
00188 /* ALL the unused bits.  */
00189 #define       S_ISPARE      (~(S_IFMT|S_ITRANS|S_INOCACHE|S_IMMAP0|    \
00190                         S_IUSEUNK|S_IUNKNOWN|07777))
00191 #endif
00192 
00193 /* Default file creation mask (umask).  */
00194 #ifdef __USE_BSD
00195 #define       CMASK         0022
00196 #endif