1 /* $NetBSD: linux_types.h,v 1.33 2021/11/25 02:27:08 ryo Exp $ */ 2 3 /*- 4 * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Frank van der Linden and Eric Haszlakiewicz. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #ifndef _LINUX_TYPES_H 33 #define _LINUX_TYPES_H 34 35 #if defined(__i386__) 36 #include <compat/linux/arch/i386/linux_types.h> 37 #elif defined(__alpha__) 38 #include <compat/linux/arch/alpha/linux_types.h> 39 #elif defined(__powerpc__) 40 #include <compat/linux/arch/powerpc/linux_types.h> 41 #elif defined(__aarch64__) 42 #include <compat/linux/arch/aarch64/linux_types.h> 43 #elif defined(__arm__) 44 #include <compat/linux/arch/arm/linux_types.h> 45 #elif defined(__m68k__) 46 #include <compat/linux/arch/m68k/linux_types.h> 47 #elif defined(__mips__) 48 #include <compat/linux/arch/mips/linux_types.h> 49 #elif defined(__amd64__) 50 #include <compat/linux/arch/amd64/linux_types.h> 51 #else 52 typedef unsigned long linux_clock_t; 53 typedef long linux_time_t; 54 typedef long linux_suseconds_t; 55 #endif 56 57 typedef unsigned short linux_gid16_t; 58 typedef unsigned short linux_uid16_t; 59 typedef unsigned short linux_umode_t; 60 61 /* 62 * From Linux include/asm-.../posix_types.h 63 */ 64 typedef struct { 65 int val[2]; 66 } linux_fsid_t; 67 68 /* 69 * Structure for uname(2) 70 */ 71 struct linux_utsname { 72 char l_sysname[65]; 73 char l_nodename[65]; 74 char l_release[65]; 75 char l_version[65]; 76 char l_machine[65]; 77 char l_domainname[65]; 78 }; 79 80 extern char linux_sysname[]; 81 extern char linux_release[]; 82 extern char linux_version[]; 83 extern char linux_machine[]; 84 85 struct linux_tms { 86 linux_clock_t ltms_utime; 87 linux_clock_t ltms_stime; 88 linux_clock_t ltms_cutime; 89 linux_clock_t ltms_cstime; 90 }; 91 92 struct linux_timeval { 93 linux_time_t tv_sec; 94 linux_suseconds_t tv_usec; 95 }; 96 97 struct linux_utimbuf { 98 linux_time_t l_actime; 99 linux_time_t l_modtime; 100 }; 101 102 struct linux___sysctl { 103 int *name; 104 int nlen; 105 void *oldval; 106 size_t *oldlenp; 107 void *newval; 108 size_t newlen; 109 unsigned long __unused0[4]; 110 }; 111 112 #include <compat/linux/common/linux_siginfo.h> 113 114 /* 115 * Generic statfs structure from Linux include/asm-generic/statfs.h 116 * Linux/x86_64 uses different (fully 64bit) struct statfs. 117 */ 118 #ifdef LINUX_STATFS_64BIT 119 struct linux_statfs { 120 long l_ftype; 121 long l_fbsize; 122 long l_fblocks; 123 long l_fbfree; 124 long l_fbavail; 125 long l_ffiles; 126 long l_fffree; 127 linux_fsid_t l_ffsid; 128 long l_fnamelen; 129 long l_ffrsize; 130 long l_fspare[5]; 131 }; 132 133 struct linux_statfs64 { 134 long l_ftype; 135 long l_fbsize; 136 long l_fblocks; 137 long l_fbfree; 138 long l_fbavail; 139 long l_ffiles; 140 long l_fffree; 141 linux_fsid_t l_ffsid; 142 long l_fnamelen; 143 long l_ffrsize; 144 long l_fspare[5]; 145 }; 146 #else /* !LINUX_STATFS_64BIT */ 147 struct linux_statfs { 148 u_int32_t l_ftype; 149 u_int32_t l_fbsize; 150 u_int32_t l_fblocks; 151 u_int32_t l_fbfree; 152 u_int32_t l_fbavail; 153 u_int32_t l_ffiles; 154 u_int32_t l_fffree; 155 linux_fsid_t l_ffsid; 156 u_int32_t l_fnamelen; 157 u_int32_t l_ffrsize; 158 u_int32_t l_fspare[5]; 159 }; 160 161 struct linux_statfs64 { 162 u_int32_t l_ftype; 163 u_int32_t l_fbsize; 164 u_int64_t l_fblocks; 165 u_int64_t l_fbfree; 166 u_int64_t l_fbavail; 167 u_int64_t l_ffiles; 168 u_int64_t l_fffree; 169 linux_fsid_t l_ffsid; 170 u_int32_t l_fnamelen; 171 u_int32_t l_ffrsize; 172 u_int32_t l_fspare[5]; 173 }; 174 #endif /* !LINUX_STATFS_64BIT */ 175 176 struct linux_statx_timestamp { 177 int64_t tv_sec; 178 uint32_t tv_nsec; 179 int32_t __reserved; 180 }; 181 182 #define STATX_TYPE 0x00000001 183 #define STATX_MODE 0x00000002 184 #define STATX_NLINK 0x00000004 185 #define STATX_UID 0x00000008 186 #define STATX_GID 0x00000010 187 #define STATX_ATIME 0x00000020 188 #define STATX_MTIME 0x00000040 189 #define STATX_CTIME 0x00000080 190 #define STATX_INO 0x00000100 191 #define STATX_SIZE 0x00000200 192 #define STATX_BLOCKS 0x00000400 193 #define STATX_BASIC_STATS 0x000007ff 194 #define STATX_BTIME 0x00000800 195 #define STATX_MNT_ID 0x00001000 196 #define STATX_ALL 0x00000fff 197 #define STATX__RESERVED 0x80000000 198 199 #define STATX_ATTR_COMPRESSED 0x00000004 200 #define STATX_ATTR_IMMUTABLE 0x00000010 201 #define STATX_ATTR_APPEND 0x00000020 202 #define STATX_ATTR_NODUMP 0x00000040 203 #define STATX_ATTR_ENCRYPTED 0x00000800 204 #define STATX_ATTR_AUTOMOUNT 0x00001000 205 #define STATX_ATTR_MOUNT_ROOT 0x00002000 206 #define STATX_ATTR_VERITY 0x00100000 207 #define STATX_ATTR_DAX 0x00200000 208 209 struct linux_statx { 210 uint32_t stx_mask; 211 uint32_t stx_blksize; 212 uint64_t stx_attributes; 213 uint32_t stx_nlink; 214 uint32_t stx_uid; 215 uint32_t stx_gid; 216 uint16_t stx_mode; 217 uint16_t __pad1; 218 uint64_t stx_ino; 219 uint64_t stx_size; 220 uint64_t stx_blocks; 221 uint64_t stx_attributes_mask; 222 struct linux_statx_timestamp stx_atime; 223 struct linux_statx_timestamp stx_btime; 224 struct linux_statx_timestamp stx_ctime; 225 struct linux_statx_timestamp stx_mtime; 226 uint32_t stx_rdev_major; 227 uint32_t stx_rdev_minor; 228 uint32_t stx_dev_major; 229 uint32_t stx_dev_minor; 230 uint64_t stx_mnt_id; 231 uint64_t __spare2; 232 uint64_t __spare3[12]; 233 } __packed; 234 235 #endif /* !_LINUX_TYPES_H */ 236