befs_fs_types.h 5.0 KB

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