The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | */ |
Elliott Hughes | b810462 | 2014-08-19 09:18:03 -0700 | [diff] [blame] | 28 | |
Elliott Hughes | 733cedd | 2020-02-21 23:21:28 -0800 | [diff] [blame] | 29 | #pragma once |
| 30 | |
| 31 | /** |
| 32 | * @file sys/stat.h |
| 33 | * @brief File status. |
| 34 | */ |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 35 | |
Elliott Hughes | 414dd2d | 2024-10-16 14:48:30 +0000 | [diff] [blame] | 36 | #include <sys/cdefs.h> |
| 37 | |
Elliott Hughes | 5704c42 | 2016-01-25 18:06:24 -0800 | [diff] [blame] | 38 | #include <bits/timespec.h> |
Yabin Cui | db49903 | 2014-12-09 20:15:48 -0800 | [diff] [blame] | 39 | #include <linux/stat.h> |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 40 | #include <sys/types.h> |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 41 | |
| 42 | __BEGIN_DECLS |
| 43 | |
Elliott Hughes | 5cc8a46 | 2022-10-06 00:26:18 +0000 | [diff] [blame] | 44 | #if defined(__aarch64__) || defined(__riscv) |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 45 | #define __STAT64_BODY \ |
Elliott Hughes | 9257c47 | 2014-12-18 15:17:42 -0800 | [diff] [blame] | 46 | dev_t st_dev; \ |
| 47 | ino_t st_ino; \ |
| 48 | mode_t st_mode; \ |
| 49 | nlink_t st_nlink; \ |
Elliott Hughes | 6b55593 | 2014-02-18 16:43:31 -0800 | [diff] [blame] | 50 | uid_t st_uid; \ |
| 51 | gid_t st_gid; \ |
Elliott Hughes | 9257c47 | 2014-12-18 15:17:42 -0800 | [diff] [blame] | 52 | dev_t st_rdev; \ |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 53 | unsigned long __pad1; \ |
Elliott Hughes | 9257c47 | 2014-12-18 15:17:42 -0800 | [diff] [blame] | 54 | off_t st_size; \ |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 55 | int st_blksize; \ |
| 56 | int __pad2; \ |
| 57 | long st_blocks; \ |
Elliott Hughes | 0ac0df8 | 2014-11-07 19:15:10 -0800 | [diff] [blame] | 58 | struct timespec st_atim; \ |
| 59 | struct timespec st_mtim; \ |
| 60 | struct timespec st_ctim; \ |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 61 | unsigned int __unused4; \ |
| 62 | unsigned int __unused5; \ |
| 63 | |
Elliott Hughes | b8fa5b1 | 2013-12-19 16:50:22 -0800 | [diff] [blame] | 64 | #elif defined(__x86_64__) |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 65 | #define __STAT64_BODY \ |
Elliott Hughes | 1c52e6c | 2014-12-18 12:38:44 -0800 | [diff] [blame] | 66 | dev_t st_dev; \ |
| 67 | ino_t st_ino; \ |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 68 | unsigned long st_nlink; \ |
Elliott Hughes | 1c52e6c | 2014-12-18 12:38:44 -0800 | [diff] [blame] | 69 | mode_t st_mode; \ |
Elliott Hughes | 6b55593 | 2014-02-18 16:43:31 -0800 | [diff] [blame] | 70 | uid_t st_uid; \ |
| 71 | gid_t st_gid; \ |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 72 | unsigned int __pad0; \ |
Elliott Hughes | 1c52e6c | 2014-12-18 12:38:44 -0800 | [diff] [blame] | 73 | dev_t st_rdev; \ |
| 74 | off_t st_size; \ |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 75 | long st_blksize; \ |
| 76 | long st_blocks; \ |
Elliott Hughes | 0ac0df8 | 2014-11-07 19:15:10 -0800 | [diff] [blame] | 77 | struct timespec st_atim; \ |
| 78 | struct timespec st_mtim; \ |
| 79 | struct timespec st_ctim; \ |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 80 | long __pad3[3]; \ |
| 81 | |
Elliott Hughes | 9257c47 | 2014-12-18 15:17:42 -0800 | [diff] [blame] | 82 | #else /* __arm__ || __i386__ */ |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 83 | #define __STAT64_BODY \ |
| 84 | unsigned long long st_dev; \ |
| 85 | unsigned char __pad0[4]; \ |
| 86 | unsigned long __st_ino; \ |
| 87 | unsigned int st_mode; \ |
Elliott Hughes | 9257c47 | 2014-12-18 15:17:42 -0800 | [diff] [blame] | 88 | nlink_t st_nlink; \ |
Elliott Hughes | 6b55593 | 2014-02-18 16:43:31 -0800 | [diff] [blame] | 89 | uid_t st_uid; \ |
| 90 | gid_t st_gid; \ |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 91 | unsigned long long st_rdev; \ |
| 92 | unsigned char __pad3[4]; \ |
| 93 | long long st_size; \ |
| 94 | unsigned long st_blksize; \ |
| 95 | unsigned long long st_blocks; \ |
Elliott Hughes | 0ac0df8 | 2014-11-07 19:15:10 -0800 | [diff] [blame] | 96 | struct timespec st_atim; \ |
| 97 | struct timespec st_mtim; \ |
| 98 | struct timespec st_ctim; \ |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 99 | unsigned long long st_ino; \ |
| 100 | |
Raghu Gandham | 6437eac | 2012-08-02 16:50:10 -0700 | [diff] [blame] | 101 | #endif |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 102 | |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 103 | /** The file information returned by fstat()/fstatat()/lstat()/stat(). */ |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 104 | struct stat { __STAT64_BODY }; |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | * A synonym for `struct stat` on Android, |
| 108 | * provided for source compatibility with other systems. |
| 109 | */ |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 110 | struct stat64 { __STAT64_BODY }; |
| 111 | |
Calin Juravle | f963da2 | 2014-05-13 11:01:11 +0100 | [diff] [blame] | 112 | #undef __STAT64_BODY |
| 113 | |
Elliott Hughes | 0ac0df8 | 2014-11-07 19:15:10 -0800 | [diff] [blame] | 114 | /* Compatibility with older versions of POSIX. */ |
| 115 | #define st_atime st_atim.tv_sec |
| 116 | #define st_mtime st_mtim.tv_sec |
| 117 | #define st_ctime st_ctim.tv_sec |
| 118 | /* Compatibility with glibc. */ |
| 119 | #define st_atimensec st_atim.tv_nsec |
| 120 | #define st_mtimensec st_mtim.tv_nsec |
| 121 | #define st_ctimensec st_ctim.tv_nsec |
Dan Albert | a4e774c | 2017-06-12 14:59:38 -0700 | [diff] [blame] | 122 | /* Compatibility with Linux headers and old NDKs. */ |
| 123 | #define st_atime_nsec st_atim.tv_nsec |
| 124 | #define st_mtime_nsec st_mtim.tv_nsec |
| 125 | #define st_ctime_nsec st_ctim.tv_nsec |
David 'Digit' Turner | 09baf4e | 2009-06-22 12:16:06 +0200 | [diff] [blame] | 126 | |
Elliott Hughes | 3ba55f8 | 2016-06-08 18:11:23 -0700 | [diff] [blame] | 127 | #if defined(__USE_BSD) |
Hakan Kvist | f27b7fb | 2012-10-10 08:32:52 +0200 | [diff] [blame] | 128 | /* Permission macros provided by glibc for compatibility with BSDs. */ |
| 129 | #define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */ |
| 130 | #define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */ |
| 131 | #define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */ |
| 132 | #endif |
| 133 | |
Elliott Hughes | 1f1a51a | 2016-03-31 17:05:30 -0700 | [diff] [blame] | 134 | #if defined(__USE_BSD) || defined(__USE_GNU) |
| 135 | #define S_IREAD S_IRUSR |
| 136 | #define S_IWRITE S_IWUSR |
| 137 | #define S_IEXEC S_IXUSR |
| 138 | #endif |
| 139 | |
Elliott Hughes | 9288761 | 2016-08-16 13:26:35 -0700 | [diff] [blame] | 140 | /* POSIX mandates these, but Linux doesn't implement them as distinct file types. */ |
| 141 | #define S_TYPEISMQ(__sb) 0 |
| 142 | #define S_TYPEISSEM(__sb) 0 |
| 143 | #define S_TYPEISSHM(__sb) 0 |
| 144 | #define S_TYPEISTMO(__sb) 0 |
| 145 | |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 146 | /** |
| 147 | * [chmod(2)](https://man7.org/linux/man-pages/man2/chmod.2.html) |
| 148 | * changes the mode of a file given a path. |
| 149 | * |
| 150 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
| 151 | */ |
zijunzhao | 1cda74d | 2023-02-03 02:28:40 +0000 | [diff] [blame] | 152 | int chmod(const char* _Nonnull __path, mode_t __mode); |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 153 | |
| 154 | /** |
| 155 | * [fchmod(2)](https://man7.org/linux/man-pages/man2/fchmod.2.html) |
| 156 | * changes the mode of a file given a file descriptor. |
| 157 | * |
| 158 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
| 159 | */ |
Elliott Hughes | ff26a16 | 2017-08-17 22:34:21 +0000 | [diff] [blame] | 160 | int fchmod(int __fd, mode_t __mode); |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 161 | |
| 162 | /** |
| 163 | * [fchmodat(2)](https://man7.org/linux/man-pages/man2/fchmodat.2.html) |
| 164 | * changes the mode of a file. |
| 165 | * |
| 166 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
| 167 | */ |
| 168 | int fchmodat(int __dir_fd, const char* _Nonnull __path, mode_t __mode, int __flags); |
| 169 | |
| 170 | /** |
| 171 | * [chmod(2)](https://man7.org/linux/man-pages/man2/chmod.2.html) |
| 172 | * changes the mode of a file given a path, without following symlinks. |
| 173 | * |
| 174 | * Equivalent to `fchmodat(AT_FDCWD, path, mode, AT_SYMLINK_NOFOLLOW)`. |
| 175 | * |
| 176 | * Available since API 36. |
| 177 | * |
| 178 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
| 179 | */ |
Dan Albert | 02ce401 | 2024-10-25 19:13:49 +0000 | [diff] [blame] | 180 | |
| 181 | #if __BIONIC_AVAILABILITY_GUARD(36) |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 182 | int lchmod(const char* _Nonnull __path, mode_t __mode) __INTRODUCED_IN(36); |
Dan Albert | 02ce401 | 2024-10-25 19:13:49 +0000 | [diff] [blame] | 183 | #endif /* __BIONIC_AVAILABILITY_GUARD(36) */ |
| 184 | |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 185 | |
| 186 | /** |
| 187 | * [mkdir(2)](https://man7.org/linux/man-pages/man2/mkdir.2.html) |
| 188 | * creates a directory. |
| 189 | * |
| 190 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
| 191 | */ |
zijunzhao | 1cda74d | 2023-02-03 02:28:40 +0000 | [diff] [blame] | 192 | int mkdir(const char* _Nonnull __path, mode_t __mode); |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 193 | |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 194 | /** |
| 195 | * [mkdirat(2)](https://man7.org/linux/man-pages/man2/mkdirat.2.html) |
| 196 | * creates a directory. |
| 197 | * |
| 198 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
| 199 | */ |
| 200 | int mkdirat(int __dir_fd, const char* _Nonnull __path, mode_t __mode); |
| 201 | |
| 202 | /** |
| 203 | * [fstat(2)](https://man7.org/linux/man-pages/man2/fstat.2.html) |
| 204 | * gets file status given a file descriptor. |
| 205 | * |
| 206 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
| 207 | */ |
zijunzhao | 1cda74d | 2023-02-03 02:28:40 +0000 | [diff] [blame] | 208 | int fstat(int __fd, struct stat* _Nonnull __buf); |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 209 | |
| 210 | /** An alias for fstat(). */ |
Elliott Hughes | 655e430 | 2023-06-16 12:39:33 -0700 | [diff] [blame] | 211 | int fstat64(int __fd, struct stat64* _Nonnull __buf); |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 212 | |
| 213 | /** |
| 214 | * [fstatat(2)](https://man7.org/linux/man-pages/man2/fstatat.2.html) |
| 215 | * gets file status. |
| 216 | * |
| 217 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
| 218 | */ |
zijunzhao | 1cda74d | 2023-02-03 02:28:40 +0000 | [diff] [blame] | 219 | int fstatat(int __dir_fd, const char* _Nonnull __path, struct stat* _Nonnull __buf, int __flags); |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 220 | |
| 221 | /** An alias for fstatat(). */ |
Elliott Hughes | 655e430 | 2023-06-16 12:39:33 -0700 | [diff] [blame] | 222 | int fstatat64(int __dir_fd, const char* _Nonnull __path, struct stat64* _Nonnull __buf, int __flags); |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 223 | |
| 224 | /** |
| 225 | * [lstat(2)](https://man7.org/linux/man-pages/man2/lstat.2.html) |
| 226 | * gets file status given a path, without following symlinks. |
| 227 | * |
| 228 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
| 229 | */ |
zijunzhao | 1cda74d | 2023-02-03 02:28:40 +0000 | [diff] [blame] | 230 | int lstat(const char* _Nonnull __path, struct stat* _Nonnull __buf); |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 231 | |
| 232 | /** An alias for lstat(). */ |
Elliott Hughes | 655e430 | 2023-06-16 12:39:33 -0700 | [diff] [blame] | 233 | int lstat64(const char* _Nonnull __path, struct stat64* _Nonnull __buf); |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 234 | |
| 235 | /** |
| 236 | * [stat(2)](https://man7.org/linux/man-pages/man2/stat.2.html) |
| 237 | * gets file status given a path. |
| 238 | * |
| 239 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
| 240 | */ |
zijunzhao | 1cda74d | 2023-02-03 02:28:40 +0000 | [diff] [blame] | 241 | int stat(const char* _Nonnull __path, struct stat* _Nonnull __buf); |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 242 | |
| 243 | /** An alias for stat(). */ |
Elliott Hughes | 655e430 | 2023-06-16 12:39:33 -0700 | [diff] [blame] | 244 | int stat64(const char* _Nonnull __path, struct stat64* _Nonnull __buf); |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 245 | |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 246 | /** |
| 247 | * [mknod(2)](https://man7.org/linux/man-pages/man2/mknod.2.html) |
| 248 | * creates a directory, special, or regular file. |
| 249 | * |
| 250 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
| 251 | */ |
zijunzhao | 1cda74d | 2023-02-03 02:28:40 +0000 | [diff] [blame] | 252 | int mknod(const char* _Nonnull __path, mode_t __mode, dev_t __dev); |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 253 | |
| 254 | /** |
| 255 | * [mknodat(2)](https://man7.org/linux/man-pages/man2/mknodat.2.html) |
| 256 | * creates a directory, special, or regular file. |
| 257 | * |
| 258 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
| 259 | */ |
| 260 | int mknodat(int __dir_fd, const char* _Nonnull __path, mode_t __mode, dev_t __dev); |
| 261 | |
| 262 | /** |
| 263 | * [umask(2)](https://man7.org/linux/man-pages/man2/umask.2.html) |
| 264 | * gets and sets the process-wide file mode creation mask. |
| 265 | * |
| 266 | * Returns the previous file mode creation mask. |
| 267 | */ |
George Burgess IV | 9024235 | 2018-02-06 12:51:31 -0800 | [diff] [blame] | 268 | mode_t umask(mode_t __mask); |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 269 | |
George Burgess IV | b97049c | 2017-07-24 15:05:05 -0700 | [diff] [blame] | 270 | #if defined(__BIONIC_INCLUDE_FORTIFY_HEADERS) |
| 271 | #include <bits/fortify/stat.h> |
| 272 | #endif |
Nick Kralevich | cd58770 | 2012-09-26 10:02:30 -0700 | [diff] [blame] | 273 | |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 274 | /** |
| 275 | * [mkfifo(2)](https://man7.org/linux/man-pages/man2/mkfifo.2.html) |
| 276 | * creates a FIFO. |
| 277 | * |
| 278 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
| 279 | */ |
Elliott Hughes | 655e430 | 2023-06-16 12:39:33 -0700 | [diff] [blame] | 280 | int mkfifo(const char* _Nonnull __path, mode_t __mode); |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 281 | |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 282 | /** |
| 283 | * [mkfifoat(2)](https://man7.org/linux/man-pages/man2/mkfifoat.2.html) |
| 284 | * creates a FIFO. |
| 285 | * |
| 286 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
| 287 | */ |
Dan Albert | 02ce401 | 2024-10-25 19:13:49 +0000 | [diff] [blame] | 288 | |
| 289 | #if __BIONIC_AVAILABILITY_GUARD(23) |
Elliott Hughes | 219e602 | 2024-08-27 19:12:08 +0000 | [diff] [blame] | 290 | int mkfifoat(int __dir_fd, const char* _Nonnull __path, mode_t __mode) __INTRODUCED_IN(23); |
Dan Albert | 02ce401 | 2024-10-25 19:13:49 +0000 | [diff] [blame] | 291 | #endif /* __BIONIC_AVAILABILITY_GUARD(23) */ |
| 292 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 293 | |
zijunzhao | 1cda74d | 2023-02-03 02:28:40 +0000 | [diff] [blame] | 294 | /** |
| 295 | * Used in the tv_nsec field of an argument to utimensat()/futimens() |
| 296 | * to set that time to the current time. |
| 297 | */ |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 298 | #define UTIME_NOW ((1L << 30) - 1L) |
zijunzhao | 1cda74d | 2023-02-03 02:28:40 +0000 | [diff] [blame] | 299 | |
| 300 | /** |
| 301 | * Used in the tv_nsec field of an argument to utimensat()/futimens() |
| 302 | * to _not_ set that time. |
| 303 | */ |
Elliott Hughes | db1ea34 | 2014-01-17 18:42:49 -0800 | [diff] [blame] | 304 | #define UTIME_OMIT ((1L << 30) - 2L) |
zijunzhao | 1cda74d | 2023-02-03 02:28:40 +0000 | [diff] [blame] | 305 | |
| 306 | /** |
| 307 | * [utimensat(2)](https://man7.org/linux/man-pages/man2/utimensat.2.html) sets |
| 308 | * file timestamps. |
| 309 | * |
| 310 | * Note: Linux supports `__path` being NULL (in which case `__dir_fd` need not |
| 311 | * be a directory), allowing futimens() to be implemented with utimensat(). |
| 312 | * For normal use of utimensat(), though, `__path` should be non-null. |
| 313 | * |
| 314 | * `__times[0]` is the access time (atime), and `__times[1]` the last modification time (mtime). |
| 315 | * If `__times` is NULL, both times are set to the current time. |
| 316 | * See also UTIME_NOW and UTIME_OMIT. |
| 317 | * |
| 318 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
| 319 | */ |
| 320 | int utimensat(int __dir_fd, const char* __BIONIC_COMPLICATED_NULLNESS __path, const struct timespec __times[_Nullable 2], int __flags); |
| 321 | |
| 322 | /** |
| 323 | * [futimens(2)](https://man7.org/linux/man-pages/man2/utimensat.2.html) sets |
| 324 | * the given file descriptor's timestamp. |
| 325 | * |
| 326 | * `__times[0]` is the access time (atime), and `__times[1]` the last modification time (mtime). |
| 327 | * If `__times` is NULL, both times are set to the current time. |
| 328 | * See also UTIME_NOW and UTIME_OMIT. |
| 329 | * |
| 330 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
zijunzhao | 1cda74d | 2023-02-03 02:28:40 +0000 | [diff] [blame] | 331 | */ |
Elliott Hughes | 655e430 | 2023-06-16 12:39:33 -0700 | [diff] [blame] | 332 | int futimens(int __fd, const struct timespec __times[_Nullable 2]); |
Ken Sumrall | ae2d5ba | 2011-03-18 11:55:12 -0700 | [diff] [blame] | 333 | |
Elliott Hughes | 733cedd | 2020-02-21 23:21:28 -0800 | [diff] [blame] | 334 | #if defined(__USE_GNU) |
| 335 | /** |
Elliott Hughes | bbd39aa | 2024-08-13 20:59:16 +0000 | [diff] [blame] | 336 | * [statx(2)](https://man7.org/linux/man-pages/man2/statx.2.html) returns |
Elliott Hughes | 733cedd | 2020-02-21 23:21:28 -0800 | [diff] [blame] | 337 | * extended file status information. |
| 338 | * |
| 339 | * Returns 0 on success and returns -1 and sets `errno` on failure. |
zijunzhao | 1cda74d | 2023-02-03 02:28:40 +0000 | [diff] [blame] | 340 | * |
| 341 | * Available since API level 30. |
Elliott Hughes | 733cedd | 2020-02-21 23:21:28 -0800 | [diff] [blame] | 342 | */ |
Dan Albert | 02ce401 | 2024-10-25 19:13:49 +0000 | [diff] [blame] | 343 | |
| 344 | #if __BIONIC_AVAILABILITY_GUARD(30) |
Elliott Hughes | 6816893 | 2024-09-12 12:07:01 +0000 | [diff] [blame] | 345 | int statx(int __dir_fd, const char* _Nullable __path, int __flags, unsigned __mask, struct statx* _Nonnull __buf) __INTRODUCED_IN(30); |
Dan Albert | 02ce401 | 2024-10-25 19:13:49 +0000 | [diff] [blame] | 346 | #endif /* __BIONIC_AVAILABILITY_GUARD(30) */ |
| 347 | |
Elliott Hughes | 733cedd | 2020-02-21 23:21:28 -0800 | [diff] [blame] | 348 | #endif |
| 349 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 350 | __END_DECLS |