befs.h 3.0 KB

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