William Juul | 0e8cc8b | 2007-11-15 11:13:05 +0100 | [diff] [blame] | 1 | /* |
Wolfgang Denk | 4b07080 | 2008-08-14 14:41:06 +0200 | [diff] [blame] | 2 | * YAFFS: Yet another Flash File System . A NAND-flash specific file system. |
William Juul | 0e8cc8b | 2007-11-15 11:13:05 +0100 | [diff] [blame] | 3 | * |
Charles Manning | 753ac61 | 2012-05-09 16:55:17 +0000 | [diff] [blame] | 4 | * Copyright (C) 2002-2011 Aleph One Ltd. |
William Juul | 0e8cc8b | 2007-11-15 11:13:05 +0100 | [diff] [blame] | 5 | * for Toby Churchill Ltd and Brightstar Engineering |
| 6 | * |
| 7 | * Created by Charles Manning <charles@aleph1.co.uk> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU Lesser General Public License version 2.1 as |
| 11 | * published by the Free Software Foundation. |
| 12 | * |
| 13 | * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. |
| 14 | */ |
| 15 | |
| 16 | |
| 17 | #ifndef __YPORTENV_H__ |
| 18 | #define __YPORTENV_H__ |
| 19 | |
Simon Glass | eb41d8a | 2020-05-10 11:40:08 -0600 | [diff] [blame] | 20 | #include <linux/bug.h> |
Charles Manning | 74f45b7 | 2012-08-14 18:26:10 +0000 | [diff] [blame] | 21 | #include <linux/types.h> |
Charles Manning | 753ac61 | 2012-05-09 16:55:17 +0000 | [diff] [blame] | 22 | |
| 23 | /* Definition of types */ |
| 24 | #ifdef CONFIG_YAFFS_DEFINES_TYPES |
| 25 | typedef unsigned char u8; |
| 26 | typedef unsigned short u16; |
| 27 | typedef unsigned u32; |
William Juul | 90ef117 | 2007-11-15 12:23:57 +0100 | [diff] [blame] | 28 | #endif |
| 29 | |
Charles Manning | 753ac61 | 2012-05-09 16:55:17 +0000 | [diff] [blame] | 30 | |
| 31 | #ifdef CONFIG_YAFFS_PROVIDE_DEFS |
| 32 | /* File types */ |
| 33 | |
| 34 | |
| 35 | #define DT_UNKNOWN 0 |
| 36 | #define DT_FIFO 1 |
| 37 | #define DT_CHR 2 |
| 38 | #define DT_DIR 4 |
| 39 | #define DT_BLK 6 |
| 40 | #define DT_REG 8 |
| 41 | #define DT_LNK 10 |
| 42 | #define DT_SOCK 12 |
| 43 | #define DT_WHT 14 |
| 44 | |
| 45 | |
| 46 | /* |
| 47 | * Attribute flags. |
| 48 | * These are or-ed together to select what has been changed. |
| 49 | */ |
| 50 | #define ATTR_MODE 1 |
| 51 | #define ATTR_UID 2 |
| 52 | #define ATTR_GID 4 |
| 53 | #define ATTR_SIZE 8 |
| 54 | #define ATTR_ATIME 16 |
| 55 | #define ATTR_MTIME 32 |
| 56 | #define ATTR_CTIME 64 |
| 57 | |
| 58 | struct iattr { |
| 59 | unsigned int ia_valid; |
| 60 | unsigned ia_mode; |
| 61 | unsigned ia_uid; |
| 62 | unsigned ia_gid; |
| 63 | unsigned ia_size; |
| 64 | unsigned ia_atime; |
| 65 | unsigned ia_mtime; |
| 66 | unsigned ia_ctime; |
| 67 | unsigned int ia_attr_flags; |
| 68 | }; |
| 69 | |
| 70 | #endif |
| 71 | |
| 72 | |
| 73 | |
William Juul | 0e8cc8b | 2007-11-15 11:13:05 +0100 | [diff] [blame] | 74 | #if defined CONFIG_YAFFS_WINCE |
| 75 | |
| 76 | #include "ywinceenv.h" |
| 77 | |
William Juul | 0e8cc8b | 2007-11-15 11:13:05 +0100 | [diff] [blame] | 78 | |
| 79 | #elif defined CONFIG_YAFFS_DIRECT |
| 80 | |
| 81 | /* Direct interface */ |
| 82 | #include "ydirectenv.h" |
| 83 | |
| 84 | #elif defined CONFIG_YAFFS_UTIL |
| 85 | |
Charles Manning | 753ac61 | 2012-05-09 16:55:17 +0000 | [diff] [blame] | 86 | #include "yutilsenv.h" |
William Juul | 0e8cc8b | 2007-11-15 11:13:05 +0100 | [diff] [blame] | 87 | |
| 88 | #else |
| 89 | /* Should have specified a configuration type */ |
| 90 | #error Unknown configuration |
| 91 | |
| 92 | #endif |
| 93 | |
Charles Manning | 753ac61 | 2012-05-09 16:55:17 +0000 | [diff] [blame] | 94 | #if defined(CONFIG_YAFFS_DIRECT) || defined(CONFIG_YAFFS_WINCE) |
William Juul | 0e8cc8b | 2007-11-15 11:13:05 +0100 | [diff] [blame] | 95 | |
Charles Manning | 753ac61 | 2012-05-09 16:55:17 +0000 | [diff] [blame] | 96 | #ifdef CONFIG_YAFFSFS_PROVIDE_VALUES |
Wolfgang Denk | 4b07080 | 2008-08-14 14:41:06 +0200 | [diff] [blame] | 97 | |
Charles Manning | 753ac61 | 2012-05-09 16:55:17 +0000 | [diff] [blame] | 98 | #ifndef O_RDONLY |
| 99 | #define O_RDONLY 00 |
| 100 | #endif |
William Juul | 0e8cc8b | 2007-11-15 11:13:05 +0100 | [diff] [blame] | 101 | |
Charles Manning | 753ac61 | 2012-05-09 16:55:17 +0000 | [diff] [blame] | 102 | #ifndef O_WRONLY |
| 103 | #define O_WRONLY 01 |
| 104 | #endif |
| 105 | |
| 106 | #ifndef O_RDWR |
| 107 | #define O_RDWR 02 |
| 108 | #endif |
| 109 | |
| 110 | #ifndef O_CREAT |
| 111 | #define O_CREAT 0100 |
| 112 | #endif |
| 113 | |
| 114 | #ifndef O_EXCL |
| 115 | #define O_EXCL 0200 |
| 116 | #endif |
| 117 | |
| 118 | #ifndef O_TRUNC |
| 119 | #define O_TRUNC 01000 |
| 120 | #endif |
| 121 | |
| 122 | #ifndef O_APPEND |
| 123 | #define O_APPEND 02000 |
| 124 | #endif |
| 125 | |
| 126 | #ifndef SEEK_SET |
| 127 | #define SEEK_SET 0 |
| 128 | #endif |
| 129 | |
| 130 | #ifndef SEEK_CUR |
| 131 | #define SEEK_CUR 1 |
| 132 | #endif |
| 133 | |
| 134 | #ifndef SEEK_END |
| 135 | #define SEEK_END 2 |
| 136 | #endif |
| 137 | |
| 138 | #ifndef EBUSY |
| 139 | #define EBUSY 16 |
| 140 | #endif |
| 141 | |
| 142 | #ifndef ENODEV |
| 143 | #define ENODEV 19 |
| 144 | #endif |
| 145 | |
| 146 | #ifndef EINVAL |
| 147 | #define EINVAL 22 |
| 148 | #endif |
| 149 | |
| 150 | #ifndef ENFILE |
| 151 | #define ENFILE 23 |
| 152 | #endif |
| 153 | |
| 154 | #ifndef EBADF |
| 155 | #define EBADF 9 |
| 156 | #endif |
| 157 | |
| 158 | #ifndef EACCES |
| 159 | #define EACCES 13 |
| 160 | #endif |
| 161 | |
| 162 | #ifndef EXDEV |
| 163 | #define EXDEV 18 |
| 164 | #endif |
| 165 | |
| 166 | #ifndef ENOENT |
| 167 | #define ENOENT 2 |
| 168 | #endif |
| 169 | |
| 170 | #ifndef ENOSPC |
| 171 | #define ENOSPC 28 |
| 172 | #endif |
| 173 | |
| 174 | #ifndef EROFS |
| 175 | #define EROFS 30 |
| 176 | #endif |
| 177 | |
| 178 | #ifndef ERANGE |
| 179 | #define ERANGE 34 |
| 180 | #endif |
| 181 | |
| 182 | #ifndef ENODATA |
| 183 | #define ENODATA 61 |
| 184 | #endif |
| 185 | |
| 186 | #ifndef ENOTEMPTY |
| 187 | #define ENOTEMPTY 39 |
| 188 | #endif |
| 189 | |
| 190 | #ifndef ENAMETOOLONG |
| 191 | #define ENAMETOOLONG 36 |
| 192 | #endif |
| 193 | |
| 194 | #ifndef ENOMEM |
| 195 | #define ENOMEM 12 |
| 196 | #endif |
| 197 | |
| 198 | #ifndef EFAULT |
| 199 | #define EFAULT 14 |
| 200 | #endif |
| 201 | |
| 202 | #ifndef EEXIST |
| 203 | #define EEXIST 17 |
| 204 | #endif |
| 205 | |
| 206 | #ifndef ENOTDIR |
| 207 | #define ENOTDIR 20 |
| 208 | #endif |
| 209 | |
| 210 | #ifndef EISDIR |
| 211 | #define EISDIR 21 |
| 212 | #endif |
| 213 | |
| 214 | #ifndef ELOOP |
| 215 | #define ELOOP 40 |
| 216 | #endif |
William Juul | 0e8cc8b | 2007-11-15 11:13:05 +0100 | [diff] [blame] | 217 | |
| 218 | |
Charles Manning | 753ac61 | 2012-05-09 16:55:17 +0000 | [diff] [blame] | 219 | /* Mode flags */ |
| 220 | |
| 221 | #ifndef S_IFMT |
| 222 | #define S_IFMT 0170000 |
| 223 | #endif |
| 224 | |
| 225 | #ifndef S_IFSOCK |
| 226 | #define S_IFSOCK 0140000 |
| 227 | #endif |
| 228 | |
| 229 | #ifndef S_IFIFO |
| 230 | #define S_IFIFO 0010000 |
| 231 | #endif |
| 232 | |
| 233 | #ifndef S_IFCHR |
| 234 | #define S_IFCHR 0020000 |
| 235 | #endif |
| 236 | |
| 237 | #ifndef S_IFBLK |
| 238 | #define S_IFBLK 0060000 |
| 239 | #endif |
| 240 | |
| 241 | #ifndef S_IFLNK |
| 242 | #define S_IFLNK 0120000 |
| 243 | #endif |
| 244 | |
| 245 | #ifndef S_IFDIR |
| 246 | #define S_IFDIR 0040000 |
| 247 | #endif |
| 248 | |
| 249 | #ifndef S_IFREG |
| 250 | #define S_IFREG 0100000 |
| 251 | #endif |
| 252 | |
| 253 | #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) |
| 254 | #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) |
| 255 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) |
| 256 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) |
| 257 | #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) |
| 258 | #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) |
| 259 | #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) |
William Juul | 0e8cc8b | 2007-11-15 11:13:05 +0100 | [diff] [blame] | 260 | |
| 261 | |
Charles Manning | 753ac61 | 2012-05-09 16:55:17 +0000 | [diff] [blame] | 262 | #ifndef S_IREAD |
| 263 | #define S_IREAD 0000400 |
| 264 | #endif |
William Juul | 0e8cc8b | 2007-11-15 11:13:05 +0100 | [diff] [blame] | 265 | |
Charles Manning | 753ac61 | 2012-05-09 16:55:17 +0000 | [diff] [blame] | 266 | #ifndef S_IWRITE |
| 267 | #define S_IWRITE 0000200 |
| 268 | #endif |
| 269 | |
| 270 | #ifndef S_IEXEC |
| 271 | #define S_IEXEC 0000100 |
| 272 | #endif |
| 273 | |
| 274 | #ifndef XATTR_CREATE |
| 275 | #define XATTR_CREATE 1 |
| 276 | #endif |
| 277 | |
| 278 | #ifndef XATTR_REPLACE |
| 279 | #define XATTR_REPLACE 2 |
| 280 | #endif |
| 281 | |
| 282 | #ifndef R_OK |
| 283 | #define R_OK 4 |
| 284 | #define W_OK 2 |
| 285 | #define X_OK 1 |
| 286 | #define F_OK 0 |
| 287 | #endif |
| 288 | |
| 289 | #else |
| 290 | #include <errno.h> |
| 291 | #include <sys/stat.h> |
| 292 | #include <fcntl.h> |
| 293 | #endif |
| 294 | |
| 295 | #endif |
| 296 | |
| 297 | #ifndef Y_DUMP_STACK |
| 298 | #define Y_DUMP_STACK() do { } while (0) |
| 299 | #endif |
| 300 | |
| 301 | #ifndef BUG |
| 302 | #define BUG() do {\ |
| 303 | yaffs_trace(YAFFS_TRACE_BUG,\ |
| 304 | "==>> yaffs bug: " __FILE__ " %d",\ |
| 305 | __LINE__);\ |
| 306 | Y_DUMP_STACK();\ |
| 307 | } while (0) |
William Juul | 0e8cc8b | 2007-11-15 11:13:05 +0100 | [diff] [blame] | 308 | #endif |
| 309 | |
| 310 | #endif |