1 /* Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library 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 GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 # error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
23 #include <bits/wordsize.h>
26 /* Versions of the `struct stat' data structure. */
27 # define _STAT_VER_KERNEL 0
28 # define _STAT_VER_LINUX 1
29 # define _STAT_VER _STAT_VER_LINUX
31 /* Versions of the `xmknod' interface. */
32 #define _MKNOD_VER_LINUX 0
34 /* Versions of the `struct stat' data structure. */
35 # define _STAT_VER_LINUX_OLD 1
36 # define _STAT_VER_KERNEL 1
37 # define _STAT_VER_SVR4 2
38 # define _STAT_VER_LINUX 3
39 # define _STAT_VER _STAT_VER_LINUX
41 /* Versions of the `xmknod' interface. */
42 # define _MKNOD_VER_LINUX 1
43 # define _MKNOD_VER_SVR4 2
44 # define _MKNOD_VER _MKNOD_VER_LINUX
50 __dev_t st_dev
; /* Device. */
51 __ino_t st_ino
; /* File serial number. */
52 __nlink_t st_nlink
; /* Link count. */
53 __mode_t st_mode
; /* File mode. */
54 __uid_t st_uid
; /* User ID of the file's owner. */
55 __gid_t st_gid
; /* Group ID of the file's group.*/
57 __dev_t st_rdev
; /* Device number, if device. */
58 __off_t st_size
; /* Size of file, in bytes. */
60 /* Nanosecond resolution timestamps are stored in a format
61 equivalent to 'struct timespec'. This is the type used
62 whenever possible but the Unix namespace rules do not allow the
63 identifier 'timespec' to appear in the <sys/stat.h> header.
64 Therefore we have to handle the use of this header in strictly
65 standard-compliant sources special. */
66 struct timespec st_atim
; /* Time of last access. */
67 struct timespec st_mtim
; /* Time of last modification. */
68 struct timespec st_ctim
; /* Time of last status change. */
69 # define st_atime st_atim.tv_sec /* Backward compatibility. */
70 # define st_mtime st_mtim.tv_sec
71 # define st_ctime st_ctim.tv_sec
73 __time_t st_atime
; /* Time of last access. */
74 unsigned long int st_atimensec
; /* Nscecs of last access. */
75 __time_t st_mtime
; /* Time of last modification. */
76 unsigned long int st_mtimensec
; /* Nsecs of last modification. */
77 __time_t st_ctime
; /* Time of last status change. */
78 unsigned long int st_ctimensec
; /* Nsecs of last status change. */
80 __blksize_t st_blksize
; /* Optimal block size for I/O. */
81 __blkcnt_t st_blocks
; /* Nr. 512-byte blocks allocated. */
87 __dev_t st_dev
; /* Device. */
89 # ifndef __USE_FILE_OFFSET64
90 __ino_t st_ino
; /* File serial number. */
92 __ino_t __st_ino
; /* 32bit file serial number. */
94 __mode_t st_mode
; /* File mode. */
95 __nlink_t st_nlink
; /* Link count. */
96 __uid_t st_uid
; /* User ID of the file's owner. */
97 __gid_t st_gid
; /* Group ID of the file's group.*/
98 __dev_t st_rdev
; /* Device number, if device. */
100 # ifndef __USE_FILE_OFFSET64
101 __off_t st_size
; /* Size of file, in bytes. */
103 __off64_t st_size
; /* Size of file, in bytes. */
105 __blksize_t st_blksize
; /* Optimal block size for I/O. */
107 # ifndef __USE_FILE_OFFSET64
108 __blkcnt_t st_blocks
; /* Number 512-byte blocks allocated. */
110 __blkcnt64_t st_blocks
; /* Number 512-byte blocks allocated. */
113 /* Nanosecond resolution timestamps are stored in a format
114 equivalent to 'struct timespec'. This is the type used
115 whenever possible but the Unix namespace rules do not allow the
116 identifier 'timespec' to appear in the <sys/stat.h> header.
117 Therefore we have to handle the use of this header in strictly
118 standard-compliant sources special. */
119 struct timespec st_atim
; /* Time of last access. */
120 struct timespec st_mtim
; /* Time of last modification. */
121 struct timespec st_ctim
; /* Time of last status change. */
122 # define st_atime st_atim.tv_sec /* Backward compatibility. */
123 # define st_mtime st_mtim.tv_sec
124 # define st_ctime st_ctim.tv_sec
126 __time_t st_atime
; /* Time of last access. */
127 unsigned long int st_atimensec
; /* Nscecs of last access. */
128 __time_t st_mtime
; /* Time of last modification. */
129 unsigned long int st_mtimensec
; /* Nsecs of last modification. */
130 __time_t st_ctime
; /* Time of last status change. */
131 unsigned long int st_ctimensec
; /* Nsecs of last status change. */
133 # ifndef __USE_FILE_OFFSET64
134 unsigned long int __unused4
;
135 unsigned long int __unused5
;
137 __ino64_t st_ino
; /* File serial number. */
142 #ifdef __USE_LARGEFILE64
143 # if __WORDSIZE == 64
144 /* Note stat64 is the same shape as stat. */
147 __dev_t st_dev
; /* Device. */
148 __ino64_t st_ino
; /* File serial number. */
149 __nlink_t st_nlink
; /* Link count. */
150 __mode_t st_mode
; /* File mode. */
151 __uid_t st_uid
; /* User ID of the file's owner. */
152 __gid_t st_gid
; /* Group ID of the file's group.*/
154 __dev_t st_rdev
; /* Device number, if device. */
155 __off_t st_size
; /* Size of file, in bytes. */
157 /* Nanosecond resolution timestamps are stored in a format
158 equivalent to 'struct timespec'. This is the type used
159 whenever possible but the Unix namespace rules do not allow the
160 identifier 'timespec' to appear in the <sys/stat.h> header.
161 Therefore we have to handle the use of this header in strictly
162 standard-compliant sources special. */
163 struct timespec st_atim
; /* Time of last access. */
164 struct timespec st_mtim
; /* Time of last modification. */
165 struct timespec st_ctim
; /* Time of last status change. */
166 # define st_atime st_atim.tv_sec /* Backward compatibility. */
167 # define st_mtime st_mtim.tv_sec
168 # define st_ctime st_ctim.tv_sec
170 __time_t st_atime
; /* Time of last access. */
171 unsigned long int st_atimensec
; /* Nscecs of last access. */
172 __time_t st_mtime
; /* Time of last modification. */
173 unsigned long int st_mtimensec
; /* Nsecs of last modification. */
174 __time_t st_ctime
; /* Time of last status change. */
175 unsigned long int st_ctimensec
; /* Nsecs of last status change. */
177 __blksize_t st_blksize
; /* Optimal block size for I/O. */
178 __blkcnt64_t st_blocks
; /* Nr. 512-byte blocks allocated. */
179 long int __unused
[3];
184 __dev_t st_dev
; /* Device. */
187 __ino_t __st_ino
; /* 32bit file serial number. */
188 __mode_t st_mode
; /* File mode. */
189 __nlink_t st_nlink
; /* Link count. */
190 __uid_t st_uid
; /* User ID of the file's owner. */
191 __gid_t st_gid
; /* Group ID of the file's group.*/
192 __dev_t st_rdev
; /* Device number, if device. */
194 __off64_t st_size
; /* Size of file, in bytes. */
195 __blksize_t st_blksize
; /* Optimal block size for I/O. */
197 __blkcnt64_t st_blocks
; /* Number 512-byte blocks allocated. */
199 /* Nanosecond resolution timestamps are stored in a format
200 equivalent to 'struct timespec'. This is the type used
201 whenever possible but the Unix namespace rules do not allow the
202 identifier 'timespec' to appear in the <sys/stat.h> header.
203 Therefore we have to handle the use of this header in strictly
204 standard-compliant sources special. */
205 struct timespec st_atim
; /* Time of last access. */
206 struct timespec st_mtim
; /* Time of last modification. */
207 struct timespec st_ctim
; /* Time of last status change. */
208 # define st_atime st_atim.tv_sec /* Backward compatibility. */
209 # define st_mtime st_mtim.tv_sec
210 # define st_ctime st_ctim.tv_sec
212 __time_t st_atime
; /* Time of last access. */
213 unsigned long int st_atimensec
; /* Nscecs of last access. */
214 __time_t st_mtime
; /* Time of last modification. */
215 unsigned long int st_mtimensec
; /* Nsecs of last modification. */
216 __time_t st_ctime
; /* Time of last status change. */
217 unsigned long int st_ctimensec
; /* Nsecs of last status change. */
219 __ino64_t st_ino
; /* File serial number. */
224 /* Tell code we have these members. */
225 #define _STATBUF_ST_BLKSIZE
226 #define _STATBUF_ST_RDEV
227 /* Nanosecond resolution time values are supported. */
228 #define _STATBUF_ST_NSEC
230 /* Encoding of the file mode. */
232 #define __S_IFMT 0170000 /* These bits determine file type. */
235 #define __S_IFDIR 0040000 /* Directory. */
236 #define __S_IFCHR 0020000 /* Character device. */
237 #define __S_IFBLK 0060000 /* Block device. */
238 #define __S_IFREG 0100000 /* Regular file. */
239 #define __S_IFIFO 0010000 /* FIFO. */
240 #define __S_IFLNK 0120000 /* Symbolic link. */
241 #define __S_IFSOCK 0140000 /* Socket. */
243 /* POSIX.1b objects. Note that these macros always evaluate to zero. But
244 they do it by enforcing the correct use of the macros. */
245 #define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
246 #define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
247 #define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
249 /* Protection bits. */
251 #define __S_ISUID 04000 /* Set user ID on execution. */
252 #define __S_ISGID 02000 /* Set group ID on execution. */
253 #define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
254 #define __S_IREAD 0400 /* Read by owner. */
255 #define __S_IWRITE 0200 /* Write by owner. */
256 #define __S_IEXEC 0100 /* Execute by owner. */