Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/befs/debug.c |
Luis de Bethencourt | a83179a | 2016-08-14 17:26:43 +0100 | [diff] [blame] | 3 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #ifdef __KERNEL__ |
| 15 | |
| 16 | #include <stdarg.h> |
| 17 | #include <linux/string.h> |
| 18 | #include <linux/spinlock.h> |
| 19 | #include <linux/kernel.h> |
| 20 | #include <linux/fs.h> |
Pekka Enberg | c325962 | 2009-03-24 10:43:50 +0200 | [diff] [blame] | 21 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
| 23 | #endif /* __KERNEL__ */ |
| 24 | |
| 25 | #include "befs.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | void |
| 28 | befs_error(const struct super_block *sb, const char *fmt, ...) |
| 29 | { |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 30 | struct va_format vaf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | va_list args; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
| 33 | va_start(args, fmt); |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 34 | vaf.fmt = fmt; |
| 35 | vaf.va = &args; |
| 36 | pr_err("(%s): %pV\n", sb->s_id, &vaf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | va_end(args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | void |
| 41 | befs_warning(const struct super_block *sb, const char *fmt, ...) |
| 42 | { |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 43 | struct va_format vaf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | va_list args; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
| 46 | va_start(args, fmt); |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 47 | vaf.fmt = fmt; |
| 48 | vaf.va = &args; |
| 49 | pr_warn("(%s): %pV\n", sb->s_id, &vaf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | va_end(args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | void |
| 54 | befs_debug(const struct super_block *sb, const char *fmt, ...) |
| 55 | { |
| 56 | #ifdef CONFIG_BEFS_DEBUG |
| 57 | |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 58 | struct va_format vaf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | va_list args; |
Luis de Bethencourt | a83179a | 2016-08-14 17:26:43 +0100 | [diff] [blame] | 60 | |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 61 | va_start(args, fmt); |
| 62 | vaf.fmt = fmt; |
| 63 | vaf.va = &args; |
| 64 | pr_debug("(%s): %pV\n", sb->s_id, &vaf); |
| 65 | va_end(args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
| 67 | #endif //CONFIG_BEFS_DEBUG |
| 68 | } |
| 69 | |
| 70 | void |
Luis de Bethencourt | a83179a | 2016-08-14 17:26:43 +0100 | [diff] [blame] | 71 | befs_dump_inode(const struct super_block *sb, befs_inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | { |
| 73 | #ifdef CONFIG_BEFS_DEBUG |
| 74 | |
| 75 | befs_block_run tmp_run; |
| 76 | |
| 77 | befs_debug(sb, "befs_inode information"); |
| 78 | |
| 79 | befs_debug(sb, " magic1 %08x", fs32_to_cpu(sb, inode->magic1)); |
| 80 | |
| 81 | tmp_run = fsrun_to_cpu(sb, inode->inode_num); |
| 82 | befs_debug(sb, " inode_num %u, %hu, %hu", |
| 83 | tmp_run.allocation_group, tmp_run.start, tmp_run.len); |
| 84 | |
| 85 | befs_debug(sb, " uid %u", fs32_to_cpu(sb, inode->uid)); |
| 86 | befs_debug(sb, " gid %u", fs32_to_cpu(sb, inode->gid)); |
| 87 | befs_debug(sb, " mode %08x", fs32_to_cpu(sb, inode->mode)); |
| 88 | befs_debug(sb, " flags %08x", fs32_to_cpu(sb, inode->flags)); |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 89 | befs_debug(sb, " create_time %llu", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | fs64_to_cpu(sb, inode->create_time)); |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 91 | befs_debug(sb, " last_modified_time %llu", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | fs64_to_cpu(sb, inode->last_modified_time)); |
| 93 | |
| 94 | tmp_run = fsrun_to_cpu(sb, inode->parent); |
| 95 | befs_debug(sb, " parent [%u, %hu, %hu]", |
| 96 | tmp_run.allocation_group, tmp_run.start, tmp_run.len); |
| 97 | |
| 98 | tmp_run = fsrun_to_cpu(sb, inode->attributes); |
| 99 | befs_debug(sb, " attributes [%u, %hu, %hu]", |
| 100 | tmp_run.allocation_group, tmp_run.start, tmp_run.len); |
| 101 | |
| 102 | befs_debug(sb, " type %08x", fs32_to_cpu(sb, inode->type)); |
| 103 | befs_debug(sb, " inode_size %u", fs32_to_cpu(sb, inode->inode_size)); |
| 104 | |
Al Viro | e5201c5 | 2005-12-24 03:09:03 -0500 | [diff] [blame] | 105 | if (S_ISLNK(fs32_to_cpu(sb, inode->mode))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | befs_debug(sb, " Symbolic link [%s]", inode->data.symlink); |
| 107 | } else { |
| 108 | int i; |
| 109 | |
| 110 | for (i = 0; i < BEFS_NUM_DIRECT_BLOCKS; i++) { |
| 111 | tmp_run = |
| 112 | fsrun_to_cpu(sb, inode->data.datastream.direct[i]); |
| 113 | befs_debug(sb, " direct %d [%u, %hu, %hu]", i, |
| 114 | tmp_run.allocation_group, tmp_run.start, |
| 115 | tmp_run.len); |
| 116 | } |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 117 | befs_debug(sb, " max_direct_range %llu", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | fs64_to_cpu(sb, |
| 119 | inode->data.datastream. |
| 120 | max_direct_range)); |
| 121 | |
| 122 | tmp_run = fsrun_to_cpu(sb, inode->data.datastream.indirect); |
| 123 | befs_debug(sb, " indirect [%u, %hu, %hu]", |
| 124 | tmp_run.allocation_group, |
| 125 | tmp_run.start, tmp_run.len); |
| 126 | |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 127 | befs_debug(sb, " max_indirect_range %llu", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | fs64_to_cpu(sb, |
| 129 | inode->data.datastream. |
| 130 | max_indirect_range)); |
| 131 | |
| 132 | tmp_run = |
| 133 | fsrun_to_cpu(sb, inode->data.datastream.double_indirect); |
| 134 | befs_debug(sb, " double indirect [%u, %hu, %hu]", |
| 135 | tmp_run.allocation_group, tmp_run.start, |
| 136 | tmp_run.len); |
| 137 | |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 138 | befs_debug(sb, " max_double_indirect_range %llu", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | fs64_to_cpu(sb, |
| 140 | inode->data.datastream. |
| 141 | max_double_indirect_range)); |
| 142 | |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 143 | befs_debug(sb, " size %llu", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | fs64_to_cpu(sb, inode->data.datastream.size)); |
| 145 | } |
| 146 | |
| 147 | #endif //CONFIG_BEFS_DEBUG |
| 148 | } |
| 149 | |
| 150 | /* |
| 151 | * Display super block structure for debug. |
| 152 | */ |
| 153 | |
| 154 | void |
Luis de Bethencourt | a83179a | 2016-08-14 17:26:43 +0100 | [diff] [blame] | 155 | befs_dump_super_block(const struct super_block *sb, befs_super_block *sup) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | { |
| 157 | #ifdef CONFIG_BEFS_DEBUG |
| 158 | |
| 159 | befs_block_run tmp_run; |
| 160 | |
| 161 | befs_debug(sb, "befs_super_block information"); |
| 162 | |
| 163 | befs_debug(sb, " name %s", sup->name); |
| 164 | befs_debug(sb, " magic1 %08x", fs32_to_cpu(sb, sup->magic1)); |
| 165 | befs_debug(sb, " fs_byte_order %08x", |
| 166 | fs32_to_cpu(sb, sup->fs_byte_order)); |
| 167 | |
| 168 | befs_debug(sb, " block_size %u", fs32_to_cpu(sb, sup->block_size)); |
| 169 | befs_debug(sb, " block_shift %u", fs32_to_cpu(sb, sup->block_shift)); |
| 170 | |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 171 | befs_debug(sb, " num_blocks %llu", fs64_to_cpu(sb, sup->num_blocks)); |
| 172 | befs_debug(sb, " used_blocks %llu", fs64_to_cpu(sb, sup->used_blocks)); |
Luis de Bethencourt | d1a8c70 | 2016-08-09 22:20:23 +0100 | [diff] [blame] | 173 | befs_debug(sb, " inode_size %u", fs32_to_cpu(sb, sup->inode_size)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
| 175 | befs_debug(sb, " magic2 %08x", fs32_to_cpu(sb, sup->magic2)); |
| 176 | befs_debug(sb, " blocks_per_ag %u", |
| 177 | fs32_to_cpu(sb, sup->blocks_per_ag)); |
| 178 | befs_debug(sb, " ag_shift %u", fs32_to_cpu(sb, sup->ag_shift)); |
| 179 | befs_debug(sb, " num_ags %u", fs32_to_cpu(sb, sup->num_ags)); |
| 180 | |
| 181 | befs_debug(sb, " flags %08x", fs32_to_cpu(sb, sup->flags)); |
| 182 | |
| 183 | tmp_run = fsrun_to_cpu(sb, sup->log_blocks); |
| 184 | befs_debug(sb, " log_blocks %u, %hu, %hu", |
| 185 | tmp_run.allocation_group, tmp_run.start, tmp_run.len); |
| 186 | |
Fabian Frederick | dac52fc | 2014-04-03 14:50:23 -0700 | [diff] [blame] | 187 | befs_debug(sb, " log_start %lld", fs64_to_cpu(sb, sup->log_start)); |
| 188 | befs_debug(sb, " log_end %lld", fs64_to_cpu(sb, sup->log_end)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | |
| 190 | befs_debug(sb, " magic3 %08x", fs32_to_cpu(sb, sup->magic3)); |
| 191 | |
| 192 | tmp_run = fsrun_to_cpu(sb, sup->root_dir); |
| 193 | befs_debug(sb, " root_dir %u, %hu, %hu", |
| 194 | tmp_run.allocation_group, tmp_run.start, tmp_run.len); |
| 195 | |
| 196 | tmp_run = fsrun_to_cpu(sb, sup->indices); |
| 197 | befs_debug(sb, " indices %u, %hu, %hu", |
| 198 | tmp_run.allocation_group, tmp_run.start, tmp_run.len); |
| 199 | |
| 200 | #endif //CONFIG_BEFS_DEBUG |
| 201 | } |
| 202 | |
| 203 | #if 0 |
| 204 | /* unused */ |
| 205 | void |
Luis de Bethencourt | a83179a | 2016-08-14 17:26:43 +0100 | [diff] [blame] | 206 | befs_dump_small_data(const struct super_block *sb, befs_small_data *sd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | { |
| 208 | } |
| 209 | |
| 210 | /* unused */ |
| 211 | void |
Al Viro | a9721f3 | 2005-12-24 14:28:55 -0500 | [diff] [blame] | 212 | befs_dump_run(const struct super_block *sb, befs_disk_block_run run) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | { |
| 214 | #ifdef CONFIG_BEFS_DEBUG |
| 215 | |
Al Viro | a9721f3 | 2005-12-24 14:28:55 -0500 | [diff] [blame] | 216 | befs_block_run n = fsrun_to_cpu(sb, run); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
Al Viro | a9721f3 | 2005-12-24 14:28:55 -0500 | [diff] [blame] | 218 | befs_debug(sb, "[%u, %hu, %hu]", n.allocation_group, n.start, n.len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | |
| 220 | #endif //CONFIG_BEFS_DEBUG |
| 221 | } |
| 222 | #endif /* 0 */ |
| 223 | |
| 224 | void |
Luis de Bethencourt | a83179a | 2016-08-14 17:26:43 +0100 | [diff] [blame] | 225 | befs_dump_index_entry(const struct super_block *sb, |
| 226 | befs_disk_btree_super *super) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | { |
| 228 | #ifdef CONFIG_BEFS_DEBUG |
| 229 | |
| 230 | befs_debug(sb, "Btree super structure"); |
| 231 | befs_debug(sb, " magic %08x", fs32_to_cpu(sb, super->magic)); |
| 232 | befs_debug(sb, " node_size %u", fs32_to_cpu(sb, super->node_size)); |
| 233 | befs_debug(sb, " max_depth %08x", fs32_to_cpu(sb, super->max_depth)); |
| 234 | |
| 235 | befs_debug(sb, " data_type %08x", fs32_to_cpu(sb, super->data_type)); |
| 236 | befs_debug(sb, " root_node_pointer %016LX", |
| 237 | fs64_to_cpu(sb, super->root_node_ptr)); |
| 238 | befs_debug(sb, " free_node_pointer %016LX", |
| 239 | fs64_to_cpu(sb, super->free_node_ptr)); |
| 240 | befs_debug(sb, " maximum size %016LX", |
| 241 | fs64_to_cpu(sb, super->max_size)); |
| 242 | |
| 243 | #endif //CONFIG_BEFS_DEBUG |
| 244 | } |
| 245 | |
| 246 | void |
Luis de Bethencourt | a83179a | 2016-08-14 17:26:43 +0100 | [diff] [blame] | 247 | befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *node) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | { |
| 249 | #ifdef CONFIG_BEFS_DEBUG |
| 250 | |
| 251 | befs_debug(sb, "Btree node structure"); |
| 252 | befs_debug(sb, " left %016LX", fs64_to_cpu(sb, node->left)); |
| 253 | befs_debug(sb, " right %016LX", fs64_to_cpu(sb, node->right)); |
| 254 | befs_debug(sb, " overflow %016LX", fs64_to_cpu(sb, node->overflow)); |
| 255 | befs_debug(sb, " all_key_count %hu", |
| 256 | fs16_to_cpu(sb, node->all_key_count)); |
| 257 | befs_debug(sb, " all_key_length %hu", |
| 258 | fs16_to_cpu(sb, node->all_key_length)); |
| 259 | |
| 260 | #endif //CONFIG_BEFS_DEBUG |
| 261 | } |