2 * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
4 * Copyright (C) 2002-2010 Aleph One Ltd.
5 * for Toby Churchill Ltd and Brightstar Engineering
7 * Created by Charles Manning <charles@aleph1.co.uk>
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.
13 * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
16 #ifndef __YPORTENV_H__
17 #define __YPORTENV_H__
20 * Define the MTD version in terms of Linux Kernel versions
21 * This allows yaffs to be used independantly of the kernel
25 #define MTD_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c))
27 #if defined CONFIG_YAFFS_WINCE
29 #include "ywinceenv.h"
31 #elif defined __KERNEL__
33 #include "moduleconfig.h"
37 #include <linux/version.h>
38 #define MTD_VERSION_CODE LINUX_VERSION_CODE
40 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19))
41 #include <linux/config.h>
43 #include <linux/version.h>
44 #include <linux/kernel.h>
46 #include <linux/sched.h>
47 #include <linux/string.h>
48 #include <linux/slab.h>
49 #include <linux/vmalloc.h>
50 #include <linux/xattr.h>
51 #include <linux/list.h>
52 #include <linux/types.h>
54 #include <linux/stat.h>
55 #include <linux/sort.h>
56 #include <linux/bitops.h>
59 #define YUCHAR unsigned char
62 #define Y_INLINE __inline__
64 #define YAFFS_LOSTNFOUND_NAME "lost+found"
65 #define YAFFS_LOSTNFOUND_PREFIX "obj"
68 #define YAFFS_ROOT_MODE 0755
69 #define YAFFS_LOSTNFOUND_MODE 0700
71 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
72 #define Y_CURRENT_TIME CURRENT_TIME.tv_sec
73 #define Y_TIME_CONVERT(x) (x).tv_sec
75 #define Y_CURRENT_TIME CURRENT_TIME
76 #define Y_TIME_CONVERT(x) (x)
79 #define yaffs_sum_cmp(x, y) ((x) == (y))
80 #define strcmp(a, b) strcmp(a, b)
83 #define TSTR(x) KERN_DEBUG x
85 #define TOUT(p) printk p
87 #define compile_time_assertion(assertion) \
88 ({ int x = __builtin_choose_expr(assertion, 0, (void)0); (void) x; })
90 #elif defined CONFIG_YAFFS_DIRECT
92 #define MTD_VERSION_CODE MTD_VERSION(2, 6, 22)
94 /* Direct interface */
95 #include "ydirectenv.h"
97 #elif defined CONFIG_YAFFS_UTIL
99 /* Stuff for YAFFS utilities */
105 #define kmalloc(x) malloc(x)
106 #define kfree(x) free(x)
107 #define kmalloc_ALT(x) malloc(x)
108 #define kfree_ALT(x) free(x)
111 #define YUCHAR unsigned char
113 #define strcat(a, b) strcat(a, b)
114 #define strcpy(a, b) strcpy(a, b)
115 #define strncpy(a, b, c) strncpy(a, b, c)
116 #define strnlen(s,m) strnlen(s,m)
117 #define sprintf sprintf
118 #define yaffs_toupper(a) toupper(a)
120 #define Y_INLINE inline
122 /* #define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s)) */
123 /* #define YALERT(s) YINFO(s) */
127 #define TOUT(p) printf p
129 #define YAFFS_LOSTNFOUND_NAME "lost+found"
130 #define YAFFS_LOSTNFOUND_PREFIX "obj"
131 /* #define YPRINTF(x) printf x */
133 #define YAFFS_ROOT_MODE 0755
134 #define YAFFS_LOSTNFOUND_MODE 0700
136 #define yaffs_sum_cmp(x, y) ((x) == (y))
137 #define strcmp(a, b) strcmp(a, b)
140 /* Should have specified a configuration type */
141 #error Unknown configuration
145 #if defined(CONFIG_YAFFS_DIRECT) || defined(CONFIG_YAFFS_WINCE)
147 #ifdef CONFIG_YAFFSFS_PROVIDE_VALUES
170 #define O_TRUNC 01000
174 #define O_APPEND 02000
238 #define ENAMETOOLONG 36
260 #define S_IFMT 0170000
264 #define S_IFLNK 0120000
268 #define S_IFDIR 0040000
272 #define S_IFREG 0100000
276 #define S_IREAD 0000400
280 #define S_IWRITE 0000200
284 #define S_IEXEC 0000100
288 #define XATTR_CREATE 1
291 #ifndef XATTR_REPLACE
292 #define XATTR_REPLACE 2
304 #include <sys/stat.h>
311 #define Y_DUMP_STACK() do { } while (0)
317 (TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),\