yportenv.h 4.4 KB

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