xref: /openbmc/u-boot/fs/yaffs2/yportenv.h (revision 4e3349b6)
1 /*
2  * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2011 Aleph One Ltd.
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 
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;
26 #endif
27 
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 
72 #if defined CONFIG_YAFFS_WINCE
73 
74 #include "ywinceenv.h"
75 
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"
85 
86 #else
87 /* Should have specified a configuration type */
88 #error Unknown configuration
89 
90 #endif
91 
92 #if defined(CONFIG_YAFFS_DIRECT) || defined(CONFIG_YAFFS_WINCE)
93 
94 #ifdef CONFIG_YAFFSFS_PROVIDE_VALUES
95 
96 #ifndef O_RDONLY
97 #define O_RDONLY	00
98 #endif
99 
100 #ifndef O_WRONLY
101 #define O_WRONLY	01
102 #endif
103 
104 #ifndef O_RDWR
105 #define O_RDWR		02
106 #endif
107 
108 #ifndef O_CREAT
109 #define O_CREAT		0100
110 #endif
111 
112 #ifndef O_EXCL
113 #define O_EXCL		0200
114 #endif
115 
116 #ifndef O_TRUNC
117 #define O_TRUNC		01000
118 #endif
119 
120 #ifndef O_APPEND
121 #define O_APPEND	02000
122 #endif
123 
124 #ifndef SEEK_SET
125 #define SEEK_SET	0
126 #endif
127 
128 #ifndef SEEK_CUR
129 #define SEEK_CUR	1
130 #endif
131 
132 #ifndef SEEK_END
133 #define SEEK_END	2
134 #endif
135 
136 #ifndef EBUSY
137 #define EBUSY	16
138 #endif
139 
140 #ifndef ENODEV
141 #define ENODEV	19
142 #endif
143 
144 #ifndef EINVAL
145 #define EINVAL	22
146 #endif
147 
148 #ifndef ENFILE
149 #define ENFILE	23
150 #endif
151 
152 #ifndef EBADF
153 #define EBADF	9
154 #endif
155 
156 #ifndef EACCES
157 #define EACCES	13
158 #endif
159 
160 #ifndef EXDEV
161 #define EXDEV	18
162 #endif
163 
164 #ifndef ENOENT
165 #define ENOENT	2
166 #endif
167 
168 #ifndef ENOSPC
169 #define ENOSPC	28
170 #endif
171 
172 #ifndef EROFS
173 #define EROFS	30
174 #endif
175 
176 #ifndef ERANGE
177 #define ERANGE 34
178 #endif
179 
180 #ifndef ENODATA
181 #define ENODATA 61
182 #endif
183 
184 #ifndef ENOTEMPTY
185 #define ENOTEMPTY 39
186 #endif
187 
188 #ifndef ENAMETOOLONG
189 #define ENAMETOOLONG 36
190 #endif
191 
192 #ifndef ENOMEM
193 #define ENOMEM 12
194 #endif
195 
196 #ifndef EFAULT
197 #define EFAULT 14
198 #endif
199 
200 #ifndef EEXIST
201 #define EEXIST 17
202 #endif
203 
204 #ifndef ENOTDIR
205 #define ENOTDIR 20
206 #endif
207 
208 #ifndef EISDIR
209 #define EISDIR 21
210 #endif
211 
212 #ifndef ELOOP
213 #define ELOOP	40
214 #endif
215 
216 
217 /* Mode flags */
218 
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
298 
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)
306 #endif
307 
308 #endif
309