0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
0015 #ifdef __KERNEL__
0016
0017 #include <linux/stdarg.h>
0018 #include <linux/string.h>
0019 #include <linux/spinlock.h>
0020 #include <linux/kernel.h>
0021 #include <linux/fs.h>
0022 #include <linux/slab.h>
0023
0024 #endif
0025
0026 #include "befs.h"
0027
0028 void
0029 befs_error(const struct super_block *sb, const char *fmt, ...)
0030 {
0031 struct va_format vaf;
0032 va_list args;
0033
0034 va_start(args, fmt);
0035 vaf.fmt = fmt;
0036 vaf.va = &args;
0037 pr_err("(%s): %pV\n", sb->s_id, &vaf);
0038 va_end(args);
0039 }
0040
0041 void
0042 befs_warning(const struct super_block *sb, const char *fmt, ...)
0043 {
0044 struct va_format vaf;
0045 va_list args;
0046
0047 va_start(args, fmt);
0048 vaf.fmt = fmt;
0049 vaf.va = &args;
0050 pr_warn("(%s): %pV\n", sb->s_id, &vaf);
0051 va_end(args);
0052 }
0053
0054 void
0055 befs_debug(const struct super_block *sb, const char *fmt, ...)
0056 {
0057 #ifdef CONFIG_BEFS_DEBUG
0058
0059 struct va_format vaf;
0060 va_list args;
0061
0062 va_start(args, fmt);
0063 vaf.fmt = fmt;
0064 vaf.va = &args;
0065 pr_debug("(%s): %pV\n", sb->s_id, &vaf);
0066 va_end(args);
0067
0068 #endif
0069 }
0070
0071 void
0072 befs_dump_inode(const struct super_block *sb, befs_inode *inode)
0073 {
0074 #ifdef CONFIG_BEFS_DEBUG
0075
0076 befs_block_run tmp_run;
0077
0078 befs_debug(sb, "befs_inode information");
0079
0080 befs_debug(sb, " magic1 %08x", fs32_to_cpu(sb, inode->magic1));
0081
0082 tmp_run = fsrun_to_cpu(sb, inode->inode_num);
0083 befs_debug(sb, " inode_num %u, %hu, %hu",
0084 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
0085
0086 befs_debug(sb, " uid %u", fs32_to_cpu(sb, inode->uid));
0087 befs_debug(sb, " gid %u", fs32_to_cpu(sb, inode->gid));
0088 befs_debug(sb, " mode %08x", fs32_to_cpu(sb, inode->mode));
0089 befs_debug(sb, " flags %08x", fs32_to_cpu(sb, inode->flags));
0090 befs_debug(sb, " create_time %llu",
0091 fs64_to_cpu(sb, inode->create_time));
0092 befs_debug(sb, " last_modified_time %llu",
0093 fs64_to_cpu(sb, inode->last_modified_time));
0094
0095 tmp_run = fsrun_to_cpu(sb, inode->parent);
0096 befs_debug(sb, " parent [%u, %hu, %hu]",
0097 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
0098
0099 tmp_run = fsrun_to_cpu(sb, inode->attributes);
0100 befs_debug(sb, " attributes [%u, %hu, %hu]",
0101 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
0102
0103 befs_debug(sb, " type %08x", fs32_to_cpu(sb, inode->type));
0104 befs_debug(sb, " inode_size %u", fs32_to_cpu(sb, inode->inode_size));
0105
0106 if (S_ISLNK(fs32_to_cpu(sb, inode->mode))) {
0107 befs_debug(sb, " Symbolic link [%s]", inode->data.symlink);
0108 } else {
0109 int i;
0110
0111 for (i = 0; i < BEFS_NUM_DIRECT_BLOCKS; i++) {
0112 tmp_run =
0113 fsrun_to_cpu(sb, inode->data.datastream.direct[i]);
0114 befs_debug(sb, " direct %d [%u, %hu, %hu]", i,
0115 tmp_run.allocation_group, tmp_run.start,
0116 tmp_run.len);
0117 }
0118 befs_debug(sb, " max_direct_range %llu",
0119 fs64_to_cpu(sb,
0120 inode->data.datastream.
0121 max_direct_range));
0122
0123 tmp_run = fsrun_to_cpu(sb, inode->data.datastream.indirect);
0124 befs_debug(sb, " indirect [%u, %hu, %hu]",
0125 tmp_run.allocation_group,
0126 tmp_run.start, tmp_run.len);
0127
0128 befs_debug(sb, " max_indirect_range %llu",
0129 fs64_to_cpu(sb,
0130 inode->data.datastream.
0131 max_indirect_range));
0132
0133 tmp_run =
0134 fsrun_to_cpu(sb, inode->data.datastream.double_indirect);
0135 befs_debug(sb, " double indirect [%u, %hu, %hu]",
0136 tmp_run.allocation_group, tmp_run.start,
0137 tmp_run.len);
0138
0139 befs_debug(sb, " max_double_indirect_range %llu",
0140 fs64_to_cpu(sb,
0141 inode->data.datastream.
0142 max_double_indirect_range));
0143
0144 befs_debug(sb, " size %llu",
0145 fs64_to_cpu(sb, inode->data.datastream.size));
0146 }
0147
0148 #endif
0149 }
0150
0151
0152
0153
0154
0155 void
0156 befs_dump_super_block(const struct super_block *sb, befs_super_block *sup)
0157 {
0158 #ifdef CONFIG_BEFS_DEBUG
0159
0160 befs_block_run tmp_run;
0161
0162 befs_debug(sb, "befs_super_block information");
0163
0164 befs_debug(sb, " name %s", sup->name);
0165 befs_debug(sb, " magic1 %08x", fs32_to_cpu(sb, sup->magic1));
0166 befs_debug(sb, " fs_byte_order %08x",
0167 fs32_to_cpu(sb, sup->fs_byte_order));
0168
0169 befs_debug(sb, " block_size %u", fs32_to_cpu(sb, sup->block_size));
0170 befs_debug(sb, " block_shift %u", fs32_to_cpu(sb, sup->block_shift));
0171
0172 befs_debug(sb, " num_blocks %llu", fs64_to_cpu(sb, sup->num_blocks));
0173 befs_debug(sb, " used_blocks %llu", fs64_to_cpu(sb, sup->used_blocks));
0174 befs_debug(sb, " inode_size %u", fs32_to_cpu(sb, sup->inode_size));
0175
0176 befs_debug(sb, " magic2 %08x", fs32_to_cpu(sb, sup->magic2));
0177 befs_debug(sb, " blocks_per_ag %u",
0178 fs32_to_cpu(sb, sup->blocks_per_ag));
0179 befs_debug(sb, " ag_shift %u", fs32_to_cpu(sb, sup->ag_shift));
0180 befs_debug(sb, " num_ags %u", fs32_to_cpu(sb, sup->num_ags));
0181
0182 befs_debug(sb, " flags %08x", fs32_to_cpu(sb, sup->flags));
0183
0184 tmp_run = fsrun_to_cpu(sb, sup->log_blocks);
0185 befs_debug(sb, " log_blocks %u, %hu, %hu",
0186 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
0187
0188 befs_debug(sb, " log_start %lld", fs64_to_cpu(sb, sup->log_start));
0189 befs_debug(sb, " log_end %lld", fs64_to_cpu(sb, sup->log_end));
0190
0191 befs_debug(sb, " magic3 %08x", fs32_to_cpu(sb, sup->magic3));
0192
0193 tmp_run = fsrun_to_cpu(sb, sup->root_dir);
0194 befs_debug(sb, " root_dir %u, %hu, %hu",
0195 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
0196
0197 tmp_run = fsrun_to_cpu(sb, sup->indices);
0198 befs_debug(sb, " indices %u, %hu, %hu",
0199 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
0200
0201 #endif
0202 }
0203
0204 #if 0
0205
0206 void
0207 befs_dump_small_data(const struct super_block *sb, befs_small_data *sd)
0208 {
0209 }
0210
0211
0212 void
0213 befs_dump_run(const struct super_block *sb, befs_disk_block_run run)
0214 {
0215 #ifdef CONFIG_BEFS_DEBUG
0216
0217 befs_block_run n = fsrun_to_cpu(sb, run);
0218
0219 befs_debug(sb, "[%u, %hu, %hu]", n.allocation_group, n.start, n.len);
0220
0221 #endif
0222 }
0223 #endif
0224
0225 void
0226 befs_dump_index_entry(const struct super_block *sb,
0227 befs_disk_btree_super *super)
0228 {
0229 #ifdef CONFIG_BEFS_DEBUG
0230
0231 befs_debug(sb, "Btree super structure");
0232 befs_debug(sb, " magic %08x", fs32_to_cpu(sb, super->magic));
0233 befs_debug(sb, " node_size %u", fs32_to_cpu(sb, super->node_size));
0234 befs_debug(sb, " max_depth %08x", fs32_to_cpu(sb, super->max_depth));
0235
0236 befs_debug(sb, " data_type %08x", fs32_to_cpu(sb, super->data_type));
0237 befs_debug(sb, " root_node_pointer %016LX",
0238 fs64_to_cpu(sb, super->root_node_ptr));
0239 befs_debug(sb, " free_node_pointer %016LX",
0240 fs64_to_cpu(sb, super->free_node_ptr));
0241 befs_debug(sb, " maximum size %016LX",
0242 fs64_to_cpu(sb, super->max_size));
0243
0244 #endif
0245 }
0246
0247 void
0248 befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *node)
0249 {
0250 #ifdef CONFIG_BEFS_DEBUG
0251
0252 befs_debug(sb, "Btree node structure");
0253 befs_debug(sb, " left %016LX", fs64_to_cpu(sb, node->left));
0254 befs_debug(sb, " right %016LX", fs64_to_cpu(sb, node->right));
0255 befs_debug(sb, " overflow %016LX", fs64_to_cpu(sb, node->overflow));
0256 befs_debug(sb, " all_key_count %hu",
0257 fs16_to_cpu(sb, node->all_key_count));
0258 befs_debug(sb, " all_key_length %hu",
0259 fs16_to_cpu(sb, node->all_key_length));
0260
0261 #endif
0262 }