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