befs.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. typedef struct befs_mount_options {
  17. gid_t gid;
  18. uid_t uid;
  19. int use_gid;
  20. int use_uid;
  21. int debug;
  22. char *iocharset;
  23. } befs_mount_options;
  24. typedef 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. befs_mount_options mount_opts;
  45. struct nls_table *nls;
  46. } befs_sb_info;
  47. typedef 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. } befs_inode_info;
  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. void befs_error(const struct super_block *sb, const char *fmt, ...);
  72. void befs_warning(const struct super_block *sb, const char *fmt, ...);
  73. void befs_debug(const struct super_block *sb, const char *fmt, ...);
  74. void befs_dump_super_block(const struct super_block *sb, befs_super_block *);
  75. void befs_dump_inode(const struct super_block *sb, befs_inode *);
  76. void befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super *);
  77. void befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *);
  78. /****************************/
  79. /* Gets a pointer to the private portion of the super_block
  80. * structure from the public part
  81. */
  82. static inline befs_sb_info *
  83. BEFS_SB(const struct super_block *super)
  84. {
  85. return (befs_sb_info *) super->s_fs_info;
  86. }
  87. static inline befs_inode_info *
  88. BEFS_I(const struct inode *inode)
  89. {
  90. return list_entry(inode, struct befs_inode_info, vfs_inode);
  91. }
  92. static inline befs_blocknr_t
  93. iaddr2blockno(struct super_block *sb, befs_inode_addr * iaddr)
  94. {
  95. return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
  96. iaddr->start);
  97. }
  98. static inline befs_inode_addr
  99. blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
  100. {
  101. befs_inode_addr iaddr;
  102. iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
  103. iaddr.start =
  104. blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
  105. iaddr.len = 1;
  106. return iaddr;
  107. }
  108. static inline unsigned int
  109. befs_iaddrs_per_block(struct super_block *sb)
  110. {
  111. return BEFS_SB(sb)->block_size / sizeof (befs_disk_inode_addr);
  112. }
  113. static inline int
  114. befs_iaddr_is_empty(befs_inode_addr * iaddr)
  115. {
  116. return (!iaddr->allocation_group) && (!iaddr->start) && (!iaddr->len);
  117. }
  118. static inline size_t
  119. befs_brun_size(struct super_block *sb, befs_block_run run)
  120. {
  121. return BEFS_SB(sb)->block_size * run.len;
  122. }
  123. #include "endian.h"
  124. #endif /* _LINUX_BEFS_H */