add experimental aarch64 support
[uclibc-ng.git] / libc / sysdeps / linux / common-generic / bits / stat.h
blob0f66fc0e7f0bd41a475793aa4154deaea9d3285d
1 /*
2 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
4 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
5 */
7 #ifndef _SYS_STAT_H
8 # error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
9 #endif
11 #include <bits/align64bit.h>
12 #include <endian.h>
14 /* Versions of the `struct stat' data structure. */
15 #define _STAT_VER_LINUX_OLD 1
16 #define _STAT_VER_KERNEL 1
17 #define _STAT_VER_SVR4 2
18 #define _STAT_VER_LINUX 3
19 #define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
21 /* Versions of the `xmknod' interface. */
22 #define _MKNOD_VER_LINUX 1
23 #define _MKNOD_VER_SVR4 2
24 #define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
27 * For 32-bit architectures, this struct is similar to the stat64 but it
28 * uses 32-bit members along with 32-bit padding. For 64-bit architectures
29 * this struct is exactly the same with the stat64 one
31 struct stat
33 unsigned long long st_dev; /* Device. */
34 unsigned long long st_ino; /* 32bit file serial number. */
35 unsigned int st_mode; /* File mode. */
36 unsigned int st_nlink; /* Link count. */
37 unsigned int st_uid; /* User ID of the file's owner. */
38 unsigned int st_gid; /* Group ID of the file's group.*/
39 unsigned long long st_rdev; /* Device number, if device. */
40 unsigned long long _pad1;
41 long long st_size; /* SIze of file, in bytes. */
42 int st_blksize; /* Optimal block size for I/O. */
43 int __pad2;
44 long long st_blocks; /* Number 512-byte blocks allocated */
45 #ifdef __USE_MISC
46 /* Nanosecond resolution timestamps are stored in a format
47 equivalent to 'struct timespec'. This is the type used
48 whenever possible but the Unix namespace rules do not allow the
49 identifier 'timespec' to appear in the <sys/stat.h> header.
50 Therefore we have to handle the use of this header in strictly
51 standard-compliant sources special. */
52 struct timespec st_atim; /* Time of last access. */
53 struct timespec st_mtim; /* Time of last modification. */
54 struct timespec st_ctim; /* Time of last status change. */
55 # define st_atime st_atim.tv_sec /* Backward compatibility. */
56 # define st_mtime st_mtim.tv_sec
57 # define st_ctime st_ctim.tv_sec
58 #else
59 int st_atime; /* Time of last access. */
60 unsigned int st_atime_nsec;
61 int st_mtime; /* Time of last modification. */
62 unsigned int st_mtime_nsec;
63 int st_ctime; /* Time of last status change. */
64 unsigned int st_ctime_nsec;
65 #endif
66 unsigned int __unused4;
67 unsigned int __unused5;
68 } __ARCH_64BIT_ALIGNMENT__;
71 #ifdef __USE_LARGEFILE64
72 struct stat64
74 unsigned long long st_dev; /* Device. */
75 unsigned long long st_ino; /* 32bit file serial number. */
76 unsigned int st_mode; /* File mode. */
77 unsigned int st_nlink; /* Link count. */
78 unsigned int st_uid; /* User ID of the file's owner. */
79 unsigned int st_gid; /* Group ID of the file's group.*/
80 unsigned long long st_rdev; /* Device number, if device. */
81 unsigned long long __pad3;
82 long long st_size; /* Size of file, in bytes. */
83 int st_blksize; /* Optimal block size for I/O. */
84 int __pad4;
85 long long st_blocks; /* Number 512-byte blocks allocated */
86 # ifdef __USE_MISC
87 /* Nanosecond resolution timestamps are stored in a format
88 equivalent to 'struct timespec'. This is the type used
89 whenever possible but the Unix namespace rules do not allow the
90 identifier 'timespec' to appear in the <sys/stat.h> header.
91 Therefore we have to handle the use of this header in strictly
92 standard-compliant sources special. */
93 struct timespec st_atim; /* Time of last access. */
94 struct timespec st_mtim; /* Time of last modification. */
95 struct timespec st_ctim; /* Time of last status change. */
96 # else
97 int st_atime; /* Time of last access. */
98 unsigned int st_atime_nsec;
99 int st_mtime; /* Time of last modification. */
100 unsigned int st_mtime_nsec;
101 int st_ctime; /* Time of last status change. */
102 unsigned int st_ctime_nsec;
103 # endif
104 unsigned int __unused4;
105 unsigned int __unused5;
107 #endif
109 /* Tell code we have these members. */
110 #define _STATBUF_ST_BLKSIZE
111 #define _STATBUF_ST_RDEV
112 /* Nanosecond resolution time values are supported. */
113 #define _STATBUF_ST_NSEC
115 /* Encoding of the file mode. */
117 #define __S_IFMT 0170000 /* These bits determine file type. */
119 /* File types. */
120 #define __S_IFDIR 0040000 /* Directory. */
121 #define __S_IFCHR 0020000 /* Character device. */
122 #define __S_IFBLK 0060000 /* Block device. */
123 #define __S_IFREG 0100000 /* Regular file. */
124 #define __S_IFIFO 0010000 /* FIFO. */
125 #define __S_IFLNK 0120000 /* Symbolic link. */
126 #define __S_IFSOCK 0140000 /* Socket. */
128 /* POSIX.1b objects. Note that these macros always evaluate to zero. But
129 they do it by enforcing the correct use of the macros. */
130 #define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
131 #define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
132 #define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
134 /* Protection bits. */
136 #define __S_ISUID 04000 /* Set user ID on execution. */
137 #define __S_ISGID 02000 /* Set group ID on execution. */
138 #define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
139 #define __S_IREAD 0400 /* Read by owner. */
140 #define __S_IWRITE 0200 /* Write by owner. */
141 #define __S_IEXEC 0100 /* Execute by owner. */
143 #ifdef __USE_ATFILE
144 # define UTIME_NOW ((1l << 30) - 1l)
145 # define UTIME_OMIT ((1l << 30) - 2l)
146 #endif