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