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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * befs_fs.h
  3.  *
  4.  * Copyright (C) 2001-2002 Will Dyson <will_dyson@pobox.com>
  5.  * Copyright (C) 1999 Makoto Kato (m_kato@ga2.so-net.ne.jp)
  6.  */
  7. #ifndef _LINUX_BEFS_FS
  8. #define _LINUX_BEFS_FS
  9. #include "befs_fs_types.h"
  10. #include "compatibility.h"
  11. /* used in debug.c */
  12. #define BEFS_VERSION "0.9.2"
  13. typedef __u64 befs_blocknr_t;
  14. typedef __u32 vfs_blocknr_t;
  15. /*
  16.  * BeFS in memory structures
  17.  */
  18. typedef struct befs_mount_options {
  19. gid_t gid;
  20. uid_t uid;
  21. int use_gid;
  22. int use_uid;
  23. int debug;
  24. char *iocharset;
  25. } befs_mount_options;
  26. typedef struct befs_sb_info {
  27. __u32 magic1;
  28. __u32 block_size;
  29. __u32 block_shift;
  30. __u32 byte_order;
  31. befs_off_t num_blocks;
  32. befs_off_t used_blocks;
  33. __u32 inode_size;
  34. __u32 magic2;
  35. /* Allocation group information */
  36. __u32 blocks_per_ag;
  37. __u32 ag_shift;
  38. __u32 num_ags;
  39. /* jornal log entry */
  40. befs_block_run log_blocks;
  41. befs_off_t log_start;
  42. befs_off_t log_end;
  43. befs_inode_addr root_dir;
  44. befs_inode_addr indices;
  45. __u32 magic3;
  46. befs_mount_options mount_opts;
  47. struct nls_table *nls;
  48. } befs_sb_info;
  49. typedef struct befs_inode_info {
  50. __u32 i_flags;
  51. __u32 i_type;
  52. befs_inode_addr i_inode_num;
  53. befs_inode_addr i_parent;
  54. befs_inode_addr i_attribute;
  55. union {
  56. befs_data_stream ds;
  57. char symlink[BEFS_SYMLINK_LEN];
  58. } i_data;
  59. } befs_inode_info;
  60. enum befs_err {
  61. BEFS_OK,
  62. BEFS_ERR,
  63. BEFS_BAD_INODE,
  64. BEFS_BT_END,
  65. BEFS_BT_EMPTY,
  66. BEFS_BT_MATCH,
  67. BEFS_BT_PARMATCH,
  68. BEFS_BT_NOT_FOUND
  69. };
  70. /****************************/
  71. /* io.c */
  72. struct buffer_head *befs_bread_iaddr(struct super_block *sb,
  73.      befs_inode_addr iaddr);
  74. struct buffer_head *befs_bread(struct super_block *sb, befs_blocknr_t block);
  75. /****************************/
  76. /****************************/
  77. /* datastream.c */
  78. struct buffer_head *befs_read_datastream(struct super_block *sb,
  79.  befs_data_stream * ds, befs_off_t pos,
  80.  uint * off);
  81. int befs_fblock2brun(struct super_block *sb, befs_data_stream * data,
  82.      befs_blocknr_t fblock, befs_block_run * run);
  83. size_t befs_read_lsymlink(struct super_block *sb, befs_data_stream * data,
  84.   void *buff, befs_off_t len);
  85. befs_blocknr_t befs_count_blocks(struct super_block *sb, befs_data_stream * ds);
  86. extern const befs_inode_addr BAD_IADDR;
  87. /****************************/
  88. /****************************/
  89. /* debug.c */
  90. void befs_error(const struct super_block *sb, const char *fmt, ...);
  91. void befs_warning(const struct super_block *sb, const char *fmt, ...);
  92. void befs_debug(const struct super_block *sb, const char *fmt, ...);
  93. void befs_dump_super_block(const struct super_block *sb, befs_super_block *);
  94. void befs_dump_inode(const struct super_block *sb, befs_inode *);
  95. void befs_dump_index_entry(const struct super_block *sb, befs_btree_super *);
  96. void befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *);
  97. void befs_dump_inode_addr(const struct super_block *sb, befs_inode_addr);
  98. /****************************/
  99. /****************************/
  100. /* btree.c */
  101. int befs_btree_find(struct super_block *sb, befs_data_stream * ds,
  102.     const char *key, befs_off_t * value);
  103. int befs_btree_read(struct super_block *sb, befs_data_stream * ds,
  104.     loff_t key_no, size_t bufsize, char *keybuf,
  105.     size_t * keysize, befs_off_t * value);
  106. /****************************/
  107. /****************************/
  108. /* super.c */
  109. int befs_load_sb(struct super_block *sb, befs_super_block * disk_sb);
  110. int befs_check_sb(struct super_block *sb);
  111. /****************************/
  112. /****************************/
  113. /* inode.c */
  114. int befs_check_inode(struct super_block *sb, befs_inode * raw_inode,
  115.      befs_blocknr_t inode);
  116. /****************************/
  117. /* Gets a pointer to the private portion of the super_block
  118.  * structure from the public part
  119.  */
  120. static inline befs_sb_info *
  121. BEFS_SB(const struct super_block *super)
  122. {
  123. return (befs_sb_info *) super->u.generic_sbp;
  124. }
  125. static inline befs_inode_info *
  126. BEFS_I(const struct inode *inode)
  127. {
  128. return (befs_inode_info *) inode->u.generic_ip;
  129. }
  130. static inline befs_blocknr_t
  131. iaddr2blockno(struct super_block *sb, befs_inode_addr * iaddr)
  132. {
  133. return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
  134. iaddr->start);
  135. }
  136. static inline befs_inode_addr
  137. blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
  138. {
  139. befs_inode_addr iaddr;
  140. iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
  141. iaddr.start =
  142.     blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
  143. iaddr.len = 1;
  144. return iaddr;
  145. }
  146. static inline unsigned int
  147. befs_iaddrs_per_block(struct super_block *sb)
  148. {
  149. return BEFS_SB(sb)->block_size / sizeof (befs_inode_addr);
  150. }
  151. static inline int
  152. befs_iaddr_is_empty(befs_inode_addr * iaddr)
  153. {
  154. return (!iaddr->allocation_group) && (!iaddr->start) && (!iaddr->len);
  155. }
  156. static inline size_t
  157. befs_brun_size(struct super_block *sb, befs_block_run run)
  158. {
  159. return BEFS_SB(sb)->block_size * run.len;
  160. }
  161. #endif /* _LINUX_BEFS_FS */