| 1 | /* $NetBSD: stat.h,v 1.7 2016/08/27 18:54:24 dholland Exp $ */ |
| 2 | |
| 3 | /*- |
| 4 | * Copyright (c) 1982, 1986, 1989, 1993 |
| 5 | * The Regents of the University of California. All rights reserved. |
| 6 | * (c) UNIX System Laboratories, Inc. |
| 7 | * All or some portions of this file are derived from material licensed |
| 8 | * to the University of California by American Telephone and Telegraph |
| 9 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with |
| 10 | * the permission of UNIX System Laboratories, Inc. |
| 11 | * |
| 12 | * Redistribution and use in source and binary forms, with or without |
| 13 | * modification, are permitted provided that the following conditions |
| 14 | * are met: |
| 15 | * 1. Redistributions of source code must retain the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer. |
| 17 | * 2. Redistributions in binary form must reproduce the above copyright |
| 18 | * notice, this list of conditions and the following disclaimer in the |
| 19 | * documentation and/or other materials provided with the distribution. |
| 20 | * 3. Neither the name of the University nor the names of its contributors |
| 21 | * may be used to endorse or promote products derived from this software |
| 22 | * without specific prior written permission. |
| 23 | * |
| 24 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 34 | * SUCH DAMAGE. |
| 35 | * |
| 36 | * @(#)stat.h 8.12 (Berkeley) 8/17/94 |
| 37 | */ |
| 38 | |
| 39 | #ifndef _COMPAT_SYS_STAT_H_ |
| 40 | #define _COMPAT_SYS_STAT_H_ |
| 41 | |
| 42 | #ifdef _KERNEL |
| 43 | #include <compat/sys/time.h> |
| 44 | |
| 45 | struct stat43 { /* BSD-4.3 stat struct */ |
| 46 | uint16_t st_dev; /* inode's device */ |
| 47 | uint32_t st_ino; /* inode's number */ |
| 48 | uint16_t st_mode; /* inode protection mode */ |
| 49 | uint16_t st_nlink; /* number of hard links */ |
| 50 | uint16_t st_uid; /* user ID of the file's owner */ |
| 51 | uint16_t st_gid; /* group ID of the file's group */ |
| 52 | uint16_t st_rdev; /* device type */ |
| 53 | int32_t st_size; /* file size, in bytes */ |
| 54 | struct timespec50 st_atimespec;/* time of last access */ |
| 55 | struct timespec50 st_mtimespec;/* time of last data modification */ |
| 56 | struct timespec50 st_ctimespec;/* time of last file status change */ |
| 57 | int32_t st_blksize; /* optimal blocksize for I/O */ |
| 58 | int32_t st_blocks; /* blocks allocated for file */ |
| 59 | uint32_t st_flags; /* user defined flags for file */ |
| 60 | uint32_t st_gen; /* file generation number */ |
| 61 | }; |
| 62 | #endif /* defined(_KERNEL) */ |
| 63 | |
| 64 | struct stat12 { /* NetBSD-1.2 stat struct */ |
| 65 | uint32_t st_dev; /* inode's device */ |
| 66 | uint32_t st_ino; /* inode's number */ |
| 67 | uint16_t st_mode; /* inode protection mode */ |
| 68 | uint16_t st_nlink; /* number of hard links */ |
| 69 | uid_t st_uid; /* user ID of the file's owner */ |
| 70 | gid_t st_gid; /* group ID of the file's group */ |
| 71 | uint32_t st_rdev; /* device type */ |
| 72 | struct timespec50 st_atimespec;/* time of last access */ |
| 73 | struct timespec50 st_mtimespec;/* time of last data modification */ |
| 74 | struct timespec50 st_ctimespec;/* time of last file status change */ |
| 75 | off_t st_size; /* file size, in bytes */ |
| 76 | int64_t st_blocks; /* blocks allocated for file */ |
| 77 | uint32_t st_blksize; /* optimal blocksize for I/O */ |
| 78 | uint32_t st_flags; /* user defined flags for file */ |
| 79 | uint32_t st_gen; /* file generation number */ |
| 80 | int32_t st_lspare; |
| 81 | int64_t st_qspare[2]; |
| 82 | }; |
| 83 | |
| 84 | /* |
| 85 | * On systems with 8 byte longs and 4 byte time_ts, padding the time_ts |
| 86 | * is required in order to have a consistent ABI. This is because the |
| 87 | * stat structure used to contain timespecs, which had different |
| 88 | * alignment constraints than a time_t and a long alone. The padding |
| 89 | * should be removed the next time the stat structure ABI is changed. |
| 90 | * (This happened when we changed to 8 byte time_t.) |
| 91 | */ |
| 92 | #if defined(_LP64) /* XXXX && _BSD_TIME_T_ == int */ |
| 93 | #define __STATPAD(x) int x; |
| 94 | #else |
| 95 | #define __STATPAD(x) /* nothing */ |
| 96 | #endif |
| 97 | |
| 98 | struct stat13 { |
| 99 | uint32_t st_dev; /* inode's device */ |
| 100 | uint32_t st_ino; /* inode's number */ |
| 101 | mode_t st_mode; /* inode protection mode */ |
| 102 | nlink_t st_nlink; /* number of hard links */ |
| 103 | uid_t st_uid; /* user ID of the file's owner */ |
| 104 | gid_t st_gid; /* group ID of the file's group */ |
| 105 | uint32_t st_rdev; /* device type */ |
| 106 | #if defined(_NETBSD_SOURCE) |
| 107 | struct timespec50 st_atimespec;/* time of last access */ |
| 108 | struct timespec50 st_mtimespec;/* time of last data modification */ |
| 109 | struct timespec50 st_ctimespec;/* time of last file status change */ |
| 110 | #else |
| 111 | __STATPAD(__pad0) |
| 112 | int32_t st_atime; /* time of last access */ |
| 113 | __STATPAD(__pad1) |
| 114 | long st_atimensec; /* nsec of last access */ |
| 115 | int32_t st_mtime; /* time of last data modification */ |
| 116 | __STATPAD(__pad2) |
| 117 | long st_mtimensec; /* nsec of last data modification */ |
| 118 | int32_t st_ctime; /* time of last file status change */ |
| 119 | __STATPAD(__pad3) |
| 120 | long st_ctimensec; /* nsec of last file status change */ |
| 121 | #endif |
| 122 | off_t st_size; /* file size, in bytes */ |
| 123 | blkcnt_t st_blocks; /* blocks allocated for file */ |
| 124 | blksize_t st_blksize; /* optimal blocksize for I/O */ |
| 125 | uint32_t st_flags; /* user defined flags for file */ |
| 126 | uint32_t st_gen; /* file generation number */ |
| 127 | uint32_t st_spare0; |
| 128 | #if defined(_NETBSD_SOURCE) |
| 129 | struct timespec50 st_birthtimespec; |
| 130 | #else |
| 131 | int32_t st_birthtime; |
| 132 | __STATPAD(__pad4) |
| 133 | long st_birthtimensec; |
| 134 | #endif |
| 135 | #if !defined(_LP64) |
| 136 | int __pad5; |
| 137 | #endif |
| 138 | }; |
| 139 | |
| 140 | struct stat30 { |
| 141 | uint32_t st_dev; /* inode's device */ |
| 142 | mode_t st_mode; /* inode protection mode */ |
| 143 | ino_t st_ino; /* inode's number */ |
| 144 | nlink_t st_nlink; /* number of hard links */ |
| 145 | uid_t st_uid; /* user ID of the file's owner */ |
| 146 | gid_t st_gid; /* group ID of the file's group */ |
| 147 | uint32_t st_rdev; /* device type */ |
| 148 | #if defined(_NETBSD_SOURCE) |
| 149 | struct timespec50 st_atimespec;/* time of last access */ |
| 150 | struct timespec50 st_mtimespec;/* time of last data modification */ |
| 151 | struct timespec50 st_ctimespec;/* time of last file status change */ |
| 152 | struct timespec50 st_birthtimespec; /* time of creation */ |
| 153 | #else |
| 154 | int32_t st_atime; /* time of last access */ |
| 155 | __STATPAD(__pad0) |
| 156 | long st_atimensec; /* nsec of last access */ |
| 157 | int32_t st_mtime; /* time of last data modification */ |
| 158 | __STATPAD(__pad1) |
| 159 | long st_mtimensec; /* nsec of last data modification */ |
| 160 | int32_t st_ctime; /* time of last file status change */ |
| 161 | __STATPAD(__pad2) |
| 162 | long st_ctimensec; /* nsec of last file status change */ |
| 163 | int32_t st_birthtime; /* time of creation */ |
| 164 | __STATPAD(__pad3) |
| 165 | long st_birthtimensec; /* nsec of time of creation */ |
| 166 | #endif |
| 167 | off_t st_size; /* file size, in bytes */ |
| 168 | blkcnt_t st_blocks; /* blocks allocated for file */ |
| 169 | blksize_t st_blksize; /* optimal blocksize for I/O */ |
| 170 | uint32_t st_flags; /* user defined flags for file */ |
| 171 | uint32_t st_gen; /* file generation number */ |
| 172 | uint32_t st_spare[2]; |
| 173 | }; |
| 174 | |
| 175 | #undef __STATPAD |
| 176 | |
| 177 | #if defined(_KERNEL) |
| 178 | void compat_12_stat_conv(const struct stat *st, struct stat12 *ost); |
| 179 | #endif |
| 180 | |
| 181 | #if !defined(_KERNEL) && !defined(_STANDALONE) |
| 182 | |
| 183 | __BEGIN_DECLS |
| 184 | int __compat_stat(const char *, struct stat12 *) __dso_hidden; |
| 185 | int __compat_fstat(int, struct stat12 *) __dso_hidden; |
| 186 | int __compat_mknod(const char *, mode_t, uint32_t) __dso_hidden; |
| 187 | int __compat___stat13(const char *, struct stat13 *) __dso_hidden; |
| 188 | int __compat___fstat13(int, struct stat13 *) __dso_hidden; |
| 189 | int __compat___stat30(const char *, struct stat30 *) __dso_hidden; |
| 190 | int __compat___fstat30(int, struct stat30 *) __dso_hidden; |
| 191 | int __stat50(const char *, struct stat *); |
| 192 | int __fstat50(int, struct stat *); |
| 193 | int __mknod50(const char *, mode_t, dev_t); |
| 194 | #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) |
| 195 | int __compat_lstat(const char *, struct stat12 *) __dso_hidden; |
| 196 | int __compat___lstat13(const char *, struct stat13 *) __dso_hidden; |
| 197 | int __compat___lstat30(const char *, struct stat30 *) __dso_hidden; |
| 198 | int __lstat50(const char *, struct stat *); |
| 199 | #endif /* defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) */ |
| 200 | __END_DECLS |
| 201 | |
| 202 | #endif /* !_KERNEL && !_STANDALONE */ |
| 203 | #endif /* !_COMPAT_SYS_STAT_H_ */ |
| 204 | |