2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / alpha / bits / stat.h
blob42748be7628690f2616c2ec53ab94c1026d750f0
1 /* Copyright (C) 1996,1997,1998,1999,2000,2001,2004
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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. */
20 #ifndef _SYS_STAT_H
21 # error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
22 #endif
24 /* Versions of the `struct stat' data structure. */
25 #define _STAT_VER_KERNEL 0
26 #define _STAT_VER_GLIBC2 1
27 #define _STAT_VER_GLIBC2_1 2
28 #define _STAT_VER_KERNEL64 3
29 #define _STAT_VER_GLIBC2_3_4 3
30 #define _STAT_VER _STAT_VER_GLIBC2_3_4
32 /* Versions of the `xmknod' interface. */
33 #define _MKNOD_VER_LINUX 0
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.
42 Use neat tidy anonymous unions and structures when possible. */
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 }; \
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
67 struct stat
69 __dev_t st_dev; /* Device. */
70 #ifdef __USE_FILE_OFFSET64
71 __ino64_t st_ino; /* File serial number. */
72 #else
73 __ino_t st_ino; /* File serial number. */
74 int __pad0; /* 64-bit st_ino. */
75 #endif
76 __dev_t st_rdev; /* Device number, if device. */
77 __off_t st_size; /* Size of file, in bytes. */
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. */
82 int __pad1; /* 64-bit st_blocks. */
83 #endif
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.*/
87 __blksize_t st_blksize; /* Optimal block size for I/O. */
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];
96 #ifdef __USE_LARGEFILE64
97 /* Note stat64 is the same shape as stat. */
98 struct stat64
100 __dev_t st_dev; /* Device. */
101 __ino64_t st_ino; /* File serial number. */
102 __dev_t st_rdev; /* Device number, if device. */
103 __off_t st_size; /* Size of file, in bytes. */
104 __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
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.*/
108 __blksize_t st_blksize; /* Optimal block size for I/O. */
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];
116 #endif
118 #undef __ST_TIME
120 /* Tell code we have these members. */
121 #define _STATBUF_ST_BLKSIZE
122 #define _STATBUF_ST_RDEV
123 #define _STATBUF_ST_NSEC
125 /* Encoding of the file mode. */
127 #define __S_IFMT 0170000 /* These bits determine file type. */
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. */
135 #define __S_IFLNK 0120000 /* Symbolic link. */
136 #define __S_IFSOCK 0140000 /* Socket. */
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)
144 /* Protection bits. */
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. */
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