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 | */ |
| 28 | #ifndef _SYS_STAT_H_ |
| 29 | #define _SYS_STAT_H_ |
| 30 | |
| 31 | #include <sys/cdefs.h> |
| 32 | #include <sys/types.h> |
| 33 | #include <sys/time.h> |
| 34 | #include <linux/stat.h> |
| 35 | |
| 36 | #include <endian.h> |
| 37 | |
| 38 | __BEGIN_DECLS |
| 39 | |
| 40 | /* really matches stat64 in the kernel, hence the padding |
| 41 | * Note: The kernel zero's the padded region because glibc might read them |
| 42 | * in the hope that the kernel has stretched to using larger sizes. |
| 43 | */ |
Raghu Gandham | 6437eac | 2012-08-02 16:50:10 -0700 | [diff] [blame] | 44 | #ifdef __mips__ |
| 45 | struct stat { |
| 46 | unsigned long st_dev; |
| 47 | unsigned long __pad0[3]; |
| 48 | |
| 49 | unsigned long long st_ino; |
| 50 | |
| 51 | unsigned int st_mode; |
| 52 | unsigned int st_nlink; |
| 53 | |
| 54 | unsigned long st_uid; |
| 55 | unsigned long st_gid; |
| 56 | |
| 57 | unsigned long st_rdev; |
| 58 | unsigned long __pad1[3]; |
| 59 | |
| 60 | long long st_size; |
| 61 | |
| 62 | unsigned long st_atime; |
| 63 | unsigned long st_atime_nsec; |
| 64 | |
| 65 | unsigned long st_mtime; |
| 66 | unsigned long st_mtime_nsec; |
| 67 | |
| 68 | unsigned long st_ctime; |
| 69 | unsigned long st_ctime_nsec; |
| 70 | |
| 71 | unsigned long st_blksize; |
| 72 | unsigned long __pad2; |
| 73 | |
| 74 | unsigned long long st_blocks; |
| 75 | }; |
| 76 | #else |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 77 | struct stat { |
| 78 | unsigned long long st_dev; |
| 79 | unsigned char __pad0[4]; |
| 80 | |
| 81 | unsigned long __st_ino; |
| 82 | unsigned int st_mode; |
| 83 | unsigned int st_nlink; |
| 84 | |
| 85 | unsigned long st_uid; |
| 86 | unsigned long st_gid; |
| 87 | |
| 88 | unsigned long long st_rdev; |
| 89 | unsigned char __pad3[4]; |
| 90 | |
| 91 | long long st_size; |
| 92 | unsigned long st_blksize; |
| 93 | unsigned long long st_blocks; |
| 94 | |
| 95 | unsigned long st_atime; |
| 96 | unsigned long st_atime_nsec; |
| 97 | |
| 98 | unsigned long st_mtime; |
| 99 | unsigned long st_mtime_nsec; |
| 100 | |
| 101 | unsigned long st_ctime; |
| 102 | unsigned long st_ctime_nsec; |
| 103 | |
| 104 | unsigned long long st_ino; |
| 105 | }; |
Raghu Gandham | 6437eac | 2012-08-02 16:50:10 -0700 | [diff] [blame] | 106 | #endif |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 107 | |
David 'Digit' Turner | 09baf4e | 2009-06-22 12:16:06 +0200 | [diff] [blame] | 108 | /* For compatibility with GLibc, we provide macro aliases |
| 109 | * for the non-Posix nano-seconds accessors. |
| 110 | */ |
| 111 | #define st_atimensec st_atime_nsec |
| 112 | #define st_mtimensec st_mtime_nsec |
| 113 | #define st_ctimensec st_ctime_nsec |
| 114 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 115 | extern int chmod(const char *, mode_t); |
| 116 | extern int fchmod(int, mode_t); |
| 117 | extern int mkdir(const char *, mode_t); |
| 118 | |
| 119 | extern int stat(const char *, struct stat *); |
| 120 | extern int fstat(int, struct stat *); |
| 121 | extern int lstat(const char *, struct stat *); |
| 122 | extern int mknod(const char *, mode_t, dev_t); |
| 123 | extern mode_t umask(mode_t); |
| 124 | |
Nick Kralevich | cd58770 | 2012-09-26 10:02:30 -0700 | [diff] [blame] | 125 | #if defined(__BIONIC_FORTIFY_INLINE) |
| 126 | |
| 127 | extern mode_t __umask_chk(mode_t); |
| 128 | extern mode_t __umask_real(mode_t) |
| 129 | __asm__(__USER_LABEL_PREFIX__ "umask"); |
| 130 | extern void __umask_error() |
| 131 | __attribute__((__error__("umask called with invalid mode"))); |
| 132 | |
| 133 | __BIONIC_FORTIFY_INLINE |
| 134 | mode_t umask(mode_t mode) { |
| 135 | if (__builtin_constant_p(mode)) { |
| 136 | if ((mode & 0777) != mode) { |
| 137 | __umask_error(); |
| 138 | } |
| 139 | return __umask_real(mode); |
| 140 | } |
| 141 | return __umask_chk(mode); |
| 142 | } |
| 143 | #endif /* defined(__BIONIC_FORTIFY_INLINE) */ |
| 144 | |
| 145 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 146 | #define stat64 stat |
| 147 | #define fstat64 fstat |
| 148 | #define lstat64 lstat |
| 149 | |
| 150 | static __inline__ int mkfifo(const char *__p, mode_t __m) |
| 151 | { |
| 152 | return mknod(__p, (__m & ~S_IFMT) | S_IFIFO, (dev_t)0); |
| 153 | } |
| 154 | |
| 155 | extern int fstatat(int dirfd, const char *path, struct stat *buf, int flags); |
| 156 | extern int mkdirat(int dirfd, const char *pathname, mode_t mode); |
| 157 | extern int fchownat(int dirfd, const char *path, uid_t owner, gid_t group, int flags); |
| 158 | extern int fchmodat(int dirfd, const char *path, mode_t mode, int flags); |
| 159 | extern int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath); |
| 160 | |
Ken Sumrall | ae2d5ba | 2011-03-18 11:55:12 -0700 | [diff] [blame] | 161 | # define UTIME_NOW ((1l << 30) - 1l) |
| 162 | # define UTIME_OMIT ((1l << 30) - 2l) |
| 163 | extern int utimensat (int fd, const char *path, const struct timespec times[2], int flags); |
| 164 | |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 165 | __END_DECLS |
| 166 | |
| 167 | #endif /* _SYS_STAT_H_ */ |