blob: 85c13392e9e897dae2ee288f301c88c3067e8303 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Fabian Frederickdac52fc2014-04-03 14:50:23 -070013#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#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 Enbergc3259622009-03-24 10:43:50 +020021#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23#endif /* __KERNEL__ */
24
25#include "befs.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Linus Torvalds1da177e2005-04-16 15:20:36 -070027void
28befs_error(const struct super_block *sb, const char *fmt, ...)
29{
Fabian Frederickdac52fc2014-04-03 14:50:23 -070030 struct va_format vaf;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33 va_start(args, fmt);
Fabian Frederickdac52fc2014-04-03 14:50:23 -070034 vaf.fmt = fmt;
35 vaf.va = &args;
36 pr_err("(%s): %pV\n", sb->s_id, &vaf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038}
39
40void
41befs_warning(const struct super_block *sb, const char *fmt, ...)
42{
Fabian Frederickdac52fc2014-04-03 14:50:23 -070043 struct va_format vaf;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
46 va_start(args, fmt);
Fabian Frederickdac52fc2014-04-03 14:50:23 -070047 vaf.fmt = fmt;
48 vaf.va = &args;
49 pr_warn("(%s): %pV\n", sb->s_id, &vaf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -070051}
52
53void
54befs_debug(const struct super_block *sb, const char *fmt, ...)
55{
56#ifdef CONFIG_BEFS_DEBUG
57
Fabian Frederickdac52fc2014-04-03 14:50:23 -070058 struct va_format vaf;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 va_list args;
Fabian Frederickdac52fc2014-04-03 14:50:23 -070060 va_start(args, fmt);
61 vaf.fmt = fmt;
62 vaf.va = &args;
63 pr_debug("(%s): %pV\n", sb->s_id, &vaf);
64 va_end(args);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66#endif //CONFIG_BEFS_DEBUG
67}
68
69void
70befs_dump_inode(const struct super_block *sb, befs_inode * inode)
71{
72#ifdef CONFIG_BEFS_DEBUG
73
74 befs_block_run tmp_run;
75
76 befs_debug(sb, "befs_inode information");
77
78 befs_debug(sb, " magic1 %08x", fs32_to_cpu(sb, inode->magic1));
79
80 tmp_run = fsrun_to_cpu(sb, inode->inode_num);
81 befs_debug(sb, " inode_num %u, %hu, %hu",
82 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
83
84 befs_debug(sb, " uid %u", fs32_to_cpu(sb, inode->uid));
85 befs_debug(sb, " gid %u", fs32_to_cpu(sb, inode->gid));
86 befs_debug(sb, " mode %08x", fs32_to_cpu(sb, inode->mode));
87 befs_debug(sb, " flags %08x", fs32_to_cpu(sb, inode->flags));
Fabian Frederickdac52fc2014-04-03 14:50:23 -070088 befs_debug(sb, " create_time %llu",
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 fs64_to_cpu(sb, inode->create_time));
Fabian Frederickdac52fc2014-04-03 14:50:23 -070090 befs_debug(sb, " last_modified_time %llu",
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 fs64_to_cpu(sb, inode->last_modified_time));
92
93 tmp_run = fsrun_to_cpu(sb, inode->parent);
94 befs_debug(sb, " parent [%u, %hu, %hu]",
95 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
96
97 tmp_run = fsrun_to_cpu(sb, inode->attributes);
98 befs_debug(sb, " attributes [%u, %hu, %hu]",
99 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
100
101 befs_debug(sb, " type %08x", fs32_to_cpu(sb, inode->type));
102 befs_debug(sb, " inode_size %u", fs32_to_cpu(sb, inode->inode_size));
103
Al Viroe5201c52005-12-24 03:09:03 -0500104 if (S_ISLNK(fs32_to_cpu(sb, inode->mode))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 befs_debug(sb, " Symbolic link [%s]", inode->data.symlink);
106 } else {
107 int i;
108
109 for (i = 0; i < BEFS_NUM_DIRECT_BLOCKS; i++) {
110 tmp_run =
111 fsrun_to_cpu(sb, inode->data.datastream.direct[i]);
112 befs_debug(sb, " direct %d [%u, %hu, %hu]", i,
113 tmp_run.allocation_group, tmp_run.start,
114 tmp_run.len);
115 }
Fabian Frederickdac52fc2014-04-03 14:50:23 -0700116 befs_debug(sb, " max_direct_range %llu",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 fs64_to_cpu(sb,
118 inode->data.datastream.
119 max_direct_range));
120
121 tmp_run = fsrun_to_cpu(sb, inode->data.datastream.indirect);
122 befs_debug(sb, " indirect [%u, %hu, %hu]",
123 tmp_run.allocation_group,
124 tmp_run.start, tmp_run.len);
125
Fabian Frederickdac52fc2014-04-03 14:50:23 -0700126 befs_debug(sb, " max_indirect_range %llu",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 fs64_to_cpu(sb,
128 inode->data.datastream.
129 max_indirect_range));
130
131 tmp_run =
132 fsrun_to_cpu(sb, inode->data.datastream.double_indirect);
133 befs_debug(sb, " double indirect [%u, %hu, %hu]",
134 tmp_run.allocation_group, tmp_run.start,
135 tmp_run.len);
136
Fabian Frederickdac52fc2014-04-03 14:50:23 -0700137 befs_debug(sb, " max_double_indirect_range %llu",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 fs64_to_cpu(sb,
139 inode->data.datastream.
140 max_double_indirect_range));
141
Fabian Frederickdac52fc2014-04-03 14:50:23 -0700142 befs_debug(sb, " size %llu",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 fs64_to_cpu(sb, inode->data.datastream.size));
144 }
145
146#endif //CONFIG_BEFS_DEBUG
147}
148
149/*
150 * Display super block structure for debug.
151 */
152
153void
154befs_dump_super_block(const struct super_block *sb, befs_super_block * sup)
155{
156#ifdef CONFIG_BEFS_DEBUG
157
158 befs_block_run tmp_run;
159
160 befs_debug(sb, "befs_super_block information");
161
162 befs_debug(sb, " name %s", sup->name);
163 befs_debug(sb, " magic1 %08x", fs32_to_cpu(sb, sup->magic1));
164 befs_debug(sb, " fs_byte_order %08x",
165 fs32_to_cpu(sb, sup->fs_byte_order));
166
167 befs_debug(sb, " block_size %u", fs32_to_cpu(sb, sup->block_size));
168 befs_debug(sb, " block_shift %u", fs32_to_cpu(sb, sup->block_shift));
169
Fabian Frederickdac52fc2014-04-03 14:50:23 -0700170 befs_debug(sb, " num_blocks %llu", fs64_to_cpu(sb, sup->num_blocks));
171 befs_debug(sb, " used_blocks %llu", fs64_to_cpu(sb, sup->used_blocks));
Luis de Bethencourtd1a8c702016-08-09 22:20:23 +0100172 befs_debug(sb, " inode_size %u", fs32_to_cpu(sb, sup->inode_size));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
174 befs_debug(sb, " magic2 %08x", fs32_to_cpu(sb, sup->magic2));
175 befs_debug(sb, " blocks_per_ag %u",
176 fs32_to_cpu(sb, sup->blocks_per_ag));
177 befs_debug(sb, " ag_shift %u", fs32_to_cpu(sb, sup->ag_shift));
178 befs_debug(sb, " num_ags %u", fs32_to_cpu(sb, sup->num_ags));
179
180 befs_debug(sb, " flags %08x", fs32_to_cpu(sb, sup->flags));
181
182 tmp_run = fsrun_to_cpu(sb, sup->log_blocks);
183 befs_debug(sb, " log_blocks %u, %hu, %hu",
184 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
185
Fabian Frederickdac52fc2014-04-03 14:50:23 -0700186 befs_debug(sb, " log_start %lld", fs64_to_cpu(sb, sup->log_start));
187 befs_debug(sb, " log_end %lld", fs64_to_cpu(sb, sup->log_end));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
189 befs_debug(sb, " magic3 %08x", fs32_to_cpu(sb, sup->magic3));
190
191 tmp_run = fsrun_to_cpu(sb, sup->root_dir);
192 befs_debug(sb, " root_dir %u, %hu, %hu",
193 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
194
195 tmp_run = fsrun_to_cpu(sb, sup->indices);
196 befs_debug(sb, " indices %u, %hu, %hu",
197 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
198
199#endif //CONFIG_BEFS_DEBUG
200}
201
202#if 0
203/* unused */
204void
205befs_dump_small_data(const struct super_block *sb, befs_small_data * sd)
206{
207}
208
209/* unused */
210void
Al Viroa9721f32005-12-24 14:28:55 -0500211befs_dump_run(const struct super_block *sb, befs_disk_block_run run)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212{
213#ifdef CONFIG_BEFS_DEBUG
214
Al Viroa9721f32005-12-24 14:28:55 -0500215 befs_block_run n = fsrun_to_cpu(sb, run);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
Al Viroa9721f32005-12-24 14:28:55 -0500217 befs_debug(sb, "[%u, %hu, %hu]", n.allocation_group, n.start, n.len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
219#endif //CONFIG_BEFS_DEBUG
220}
221#endif /* 0 */
222
223void
Al Viroa9721f32005-12-24 14:28:55 -0500224befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super * super)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225{
226#ifdef CONFIG_BEFS_DEBUG
227
228 befs_debug(sb, "Btree super structure");
229 befs_debug(sb, " magic %08x", fs32_to_cpu(sb, super->magic));
230 befs_debug(sb, " node_size %u", fs32_to_cpu(sb, super->node_size));
231 befs_debug(sb, " max_depth %08x", fs32_to_cpu(sb, super->max_depth));
232
233 befs_debug(sb, " data_type %08x", fs32_to_cpu(sb, super->data_type));
234 befs_debug(sb, " root_node_pointer %016LX",
235 fs64_to_cpu(sb, super->root_node_ptr));
236 befs_debug(sb, " free_node_pointer %016LX",
237 fs64_to_cpu(sb, super->free_node_ptr));
238 befs_debug(sb, " maximum size %016LX",
239 fs64_to_cpu(sb, super->max_size));
240
241#endif //CONFIG_BEFS_DEBUG
242}
243
244void
245befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead * node)
246{
247#ifdef CONFIG_BEFS_DEBUG
248
249 befs_debug(sb, "Btree node structure");
250 befs_debug(sb, " left %016LX", fs64_to_cpu(sb, node->left));
251 befs_debug(sb, " right %016LX", fs64_to_cpu(sb, node->right));
252 befs_debug(sb, " overflow %016LX", fs64_to_cpu(sb, node->overflow));
253 befs_debug(sb, " all_key_count %hu",
254 fs16_to_cpu(sb, node->all_key_count));
255 befs_debug(sb, " all_key_length %hu",
256 fs16_to_cpu(sb, node->all_key_length));
257
258#endif //CONFIG_BEFS_DEBUG
259}