1 /*
2 * Copyright (C) 2017 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 #include <sys/stat.h>
30
31 #include "header_checks.h"
32
sys_stat_h()33 static void sys_stat_h() {
34 TYPE(struct stat);
35 #if defined(__BIONIC__) && (defined(__arm__) || defined(__i386__))
36 STRUCT_MEMBER(struct stat, unsigned long long, st_dev);
37 #else
38 STRUCT_MEMBER(struct stat, dev_t, st_dev);
39 #endif
40 #if defined(__BIONIC__) && !defined(__LP64__)
41 STRUCT_MEMBER(struct stat, unsigned long long, st_ino);
42 #else
43 STRUCT_MEMBER(struct stat, ino_t, st_ino);
44 #endif
45 #if defined(__BIONIC__) && (defined(__arm__) || defined(__i386__))
46 STRUCT_MEMBER(struct stat, unsigned int, st_mode);
47 #else
48 STRUCT_MEMBER(struct stat, mode_t, st_mode);
49 #endif
50 #if defined(__BIONIC__) && defined(__x86_64__)
51 // We can't just fix the x86_64 nlink_t because it's ABI via <fts.h>.
52 STRUCT_MEMBER(struct stat, unsigned long, st_nlink);
53 #else
54 STRUCT_MEMBER(struct stat, nlink_t, st_nlink);
55 #endif
56 STRUCT_MEMBER(struct stat, uid_t, st_uid);
57 STRUCT_MEMBER(struct stat, gid_t, st_gid);
58 #if defined(__BIONIC__) && (defined(__arm__) || defined(__i386__))
59 STRUCT_MEMBER(struct stat, unsigned long long, st_rdev);
60 #else
61 STRUCT_MEMBER(struct stat, dev_t, st_rdev);
62 #endif
63 #if defined(__BIONIC__) && !defined(__LP64__)
64 STRUCT_MEMBER(struct stat, long long, st_size);
65 #else
66 STRUCT_MEMBER(struct stat, off_t, st_size);
67 #endif
68 STRUCT_MEMBER(struct stat, struct timespec, st_atim);
69 STRUCT_MEMBER(struct stat, struct timespec, st_mtim);
70 STRUCT_MEMBER(struct stat, struct timespec, st_ctim);
71 #if defined(__BIONIC__)
72 #if defined(__aarch64__) || (defined(__mips__) && defined(__LP64__))
73 STRUCT_MEMBER(struct stat, int, st_blksize);
74 #elif defined(__mips__) && !defined(__LP64__)
75 STRUCT_MEMBER(struct stat, unsigned int, st_blksize);
76 #elif defined(__x86_64__)
77 STRUCT_MEMBER(struct stat, long, st_blksize);
78 #else
79 STRUCT_MEMBER(struct stat, unsigned long, st_blksize);
80 #endif
81 #else
82 STRUCT_MEMBER(struct stat, blksize_t, st_blksize);
83 #endif
84 #if defined(__BIONIC__)
85 #if defined(__LP64__)
86 STRUCT_MEMBER(struct stat, long, st_blocks);
87 #else
88 STRUCT_MEMBER(struct stat, unsigned long long, st_blocks);
89 #endif
90 #else
91 STRUCT_MEMBER(struct stat, blkcnt_t, st_blocks);
92 #endif
93
94 TYPE(blkcnt_t);
95 TYPE(blksize_t);
96 TYPE(dev_t);
97 TYPE(ino_t);
98 TYPE(mode_t);
99 TYPE(nlink_t);
100 TYPE(uid_t);
101 TYPE(gid_t);
102 TYPE(off_t);
103 TYPE(time_t);
104
105 TYPE(struct timespec);
106
107 #if !defined(st_atime)
108 #error st_atime
109 #endif
110 #if !defined(st_ctime)
111 #error st_ctime
112 #endif
113 #if !defined(st_mtime)
114 #error st_mtime
115 #endif
116
117 #include "sys_stat_h_mode_constants.h"
118 #include "sys_stat_h_file_type_test_macros.h"
119
120 #if !defined(S_TYPEISMQ)
121 #error S_TYPEISMQ
122 #endif
123 #if !defined(S_TYPEISSEM)
124 #error S_TYPEISSEM
125 #endif
126 #if !defined(S_TYPEISSHM)
127 #error S_TYPEISSHM
128 #endif
129
130 #if !defined(__BIONIC__) && !defined(__GLIBC__)
131 #if !defined(S_TYPEISTMO)
132 #error S_TYPEISTMO
133 #endif
134 #endif
135
136 MACRO(UTIME_NOW);
137 MACRO(UTIME_OMIT);
138
139 FUNCTION(chmod, int (*f)(const char*, mode_t));
140 FUNCTION(fchmod, int (*f)(int, mode_t));
141 FUNCTION(fchmodat, int (*f)(int, const char*, mode_t, int));
142 FUNCTION(fstat, int (*f)(int, struct stat*));
143 FUNCTION(fstatat, int (*f)(int, const char*, struct stat*, int));
144 FUNCTION(futimens, int (*f)(int, const struct timespec[2]));
145 FUNCTION(lstat, int (*f)(const char*, struct stat*));
146 FUNCTION(lstat, int (*f)(const char*, struct stat*));
147 FUNCTION(mkdir, int (*f)(const char*, mode_t));
148 FUNCTION(mkdirat, int (*f)(int, const char*, mode_t));
149 FUNCTION(mkfifo, int (*f)(const char*, mode_t));
150 FUNCTION(mkfifoat, int (*f)(int, const char*, mode_t));
151 FUNCTION(mknod, int (*f)(const char*, mode_t, dev_t));
152 FUNCTION(mknodat, int (*f)(int, const char*, mode_t, dev_t));
153 FUNCTION(stat, int (*f)(const char*, struct stat*));
154 FUNCTION(umask, mode_t (*f)(mode_t));
155 FUNCTION(utimensat, int (*f)(int, const char*, const struct timespec[2], int));
156 }
157