befs.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. /* State of the superblock */
  38. u32 flags;
  39. /* Journal 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. struct befs_mount_options mount_opts;
  47. struct nls_table *nls;
  48. };
  49. 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. struct inode vfs_inode;
  60. };
  61. enum befs_err {
  62. BEFS_OK,
  63. BEFS_ERR,
  64. BEFS_BAD_INODE,
  65. BEFS_BT_END,
  66. BEFS_BT_EMPTY,
  67. BEFS_BT_MATCH,
  68. BEFS_BT_OVERFLOW,
  69. BEFS_BT_NOT_FOUND
  70. };
  71. /****************************/
  72. /* debug.c */
  73. __printf(2, 3)
  74. void befs_error(const struct super_block *sb, const char *fmt, ...);
  75. __printf(2, 3)
  76. void befs_warning(const struct super_block *sb, const char *fmt, ...);
  77. __printf(2, 3)
  78. void befs_debug(const struct super_block *sb, const char *fmt, ...);
  79. void befs_dump_super_block(const struct super_block *sb, befs_super_block *);
  80. void befs_dump_inode(const struct super_block *sb, befs_inode *);
  81. void befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super *);
  82. void befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *);
  83. /****************************/
  84. /* Gets a pointer to the private portion of the super_block
  85. * structure from the public part
  86. */
  87. static inline struct befs_sb_info *
  88. BEFS_SB(const struct super_block *super)
  89. {
  90. return (struct befs_sb_info *) super->s_fs_info;
  91. }
  92. static inline struct befs_inode_info *
  93. BEFS_I(const struct inode *inode)
  94. {
  95. return container_of(inode, struct befs_inode_info, vfs_inode);
  96. }
  97. static inline befs_blocknr_t
  98. iaddr2blockno(struct super_block *sb, const befs_inode_addr *iaddr)
  99. {
  100. return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
  101. iaddr->start);
  102. }
  103. static inline befs_inode_addr
  104. blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
  105. {
  106. befs_inode_addr iaddr;
  107. iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
  108. iaddr.start =
  109. blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
  110. iaddr.len = 1;
  111. return iaddr;
  112. }
  113. static inline unsigned int
  114. befs_iaddrs_per_block(struct super_block *sb)
  115. {
  116. return BEFS_SB(sb)->block_size / sizeof (befs_disk_inode_addr);
  117. }
  118. #include "endian.h"
  119. #endif /* _LINUX_BEFS_H */