]>
Commit | Line | Data |
---|---|---|
c72aaf43 RH |
1 | /* Copyright (C) 1996,1997,1998,1999,2000,2001,2004 |
2 | Free Software Foundation, Inc. | |
54d79e99 | 3 | This file is part of the GNU C Library. |
510ca033 | 4 | |
54d79e99 | 5 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
510ca033 | 9 | |
54d79e99 UD |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
510ca033 | 14 | |
41bdb6e2 AJ |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, write to the Free | |
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | 02111-1307 USA. */ | |
510ca033 | 19 | |
f4017d20 UD |
20 | #ifndef _SYS_STAT_H |
21 | # error "Never include <bits/stat.h> directly; use <sys/stat.h> instead." | |
22 | #endif | |
510ca033 | 23 | |
46ec036d | 24 | /* Versions of the `struct stat' data structure. */ |
1cab5444 UD |
25 | #define _STAT_VER_KERNEL 0 |
26 | #define _STAT_VER_GLIBC2 1 | |
27 | #define _STAT_VER_GLIBC2_1 2 | |
c72aaf43 RH |
28 | #define _STAT_VER_KERNEL64 3 |
29 | #define _STAT_VER_GLIBC2_3_4 3 | |
30 | #define _STAT_VER _STAT_VER_GLIBC2_3_4 | |
510ca033 | 31 | |
46ec036d UD |
32 | /* Versions of the `xmknod' interface. */ |
33 | #define _MKNOD_VER_LINUX 0 | |
510ca033 | 34 | |
c72aaf43 RH |
35 | |
36 | /* Nanosecond resolution timestamps are stored in a format equivalent to | |
37 | 'struct timespec'. This is the type used whenever possible but the | |
38 | Unix namespace rules do not allow the identifier 'timespec' to appear | |
39 | in the <sys/stat.h> header. Therefore we have to handle the use of | |
40 | this header in strictly standard-compliant sources special. | |
41 | ||
42 | Use neat tidy anonymous unions and structures when possible. */ | |
43 | ||
44 | #ifdef __USE_MISC | |
45 | # if __GNUC_PREREQ(3,3) | |
46 | # define __ST_TIME(X) \ | |
47 | __extension__ union { \ | |
48 | struct timespec st_##X##tim; \ | |
49 | struct { \ | |
50 | __time_t st_##X##time; \ | |
51 | unsigned long st_##X##timensec; \ | |
52 | }; \ | |
53 | } | |
54 | # else | |
55 | # define __ST_TIME(X) struct timespec st_##X##tim | |
56 | # define st_atime st_atim.tv_sec | |
57 | # define st_mtime st_mtim.tv_sec | |
58 | # define st_ctime st_ctim.tv_sec | |
59 | # endif | |
60 | #else | |
61 | # define __ST_TIME(X) \ | |
62 | __time_t st_##X##time; \ | |
63 | unsigned long st_##X##timensec | |
64 | #endif | |
65 | ||
66 | ||
46ec036d UD |
67 | struct stat |
68 | { | |
0d8733c4 | 69 | __dev_t st_dev; /* Device. */ |
1cab5444 UD |
70 | #ifdef __USE_FILE_OFFSET64 |
71 | __ino64_t st_ino; /* File serial number. */ | |
72 | #else | |
0d8733c4 | 73 | __ino_t st_ino; /* File serial number. */ |
c72aaf43 | 74 | int __pad0; /* 64-bit st_ino. */ |
1cab5444 | 75 | #endif |
0d8733c4 UD |
76 | __dev_t st_rdev; /* Device number, if device. */ |
77 | __off_t st_size; /* Size of file, in bytes. */ | |
1cab5444 UD |
78 | #ifdef __USE_FILE_OFFSET64 |
79 | __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */ | |
80 | #else | |
81 | __blkcnt_t st_blocks; /* Nr. 512-byte blocks allocated. */ | |
c72aaf43 | 82 | int __pad1; /* 64-bit st_blocks. */ |
1cab5444 | 83 | #endif |
c72aaf43 RH |
84 | __mode_t st_mode; /* File mode. */ |
85 | __uid_t st_uid; /* User ID of the file's owner. */ | |
86 | __gid_t st_gid; /* Group ID of the file's group.*/ | |
219aa9e9 | 87 | __blksize_t st_blksize; /* Optimal block size for I/O. */ |
c72aaf43 RH |
88 | __nlink_t st_nlink; /* Link count. */ |
89 | int __pad2; /* Real padding. */ | |
90 | __ST_TIME(a); /* Time of last access. */ | |
91 | __ST_TIME(m); /* Time of last modification. */ | |
92 | __ST_TIME(c); /* Time of last status change. */ | |
93 | long __unused[3]; | |
510ca033 RM |
94 | }; |
95 | ||
1cab5444 UD |
96 | #ifdef __USE_LARGEFILE64 |
97 | /* Note stat64 is the same shape as stat. */ | |
98 | struct stat64 | |
99 | { | |
100 | __dev_t st_dev; /* Device. */ | |
101 | __ino64_t st_ino; /* File serial number. */ | |
1cab5444 UD |
102 | __dev_t st_rdev; /* Device number, if device. */ |
103 | __off_t st_size; /* Size of file, in bytes. */ | |
1cab5444 | 104 | __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */ |
c72aaf43 RH |
105 | __mode_t st_mode; /* File mode. */ |
106 | __uid_t st_uid; /* User ID of the file's owner. */ | |
107 | __gid_t st_gid; /* Group ID of the file's group.*/ | |
219aa9e9 | 108 | __blksize_t st_blksize; /* Optimal block size for I/O. */ |
c72aaf43 RH |
109 | __nlink_t st_nlink; /* Link count. */ |
110 | int __pad0; /* Real padding. */ | |
111 | __ST_TIME(a); /* Time of last access. */ | |
112 | __ST_TIME(m); /* Time of last modification. */ | |
113 | __ST_TIME(c); /* Time of last status change. */ | |
114 | long __unused[3]; | |
1cab5444 UD |
115 | }; |
116 | #endif | |
117 | ||
c72aaf43 RH |
118 | #undef __ST_TIME |
119 | ||
af69217f UD |
120 | /* Tell code we have these members. */ |
121 | #define _STATBUF_ST_BLKSIZE | |
122 | #define _STATBUF_ST_RDEV | |
c72aaf43 | 123 | #define _STATBUF_ST_NSEC |
1cab5444 | 124 | |
510ca033 RM |
125 | /* Encoding of the file mode. */ |
126 | ||
127 | #define __S_IFMT 0170000 /* These bits determine file type. */ | |
128 | ||
129 | /* File types. */ | |
130 | #define __S_IFDIR 0040000 /* Directory. */ | |
131 | #define __S_IFCHR 0020000 /* Character device. */ | |
132 | #define __S_IFBLK 0060000 /* Block device. */ | |
133 | #define __S_IFREG 0100000 /* Regular file. */ | |
134 | #define __S_IFIFO 0010000 /* FIFO. */ | |
510ca033 RM |
135 | #define __S_IFLNK 0120000 /* Symbolic link. */ |
136 | #define __S_IFSOCK 0140000 /* Socket. */ | |
137 | ||
368cfb94 UD |
138 | /* POSIX.1b objects. Note that these macros always evaluate to zero. But |
139 | they do it by enforcing the correct use of the macros. */ | |
140 | #define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode) | |
141 | #define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode) | |
142 | #define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode) | |
2fcbf75b | 143 | |
510ca033 RM |
144 | /* Protection bits. */ |
145 | ||
146 | #define __S_ISUID 04000 /* Set user ID on execution. */ | |
147 | #define __S_ISGID 02000 /* Set group ID on execution. */ | |
148 | #define __S_ISVTX 01000 /* Save swapped text after use (sticky). */ | |
149 | #define __S_IREAD 0400 /* Read by owner. */ | |
150 | #define __S_IWRITE 0200 /* Write by owner. */ | |
151 | #define __S_IEXEC 0100 /* Execute by owner. */ | |
c27d2078 UD |
152 | |
153 | #if defined __USE_ATFILE || defined __USE_GNU | |
154 | /* XXX This will change to the macro for the next 2008 POSIX revision. */ | |
155 | # define UTIME_NOW ((1l << 30) - 1l) | |
156 | # define UTIME_OMIT ((1l << 30) - 2l) | |
157 | #endif |