blob: b23042948db5d51b30420a5e16c291d513c3b59c [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
William Juulc051bbe2007-11-15 11:13:05 +010016#ifndef __YPORTENV_H__
17#define __YPORTENV_H__
18
Simon Glassc06c1be2020-05-10 11:40:08 -060019#include <linux/bug.h>
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#ifdef CONFIG_YAFFS_PROVIDE_DEFS
30/* File types */
31
Charles Manning3796e1f2012-05-09 16:55:17 +000032#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 Manning3796e1f2012-05-09 16:55:17 +000042/*
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
54struct 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 Juulc051bbe2007-11-15 11:13:05 +010068#if defined CONFIG_YAFFS_WINCE
69
70#include "ywinceenv.h"
71
Charles Manning3796e1f2012-05-09 16:55:17 +000072#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 Juulc051bbe2007-11-15 11:13:05 +010080
Charles Manning3796e1f2012-05-09 16:55:17 +000081#else
82/* Should have specified a configuration type */
83#error Unknown configuration
William Juulc051bbe2007-11-15 11:13:05 +010084
William Juulc051bbe2007-11-15 11:13:05 +010085#endif
William Juulc051bbe2007-11-15 11:13:05 +010086
Charles Manning3796e1f2012-05-09 16:55:17 +000087#if defined(CONFIG_YAFFS_DIRECT) || defined(CONFIG_YAFFS_WINCE)
William Juulc051bbe2007-11-15 11:13:05 +010088
Charles Manning3796e1f2012-05-09 16:55:17 +000089#ifdef CONFIG_YAFFSFS_PROVIDE_VALUES
William Juulc051bbe2007-11-15 11:13:05 +010090
Charles Manning3796e1f2012-05-09 16:55:17 +000091#ifndef O_RDONLY
92#define O_RDONLY 00
93#endif
William Juulc051bbe2007-11-15 11:13:05 +010094
Charles Manning3796e1f2012-05-09 16:55:17 +000095#ifndef O_WRONLY
96#define O_WRONLY 01
97#endif
William Juulc051bbe2007-11-15 11:13:05 +010098
Charles Manning3796e1f2012-05-09 16:55:17 +000099#ifndef O_RDWR
100#define O_RDWR 02
101#endif
William Juulc051bbe2007-11-15 11:13:05 +0100102
Charles Manning3796e1f2012-05-09 16:55:17 +0000103#ifndef O_CREAT
104#define O_CREAT 0100
105#endif
William Juulc051bbe2007-11-15 11:13:05 +0100106
Charles Manning3796e1f2012-05-09 16:55:17 +0000107#ifndef O_EXCL
108#define O_EXCL 0200
William Juulc051bbe2007-11-15 11:13:05 +0100109#endif
110
Charles Manning3796e1f2012-05-09 16:55:17 +0000111#ifndef O_TRUNC
112#define O_TRUNC 01000
113#endif
William Juulc051bbe2007-11-15 11:13:05 +0100114
Charles Manning3796e1f2012-05-09 16:55:17 +0000115#ifndef O_APPEND
116#define O_APPEND 02000
117#endif
William Juulc051bbe2007-11-15 11:13:05 +0100118
Charles Manning3796e1f2012-05-09 16:55:17 +0000119#ifndef SEEK_SET
120#define SEEK_SET 0
121#endif
William Juulc051bbe2007-11-15 11:13:05 +0100122
Charles Manning3796e1f2012-05-09 16:55:17 +0000123#ifndef SEEK_CUR
124#define SEEK_CUR 1
125#endif
William Juulc051bbe2007-11-15 11:13:05 +0100126
Charles Manning3796e1f2012-05-09 16:55:17 +0000127#ifndef SEEK_END
128#define SEEK_END 2
129#endif
William Juulc051bbe2007-11-15 11:13:05 +0100130
Charles Manning3796e1f2012-05-09 16:55:17 +0000131#ifndef EBUSY
132#define EBUSY 16
133#endif
William Juulc051bbe2007-11-15 11:13:05 +0100134
Charles Manning3796e1f2012-05-09 16:55:17 +0000135#ifndef ENODEV
136#define ENODEV 19
137#endif
William Juulc051bbe2007-11-15 11:13:05 +0100138
Charles Manning3796e1f2012-05-09 16:55:17 +0000139#ifndef EINVAL
140#define EINVAL 22
141#endif
William Juulc051bbe2007-11-15 11:13:05 +0100142
Charles Manning3796e1f2012-05-09 16:55:17 +0000143#ifndef ENFILE
144#define ENFILE 23
145#endif
William Juulc051bbe2007-11-15 11:13:05 +0100146
Charles Manning3796e1f2012-05-09 16:55:17 +0000147#ifndef EBADF
148#define EBADF 9
149#endif
William Juulc051bbe2007-11-15 11:13:05 +0100150
Charles Manning3796e1f2012-05-09 16:55:17 +0000151#ifndef EACCES
152#define EACCES 13
153#endif
William Juulc051bbe2007-11-15 11:13:05 +0100154
Charles Manning3796e1f2012-05-09 16:55:17 +0000155#ifndef EXDEV
156#define EXDEV 18
157#endif
William Juulc051bbe2007-11-15 11:13:05 +0100158
Charles Manning3796e1f2012-05-09 16:55:17 +0000159#ifndef ENOENT
160#define ENOENT 2
161#endif
William Juulc051bbe2007-11-15 11:13:05 +0100162
Charles Manning3796e1f2012-05-09 16:55:17 +0000163#ifndef ENOSPC
164#define ENOSPC 28
165#endif
William Juulc051bbe2007-11-15 11:13:05 +0100166
Charles Manning3796e1f2012-05-09 16:55:17 +0000167#ifndef EROFS
168#define EROFS 30
169#endif
William Juulc051bbe2007-11-15 11:13:05 +0100170
Charles Manning3796e1f2012-05-09 16:55:17 +0000171#ifndef ERANGE
172#define ERANGE 34
173#endif
William Juulc051bbe2007-11-15 11:13:05 +0100174
Charles Manning3796e1f2012-05-09 16:55:17 +0000175#ifndef ENODATA
176#define ENODATA 61
177#endif
William Juulc051bbe2007-11-15 11:13:05 +0100178
Charles Manning3796e1f2012-05-09 16:55:17 +0000179#ifndef ENOTEMPTY
180#define ENOTEMPTY 39
181#endif
William Juulc051bbe2007-11-15 11:13:05 +0100182
Charles Manning3796e1f2012-05-09 16:55:17 +0000183#ifndef ENAMETOOLONG
184#define ENAMETOOLONG 36
185#endif
William Juulc051bbe2007-11-15 11:13:05 +0100186
Charles Manning3796e1f2012-05-09 16:55:17 +0000187#ifndef ENOMEM
188#define ENOMEM 12
William Juulc051bbe2007-11-15 11:13:05 +0100189#endif
190
Charles Manning3796e1f2012-05-09 16:55:17 +0000191#ifndef EFAULT
192#define EFAULT 14
193#endif
William Juulc051bbe2007-11-15 11:13:05 +0100194
Charles Manning3796e1f2012-05-09 16:55:17 +0000195#ifndef EEXIST
196#define EEXIST 17
197#endif
Wolfgang Denk74e0dde2008-08-14 14:41:06 +0200198
Charles Manning3796e1f2012-05-09 16:55:17 +0000199#ifndef ENOTDIR
200#define ENOTDIR 20
201#endif
William Juulc051bbe2007-11-15 11:13:05 +0100202
Charles Manning3796e1f2012-05-09 16:55:17 +0000203#ifndef EISDIR
204#define EISDIR 21
205#endif
William Juulc051bbe2007-11-15 11:13:05 +0100206
Charles Manning3796e1f2012-05-09 16:55:17 +0000207#ifndef ELOOP
208#define ELOOP 40
209#endif
William Juulc051bbe2007-11-15 11:13:05 +0100210
Charles Manning3796e1f2012-05-09 16:55:17 +0000211/* Mode flags */
William Juulc051bbe2007-11-15 11:13:05 +0100212
Charles Manning3796e1f2012-05-09 16:55:17 +0000213#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 Manning3796e1f2012-05-09 16:55:17 +0000253#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 Juulc051bbe2007-11-15 11:13:05 +0100291
Charles Manning3796e1f2012-05-09 16:55:17 +0000292#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 Juulc051bbe2007-11-15 11:13:05 +0100299#endif
300
301#endif