blob: 251eba07921786010390cbbd6784beecdfe9d918 [file] [log] [blame]
William Juulc051bbe2007-11-15 11:13:05 +01001/*
Wolfgang Denk74e0dde2008-08-14 14:41:06 +02002 * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
William Juulc051bbe2007-11-15 11:13:05 +01003 *
Charles Manning3796e1f2012-05-09 16:55:17 +00004 * Copyright (C) 2002-2011 Aleph One Ltd.
William Juulc051bbe2007-11-15 11:13:05 +01005 * 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 Manning4f28fc22012-08-14 18:26:10 +000020#include <linux/types.h>
Charles Manning3796e1f2012-05-09 16:55:17 +000021
22/* Definition of types */
23#ifdef CONFIG_YAFFS_DEFINES_TYPES
24typedef unsigned char u8;
25typedef unsigned short u16;
26typedef unsigned u32;
William Juule24ebad2007-11-15 12:23:57 +010027#endif
28
Charles Manning3796e1f2012-05-09 16:55:17 +000029
30#ifdef CONFIG_YAFFS_PROVIDE_DEFS
31/* File types */
32
33
34#define DT_UNKNOWN 0
35#define DT_FIFO 1
36#define DT_CHR 2
37#define DT_DIR 4
38#define DT_BLK 6
39#define DT_REG 8
40#define DT_LNK 10
41#define DT_SOCK 12
42#define DT_WHT 14
43
44
45/*
46 * Attribute flags.
47 * These are or-ed together to select what has been changed.
48 */
49#define ATTR_MODE 1
50#define ATTR_UID 2
51#define ATTR_GID 4
52#define ATTR_SIZE 8
53#define ATTR_ATIME 16
54#define ATTR_MTIME 32
55#define ATTR_CTIME 64
56
57struct iattr {
58 unsigned int ia_valid;
59 unsigned ia_mode;
60 unsigned ia_uid;
61 unsigned ia_gid;
62 unsigned ia_size;
63 unsigned ia_atime;
64 unsigned ia_mtime;
65 unsigned ia_ctime;
66 unsigned int ia_attr_flags;
67};
68
69#endif
70
71
72
William Juulc051bbe2007-11-15 11:13:05 +010073#if defined CONFIG_YAFFS_WINCE
74
75#include "ywinceenv.h"
76
Charles Manning3796e1f2012-05-09 16:55:17 +000077
78#elif defined CONFIG_YAFFS_DIRECT
79
80/* Direct interface */
81#include "ydirectenv.h"
82
83#elif defined CONFIG_YAFFS_UTIL
84
85#include "yutilsenv.h"
William Juulc051bbe2007-11-15 11:13:05 +010086
Charles Manning3796e1f2012-05-09 16:55:17 +000087#else
88/* Should have specified a configuration type */
89#error Unknown configuration
William Juulc051bbe2007-11-15 11:13:05 +010090
William Juulc051bbe2007-11-15 11:13:05 +010091#endif
William Juulc051bbe2007-11-15 11:13:05 +010092
Charles Manning3796e1f2012-05-09 16:55:17 +000093#if defined(CONFIG_YAFFS_DIRECT) || defined(CONFIG_YAFFS_WINCE)
William Juulc051bbe2007-11-15 11:13:05 +010094
Charles Manning3796e1f2012-05-09 16:55:17 +000095#ifdef CONFIG_YAFFSFS_PROVIDE_VALUES
William Juulc051bbe2007-11-15 11:13:05 +010096
Charles Manning3796e1f2012-05-09 16:55:17 +000097#ifndef O_RDONLY
98#define O_RDONLY 00
99#endif
William Juulc051bbe2007-11-15 11:13:05 +0100100
Charles Manning3796e1f2012-05-09 16:55:17 +0000101#ifndef O_WRONLY
102#define O_WRONLY 01
103#endif
William Juulc051bbe2007-11-15 11:13:05 +0100104
Charles Manning3796e1f2012-05-09 16:55:17 +0000105#ifndef O_RDWR
106#define O_RDWR 02
107#endif
William Juulc051bbe2007-11-15 11:13:05 +0100108
Charles Manning3796e1f2012-05-09 16:55:17 +0000109#ifndef O_CREAT
110#define O_CREAT 0100
111#endif
William Juulc051bbe2007-11-15 11:13:05 +0100112
Charles Manning3796e1f2012-05-09 16:55:17 +0000113#ifndef O_EXCL
114#define O_EXCL 0200
William Juulc051bbe2007-11-15 11:13:05 +0100115#endif
116
Charles Manning3796e1f2012-05-09 16:55:17 +0000117#ifndef O_TRUNC
118#define O_TRUNC 01000
119#endif
William Juulc051bbe2007-11-15 11:13:05 +0100120
Charles Manning3796e1f2012-05-09 16:55:17 +0000121#ifndef O_APPEND
122#define O_APPEND 02000
123#endif
William Juulc051bbe2007-11-15 11:13:05 +0100124
Charles Manning3796e1f2012-05-09 16:55:17 +0000125#ifndef SEEK_SET
126#define SEEK_SET 0
127#endif
William Juulc051bbe2007-11-15 11:13:05 +0100128
Charles Manning3796e1f2012-05-09 16:55:17 +0000129#ifndef SEEK_CUR
130#define SEEK_CUR 1
131#endif
William Juulc051bbe2007-11-15 11:13:05 +0100132
Charles Manning3796e1f2012-05-09 16:55:17 +0000133#ifndef SEEK_END
134#define SEEK_END 2
135#endif
William Juulc051bbe2007-11-15 11:13:05 +0100136
Charles Manning3796e1f2012-05-09 16:55:17 +0000137#ifndef EBUSY
138#define EBUSY 16
139#endif
William Juulc051bbe2007-11-15 11:13:05 +0100140
Charles Manning3796e1f2012-05-09 16:55:17 +0000141#ifndef ENODEV
142#define ENODEV 19
143#endif
William Juulc051bbe2007-11-15 11:13:05 +0100144
Charles Manning3796e1f2012-05-09 16:55:17 +0000145#ifndef EINVAL
146#define EINVAL 22
147#endif
William Juulc051bbe2007-11-15 11:13:05 +0100148
Charles Manning3796e1f2012-05-09 16:55:17 +0000149#ifndef ENFILE
150#define ENFILE 23
151#endif
William Juulc051bbe2007-11-15 11:13:05 +0100152
Charles Manning3796e1f2012-05-09 16:55:17 +0000153#ifndef EBADF
154#define EBADF 9
155#endif
William Juulc051bbe2007-11-15 11:13:05 +0100156
Charles Manning3796e1f2012-05-09 16:55:17 +0000157#ifndef EACCES
158#define EACCES 13
159#endif
William Juulc051bbe2007-11-15 11:13:05 +0100160
Charles Manning3796e1f2012-05-09 16:55:17 +0000161#ifndef EXDEV
162#define EXDEV 18
163#endif
William Juulc051bbe2007-11-15 11:13:05 +0100164
Charles Manning3796e1f2012-05-09 16:55:17 +0000165#ifndef ENOENT
166#define ENOENT 2
167#endif
William Juulc051bbe2007-11-15 11:13:05 +0100168
Charles Manning3796e1f2012-05-09 16:55:17 +0000169#ifndef ENOSPC
170#define ENOSPC 28
171#endif
William Juulc051bbe2007-11-15 11:13:05 +0100172
Charles Manning3796e1f2012-05-09 16:55:17 +0000173#ifndef EROFS
174#define EROFS 30
175#endif
William Juulc051bbe2007-11-15 11:13:05 +0100176
Charles Manning3796e1f2012-05-09 16:55:17 +0000177#ifndef ERANGE
178#define ERANGE 34
179#endif
William Juulc051bbe2007-11-15 11:13:05 +0100180
Charles Manning3796e1f2012-05-09 16:55:17 +0000181#ifndef ENODATA
182#define ENODATA 61
183#endif
William Juulc051bbe2007-11-15 11:13:05 +0100184
Charles Manning3796e1f2012-05-09 16:55:17 +0000185#ifndef ENOTEMPTY
186#define ENOTEMPTY 39
187#endif
William Juulc051bbe2007-11-15 11:13:05 +0100188
Charles Manning3796e1f2012-05-09 16:55:17 +0000189#ifndef ENAMETOOLONG
190#define ENAMETOOLONG 36
191#endif
William Juulc051bbe2007-11-15 11:13:05 +0100192
Charles Manning3796e1f2012-05-09 16:55:17 +0000193#ifndef ENOMEM
194#define ENOMEM 12
William Juulc051bbe2007-11-15 11:13:05 +0100195#endif
196
Charles Manning3796e1f2012-05-09 16:55:17 +0000197#ifndef EFAULT
198#define EFAULT 14
199#endif
William Juulc051bbe2007-11-15 11:13:05 +0100200
Charles Manning3796e1f2012-05-09 16:55:17 +0000201#ifndef EEXIST
202#define EEXIST 17
203#endif
Wolfgang Denk74e0dde2008-08-14 14:41:06 +0200204
Charles Manning3796e1f2012-05-09 16:55:17 +0000205#ifndef ENOTDIR
206#define ENOTDIR 20
207#endif
William Juulc051bbe2007-11-15 11:13:05 +0100208
Charles Manning3796e1f2012-05-09 16:55:17 +0000209#ifndef EISDIR
210#define EISDIR 21
211#endif
William Juulc051bbe2007-11-15 11:13:05 +0100212
Charles Manning3796e1f2012-05-09 16:55:17 +0000213#ifndef ELOOP
214#define ELOOP 40
215#endif
William Juulc051bbe2007-11-15 11:13:05 +0100216
William Juulc051bbe2007-11-15 11:13:05 +0100217
Charles Manning3796e1f2012-05-09 16:55:17 +0000218/* Mode flags */
William Juulc051bbe2007-11-15 11:13:05 +0100219
Charles Manning3796e1f2012-05-09 16:55:17 +0000220#ifndef S_IFMT
221#define S_IFMT 0170000
222#endif
223
224#ifndef S_IFSOCK
225#define S_IFSOCK 0140000
226#endif
227
228#ifndef S_IFIFO
229#define S_IFIFO 0010000
230#endif
231
232#ifndef S_IFCHR
233#define S_IFCHR 0020000
234#endif
235
236#ifndef S_IFBLK
237#define S_IFBLK 0060000
238#endif
239
240#ifndef S_IFLNK
241#define S_IFLNK 0120000
242#endif
243
244#ifndef S_IFDIR
245#define S_IFDIR 0040000
246#endif
247
248#ifndef S_IFREG
249#define S_IFREG 0100000
250#endif
251
252#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
253#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
254#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
255#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
256#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
257#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
258#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
259
260
261#ifndef S_IREAD
262#define S_IREAD 0000400
263#endif
264
265#ifndef S_IWRITE
266#define S_IWRITE 0000200
267#endif
268
269#ifndef S_IEXEC
270#define S_IEXEC 0000100
271#endif
272
273#ifndef XATTR_CREATE
274#define XATTR_CREATE 1
275#endif
276
277#ifndef XATTR_REPLACE
278#define XATTR_REPLACE 2
279#endif
280
281#ifndef R_OK
282#define R_OK 4
283#define W_OK 2
284#define X_OK 1
285#define F_OK 0
286#endif
287
288#else
289#include <errno.h>
290#include <sys/stat.h>
291#include <fcntl.h>
292#endif
293
294#endif
295
296#ifndef Y_DUMP_STACK
297#define Y_DUMP_STACK() do { } while (0)
298#endif
William Juulc051bbe2007-11-15 11:13:05 +0100299
Charles Manning3796e1f2012-05-09 16:55:17 +0000300#ifndef BUG
301#define BUG() do {\
302 yaffs_trace(YAFFS_TRACE_BUG,\
303 "==>> yaffs bug: " __FILE__ " %d",\
304 __LINE__);\
305 Y_DUMP_STACK();\
306} while (0)
William Juulc051bbe2007-11-15 11:13:05 +0100307#endif
308
309#endif