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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * include/linux/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_CLEAN = 0x434c454e,
  40. BEFS_DIRTY = 0x44495254,
  41. BEFS_BYTESEX_BE = 0x45474942,
  42. BEFS_BYTESEX_LE = 0x42494745,
  43. BEFS_SUPER_MAGIC1 = 0x42465331, /* BFS1 */
  44. BEFS_SUPER_MAGIC2 = 0xdd121031,
  45. BEFS_SUPER_MAGIC3 = 0x15b6830e,
  46. };
  47. #define BEFS_SUPER_MAGIC BEFS_SUPER_MAGIC1
  48. /*
  49.  * Flags of inode
  50.  */
  51. #define BEFS_INODE_MAGIC1 0x3bbe0ad9
  52. enum inode_flags {
  53. BEFS_INODE_IN_USE = 0x00000001,
  54. BEFS_ATTR_INODE = 0x00000004,
  55. BEFS_INODE_LOGGED = 0x00000008,
  56. BEFS_INODE_DELETED = 0x00000010,
  57. BEFS_LONG_SYMLINK = 0x00000040,
  58. BEFS_PERMANENT_FLAG = 0x0000ffff,
  59. BEFS_INODE_NO_CREATE = 0x00010000,
  60. BEFS_INODE_WAS_WRITTEN = 0x00020000,
  61. BEFS_NO_TRANSACTION = 0x00040000,
  62. };
  63. /* 
  64.  * On-Disk datastructures of BeFS
  65.  */
  66. typedef __u64 befs_off_t;
  67. typedef __u64 befs_time_t;
  68. typedef void befs_binode_etc;
  69. /* Block runs */
  70. typedef struct {
  71. __u32 allocation_group;
  72. __u16 start;
  73. __u16 len;
  74. } PACKED befs_block_run;
  75. typedef befs_block_run befs_inode_addr;
  76. /*
  77.  * The Superblock Structure
  78.  */
  79. typedef struct {
  80. char name[B_OS_NAME_LENGTH];
  81. __u32 magic1;
  82. __u32 fs_byte_order;
  83. __u32 block_size;
  84. __u32 block_shift;
  85. befs_off_t num_blocks;
  86. befs_off_t used_blocks;
  87. __u32 inode_size;
  88. __u32 magic2;
  89. __u32 blocks_per_ag;
  90. __u32 ag_shift;
  91. __u32 num_ags;
  92. __u32 flags;
  93. befs_block_run log_blocks;
  94. befs_off_t log_start;
  95. befs_off_t log_end;
  96. __u32 magic3;
  97. befs_inode_addr root_dir;
  98. befs_inode_addr indices;
  99. } PACKED befs_super_block;
  100. /* 
  101.  * Note: the indirect and dbl_indir block_runs may
  102.  * be longer than one block!
  103.  */
  104. typedef struct {
  105. befs_block_run direct[BEFS_NUM_DIRECT_BLOCKS];
  106. befs_off_t max_direct_range;
  107. befs_block_run indirect;
  108. befs_off_t max_indirect_range;
  109. befs_block_run double_indirect;
  110. befs_off_t max_double_indirect_range;
  111. befs_off_t size;
  112. } PACKED befs_data_stream;
  113. /* Attribute */
  114. typedef struct {
  115. __u32 type;
  116. __u16 name_size;
  117. __u16 data_size;
  118. char name[1];
  119. } PACKED befs_small_data;
  120. /* Inode structure */
  121. typedef struct {
  122. __u32 magic1;
  123. befs_inode_addr inode_num;
  124. __u32 uid;
  125. __u32 gid;
  126. __u32 mode;
  127. __u32 flags;
  128. befs_time_t create_time;
  129. befs_time_t last_modified_time;
  130. befs_inode_addr parent;
  131. befs_inode_addr attributes;
  132. __u32 type;
  133. __u32 inode_size;
  134. __u32 etc; /* not use */
  135. union {
  136. befs_data_stream datastream;
  137. char symlink[BEFS_SYMLINK_LEN];
  138. } data;
  139. __u32 pad[4]; /* not use */
  140. befs_small_data small_data[1];
  141. } PACKED befs_inode;
  142. /*
  143.  * B+tree superblock
  144.  */
  145. #define BEFS_BTREE_MAGIC 0x69f6c2e8
  146. enum btree_types {
  147. BTREE_STRING_TYPE = 0,
  148. BTREE_INT32_TYPE = 1,
  149. BTREE_UINT32_TYPE = 2,
  150. BTREE_INT64_TYPE = 3,
  151. BTREE_UINT64_TYPE = 4,
  152. BTREE_FLOAT_TYPE = 5,
  153. BTREE_DOUBLE_TYPE = 6
  154. };
  155. typedef struct {
  156. __u32 magic;
  157. __u32 node_size;
  158. __u32 max_depth;
  159. __u32 data_type;
  160. befs_off_t root_node_ptr;
  161. befs_off_t free_node_ptr;
  162. befs_off_t max_size;
  163. } PACKED befs_btree_super;
  164. /*
  165.  * Header stucture of each btree node
  166.  */
  167. typedef struct {
  168. befs_off_t left;
  169. befs_off_t right;
  170. befs_off_t overflow;
  171. __u16 all_key_count;
  172. __u16 all_key_length;
  173. } PACKED befs_btree_nodehead;
  174. #endif /* _LINUX_BEFS_FS_TYPES */