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