debug.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /*
  2. * linux/fs/befs/debug.c
  3. *
  4. * Copyright (C) 2001 Will Dyson (will_dyson at pobox.com)
  5. *
  6. * With help from the ntfs-tng driver by Anton Altparmakov
  7. *
  8. * Copyright (C) 1999 Makoto Kato (m_kato@ga2.so-net.ne.jp)
  9. *
  10. * debug functions
  11. */
  12. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  13. #ifdef __KERNEL__
  14. #include <stdarg.h>
  15. #include <linux/string.h>
  16. #include <linux/spinlock.h>
  17. #include <linux/kernel.h>
  18. #include <linux/fs.h>
  19. #include <linux/slab.h>
  20. #endif /* __KERNEL__ */
  21. #include "befs.h"
  22. void
  23. befs_error(const struct super_block *sb, const char *fmt, ...)
  24. {
  25. struct va_format vaf;
  26. va_list args;
  27. va_start(args, fmt);
  28. vaf.fmt = fmt;
  29. vaf.va = &args;
  30. pr_err("(%s): %pV\n", sb->s_id, &vaf);
  31. va_end(args);
  32. }
  33. void
  34. befs_warning(const struct super_block *sb, const char *fmt, ...)
  35. {
  36. struct va_format vaf;
  37. va_list args;
  38. va_start(args, fmt);
  39. vaf.fmt = fmt;
  40. vaf.va = &args;
  41. pr_warn("(%s): %pV\n", sb->s_id, &vaf);
  42. va_end(args);
  43. }
  44. void
  45. befs_debug(const struct super_block *sb, const char *fmt, ...)
  46. {
  47. #ifdef CONFIG_BEFS_DEBUG
  48. struct va_format vaf;
  49. va_list args;
  50. va_start(args, fmt);
  51. vaf.fmt = fmt;
  52. vaf.va = &args;
  53. pr_debug("(%s): %pV\n", sb->s_id, &vaf);
  54. va_end(args);
  55. #endif //CONFIG_BEFS_DEBUG
  56. }
  57. void
  58. befs_dump_inode(const struct super_block *sb, befs_inode * inode)
  59. {
  60. #ifdef CONFIG_BEFS_DEBUG
  61. befs_block_run tmp_run;
  62. befs_debug(sb, "befs_inode information");
  63. befs_debug(sb, " magic1 %08x", fs32_to_cpu(sb, inode->magic1));
  64. tmp_run = fsrun_to_cpu(sb, inode->inode_num);
  65. befs_debug(sb, " inode_num %u, %hu, %hu",
  66. tmp_run.allocation_group, tmp_run.start, tmp_run.len);
  67. befs_debug(sb, " uid %u", fs32_to_cpu(sb, inode->uid));
  68. befs_debug(sb, " gid %u", fs32_to_cpu(sb, inode->gid));
  69. befs_debug(sb, " mode %08x", fs32_to_cpu(sb, inode->mode));
  70. befs_debug(sb, " flags %08x", fs32_to_cpu(sb, inode->flags));
  71. befs_debug(sb, " create_time %llu",
  72. fs64_to_cpu(sb, inode->create_time));
  73. befs_debug(sb, " last_modified_time %llu",
  74. fs64_to_cpu(sb, inode->last_modified_time));
  75. tmp_run = fsrun_to_cpu(sb, inode->parent);
  76. befs_debug(sb, " parent [%u, %hu, %hu]",
  77. tmp_run.allocation_group, tmp_run.start, tmp_run.len);
  78. tmp_run = fsrun_to_cpu(sb, inode->attributes);
  79. befs_debug(sb, " attributes [%u, %hu, %hu]",
  80. tmp_run.allocation_group, tmp_run.start, tmp_run.len);
  81. befs_debug(sb, " type %08x", fs32_to_cpu(sb, inode->type));
  82. befs_debug(sb, " inode_size %u", fs32_to_cpu(sb, inode->inode_size));
  83. if (S_ISLNK(fs32_to_cpu(sb, inode->mode))) {
  84. befs_debug(sb, " Symbolic link [%s]", inode->data.symlink);
  85. } else {
  86. int i;
  87. for (i = 0; i < BEFS_NUM_DIRECT_BLOCKS; i++) {
  88. tmp_run =
  89. fsrun_to_cpu(sb, inode->data.datastream.direct[i]);
  90. befs_debug(sb, " direct %d [%u, %hu, %hu]", i,
  91. tmp_run.allocation_group, tmp_run.start,
  92. tmp_run.len);
  93. }
  94. befs_debug(sb, " max_direct_range %llu",
  95. fs64_to_cpu(sb,
  96. inode->data.datastream.
  97. max_direct_range));
  98. tmp_run = fsrun_to_cpu(sb, inode->data.datastream.indirect);
  99. befs_debug(sb, " indirect [%u, %hu, %hu]",
  100. tmp_run.allocation_group,
  101. tmp_run.start, tmp_run.len);
  102. befs_debug(sb, " max_indirect_range %llu",
  103. fs64_to_cpu(sb,
  104. inode->data.datastream.
  105. max_indirect_range));
  106. tmp_run =
  107. fsrun_to_cpu(sb, inode->data.datastream.double_indirect);
  108. befs_debug(sb, " double indirect [%u, %hu, %hu]",
  109. tmp_run.allocation_group, tmp_run.start,
  110. tmp_run.len);
  111. befs_debug(sb, " max_double_indirect_range %llu",
  112. fs64_to_cpu(sb,
  113. inode->data.datastream.
  114. max_double_indirect_range));
  115. befs_debug(sb, " size %llu",
  116. fs64_to_cpu(sb, inode->data.datastream.size));
  117. }
  118. #endif //CONFIG_BEFS_DEBUG
  119. }
  120. /*
  121. * Display super block structure for debug.
  122. */
  123. void
  124. befs_dump_super_block(const struct super_block *sb, befs_super_block * sup)
  125. {
  126. #ifdef CONFIG_BEFS_DEBUG
  127. befs_block_run tmp_run;
  128. befs_debug(sb, "befs_super_block information");
  129. befs_debug(sb, " name %s", sup->name);
  130. befs_debug(sb, " magic1 %08x", fs32_to_cpu(sb, sup->magic1));
  131. befs_debug(sb, " fs_byte_order %08x",
  132. fs32_to_cpu(sb, sup->fs_byte_order));
  133. befs_debug(sb, " block_size %u", fs32_to_cpu(sb, sup->block_size));
  134. befs_debug(sb, " block_shift %u", fs32_to_cpu(sb, sup->block_shift));
  135. befs_debug(sb, " num_blocks %llu", fs64_to_cpu(sb, sup->num_blocks));
  136. befs_debug(sb, " used_blocks %llu", fs64_to_cpu(sb, sup->used_blocks));
  137. befs_debug(sb, " magic2 %08x", fs32_to_cpu(sb, sup->magic2));
  138. befs_debug(sb, " blocks_per_ag %u",
  139. fs32_to_cpu(sb, sup->blocks_per_ag));
  140. befs_debug(sb, " ag_shift %u", fs32_to_cpu(sb, sup->ag_shift));
  141. befs_debug(sb, " num_ags %u", fs32_to_cpu(sb, sup->num_ags));
  142. befs_debug(sb, " flags %08x", fs32_to_cpu(sb, sup->flags));
  143. tmp_run = fsrun_to_cpu(sb, sup->log_blocks);
  144. befs_debug(sb, " log_blocks %u, %hu, %hu",
  145. tmp_run.allocation_group, tmp_run.start, tmp_run.len);
  146. befs_debug(sb, " log_start %lld", fs64_to_cpu(sb, sup->log_start));
  147. befs_debug(sb, " log_end %lld", fs64_to_cpu(sb, sup->log_end));
  148. befs_debug(sb, " magic3 %08x", fs32_to_cpu(sb, sup->magic3));
  149. tmp_run = fsrun_to_cpu(sb, sup->root_dir);
  150. befs_debug(sb, " root_dir %u, %hu, %hu",
  151. tmp_run.allocation_group, tmp_run.start, tmp_run.len);
  152. tmp_run = fsrun_to_cpu(sb, sup->indices);
  153. befs_debug(sb, " indices %u, %hu, %hu",
  154. tmp_run.allocation_group, tmp_run.start, tmp_run.len);
  155. #endif //CONFIG_BEFS_DEBUG
  156. }
  157. #if 0
  158. /* unused */
  159. void
  160. befs_dump_small_data(const struct super_block *sb, befs_small_data * sd)
  161. {
  162. }
  163. /* unused */
  164. void
  165. befs_dump_run(const struct super_block *sb, befs_disk_block_run run)
  166. {
  167. #ifdef CONFIG_BEFS_DEBUG
  168. befs_block_run n = fsrun_to_cpu(sb, run);
  169. befs_debug(sb, "[%u, %hu, %hu]", n.allocation_group, n.start, n.len);
  170. #endif //CONFIG_BEFS_DEBUG
  171. }
  172. #endif /* 0 */
  173. void
  174. befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super * super)
  175. {
  176. #ifdef CONFIG_BEFS_DEBUG
  177. befs_debug(sb, "Btree super structure");
  178. befs_debug(sb, " magic %08x", fs32_to_cpu(sb, super->magic));
  179. befs_debug(sb, " node_size %u", fs32_to_cpu(sb, super->node_size));
  180. befs_debug(sb, " max_depth %08x", fs32_to_cpu(sb, super->max_depth));
  181. befs_debug(sb, " data_type %08x", fs32_to_cpu(sb, super->data_type));
  182. befs_debug(sb, " root_node_pointer %016LX",
  183. fs64_to_cpu(sb, super->root_node_ptr));
  184. befs_debug(sb, " free_node_pointer %016LX",
  185. fs64_to_cpu(sb, super->free_node_ptr));
  186. befs_debug(sb, " maximum size %016LX",
  187. fs64_to_cpu(sb, super->max_size));
  188. #endif //CONFIG_BEFS_DEBUG
  189. }
  190. void
  191. befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead * node)
  192. {
  193. #ifdef CONFIG_BEFS_DEBUG
  194. befs_debug(sb, "Btree node structure");
  195. befs_debug(sb, " left %016LX", fs64_to_cpu(sb, node->left));
  196. befs_debug(sb, " right %016LX", fs64_to_cpu(sb, node->right));
  197. befs_debug(sb, " overflow %016LX", fs64_to_cpu(sb, node->overflow));
  198. befs_debug(sb, " all_key_count %hu",
  199. fs16_to_cpu(sb, node->all_key_count));
  200. befs_debug(sb, " all_key_length %hu",
  201. fs16_to_cpu(sb, node->all_key_length));
  202. #endif //CONFIG_BEFS_DEBUG
  203. }