blob: 081391a1d0fe5867e5019cab5725f85db3be2c39 [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
Simon Glassc06c1be2020-05-10 11:40:08 -060020#include <linux/bug.h>
Charles Manning4f28fc22012-08-14 18:26:10 +000021#include <linux/types.h>
Charles Manning3796e1f2012-05-09 16:55:17 +000022
23/* Definition of types */
24#ifdef CONFIG_YAFFS_DEFINES_TYPES
25typedef unsigned char u8;
26typedef unsigned short u16;
27typedef unsigned u32;
William Juule24ebad2007-11-15 12:23:57 +010028#endif
29
Charles Manning3796e1f2012-05-09 16:55:17 +000030
31#ifdef CONFIG_YAFFS_PROVIDE_DEFS
32/* File types */
33
34
35#define DT_UNKNOWN 0
36#define DT_FIFO 1
37#define DT_CHR 2
38#define DT_DIR 4
39#define DT_BLK 6
40#define DT_REG 8
41#define DT_LNK 10
42#define DT_SOCK 12
43#define DT_WHT 14
44
45
46/*
47 * Attribute flags.
48 * These are or-ed together to select what has been changed.
49 */
50#define ATTR_MODE 1
51#define ATTR_UID 2
52#define ATTR_GID 4
53#define ATTR_SIZE 8
54#define ATTR_ATIME 16
55#define ATTR_MTIME 32
56#define ATTR_CTIME 64
57
58struct iattr {
59 unsigned int ia_valid;
60 unsigned ia_mode;
61 unsigned ia_uid;
62 unsigned ia_gid;
63 unsigned ia_size;
64 unsigned ia_atime;
65 unsigned ia_mtime;
66 unsigned ia_ctime;
67 unsigned int ia_attr_flags;
68};
69
70#endif
71
72
73
William Juulc051bbe2007-11-15 11:13:05 +010074#if defined CONFIG_YAFFS_WINCE
75
76#include "ywinceenv.h"
77
Charles Manning3796e1f2012-05-09 16:55:17 +000078
79#elif defined CONFIG_YAFFS_DIRECT
80
81/* Direct interface */
82#include "ydirectenv.h"
83
84#elif defined CONFIG_YAFFS_UTIL
85
86#include "yutilsenv.h"
William Juulc051bbe2007-11-15 11:13:05 +010087
Charles Manning3796e1f2012-05-09 16:55:17 +000088#else
89/* Should have specified a configuration type */
90#error Unknown configuration
William Juulc051bbe2007-11-15 11:13:05 +010091
William Juulc051bbe2007-11-15 11:13:05 +010092#endif
William Juulc051bbe2007-11-15 11:13:05 +010093
Charles Manning3796e1f2012-05-09 16:55:17 +000094#if defined(CONFIG_YAFFS_DIRECT) || defined(CONFIG_YAFFS_WINCE)
William Juulc051bbe2007-11-15 11:13:05 +010095
Charles Manning3796e1f2012-05-09 16:55:17 +000096#ifdef CONFIG_YAFFSFS_PROVIDE_VALUES
William Juulc051bbe2007-11-15 11:13:05 +010097
Charles Manning3796e1f2012-05-09 16:55:17 +000098#ifndef O_RDONLY
99#define O_RDONLY 00
100#endif
William Juulc051bbe2007-11-15 11:13:05 +0100101
Charles Manning3796e1f2012-05-09 16:55:17 +0000102#ifndef O_WRONLY
103#define O_WRONLY 01
104#endif
William Juulc051bbe2007-11-15 11:13:05 +0100105
Charles Manning3796e1f2012-05-09 16:55:17 +0000106#ifndef O_RDWR
107#define O_RDWR 02
108#endif
William Juulc051bbe2007-11-15 11:13:05 +0100109
Charles Manning3796e1f2012-05-09 16:55:17 +0000110#ifndef O_CREAT
111#define O_CREAT 0100
112#endif
William Juulc051bbe2007-11-15 11:13:05 +0100113
Charles Manning3796e1f2012-05-09 16:55:17 +0000114#ifndef O_EXCL
115#define O_EXCL 0200
William Juulc051bbe2007-11-15 11:13:05 +0100116#endif
117
Charles Manning3796e1f2012-05-09 16:55:17 +0000118#ifndef O_TRUNC
119#define O_TRUNC 01000
120#endif
William Juulc051bbe2007-11-15 11:13:05 +0100121
Charles Manning3796e1f2012-05-09 16:55:17 +0000122#ifndef O_APPEND
123#define O_APPEND 02000
124#endif
William Juulc051bbe2007-11-15 11:13:05 +0100125
Charles Manning3796e1f2012-05-09 16:55:17 +0000126#ifndef SEEK_SET
127#define SEEK_SET 0
128#endif
William Juulc051bbe2007-11-15 11:13:05 +0100129
Charles Manning3796e1f2012-05-09 16:55:17 +0000130#ifndef SEEK_CUR
131#define SEEK_CUR 1
132#endif
William Juulc051bbe2007-11-15 11:13:05 +0100133
Charles Manning3796e1f2012-05-09 16:55:17 +0000134#ifndef SEEK_END
135#define SEEK_END 2
136#endif
William Juulc051bbe2007-11-15 11:13:05 +0100137
Charles Manning3796e1f2012-05-09 16:55:17 +0000138#ifndef EBUSY
139#define EBUSY 16
140#endif
William Juulc051bbe2007-11-15 11:13:05 +0100141
Charles Manning3796e1f2012-05-09 16:55:17 +0000142#ifndef ENODEV
143#define ENODEV 19
144#endif
William Juulc051bbe2007-11-15 11:13:05 +0100145
Charles Manning3796e1f2012-05-09 16:55:17 +0000146#ifndef EINVAL
147#define EINVAL 22
148#endif
William Juulc051bbe2007-11-15 11:13:05 +0100149
Charles Manning3796e1f2012-05-09 16:55:17 +0000150#ifndef ENFILE
151#define ENFILE 23
152#endif
William Juulc051bbe2007-11-15 11:13:05 +0100153
Charles Manning3796e1f2012-05-09 16:55:17 +0000154#ifndef EBADF
155#define EBADF 9
156#endif
William Juulc051bbe2007-11-15 11:13:05 +0100157
Charles Manning3796e1f2012-05-09 16:55:17 +0000158#ifndef EACCES
159#define EACCES 13
160#endif
William Juulc051bbe2007-11-15 11:13:05 +0100161
Charles Manning3796e1f2012-05-09 16:55:17 +0000162#ifndef EXDEV
163#define EXDEV 18
164#endif
William Juulc051bbe2007-11-15 11:13:05 +0100165
Charles Manning3796e1f2012-05-09 16:55:17 +0000166#ifndef ENOENT
167#define ENOENT 2
168#endif
William Juulc051bbe2007-11-15 11:13:05 +0100169
Charles Manning3796e1f2012-05-09 16:55:17 +0000170#ifndef ENOSPC
171#define ENOSPC 28
172#endif
William Juulc051bbe2007-11-15 11:13:05 +0100173
Charles Manning3796e1f2012-05-09 16:55:17 +0000174#ifndef EROFS
175#define EROFS 30
176#endif
William Juulc051bbe2007-11-15 11:13:05 +0100177
Charles Manning3796e1f2012-05-09 16:55:17 +0000178#ifndef ERANGE
179#define ERANGE 34
180#endif
William Juulc051bbe2007-11-15 11:13:05 +0100181
Charles Manning3796e1f2012-05-09 16:55:17 +0000182#ifndef ENODATA
183#define ENODATA 61
184#endif
William Juulc051bbe2007-11-15 11:13:05 +0100185
Charles Manning3796e1f2012-05-09 16:55:17 +0000186#ifndef ENOTEMPTY
187#define ENOTEMPTY 39
188#endif
William Juulc051bbe2007-11-15 11:13:05 +0100189
Charles Manning3796e1f2012-05-09 16:55:17 +0000190#ifndef ENAMETOOLONG
191#define ENAMETOOLONG 36
192#endif
William Juulc051bbe2007-11-15 11:13:05 +0100193
Charles Manning3796e1f2012-05-09 16:55:17 +0000194#ifndef ENOMEM
195#define ENOMEM 12
William Juulc051bbe2007-11-15 11:13:05 +0100196#endif
197
Charles Manning3796e1f2012-05-09 16:55:17 +0000198#ifndef EFAULT
199#define EFAULT 14
200#endif
William Juulc051bbe2007-11-15 11:13:05 +0100201
Charles Manning3796e1f2012-05-09 16:55:17 +0000202#ifndef EEXIST
203#define EEXIST 17
204#endif
Wolfgang Denk74e0dde2008-08-14 14:41:06 +0200205
Charles Manning3796e1f2012-05-09 16:55:17 +0000206#ifndef ENOTDIR
207#define ENOTDIR 20
208#endif
William Juulc051bbe2007-11-15 11:13:05 +0100209
Charles Manning3796e1f2012-05-09 16:55:17 +0000210#ifndef EISDIR
211#define EISDIR 21
212#endif
William Juulc051bbe2007-11-15 11:13:05 +0100213
Charles Manning3796e1f2012-05-09 16:55:17 +0000214#ifndef ELOOP
215#define ELOOP 40
216#endif
William Juulc051bbe2007-11-15 11:13:05 +0100217
William Juulc051bbe2007-11-15 11:13:05 +0100218
Charles Manning3796e1f2012-05-09 16:55:17 +0000219/* Mode flags */
William Juulc051bbe2007-11-15 11:13:05 +0100220
Charles Manning3796e1f2012-05-09 16:55:17 +0000221#ifndef S_IFMT
222#define S_IFMT 0170000
223#endif
224
225#ifndef S_IFSOCK
226#define S_IFSOCK 0140000
227#endif
228
229#ifndef S_IFIFO
230#define S_IFIFO 0010000
231#endif
232
233#ifndef S_IFCHR
234#define S_IFCHR 0020000
235#endif
236
237#ifndef S_IFBLK
238#define S_IFBLK 0060000
239#endif
240
241#ifndef S_IFLNK
242#define S_IFLNK 0120000
243#endif
244
245#ifndef S_IFDIR
246#define S_IFDIR 0040000
247#endif
248
249#ifndef S_IFREG
250#define S_IFREG 0100000
251#endif
252
253#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
254#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
255#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
256#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
257#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
258#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
259#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
260
261
262#ifndef S_IREAD
263#define S_IREAD 0000400
264#endif
265
266#ifndef S_IWRITE
267#define S_IWRITE 0000200
268#endif
269
270#ifndef S_IEXEC
271#define S_IEXEC 0000100
272#endif
273
274#ifndef XATTR_CREATE
275#define XATTR_CREATE 1
276#endif
277
278#ifndef XATTR_REPLACE
279#define XATTR_REPLACE 2
280#endif
281
282#ifndef R_OK
283#define R_OK 4
284#define W_OK 2
285#define X_OK 1
286#define F_OK 0
287#endif
288
289#else
290#include <errno.h>
291#include <sys/stat.h>
292#include <fcntl.h>
293#endif
294
295#endif
296
297#ifndef Y_DUMP_STACK
298#define Y_DUMP_STACK() do { } while (0)
299#endif
William Juulc051bbe2007-11-15 11:13:05 +0100300
Charles Manning3796e1f2012-05-09 16:55:17 +0000301#ifndef BUG
302#define BUG() do {\
303 yaffs_trace(YAFFS_TRACE_BUG,\
304 "==>> yaffs bug: " __FILE__ " %d",\
305 __LINE__);\
306 Y_DUMP_STACK();\
307} while (0)
William Juulc051bbe2007-11-15 11:13:05 +0100308#endif
309
310#endif