amigaffs.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:6k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. #ifndef AMIGAFFS_H
  2. #define AMIGAFFS_H
  3. #include <linux/types.h>
  4. #include <linux/locks.h>
  5. #include <asm/byteorder.h>
  6. /* AmigaOS allows file names with up to 30 characters length.
  7.  * Names longer than that will be silently truncated. If you
  8.  * want to disallow this, comment out the following #define.
  9.  * Creating filesystem objects with longer names will then
  10.  * result in an error (ENAMETOOLONG).
  11.  */
  12. /*#define AFFS_NO_TRUNCATE */
  13. /* Ugly macros make the code more pretty. */
  14. #define GET_END_PTR(st,p,sz)  ((st *)((char *)(p)+((sz)-sizeof(st))))
  15. #define AFFS_GET_HASHENTRY(data,hashkey) be32_to_cpu(((struct dir_front *)data)->hashtable[hashkey])
  16. #define AFFS_BLOCK(sb, bh, blk) (AFFS_HEAD(bh)->table[(sb)->u.affs_sb.s_hashsize-1-(blk)])
  17. static inline void
  18. affs_set_blocksize(struct super_block *sb, int size)
  19. {
  20. set_blocksize(sb->s_dev, size);
  21. sb->s_blocksize = size;
  22. }
  23. static inline struct buffer_head *
  24. affs_bread(struct super_block *sb, int block)
  25. {
  26. pr_debug(KERN_DEBUG "affs_bread: %dn", block);
  27. if (block >= AFFS_SB->s_reserved && block < AFFS_SB->s_partition_size)
  28. return sb_bread(sb, block);
  29. return NULL;
  30. }
  31. static inline struct buffer_head *
  32. affs_getblk(struct super_block *sb, int block)
  33. {
  34. pr_debug(KERN_DEBUG "affs_getblk: %dn", block);
  35. if (block >= AFFS_SB->s_reserved && block < AFFS_SB->s_partition_size)
  36. return sb_getblk(sb, block);
  37. return NULL;
  38. }
  39. static inline struct buffer_head *
  40. affs_getzeroblk(struct super_block *sb, int block)
  41. {
  42. struct buffer_head *bh;
  43. pr_debug(KERN_DEBUG "affs_getzeroblk: %dn", block);
  44. if (block >= AFFS_SB->s_reserved && block < AFFS_SB->s_partition_size) {
  45. bh = sb_getblk(sb, block);
  46. lock_buffer(bh);
  47. memset(bh->b_data, 0 , sb->s_blocksize);
  48. mark_buffer_uptodate(bh, 1);
  49. unlock_buffer(bh);
  50. return bh;
  51. }
  52. return NULL;
  53. }
  54. static inline struct buffer_head *
  55. affs_getemptyblk(struct super_block *sb, int block)
  56. {
  57. struct buffer_head *bh;
  58. pr_debug(KERN_DEBUG "affs_getemptyblk: %dn", block);
  59. if (block >= AFFS_SB->s_reserved && block < AFFS_SB->s_partition_size) {
  60. bh = sb_getblk(sb, block);
  61. wait_on_buffer(bh);
  62. mark_buffer_uptodate(bh, 1);
  63. return bh;
  64. }
  65. return NULL;
  66. }
  67. static inline void
  68. affs_brelse(struct buffer_head *bh)
  69. {
  70. if (bh)
  71. pr_debug(KERN_DEBUG "affs_brelse: %ldn", bh->b_blocknr);
  72. brelse(bh);
  73. }
  74. static inline void
  75. affs_adjust_checksum(struct buffer_head *bh, u32 val)
  76. {
  77. u32 tmp = be32_to_cpu(((u32 *)bh->b_data)[5]);
  78. ((u32 *)bh->b_data)[5] = cpu_to_be32(tmp - val);
  79. }
  80. static inline void
  81. affs_adjust_bitmapchecksum(struct buffer_head *bh, u32 val)
  82. {
  83. u32 tmp = be32_to_cpu(((u32 *)bh->b_data)[0]);
  84. ((u32 *)bh->b_data)[0] = cpu_to_be32(tmp - val);
  85. }
  86. static inline void
  87. affs_lock_link(struct inode *inode)
  88. {
  89. down(&AFFS_INODE->i_link_lock);
  90. }
  91. static inline void
  92. affs_unlock_link(struct inode *inode)
  93. {
  94. up(&AFFS_INODE->i_link_lock);
  95. }
  96. static inline void
  97. affs_lock_dir(struct inode *inode)
  98. {
  99. down(&AFFS_INODE->i_hash_lock);
  100. }
  101. static inline void
  102. affs_unlock_dir(struct inode *inode)
  103. {
  104. up(&AFFS_INODE->i_hash_lock);
  105. }
  106. static inline void
  107. affs_lock_ext(struct inode *inode)
  108. {
  109. down(&AFFS_INODE->i_ext_lock);
  110. }
  111. static inline void
  112. affs_unlock_ext(struct inode *inode)
  113. {
  114. up(&AFFS_INODE->i_ext_lock);
  115. }
  116. #ifdef __LITTLE_ENDIAN
  117. #define BO_EXBITS 0x18UL
  118. #elif defined(__BIG_ENDIAN)
  119. #define BO_EXBITS 0x00UL
  120. #else
  121. #error Endianness must be known for affs to work.
  122. #endif
  123. #define FS_OFS 0x444F5300
  124. #define FS_FFS 0x444F5301
  125. #define FS_INTLOFS 0x444F5302
  126. #define FS_INTLFFS 0x444F5303
  127. #define FS_DCOFS 0x444F5304
  128. #define FS_DCFFS 0x444F5305
  129. #define MUFS_FS 0x6d754653   /* 'muFS' */
  130. #define MUFS_OFS 0x6d754600   /* 'muF' */
  131. #define MUFS_FFS 0x6d754601   /* 'muF1' */
  132. #define MUFS_INTLOFS 0x6d754602   /* 'muF2' */
  133. #define MUFS_INTLFFS 0x6d754603   /* 'muF3' */
  134. #define MUFS_DCOFS 0x6d754604   /* 'muF4' */
  135. #define MUFS_DCFFS 0x6d754605   /* 'muF5' */
  136. #define T_SHORT 2
  137. #define T_LIST 16
  138. #define T_DATA 8
  139. #define ST_LINKFILE -4
  140. #define ST_FILE -3
  141. #define ST_ROOT 1
  142. #define ST_USERDIR 2
  143. #define ST_SOFTLINK 3
  144. #define ST_LINKDIR 4
  145. #define AFFS_ROOT_BMAPS 25
  146. #define AFFS_HEAD(bh) ((struct affs_head *)(bh)->b_data)
  147. #define AFFS_TAIL(sb, bh) ((struct affs_tail *)((bh)->b_data+(sb)->s_blocksize-sizeof(struct affs_tail)))
  148. #define AFFS_ROOT_HEAD(bh) ((struct affs_root_head *)(bh)->b_data)
  149. #define AFFS_ROOT_TAIL(sb, bh) ((struct affs_root_tail *)((bh)->b_data+(sb)->s_blocksize-sizeof(struct affs_root_tail)))
  150. #define AFFS_DATA_HEAD(bh) ((struct affs_data_head *)(bh)->b_data)
  151. #define AFFS_DATA(bh) (((struct affs_data_head *)(bh)->b_data)->data)
  152. struct affs_date {
  153. u32 days;
  154. u32 mins;
  155. u32 ticks;
  156. };
  157. struct affs_short_date {
  158. u16 days;
  159. u16 mins;
  160. u16 ticks;
  161. };
  162. struct affs_root_head {
  163. u32 ptype;
  164. u32 spare1;
  165. u32 spare2;
  166. u32 hash_size;
  167. u32 spare3;
  168. u32 checksum;
  169. u32 hashtable[1];
  170. };
  171. struct affs_root_tail {
  172. u32 bm_flag;
  173. u32 bm_blk[AFFS_ROOT_BMAPS];
  174. u32 bm_ext;
  175. struct affs_date root_change;
  176. u8 disk_name[32];
  177. u32 spare1;
  178. u32 spare2;
  179. struct affs_date disk_change;
  180. struct affs_date disk_create;
  181. u32 spare3;
  182. u32 spare4;
  183. u32 dcache;
  184. u32 stype;
  185. };
  186. struct affs_head {
  187. u32 ptype;
  188. u32 key;
  189. u32 block_count;
  190. u32 spare1;
  191. u32 first_data;
  192. u32 checksum;
  193. u32 table[1];
  194. };
  195. struct affs_tail {
  196. u32 spare1;
  197. u16 uid;
  198. u16 gid;
  199. u32 protect;
  200. u32 size;
  201. u8 comment[92];
  202. struct affs_date change;
  203. u8 name[32];
  204. u32 spare2;
  205. u32 original;
  206. u32 link_chain;
  207. u32 spare[5];
  208. u32 hash_chain;
  209. u32 parent;
  210. u32 extension;
  211. u32 stype;
  212. };
  213. struct slink_front
  214. {
  215. u32 ptype;
  216. u32 key;
  217. u32 spare1[3];
  218. u32 checksum;
  219. u8 symname[1]; /* depends on block size */
  220. };
  221. struct affs_data_head
  222. {
  223. u32 ptype;
  224. u32 key;
  225. u32 sequence;
  226. u32 size;
  227. u32 next;
  228. u32 checksum;
  229. u8 data[1]; /* depends on block size */
  230. };
  231. /* Permission bits */
  232. #define FIBF_OTR_READ 0x8000
  233. #define FIBF_OTR_WRITE 0x4000
  234. #define FIBF_OTR_EXECUTE 0x2000
  235. #define FIBF_OTR_DELETE 0x1000
  236. #define FIBF_GRP_READ 0x0800
  237. #define FIBF_GRP_WRITE 0x0400
  238. #define FIBF_GRP_EXECUTE 0x0200
  239. #define FIBF_GRP_DELETE 0x0100
  240. #define FIBF_HIDDEN 0x0080
  241. #define FIBF_SCRIPT 0x0040
  242. #define FIBF_PURE 0x0020 /* no use under linux */
  243. #define FIBF_ARCHIVED 0x0010 /* never set, always cleared on write */
  244. #define FIBF_NOREAD 0x0008 /* 0 means allowed */
  245. #define FIBF_NOWRITE 0x0004 /* 0 means allowed */
  246. #define FIBF_NOEXECUTE 0x0002 /* 0 means allowed, ignored under linux */
  247. #define FIBF_NODELETE 0x0001 /* 0 means allowed */
  248. #define FIBF_OWNER 0x000F /* Bits pertaining to owner */
  249. #define FIBF_MASK 0xEE0E /* Bits modified by Linux */
  250. #endif