befs_fs_types.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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_SUPER_MAGIC BEFS_SUPER_MAGIC1
  49. /*
  50. * Flags of inode
  51. */
  52. #define BEFS_INODE_MAGIC1 0x3bbe0ad9
  53. enum inode_flags {
  54. BEFS_INODE_IN_USE = 0x00000001,
  55. BEFS_ATTR_INODE = 0x00000004,
  56. BEFS_INODE_LOGGED = 0x00000008,
  57. BEFS_INODE_DELETED = 0x00000010,
  58. BEFS_LONG_SYMLINK = 0x00000040,
  59. BEFS_PERMANENT_FLAG = 0x0000ffff,
  60. BEFS_INODE_NO_CREATE = 0x00010000,
  61. BEFS_INODE_WAS_WRITTEN = 0x00020000,
  62. BEFS_NO_TRANSACTION = 0x00040000,
  63. };
  64. /*
  65. * On-Disk datastructures of BeFS
  66. */
  67. typedef u64 __bitwise fs64;
  68. typedef u32 __bitwise fs32;
  69. typedef u16 __bitwise fs16;
  70. typedef u64 befs_off_t;
  71. typedef fs64 befs_time_t;
  72. /* Block runs */
  73. typedef struct {
  74. fs32 allocation_group;
  75. fs16 start;
  76. fs16 len;
  77. } PACKED befs_disk_block_run;
  78. typedef struct {
  79. u32 allocation_group;
  80. u16 start;
  81. u16 len;
  82. } PACKED befs_block_run;
  83. typedef befs_disk_block_run befs_disk_inode_addr;
  84. typedef befs_block_run befs_inode_addr;
  85. /*
  86. * The Superblock Structure
  87. */
  88. typedef struct {
  89. char name[B_OS_NAME_LENGTH];
  90. fs32 magic1;
  91. fs32 fs_byte_order;
  92. fs32 block_size;
  93. fs32 block_shift;
  94. fs64 num_blocks;
  95. fs64 used_blocks;
  96. fs32 inode_size;
  97. fs32 magic2;
  98. fs32 blocks_per_ag;
  99. fs32 ag_shift;
  100. fs32 num_ags;
  101. fs32 flags;
  102. befs_disk_block_run log_blocks;
  103. fs64 log_start;
  104. fs64 log_end;
  105. fs32 magic3;
  106. befs_disk_inode_addr root_dir;
  107. befs_disk_inode_addr indices;
  108. } PACKED befs_super_block;
  109. /*
  110. * Note: the indirect and dbl_indir block_runs may
  111. * be longer than one block!
  112. */
  113. typedef struct {
  114. befs_disk_block_run direct[BEFS_NUM_DIRECT_BLOCKS];
  115. fs64 max_direct_range;
  116. befs_disk_block_run indirect;
  117. fs64 max_indirect_range;
  118. befs_disk_block_run double_indirect;
  119. fs64 max_double_indirect_range;
  120. fs64 size;
  121. } PACKED befs_disk_data_stream;
  122. typedef struct {
  123. befs_block_run direct[BEFS_NUM_DIRECT_BLOCKS];
  124. befs_off_t max_direct_range;
  125. befs_block_run indirect;
  126. befs_off_t max_indirect_range;
  127. befs_block_run double_indirect;
  128. befs_off_t max_double_indirect_range;
  129. befs_off_t size;
  130. } PACKED befs_data_stream;
  131. /* Attribute */
  132. typedef struct {
  133. fs32 type;
  134. fs16 name_size;
  135. fs16 data_size;
  136. char name[1];
  137. } PACKED befs_small_data;
  138. /* Inode structure */
  139. typedef struct {
  140. fs32 magic1;
  141. befs_disk_inode_addr inode_num;
  142. fs32 uid;
  143. fs32 gid;
  144. fs32 mode;
  145. fs32 flags;
  146. befs_time_t create_time;
  147. befs_time_t last_modified_time;
  148. befs_disk_inode_addr parent;
  149. befs_disk_inode_addr attributes;
  150. fs32 type;
  151. fs32 inode_size;
  152. fs32 etc; /* not use */
  153. union {
  154. befs_disk_data_stream datastream;
  155. char symlink[BEFS_SYMLINK_LEN];
  156. } data;
  157. fs32 pad[4]; /* not use */
  158. befs_small_data small_data[1];
  159. } PACKED befs_inode;
  160. /*
  161. * B+tree superblock
  162. */
  163. #define BEFS_BTREE_MAGIC 0x69f6c2e8
  164. enum btree_types {
  165. BTREE_STRING_TYPE = 0,
  166. BTREE_INT32_TYPE = 1,
  167. BTREE_UINT32_TYPE = 2,
  168. BTREE_INT64_TYPE = 3,
  169. BTREE_UINT64_TYPE = 4,
  170. BTREE_FLOAT_TYPE = 5,
  171. BTREE_DOUBLE_TYPE = 6
  172. };
  173. typedef struct {
  174. fs32 magic;
  175. fs32 node_size;
  176. fs32 max_depth;
  177. fs32 data_type;
  178. fs64 root_node_ptr;
  179. fs64 free_node_ptr;
  180. fs64 max_size;
  181. } PACKED befs_disk_btree_super;
  182. typedef struct {
  183. u32 magic;
  184. u32 node_size;
  185. u32 max_depth;
  186. u32 data_type;
  187. befs_off_t root_node_ptr;
  188. befs_off_t free_node_ptr;
  189. befs_off_t max_size;
  190. } PACKED befs_btree_super;
  191. /*
  192. * Header stucture of each btree node
  193. */
  194. typedef struct {
  195. fs64 left;
  196. fs64 right;
  197. fs64 overflow;
  198. fs16 all_key_count;
  199. fs16 all_key_length;
  200. } PACKED befs_btree_nodehead;
  201. typedef struct {
  202. befs_off_t left;
  203. befs_off_t right;
  204. befs_off_t overflow;
  205. u16 all_key_count;
  206. u16 all_key_length;
  207. } PACKED befs_host_btree_nodehead;
  208. #endif /* _LINUX_BEFS_FS_TYPES */