befs.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * befs.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_H
  8. #define _LINUX_BEFS_H
  9. #include "befs_fs_types.h"
  10. /* used in debug.c */
  11. #define BEFS_VERSION "0.9.3"
  12. typedef u64 befs_blocknr_t;
  13. /*
  14. * BeFS in memory structures
  15. */
  16. struct befs_mount_options {
  17. kgid_t gid;
  18. kuid_t uid;
  19. int use_gid;
  20. int use_uid;
  21. int debug;
  22. char *iocharset;
  23. };
  24. struct befs_sb_info {
  25. u32 magic1;
  26. u32 block_size;
  27. u32 block_shift;
  28. int byte_order;
  29. befs_off_t num_blocks;
  30. befs_off_t used_blocks;
  31. u32 inode_size;
  32. u32 magic2;
  33. /* Allocation group information */
  34. u32 blocks_per_ag;
  35. u32 ag_shift;
  36. u32 num_ags;
  37. /* jornal log entry */
  38. befs_block_run log_blocks;
  39. befs_off_t log_start;
  40. befs_off_t log_end;
  41. befs_inode_addr root_dir;
  42. befs_inode_addr indices;
  43. u32 magic3;
  44. struct befs_mount_options mount_opts;
  45. struct nls_table *nls;
  46. };
  47. struct befs_inode_info {
  48. u32 i_flags;
  49. u32 i_type;
  50. befs_inode_addr i_inode_num;
  51. befs_inode_addr i_parent;
  52. befs_inode_addr i_attribute;
  53. union {
  54. befs_data_stream ds;
  55. char symlink[BEFS_SYMLINK_LEN];
  56. } i_data;
  57. struct inode vfs_inode;
  58. };
  59. enum befs_err {
  60. BEFS_OK,
  61. BEFS_ERR,
  62. BEFS_BAD_INODE,
  63. BEFS_BT_END,
  64. BEFS_BT_EMPTY,
  65. BEFS_BT_MATCH,
  66. BEFS_BT_PARMATCH,
  67. BEFS_BT_NOT_FOUND
  68. };
  69. /****************************/
  70. /* debug.c */
  71. __printf(2, 3)
  72. void befs_error(const struct super_block *sb, const char *fmt, ...);
  73. __printf(2, 3)
  74. void befs_warning(const struct super_block *sb, const char *fmt, ...);
  75. __printf(2, 3)
  76. void befs_debug(const struct super_block *sb, const char *fmt, ...);
  77. void befs_dump_super_block(const struct super_block *sb, befs_super_block *);
  78. void befs_dump_inode(const struct super_block *sb, befs_inode *);
  79. void befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super *);
  80. void befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *);
  81. /****************************/
  82. /* Gets a pointer to the private portion of the super_block
  83. * structure from the public part
  84. */
  85. static inline struct befs_sb_info *
  86. BEFS_SB(const struct super_block *super)
  87. {
  88. return (struct befs_sb_info *) super->s_fs_info;
  89. }
  90. static inline struct befs_inode_info *
  91. BEFS_I(const struct inode *inode)
  92. {
  93. return container_of(inode, struct befs_inode_info, vfs_inode);
  94. }
  95. static inline befs_blocknr_t
  96. iaddr2blockno(struct super_block *sb, befs_inode_addr * iaddr)
  97. {
  98. return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
  99. iaddr->start);
  100. }
  101. static inline befs_inode_addr
  102. blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
  103. {
  104. befs_inode_addr iaddr;
  105. iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
  106. iaddr.start =
  107. blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
  108. iaddr.len = 1;
  109. return iaddr;
  110. }
  111. static inline unsigned int
  112. befs_iaddrs_per_block(struct super_block *sb)
  113. {
  114. return BEFS_SB(sb)->block_size / sizeof (befs_disk_inode_addr);
  115. }
  116. static inline int
  117. befs_iaddr_is_empty(befs_inode_addr * iaddr)
  118. {
  119. return (!iaddr->allocation_group) && (!iaddr->start) && (!iaddr->len);
  120. }
  121. static inline size_t
  122. befs_brun_size(struct super_block *sb, befs_block_run run)
  123. {
  124. return BEFS_SB(sb)->block_size * run.len;
  125. }
  126. #include "endian.h"
  127. #endif /* _LINUX_BEFS_H */