xref: /aosp_15_r20/bionic/libc/include/sys/stat.h (revision 8d67ca893c1523eb926b9080dbe4e2ffd2a27ba1)
1*8d67ca89SAndroid Build Coastguard Worker /*
2*8d67ca89SAndroid Build Coastguard Worker  * Copyright (C) 2008 The Android Open Source Project
3*8d67ca89SAndroid Build Coastguard Worker  * All rights reserved.
4*8d67ca89SAndroid Build Coastguard Worker  *
5*8d67ca89SAndroid Build Coastguard Worker  * Redistribution and use in source and binary forms, with or without
6*8d67ca89SAndroid Build Coastguard Worker  * modification, are permitted provided that the following conditions
7*8d67ca89SAndroid Build Coastguard Worker  * are met:
8*8d67ca89SAndroid Build Coastguard Worker  *  * Redistributions of source code must retain the above copyright
9*8d67ca89SAndroid Build Coastguard Worker  *    notice, this list of conditions and the following disclaimer.
10*8d67ca89SAndroid Build Coastguard Worker  *  * Redistributions in binary form must reproduce the above copyright
11*8d67ca89SAndroid Build Coastguard Worker  *    notice, this list of conditions and the following disclaimer in
12*8d67ca89SAndroid Build Coastguard Worker  *    the documentation and/or other materials provided with the
13*8d67ca89SAndroid Build Coastguard Worker  *    distribution.
14*8d67ca89SAndroid Build Coastguard Worker  *
15*8d67ca89SAndroid Build Coastguard Worker  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16*8d67ca89SAndroid Build Coastguard Worker  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17*8d67ca89SAndroid Build Coastguard Worker  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18*8d67ca89SAndroid Build Coastguard Worker  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19*8d67ca89SAndroid Build Coastguard Worker  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20*8d67ca89SAndroid Build Coastguard Worker  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21*8d67ca89SAndroid Build Coastguard Worker  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22*8d67ca89SAndroid Build Coastguard Worker  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23*8d67ca89SAndroid Build Coastguard Worker  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24*8d67ca89SAndroid Build Coastguard Worker  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25*8d67ca89SAndroid Build Coastguard Worker  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26*8d67ca89SAndroid Build Coastguard Worker  * SUCH DAMAGE.
27*8d67ca89SAndroid Build Coastguard Worker  */
28*8d67ca89SAndroid Build Coastguard Worker 
29*8d67ca89SAndroid Build Coastguard Worker #pragma once
30*8d67ca89SAndroid Build Coastguard Worker 
31*8d67ca89SAndroid Build Coastguard Worker /**
32*8d67ca89SAndroid Build Coastguard Worker  * @file sys/stat.h
33*8d67ca89SAndroid Build Coastguard Worker  * @brief File status.
34*8d67ca89SAndroid Build Coastguard Worker  */
35*8d67ca89SAndroid Build Coastguard Worker 
36*8d67ca89SAndroid Build Coastguard Worker #include <sys/cdefs.h>
37*8d67ca89SAndroid Build Coastguard Worker 
38*8d67ca89SAndroid Build Coastguard Worker #include <bits/timespec.h>
39*8d67ca89SAndroid Build Coastguard Worker #include <linux/stat.h>
40*8d67ca89SAndroid Build Coastguard Worker #include <sys/types.h>
41*8d67ca89SAndroid Build Coastguard Worker 
42*8d67ca89SAndroid Build Coastguard Worker __BEGIN_DECLS
43*8d67ca89SAndroid Build Coastguard Worker 
44*8d67ca89SAndroid Build Coastguard Worker #if defined(__aarch64__) || defined(__riscv)
45*8d67ca89SAndroid Build Coastguard Worker #define __STAT64_BODY \
46*8d67ca89SAndroid Build Coastguard Worker   dev_t st_dev; \
47*8d67ca89SAndroid Build Coastguard Worker   ino_t st_ino; \
48*8d67ca89SAndroid Build Coastguard Worker   mode_t st_mode; \
49*8d67ca89SAndroid Build Coastguard Worker   nlink_t st_nlink; \
50*8d67ca89SAndroid Build Coastguard Worker   uid_t st_uid; \
51*8d67ca89SAndroid Build Coastguard Worker   gid_t st_gid; \
52*8d67ca89SAndroid Build Coastguard Worker   dev_t st_rdev; \
53*8d67ca89SAndroid Build Coastguard Worker   unsigned long __pad1; \
54*8d67ca89SAndroid Build Coastguard Worker   off_t st_size; \
55*8d67ca89SAndroid Build Coastguard Worker   int st_blksize; \
56*8d67ca89SAndroid Build Coastguard Worker   int __pad2; \
57*8d67ca89SAndroid Build Coastguard Worker   long st_blocks; \
58*8d67ca89SAndroid Build Coastguard Worker   struct timespec st_atim; \
59*8d67ca89SAndroid Build Coastguard Worker   struct timespec st_mtim; \
60*8d67ca89SAndroid Build Coastguard Worker   struct timespec st_ctim; \
61*8d67ca89SAndroid Build Coastguard Worker   unsigned int __unused4; \
62*8d67ca89SAndroid Build Coastguard Worker   unsigned int __unused5; \
63*8d67ca89SAndroid Build Coastguard Worker 
64*8d67ca89SAndroid Build Coastguard Worker #elif defined(__x86_64__)
65*8d67ca89SAndroid Build Coastguard Worker #define __STAT64_BODY \
66*8d67ca89SAndroid Build Coastguard Worker   dev_t st_dev; \
67*8d67ca89SAndroid Build Coastguard Worker   ino_t st_ino; \
68*8d67ca89SAndroid Build Coastguard Worker   unsigned long st_nlink; \
69*8d67ca89SAndroid Build Coastguard Worker   mode_t st_mode; \
70*8d67ca89SAndroid Build Coastguard Worker   uid_t st_uid; \
71*8d67ca89SAndroid Build Coastguard Worker   gid_t st_gid; \
72*8d67ca89SAndroid Build Coastguard Worker   unsigned int __pad0; \
73*8d67ca89SAndroid Build Coastguard Worker   dev_t st_rdev; \
74*8d67ca89SAndroid Build Coastguard Worker   off_t st_size; \
75*8d67ca89SAndroid Build Coastguard Worker   long st_blksize; \
76*8d67ca89SAndroid Build Coastguard Worker   long st_blocks; \
77*8d67ca89SAndroid Build Coastguard Worker   struct timespec st_atim; \
78*8d67ca89SAndroid Build Coastguard Worker   struct timespec st_mtim; \
79*8d67ca89SAndroid Build Coastguard Worker   struct timespec st_ctim; \
80*8d67ca89SAndroid Build Coastguard Worker   long __pad3[3]; \
81*8d67ca89SAndroid Build Coastguard Worker 
82*8d67ca89SAndroid Build Coastguard Worker #else /* __arm__ || __i386__ */
83*8d67ca89SAndroid Build Coastguard Worker #define __STAT64_BODY \
84*8d67ca89SAndroid Build Coastguard Worker   unsigned long long st_dev; \
85*8d67ca89SAndroid Build Coastguard Worker   unsigned char __pad0[4]; \
86*8d67ca89SAndroid Build Coastguard Worker   unsigned long __st_ino; \
87*8d67ca89SAndroid Build Coastguard Worker   unsigned int st_mode; \
88*8d67ca89SAndroid Build Coastguard Worker   nlink_t st_nlink; \
89*8d67ca89SAndroid Build Coastguard Worker   uid_t st_uid; \
90*8d67ca89SAndroid Build Coastguard Worker   gid_t st_gid; \
91*8d67ca89SAndroid Build Coastguard Worker   unsigned long long st_rdev; \
92*8d67ca89SAndroid Build Coastguard Worker   unsigned char __pad3[4]; \
93*8d67ca89SAndroid Build Coastguard Worker   long long st_size; \
94*8d67ca89SAndroid Build Coastguard Worker   unsigned long st_blksize; \
95*8d67ca89SAndroid Build Coastguard Worker   unsigned long long st_blocks; \
96*8d67ca89SAndroid Build Coastguard Worker   struct timespec st_atim; \
97*8d67ca89SAndroid Build Coastguard Worker   struct timespec st_mtim; \
98*8d67ca89SAndroid Build Coastguard Worker   struct timespec st_ctim; \
99*8d67ca89SAndroid Build Coastguard Worker   unsigned long long st_ino; \
100*8d67ca89SAndroid Build Coastguard Worker 
101*8d67ca89SAndroid Build Coastguard Worker #endif
102*8d67ca89SAndroid Build Coastguard Worker 
103*8d67ca89SAndroid Build Coastguard Worker /** The file information returned by fstat()/fstatat()/lstat()/stat(). */
104*8d67ca89SAndroid Build Coastguard Worker struct stat { __STAT64_BODY };
105*8d67ca89SAndroid Build Coastguard Worker 
106*8d67ca89SAndroid Build Coastguard Worker /**
107*8d67ca89SAndroid Build Coastguard Worker  * A synonym for `struct stat` on Android,
108*8d67ca89SAndroid Build Coastguard Worker  * provided for source compatibility with other systems.
109*8d67ca89SAndroid Build Coastguard Worker  */
110*8d67ca89SAndroid Build Coastguard Worker struct stat64 { __STAT64_BODY };
111*8d67ca89SAndroid Build Coastguard Worker 
112*8d67ca89SAndroid Build Coastguard Worker #undef __STAT64_BODY
113*8d67ca89SAndroid Build Coastguard Worker 
114*8d67ca89SAndroid Build Coastguard Worker /* Compatibility with older versions of POSIX. */
115*8d67ca89SAndroid Build Coastguard Worker #define st_atime st_atim.tv_sec
116*8d67ca89SAndroid Build Coastguard Worker #define st_mtime st_mtim.tv_sec
117*8d67ca89SAndroid Build Coastguard Worker #define st_ctime st_ctim.tv_sec
118*8d67ca89SAndroid Build Coastguard Worker /* Compatibility with glibc. */
119*8d67ca89SAndroid Build Coastguard Worker #define st_atimensec st_atim.tv_nsec
120*8d67ca89SAndroid Build Coastguard Worker #define st_mtimensec st_mtim.tv_nsec
121*8d67ca89SAndroid Build Coastguard Worker #define st_ctimensec st_ctim.tv_nsec
122*8d67ca89SAndroid Build Coastguard Worker /* Compatibility with Linux headers and old NDKs. */
123*8d67ca89SAndroid Build Coastguard Worker #define st_atime_nsec st_atim.tv_nsec
124*8d67ca89SAndroid Build Coastguard Worker #define st_mtime_nsec st_mtim.tv_nsec
125*8d67ca89SAndroid Build Coastguard Worker #define st_ctime_nsec st_ctim.tv_nsec
126*8d67ca89SAndroid Build Coastguard Worker 
127*8d67ca89SAndroid Build Coastguard Worker #if defined(__USE_BSD)
128*8d67ca89SAndroid Build Coastguard Worker /* Permission macros provided by glibc for compatibility with BSDs. */
129*8d67ca89SAndroid Build Coastguard Worker #define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
130*8d67ca89SAndroid Build Coastguard Worker #define ALLPERMS    (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */
131*8d67ca89SAndroid Build Coastguard Worker #define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */
132*8d67ca89SAndroid Build Coastguard Worker #endif
133*8d67ca89SAndroid Build Coastguard Worker 
134*8d67ca89SAndroid Build Coastguard Worker #if defined(__USE_BSD) || defined(__USE_GNU)
135*8d67ca89SAndroid Build Coastguard Worker #define S_IREAD S_IRUSR
136*8d67ca89SAndroid Build Coastguard Worker #define S_IWRITE S_IWUSR
137*8d67ca89SAndroid Build Coastguard Worker #define S_IEXEC S_IXUSR
138*8d67ca89SAndroid Build Coastguard Worker #endif
139*8d67ca89SAndroid Build Coastguard Worker 
140*8d67ca89SAndroid Build Coastguard Worker /* POSIX mandates these, but Linux doesn't implement them as distinct file types. */
141*8d67ca89SAndroid Build Coastguard Worker #define S_TYPEISMQ(__sb) 0
142*8d67ca89SAndroid Build Coastguard Worker #define S_TYPEISSEM(__sb) 0
143*8d67ca89SAndroid Build Coastguard Worker #define S_TYPEISSHM(__sb) 0
144*8d67ca89SAndroid Build Coastguard Worker #define S_TYPEISTMO(__sb) 0
145*8d67ca89SAndroid Build Coastguard Worker 
146*8d67ca89SAndroid Build Coastguard Worker /**
147*8d67ca89SAndroid Build Coastguard Worker  * [chmod(2)](https://man7.org/linux/man-pages/man2/chmod.2.html)
148*8d67ca89SAndroid Build Coastguard Worker  * changes the mode of a file given a path.
149*8d67ca89SAndroid Build Coastguard Worker  *
150*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
151*8d67ca89SAndroid Build Coastguard Worker  */
152*8d67ca89SAndroid Build Coastguard Worker int chmod(const char* _Nonnull __path, mode_t __mode);
153*8d67ca89SAndroid Build Coastguard Worker 
154*8d67ca89SAndroid Build Coastguard Worker /**
155*8d67ca89SAndroid Build Coastguard Worker  * [fchmod(2)](https://man7.org/linux/man-pages/man2/fchmod.2.html)
156*8d67ca89SAndroid Build Coastguard Worker  * changes the mode of a file given a file descriptor.
157*8d67ca89SAndroid Build Coastguard Worker  *
158*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
159*8d67ca89SAndroid Build Coastguard Worker  */
160*8d67ca89SAndroid Build Coastguard Worker int fchmod(int __fd, mode_t __mode);
161*8d67ca89SAndroid Build Coastguard Worker 
162*8d67ca89SAndroid Build Coastguard Worker /**
163*8d67ca89SAndroid Build Coastguard Worker  * [fchmodat(2)](https://man7.org/linux/man-pages/man2/fchmodat.2.html)
164*8d67ca89SAndroid Build Coastguard Worker  * changes the mode of a file.
165*8d67ca89SAndroid Build Coastguard Worker  *
166*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
167*8d67ca89SAndroid Build Coastguard Worker  */
168*8d67ca89SAndroid Build Coastguard Worker int fchmodat(int __dir_fd, const char* _Nonnull __path, mode_t __mode, int __flags);
169*8d67ca89SAndroid Build Coastguard Worker 
170*8d67ca89SAndroid Build Coastguard Worker /**
171*8d67ca89SAndroid Build Coastguard Worker  * [chmod(2)](https://man7.org/linux/man-pages/man2/chmod.2.html)
172*8d67ca89SAndroid Build Coastguard Worker  * changes the mode of a file given a path, without following symlinks.
173*8d67ca89SAndroid Build Coastguard Worker  *
174*8d67ca89SAndroid Build Coastguard Worker  * Equivalent to `fchmodat(AT_FDCWD, path, mode, AT_SYMLINK_NOFOLLOW)`.
175*8d67ca89SAndroid Build Coastguard Worker  *
176*8d67ca89SAndroid Build Coastguard Worker  * Available since API 36.
177*8d67ca89SAndroid Build Coastguard Worker  *
178*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
179*8d67ca89SAndroid Build Coastguard Worker  */
180*8d67ca89SAndroid Build Coastguard Worker 
181*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(36)
182*8d67ca89SAndroid Build Coastguard Worker int lchmod(const char* _Nonnull __path, mode_t __mode) __INTRODUCED_IN(36);
183*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(36) */
184*8d67ca89SAndroid Build Coastguard Worker 
185*8d67ca89SAndroid Build Coastguard Worker 
186*8d67ca89SAndroid Build Coastguard Worker /**
187*8d67ca89SAndroid Build Coastguard Worker  * [mkdir(2)](https://man7.org/linux/man-pages/man2/mkdir.2.html)
188*8d67ca89SAndroid Build Coastguard Worker  * creates a directory.
189*8d67ca89SAndroid Build Coastguard Worker  *
190*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
191*8d67ca89SAndroid Build Coastguard Worker  */
192*8d67ca89SAndroid Build Coastguard Worker int mkdir(const char* _Nonnull __path, mode_t __mode);
193*8d67ca89SAndroid Build Coastguard Worker 
194*8d67ca89SAndroid Build Coastguard Worker /**
195*8d67ca89SAndroid Build Coastguard Worker  * [mkdirat(2)](https://man7.org/linux/man-pages/man2/mkdirat.2.html)
196*8d67ca89SAndroid Build Coastguard Worker  * creates a directory.
197*8d67ca89SAndroid Build Coastguard Worker  *
198*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
199*8d67ca89SAndroid Build Coastguard Worker  */
200*8d67ca89SAndroid Build Coastguard Worker int mkdirat(int __dir_fd, const char* _Nonnull __path, mode_t __mode);
201*8d67ca89SAndroid Build Coastguard Worker 
202*8d67ca89SAndroid Build Coastguard Worker /**
203*8d67ca89SAndroid Build Coastguard Worker  * [fstat(2)](https://man7.org/linux/man-pages/man2/fstat.2.html)
204*8d67ca89SAndroid Build Coastguard Worker  * gets file status given a file descriptor.
205*8d67ca89SAndroid Build Coastguard Worker  *
206*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
207*8d67ca89SAndroid Build Coastguard Worker  */
208*8d67ca89SAndroid Build Coastguard Worker int fstat(int __fd, struct stat* _Nonnull __buf);
209*8d67ca89SAndroid Build Coastguard Worker 
210*8d67ca89SAndroid Build Coastguard Worker /** An alias for fstat(). */
211*8d67ca89SAndroid Build Coastguard Worker int fstat64(int __fd, struct stat64* _Nonnull __buf);
212*8d67ca89SAndroid Build Coastguard Worker 
213*8d67ca89SAndroid Build Coastguard Worker /**
214*8d67ca89SAndroid Build Coastguard Worker  * [fstatat(2)](https://man7.org/linux/man-pages/man2/fstatat.2.html)
215*8d67ca89SAndroid Build Coastguard Worker  * gets file status.
216*8d67ca89SAndroid Build Coastguard Worker  *
217*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
218*8d67ca89SAndroid Build Coastguard Worker  */
219*8d67ca89SAndroid Build Coastguard Worker int fstatat(int __dir_fd, const char* _Nonnull __path, struct stat* _Nonnull __buf, int __flags);
220*8d67ca89SAndroid Build Coastguard Worker 
221*8d67ca89SAndroid Build Coastguard Worker /** An alias for fstatat(). */
222*8d67ca89SAndroid Build Coastguard Worker int fstatat64(int __dir_fd, const char* _Nonnull __path, struct stat64* _Nonnull __buf, int __flags);
223*8d67ca89SAndroid Build Coastguard Worker 
224*8d67ca89SAndroid Build Coastguard Worker /**
225*8d67ca89SAndroid Build Coastguard Worker  * [lstat(2)](https://man7.org/linux/man-pages/man2/lstat.2.html)
226*8d67ca89SAndroid Build Coastguard Worker  * gets file status given a path, without following symlinks.
227*8d67ca89SAndroid Build Coastguard Worker  *
228*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
229*8d67ca89SAndroid Build Coastguard Worker  */
230*8d67ca89SAndroid Build Coastguard Worker int lstat(const char* _Nonnull __path, struct stat* _Nonnull __buf);
231*8d67ca89SAndroid Build Coastguard Worker 
232*8d67ca89SAndroid Build Coastguard Worker /** An alias for lstat(). */
233*8d67ca89SAndroid Build Coastguard Worker int lstat64(const char* _Nonnull __path, struct stat64* _Nonnull __buf);
234*8d67ca89SAndroid Build Coastguard Worker 
235*8d67ca89SAndroid Build Coastguard Worker /**
236*8d67ca89SAndroid Build Coastguard Worker  * [stat(2)](https://man7.org/linux/man-pages/man2/stat.2.html)
237*8d67ca89SAndroid Build Coastguard Worker  * gets file status given a path.
238*8d67ca89SAndroid Build Coastguard Worker  *
239*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
240*8d67ca89SAndroid Build Coastguard Worker  */
241*8d67ca89SAndroid Build Coastguard Worker int stat(const char* _Nonnull __path, struct stat* _Nonnull __buf);
242*8d67ca89SAndroid Build Coastguard Worker 
243*8d67ca89SAndroid Build Coastguard Worker /** An alias for stat(). */
244*8d67ca89SAndroid Build Coastguard Worker int stat64(const char* _Nonnull __path, struct stat64* _Nonnull __buf);
245*8d67ca89SAndroid Build Coastguard Worker 
246*8d67ca89SAndroid Build Coastguard Worker /**
247*8d67ca89SAndroid Build Coastguard Worker  * [mknod(2)](https://man7.org/linux/man-pages/man2/mknod.2.html)
248*8d67ca89SAndroid Build Coastguard Worker  * creates a directory, special, or regular file.
249*8d67ca89SAndroid Build Coastguard Worker  *
250*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
251*8d67ca89SAndroid Build Coastguard Worker  */
252*8d67ca89SAndroid Build Coastguard Worker int mknod(const char* _Nonnull __path, mode_t __mode, dev_t __dev);
253*8d67ca89SAndroid Build Coastguard Worker 
254*8d67ca89SAndroid Build Coastguard Worker /**
255*8d67ca89SAndroid Build Coastguard Worker  * [mknodat(2)](https://man7.org/linux/man-pages/man2/mknodat.2.html)
256*8d67ca89SAndroid Build Coastguard Worker  * creates a directory, special, or regular file.
257*8d67ca89SAndroid Build Coastguard Worker  *
258*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
259*8d67ca89SAndroid Build Coastguard Worker  */
260*8d67ca89SAndroid Build Coastguard Worker int mknodat(int __dir_fd, const char* _Nonnull __path, mode_t __mode, dev_t __dev);
261*8d67ca89SAndroid Build Coastguard Worker 
262*8d67ca89SAndroid Build Coastguard Worker /**
263*8d67ca89SAndroid Build Coastguard Worker  * [umask(2)](https://man7.org/linux/man-pages/man2/umask.2.html)
264*8d67ca89SAndroid Build Coastguard Worker  * gets and sets the process-wide file mode creation mask.
265*8d67ca89SAndroid Build Coastguard Worker  *
266*8d67ca89SAndroid Build Coastguard Worker  * Returns the previous file mode creation mask.
267*8d67ca89SAndroid Build Coastguard Worker  */
268*8d67ca89SAndroid Build Coastguard Worker mode_t umask(mode_t __mask);
269*8d67ca89SAndroid Build Coastguard Worker 
270*8d67ca89SAndroid Build Coastguard Worker #if defined(__BIONIC_INCLUDE_FORTIFY_HEADERS)
271*8d67ca89SAndroid Build Coastguard Worker #include <bits/fortify/stat.h>
272*8d67ca89SAndroid Build Coastguard Worker #endif
273*8d67ca89SAndroid Build Coastguard Worker 
274*8d67ca89SAndroid Build Coastguard Worker /**
275*8d67ca89SAndroid Build Coastguard Worker  * [mkfifo(2)](https://man7.org/linux/man-pages/man2/mkfifo.2.html)
276*8d67ca89SAndroid Build Coastguard Worker  * creates a FIFO.
277*8d67ca89SAndroid Build Coastguard Worker  *
278*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
279*8d67ca89SAndroid Build Coastguard Worker  */
280*8d67ca89SAndroid Build Coastguard Worker int mkfifo(const char* _Nonnull __path, mode_t __mode);
281*8d67ca89SAndroid Build Coastguard Worker 
282*8d67ca89SAndroid Build Coastguard Worker /**
283*8d67ca89SAndroid Build Coastguard Worker  * [mkfifoat(2)](https://man7.org/linux/man-pages/man2/mkfifoat.2.html)
284*8d67ca89SAndroid Build Coastguard Worker  * creates a FIFO.
285*8d67ca89SAndroid Build Coastguard Worker  *
286*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
287*8d67ca89SAndroid Build Coastguard Worker  */
288*8d67ca89SAndroid Build Coastguard Worker 
289*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(23)
290*8d67ca89SAndroid Build Coastguard Worker int mkfifoat(int __dir_fd, const char* _Nonnull __path, mode_t __mode) __INTRODUCED_IN(23);
291*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(23) */
292*8d67ca89SAndroid Build Coastguard Worker 
293*8d67ca89SAndroid Build Coastguard Worker 
294*8d67ca89SAndroid Build Coastguard Worker /**
295*8d67ca89SAndroid Build Coastguard Worker  * Used in the tv_nsec field of an argument to utimensat()/futimens()
296*8d67ca89SAndroid Build Coastguard Worker  * to set that time to the current time.
297*8d67ca89SAndroid Build Coastguard Worker  */
298*8d67ca89SAndroid Build Coastguard Worker #define UTIME_NOW  ((1L << 30) - 1L)
299*8d67ca89SAndroid Build Coastguard Worker 
300*8d67ca89SAndroid Build Coastguard Worker /**
301*8d67ca89SAndroid Build Coastguard Worker  * Used in the tv_nsec field of an argument to utimensat()/futimens()
302*8d67ca89SAndroid Build Coastguard Worker  * to _not_ set that time.
303*8d67ca89SAndroid Build Coastguard Worker  */
304*8d67ca89SAndroid Build Coastguard Worker #define UTIME_OMIT ((1L << 30) - 2L)
305*8d67ca89SAndroid Build Coastguard Worker 
306*8d67ca89SAndroid Build Coastguard Worker /**
307*8d67ca89SAndroid Build Coastguard Worker  * [utimensat(2)](https://man7.org/linux/man-pages/man2/utimensat.2.html) sets
308*8d67ca89SAndroid Build Coastguard Worker  * file timestamps.
309*8d67ca89SAndroid Build Coastguard Worker  *
310*8d67ca89SAndroid Build Coastguard Worker  * Note: Linux supports `__path` being NULL (in which case `__dir_fd` need not
311*8d67ca89SAndroid Build Coastguard Worker  * be a directory), allowing futimens() to be implemented with utimensat().
312*8d67ca89SAndroid Build Coastguard Worker  * For normal use of utimensat(), though, `__path` should be non-null.
313*8d67ca89SAndroid Build Coastguard Worker  *
314*8d67ca89SAndroid Build Coastguard Worker  * `__times[0]` is the access time (atime), and `__times[1]` the last modification time (mtime).
315*8d67ca89SAndroid Build Coastguard Worker  * If `__times` is NULL, both times are set to the current time.
316*8d67ca89SAndroid Build Coastguard Worker  * See also UTIME_NOW and UTIME_OMIT.
317*8d67ca89SAndroid Build Coastguard Worker  *
318*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
319*8d67ca89SAndroid Build Coastguard Worker  */
320*8d67ca89SAndroid Build Coastguard Worker int utimensat(int __dir_fd, const char* __BIONIC_COMPLICATED_NULLNESS __path, const struct timespec __times[_Nullable 2], int __flags);
321*8d67ca89SAndroid Build Coastguard Worker 
322*8d67ca89SAndroid Build Coastguard Worker /**
323*8d67ca89SAndroid Build Coastguard Worker  * [futimens(2)](https://man7.org/linux/man-pages/man2/utimensat.2.html) sets
324*8d67ca89SAndroid Build Coastguard Worker  * the given file descriptor's timestamp.
325*8d67ca89SAndroid Build Coastguard Worker  *
326*8d67ca89SAndroid Build Coastguard Worker  * `__times[0]` is the access time (atime), and `__times[1]` the last modification time (mtime).
327*8d67ca89SAndroid Build Coastguard Worker  * If `__times` is NULL, both times are set to the current time.
328*8d67ca89SAndroid Build Coastguard Worker  * See also UTIME_NOW and UTIME_OMIT.
329*8d67ca89SAndroid Build Coastguard Worker  *
330*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
331*8d67ca89SAndroid Build Coastguard Worker  */
332*8d67ca89SAndroid Build Coastguard Worker int futimens(int __fd, const struct timespec __times[_Nullable 2]);
333*8d67ca89SAndroid Build Coastguard Worker 
334*8d67ca89SAndroid Build Coastguard Worker #if defined(__USE_GNU)
335*8d67ca89SAndroid Build Coastguard Worker /**
336*8d67ca89SAndroid Build Coastguard Worker  * [statx(2)](https://man7.org/linux/man-pages/man2/statx.2.html) returns
337*8d67ca89SAndroid Build Coastguard Worker  * extended file status information.
338*8d67ca89SAndroid Build Coastguard Worker  *
339*8d67ca89SAndroid Build Coastguard Worker  * Returns 0 on success and returns -1 and sets `errno` on failure.
340*8d67ca89SAndroid Build Coastguard Worker  *
341*8d67ca89SAndroid Build Coastguard Worker  * Available since API level 30.
342*8d67ca89SAndroid Build Coastguard Worker  */
343*8d67ca89SAndroid Build Coastguard Worker 
344*8d67ca89SAndroid Build Coastguard Worker #if __BIONIC_AVAILABILITY_GUARD(30)
345*8d67ca89SAndroid Build Coastguard Worker int statx(int __dir_fd, const char* _Nullable __path, int __flags, unsigned __mask, struct statx* _Nonnull __buf) __INTRODUCED_IN(30);
346*8d67ca89SAndroid Build Coastguard Worker #endif /* __BIONIC_AVAILABILITY_GUARD(30) */
347*8d67ca89SAndroid Build Coastguard Worker 
348*8d67ca89SAndroid Build Coastguard Worker #endif
349*8d67ca89SAndroid Build Coastguard Worker 
350*8d67ca89SAndroid Build Coastguard Worker __END_DECLS
351