yportenv.h 4.3 KB

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