/fs/befs/befs_fs_types.h

https://bitbucket.org/slukk/jb-tsm-kernel-4.2 · C Header · 255 lines · 164 code · 43 blank · 48 comment · 0 complexity · 62cd35d1c13de5e4b04cfa3773a4e164 MD5 · raw file

  1. /*
  2. * fs/befs/befs_fs_types.h
  3. *
  4. * Copyright (C) 2001 Will Dyson (will@cs.earlham.edu)
  5. *
  6. *
  7. *
  8. * from linux/include/linux/befs_fs.h
  9. *
  10. * Copyright (C) 1999 Makoto Kato (m_kato@ga2.so-net.ne.jp)
  11. *
  12. */
  13. #ifndef _LINUX_BEFS_FS_TYPES
  14. #define _LINUX_BEFS_FS_TYPES
  15. #ifdef __KERNEL__
  16. #include <linux/types.h>
  17. #endif /*__KERNEL__*/
  18. #define PACKED __attribute__ ((__packed__))
  19. /*
  20. * Max name lengths of BFS
  21. */
  22. #define BEFS_NAME_LEN 255
  23. #define BEFS_SYMLINK_LEN 144
  24. #define BEFS_NUM_DIRECT_BLOCKS 12
  25. #define B_OS_NAME_LENGTH 32
  26. /* The datastream blocks mapped by the double-indirect
  27. * block are always 4 fs blocks long.
  28. * This eliminates the need for linear searches among
  29. * the potentially huge number of indirect blocks
  30. *
  31. * Err. Should that be 4 fs blocks or 4k???
  32. * It matters on large blocksize volumes
  33. */
  34. #define BEFS_DBLINDIR_BRUN_LEN 4
  35. /*
  36. * Flags of superblock
  37. */
  38. enum super_flags {
  39. BEFS_BYTESEX_BE,
  40. BEFS_BYTESEX_LE,
  41. BEFS_CLEAN = 0x434c454e,
  42. BEFS_DIRTY = 0x44495254,
  43. BEFS_SUPER_MAGIC1 = 0x42465331, /* BFS1 */
  44. BEFS_SUPER_MAGIC2 = 0xdd121031,
  45. BEFS_SUPER_MAGIC3 = 0x15b6830e,
  46. };
  47. #define BEFS_BYTEORDER_NATIVE 0x42494745
  48. #define BEFS_BYTEORDER_NATIVE_LE (__force fs32)cpu_to_le32(BEFS_BYTEORDER_NATIVE)
  49. #define BEFS_BYTEORDER_NATIVE_BE (__force fs32)cpu_to_be32(BEFS_BYTEORDER_NATIVE)
  50. #define BEFS_SUPER_MAGIC BEFS_SUPER_MAGIC1
  51. #define BEFS_SUPER_MAGIC1_LE (__force fs32)cpu_to_le32(BEFS_SUPER_MAGIC1)
  52. #define BEFS_SUPER_MAGIC1_BE (__force fs32)cpu_to_be32(BEFS_SUPER_MAGIC1)
  53. /*
  54. * Flags of inode
  55. */
  56. #define BEFS_INODE_MAGIC1 0x3bbe0ad9
  57. enum inode_flags {
  58. BEFS_INODE_IN_USE = 0x00000001,
  59. BEFS_ATTR_INODE = 0x00000004,
  60. BEFS_INODE_LOGGED = 0x00000008,
  61. BEFS_INODE_DELETED = 0x00000010,
  62. BEFS_LONG_SYMLINK = 0x00000040,
  63. BEFS_PERMANENT_FLAG = 0x0000ffff,
  64. BEFS_INODE_NO_CREATE = 0x00010000,
  65. BEFS_INODE_WAS_WRITTEN = 0x00020000,
  66. BEFS_NO_TRANSACTION = 0x00040000,
  67. };
  68. /*
  69. * On-Disk datastructures of BeFS
  70. */
  71. typedef u64 __bitwise fs64;
  72. typedef u32 __bitwise fs32;
  73. typedef u16 __bitwise fs16;
  74. typedef u64 befs_off_t;
  75. typedef fs64 befs_time_t;
  76. /* Block runs */
  77. typedef struct {
  78. fs32 allocation_group;
  79. fs16 start;
  80. fs16 len;
  81. } PACKED befs_disk_block_run;
  82. typedef struct {
  83. u32 allocation_group;
  84. u16 start;
  85. u16 len;
  86. } PACKED befs_block_run;
  87. typedef befs_disk_block_run befs_disk_inode_addr;
  88. typedef befs_block_run befs_inode_addr;
  89. /*
  90. * The Superblock Structure
  91. */
  92. typedef struct {
  93. char name[B_OS_NAME_LENGTH];
  94. fs32 magic1;
  95. fs32 fs_byte_order;
  96. fs32 block_size;
  97. fs32 block_shift;
  98. fs64 num_blocks;
  99. fs64 used_blocks;
  100. fs32 inode_size;
  101. fs32 magic2;
  102. fs32 blocks_per_ag;
  103. fs32 ag_shift;
  104. fs32 num_ags;
  105. fs32 flags;
  106. befs_disk_block_run log_blocks;
  107. fs64 log_start;
  108. fs64 log_end;
  109. fs32 magic3;
  110. befs_disk_inode_addr root_dir;
  111. befs_disk_inode_addr indices;
  112. } PACKED befs_super_block;
  113. /*
  114. * Note: the indirect and dbl_indir block_runs may
  115. * be longer than one block!
  116. */
  117. typedef struct {
  118. befs_disk_block_run direct[BEFS_NUM_DIRECT_BLOCKS];
  119. fs64 max_direct_range;
  120. befs_disk_block_run indirect;
  121. fs64 max_indirect_range;
  122. befs_disk_block_run double_indirect;
  123. fs64 max_double_indirect_range;
  124. fs64 size;
  125. } PACKED befs_disk_data_stream;
  126. typedef struct {
  127. befs_block_run direct[BEFS_NUM_DIRECT_BLOCKS];
  128. befs_off_t max_direct_range;
  129. befs_block_run indirect;
  130. befs_off_t max_indirect_range;
  131. befs_block_run double_indirect;
  132. befs_off_t max_double_indirect_range;
  133. befs_off_t size;
  134. } PACKED befs_data_stream;
  135. /* Attribute */
  136. typedef struct {
  137. fs32 type;
  138. fs16 name_size;
  139. fs16 data_size;
  140. char name[1];
  141. } PACKED befs_small_data;
  142. /* Inode structure */
  143. typedef struct {
  144. fs32 magic1;
  145. befs_disk_inode_addr inode_num;
  146. fs32 uid;
  147. fs32 gid;
  148. fs32 mode;
  149. fs32 flags;
  150. befs_time_t create_time;
  151. befs_time_t last_modified_time;
  152. befs_disk_inode_addr parent;
  153. befs_disk_inode_addr attributes;
  154. fs32 type;
  155. fs32 inode_size;
  156. fs32 etc; /* not use */
  157. union {
  158. befs_disk_data_stream datastream;
  159. char symlink[BEFS_SYMLINK_LEN];
  160. } data;
  161. fs32 pad[4]; /* not use */
  162. befs_small_data small_data[1];
  163. } PACKED befs_inode;
  164. /*
  165. * B+tree superblock
  166. */
  167. #define BEFS_BTREE_MAGIC 0x69f6c2e8
  168. enum btree_types {
  169. BTREE_STRING_TYPE = 0,
  170. BTREE_INT32_TYPE = 1,
  171. BTREE_UINT32_TYPE = 2,
  172. BTREE_INT64_TYPE = 3,
  173. BTREE_UINT64_TYPE = 4,
  174. BTREE_FLOAT_TYPE = 5,
  175. BTREE_DOUBLE_TYPE = 6
  176. };
  177. typedef struct {
  178. fs32 magic;
  179. fs32 node_size;
  180. fs32 max_depth;
  181. fs32 data_type;
  182. fs64 root_node_ptr;
  183. fs64 free_node_ptr;
  184. fs64 max_size;
  185. } PACKED befs_disk_btree_super;
  186. typedef struct {
  187. u32 magic;
  188. u32 node_size;
  189. u32 max_depth;
  190. u32 data_type;
  191. befs_off_t root_node_ptr;
  192. befs_off_t free_node_ptr;
  193. befs_off_t max_size;
  194. } PACKED befs_btree_super;
  195. /*
  196. * Header structure of each btree node
  197. */
  198. typedef struct {
  199. fs64 left;
  200. fs64 right;
  201. fs64 overflow;
  202. fs16 all_key_count;
  203. fs16 all_key_length;
  204. } PACKED befs_btree_nodehead;
  205. typedef struct {
  206. befs_off_t left;
  207. befs_off_t right;
  208. befs_off_t overflow;
  209. u16 all_key_count;
  210. u16 all_key_length;
  211. } PACKED befs_host_btree_nodehead;
  212. #endif /* _LINUX_BEFS_FS_TYPES */