• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2017 The Android Open Source Project
2 // SPDX-License-Identifier: BSD-2-Clause
3 
4 #include <sys/stat.h>
5 
6 #include "header_checks.h"
7 
sys_stat_h()8 static void sys_stat_h() {
9   TYPE(struct stat);
10 #if defined(__BIONIC__) && (defined(__arm__) || defined(__i386__))
11   STRUCT_MEMBER(struct stat, unsigned long long, st_dev);
12 #else
13   STRUCT_MEMBER(struct stat, dev_t, st_dev);
14 #endif
15 #if defined(__BIONIC__) && !defined(__LP64__)
16   STRUCT_MEMBER(struct stat, unsigned long long, st_ino);
17 #else
18   STRUCT_MEMBER(struct stat, ino_t, st_ino);
19 #endif
20 #if defined(__BIONIC__) && (defined(__arm__) || defined(__i386__))
21   STRUCT_MEMBER(struct stat, unsigned int, st_mode);
22 #else
23   STRUCT_MEMBER(struct stat, mode_t, st_mode);
24 #endif
25 #if defined(__BIONIC__) && defined(__x86_64__)
26   // We can't just fix the x86_64 nlink_t because it's ABI via <fts.h>.
27   STRUCT_MEMBER(struct stat, unsigned long, st_nlink);
28 #else
29   STRUCT_MEMBER(struct stat, nlink_t, st_nlink);
30 #endif
31   STRUCT_MEMBER(struct stat, uid_t, st_uid);
32   STRUCT_MEMBER(struct stat, gid_t, st_gid);
33 #if defined(__BIONIC__) && (defined(__arm__) || defined(__i386__))
34   STRUCT_MEMBER(struct stat, unsigned long long, st_rdev);
35 #else
36   STRUCT_MEMBER(struct stat, dev_t, st_rdev);
37 #endif
38 #if defined(__BIONIC__) && !defined(__LP64__)
39   STRUCT_MEMBER(struct stat, long long, st_size);
40 #else
41   STRUCT_MEMBER(struct stat, off_t, st_size);
42 #endif
43   STRUCT_MEMBER(struct stat, struct timespec, st_atim);
44   STRUCT_MEMBER(struct stat, struct timespec, st_mtim);
45   STRUCT_MEMBER(struct stat, struct timespec, st_ctim);
46 #if defined(__BIONIC__)
47 #if defined(__aarch64__) || defined(__riscv)
48   STRUCT_MEMBER(struct stat, int, st_blksize);
49 #elif defined(__x86_64__)
50   STRUCT_MEMBER(struct stat, long, st_blksize);
51 #else
52   STRUCT_MEMBER(struct stat, unsigned long, st_blksize);
53 #endif
54 #else
55   STRUCT_MEMBER(struct stat, blksize_t, st_blksize);
56 #endif
57 #if defined(__BIONIC__)
58 #if defined(__LP64__)
59   STRUCT_MEMBER(struct stat, long, st_blocks);
60 #else
61   STRUCT_MEMBER(struct stat, unsigned long long, st_blocks);
62 #endif
63 #else
64   STRUCT_MEMBER(struct stat, blkcnt_t, st_blocks);
65 #endif
66 
67   TYPE(blkcnt_t);
68   TYPE(blksize_t);
69   TYPE(dev_t);
70   TYPE(ino_t);
71   TYPE(mode_t);
72   TYPE(nlink_t);
73   TYPE(uid_t);
74   TYPE(gid_t);
75   TYPE(off_t);
76   TYPE(time_t);
77 
78   TYPE(struct timespec);
79 
80 #if !defined(st_atime)
81 #error st_atime
82 #endif
83 #if !defined(st_ctime)
84 #error st_ctime
85 #endif
86 #if !defined(st_mtime)
87 #error st_mtime
88 #endif
89 
90 #include "sys_stat_h_mode_constants.h"
91 #include "sys_stat_h_file_type_test_macros.h"
92 
93 #if !defined(S_TYPEISMQ)
94 #error S_TYPEISMQ
95 #endif
96 #if !defined(S_TYPEISSEM)
97 #error S_TYPEISSEM
98 #endif
99 #if !defined(S_TYPEISSHM)
100 #error S_TYPEISSHM
101 #endif
102 
103 #if !defined(__BIONIC__) && !defined(__GLIBC__)
104 #if !defined(S_TYPEISTMO)
105 #error S_TYPEISTMO
106 #endif
107 #endif
108 
109   MACRO(UTIME_NOW);
110   MACRO(UTIME_OMIT);
111 
112   FUNCTION(chmod, int (*f)(const char*, mode_t));
113   FUNCTION(fchmod, int (*f)(int, mode_t));
114   FUNCTION(fchmodat, int (*f)(int, const char*, mode_t, int));
115   FUNCTION(fstat, int (*f)(int, struct stat*));
116   FUNCTION(fstatat, int (*f)(int, const char*, struct stat*, int));
117   FUNCTION(futimens, int (*f)(int, const struct timespec[2]));
118   FUNCTION(lstat, int (*f)(const char*, struct stat*));
119   FUNCTION(lstat, int (*f)(const char*, struct stat*));
120   FUNCTION(mkdir, int (*f)(const char*, mode_t));
121   FUNCTION(mkdirat, int (*f)(int, const char*, mode_t));
122   FUNCTION(mkfifo, int (*f)(const char*, mode_t));
123   FUNCTION(mkfifoat, int (*f)(int, const char*, mode_t));
124   FUNCTION(mknod, int (*f)(const char*, mode_t, dev_t));
125   FUNCTION(mknodat, int (*f)(int, const char*, mode_t, dev_t));
126   FUNCTION(stat, int (*f)(const char*, struct stat*));
127   FUNCTION(umask, mode_t (*f)(mode_t));
128   FUNCTION(utimensat, int (*f)(int, const char*, const struct timespec[2], int));
129 }
130