yportenv.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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. #ifndef __YPORTENV_H__
  16. #define __YPORTENV_H__
  17. #include <linux/bug.h>
  18. #include <linux/types.h>
  19. /* Definition of types */
  20. #ifdef CONFIG_YAFFS_DEFINES_TYPES
  21. typedef unsigned char u8;
  22. typedef unsigned short u16;
  23. typedef unsigned u32;
  24. #endif
  25. #ifdef CONFIG_YAFFS_PROVIDE_DEFS
  26. /* File types */
  27. #define DT_UNKNOWN 0
  28. #define DT_FIFO 1
  29. #define DT_CHR 2
  30. #define DT_DIR 4
  31. #define DT_BLK 6
  32. #define DT_REG 8
  33. #define DT_LNK 10
  34. #define DT_SOCK 12
  35. #define DT_WHT 14
  36. /*
  37. * Attribute flags.
  38. * These are or-ed together to select what has been changed.
  39. */
  40. #define ATTR_MODE 1
  41. #define ATTR_UID 2
  42. #define ATTR_GID 4
  43. #define ATTR_SIZE 8
  44. #define ATTR_ATIME 16
  45. #define ATTR_MTIME 32
  46. #define ATTR_CTIME 64
  47. struct iattr {
  48. unsigned int ia_valid;
  49. unsigned ia_mode;
  50. unsigned ia_uid;
  51. unsigned ia_gid;
  52. unsigned ia_size;
  53. unsigned ia_atime;
  54. unsigned ia_mtime;
  55. unsigned ia_ctime;
  56. unsigned int ia_attr_flags;
  57. };
  58. #endif
  59. #if defined CONFIG_YAFFS_WINCE
  60. #include "ywinceenv.h"
  61. #elif defined CONFIG_YAFFS_DIRECT
  62. /* Direct interface */
  63. #include "ydirectenv.h"
  64. #elif defined CONFIG_YAFFS_UTIL
  65. #include "yutilsenv.h"
  66. #else
  67. /* Should have specified a configuration type */
  68. #error Unknown configuration
  69. #endif
  70. #if defined(CONFIG_YAFFS_DIRECT) || defined(CONFIG_YAFFS_WINCE)
  71. #ifdef CONFIG_YAFFSFS_PROVIDE_VALUES
  72. #ifndef O_RDONLY
  73. #define O_RDONLY 00
  74. #endif
  75. #ifndef O_WRONLY
  76. #define O_WRONLY 01
  77. #endif
  78. #ifndef O_RDWR
  79. #define O_RDWR 02
  80. #endif
  81. #ifndef O_CREAT
  82. #define O_CREAT 0100
  83. #endif
  84. #ifndef O_EXCL
  85. #define O_EXCL 0200
  86. #endif
  87. #ifndef O_TRUNC
  88. #define O_TRUNC 01000
  89. #endif
  90. #ifndef O_APPEND
  91. #define O_APPEND 02000
  92. #endif
  93. #ifndef SEEK_SET
  94. #define SEEK_SET 0
  95. #endif
  96. #ifndef SEEK_CUR
  97. #define SEEK_CUR 1
  98. #endif
  99. #ifndef SEEK_END
  100. #define SEEK_END 2
  101. #endif
  102. #ifndef EBUSY
  103. #define EBUSY 16
  104. #endif
  105. #ifndef ENODEV
  106. #define ENODEV 19
  107. #endif
  108. #ifndef EINVAL
  109. #define EINVAL 22
  110. #endif
  111. #ifndef ENFILE
  112. #define ENFILE 23
  113. #endif
  114. #ifndef EBADF
  115. #define EBADF 9
  116. #endif
  117. #ifndef EACCES
  118. #define EACCES 13
  119. #endif
  120. #ifndef EXDEV
  121. #define EXDEV 18
  122. #endif
  123. #ifndef ENOENT
  124. #define ENOENT 2
  125. #endif
  126. #ifndef ENOSPC
  127. #define ENOSPC 28
  128. #endif
  129. #ifndef EROFS
  130. #define EROFS 30
  131. #endif
  132. #ifndef ERANGE
  133. #define ERANGE 34
  134. #endif
  135. #ifndef ENODATA
  136. #define ENODATA 61
  137. #endif
  138. #ifndef ENOTEMPTY
  139. #define ENOTEMPTY 39
  140. #endif
  141. #ifndef ENAMETOOLONG
  142. #define ENAMETOOLONG 36
  143. #endif
  144. #ifndef ENOMEM
  145. #define ENOMEM 12
  146. #endif
  147. #ifndef EFAULT
  148. #define EFAULT 14
  149. #endif
  150. #ifndef EEXIST
  151. #define EEXIST 17
  152. #endif
  153. #ifndef ENOTDIR
  154. #define ENOTDIR 20
  155. #endif
  156. #ifndef EISDIR
  157. #define EISDIR 21
  158. #endif
  159. #ifndef ELOOP
  160. #define ELOOP 40
  161. #endif
  162. /* Mode flags */
  163. #ifndef S_IFMT
  164. #define S_IFMT 0170000
  165. #endif
  166. #ifndef S_IFSOCK
  167. #define S_IFSOCK 0140000
  168. #endif
  169. #ifndef S_IFIFO
  170. #define S_IFIFO 0010000
  171. #endif
  172. #ifndef S_IFCHR
  173. #define S_IFCHR 0020000
  174. #endif
  175. #ifndef S_IFBLK
  176. #define S_IFBLK 0060000
  177. #endif
  178. #ifndef S_IFLNK
  179. #define S_IFLNK 0120000
  180. #endif
  181. #ifndef S_IFDIR
  182. #define S_IFDIR 0040000
  183. #endif
  184. #ifndef S_IFREG
  185. #define S_IFREG 0100000
  186. #endif
  187. #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
  188. #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
  189. #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  190. #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  191. #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
  192. #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
  193. #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
  194. #ifndef S_IREAD
  195. #define S_IREAD 0000400
  196. #endif
  197. #ifndef S_IWRITE
  198. #define S_IWRITE 0000200
  199. #endif
  200. #ifndef S_IEXEC
  201. #define S_IEXEC 0000100
  202. #endif
  203. #ifndef XATTR_CREATE
  204. #define XATTR_CREATE 1
  205. #endif
  206. #ifndef XATTR_REPLACE
  207. #define XATTR_REPLACE 2
  208. #endif
  209. #ifndef R_OK
  210. #define R_OK 4
  211. #define W_OK 2
  212. #define X_OK 1
  213. #define F_OK 0
  214. #endif
  215. #else
  216. #include <errno.h>
  217. #include <sys/stat.h>
  218. #include <fcntl.h>
  219. #endif
  220. #endif
  221. #ifndef Y_DUMP_STACK
  222. #define Y_DUMP_STACK() do { } while (0)
  223. #endif
  224. #ifndef BUG
  225. #define BUG() do {\
  226. yaffs_trace(YAFFS_TRACE_BUG,\
  227. "==>> yaffs bug: " __FILE__ " %d",\
  228. __LINE__);\
  229. Y_DUMP_STACK();\
  230. } while (0)
  231. #endif
  232. #endif