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