Back to index

glibc  2.9
stat.h
Go to the documentation of this file.
00001 /* Copyright (C) 1993, 96, 97, 98, 99, 2000 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 /* Length of array allocated for file system type name.  */
00026 #define _ST_FSTYPSZ  16
00027 
00028 
00029 /* Structure describing file characteristics.  */
00030 struct stat
00031   {
00032     __dev_t st_dev;
00033     long int st_filler1[3];
00034     __ino_t st_ino;         /* File serial number.             */
00035     __mode_t st_mode;              /* File mode.  */
00036     __nlink_t st_nlink;            /* Link count.  */
00037     __uid_t st_uid;         /* User ID of the file's owner.    */
00038     __gid_t st_gid;         /* Group ID of the file's group.*/
00039     __dev_t st_rdev; /* Device number, if device.  */
00040     long int st_filler2[2];
00041 
00042     __off_t st_size;        /* Size of file, in bytes.  */
00043     /* SVR4 added this extra long to allow for expansion of off_t.  */
00044     long int st_filler3;
00045 
00046     __time_t st_atime;             /* Time of last access.  */
00047     unsigned long int st_atime_usec;
00048     __time_t st_mtime;             /* Time of last modification.  */
00049     unsigned long int st_mtime_usec;
00050     __time_t st_ctime;             /* Time of last status change.  */
00051     unsigned long int st_ctime_usec;
00052 
00053     __blksize_t st_blksize; /* Optimal block size for I/O.  */
00054 #define       _STATBUF_ST_BLKSIZE  /* Tell code we have this member.  */
00055 
00056     __blkcnt_t st_blocks;   /* Number of 512-byte blocks allocated.  */
00057     char st_fstype[_ST_FSTYPSZ];
00058     long int st_filler4[8];
00059   };
00060 
00061 #ifdef __USE_LARGEFILE64
00062 /* struct stat64 has the shape as stat */
00063 struct stat64
00064   {
00065     __dev_t st_dev;                /* Device */
00066     long int st_filler1[2];
00067     __ino64_t st_ino;                     /* File serial number */
00068     __mode_t st_mode;                     /* File mode */
00069     __nlink_t st_nlink;                   /* Link count */
00070     __uid_t st_uid;                /* User ID of the file's owner. */
00071     __gid_t st_gid;                /* Group ID of the file's group.*/
00072     __dev_t st_rdev;               /* Device number, if device */
00073     long int st_filler2;
00074 
00075     __off64_t st_size;                    /* Size of file, in bytes. */
00076 
00077     __time_t st_atime;                    /* Time of last access */
00078     unsigned long int st_atime_usec;
00079     __time_t st_mtime;                    /* Time of last modification */
00080     unsigned long int st_mtime_usec;
00081     __time_t st_ctime;                    /* Time of last status change */
00082     unsigned long int st_ctime_usec;
00083 
00084     __blksize_t st_blksize;
00085     __blkcnt64_t st_blocks;
00086     char st_fstype[_ST_FSTYPSZ];
00087     long int st_filler3[8];
00088 };
00089 #endif
00090 
00091 
00092 /* Encoding of the file mode.  */
00093 
00094 #define       __S_IFMT      0170000       /* These bits determine file type.  */
00095 
00096 /* File types.  */
00097 #define       __S_IFDIR     0040000       /* Directory.  */
00098 #define       __S_IFCHR     0020000       /* Character device.  */
00099 #define       __S_IFBLK     0060000       /* Block device.  */
00100 #define       __S_IFREG     0100000       /* Regular file.  */
00101 #define       __S_IFIFO     0010000       /* FIFO.  */
00102 
00103 /* These don't actually exist on System V, but having them doesn't hurt.  */
00104 #define       __S_IFLNK     0120000       /* Symbolic link.  */
00105 #define       __S_IFSOCK    0140000       /* Socket.  */
00106 
00107 /* POSIX.1b objects.  */
00108 #define __S_TYPEISMQ(buf) (0)
00109 #define __S_TYPEISSEM(buf) (0)
00110 #define __S_TYPEISSHM(buf) (0)
00111 
00112 /* Protection bits.  */
00113 
00114 #define       __S_ISUID     04000  /* Set user ID on execution.  */
00115 #define       __S_ISGID     02000  /* Set group ID on execution.  */
00116 #define       __S_ISVTX     01000  /* Save swapped text after use (sticky).  */
00117 #define       __S_IREAD     0400   /* Read by owner.  */
00118 #define       __S_IWRITE    0200   /* Write by owner.  */
00119 #define       __S_IEXEC     0100   /* Execute by owner.  */