Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / fs / befs / debug.c
blob875cc0aa318c9c803ee70bd0fe64532fb80dedfa
1 /*
2 * linux/fs/befs/debug.c
3 *
4 * Copyright (C) 2001 Will Dyson (will_dyson at pobox.com)
6 * With help from the ntfs-tng driver by Anton Altparmakov
8 * Copyright (C) 1999 Makoto Kato (m_kato@ga2.so-net.ne.jp)
10 * debug functions
13 #ifdef __KERNEL__
15 #include <stdarg.h>
16 #include <linux/string.h>
17 #include <linux/spinlock.h>
18 #include <linux/kernel.h>
19 #include <linux/fs.h>
21 #endif /* __KERNEL__ */
23 #include "befs.h"
24 #include "endian.h"
26 #define ERRBUFSIZE 1024
28 void
29 befs_error(const struct super_block *sb, const char *fmt, ...)
31 va_list args;
32 char *err_buf = (char *) kmalloc(ERRBUFSIZE, GFP_KERNEL);
33 if (err_buf == NULL) {
34 printk(KERN_ERR "could not allocate %d bytes\n", ERRBUFSIZE);
35 return;
38 va_start(args, fmt);
39 vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
40 va_end(args);
42 printk(KERN_ERR "BeFS(%s): %s\n", sb->s_id, err_buf);
43 kfree(err_buf);
46 void
47 befs_warning(const struct super_block *sb, const char *fmt, ...)
49 va_list args;
50 char *err_buf = (char *) kmalloc(ERRBUFSIZE, GFP_KERNEL);
51 if (err_buf == NULL) {
52 printk(KERN_ERR "could not allocate %d bytes\n", ERRBUFSIZE);
53 return;
56 va_start(args, fmt);
57 vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
58 va_end(args);
60 printk(KERN_WARNING "BeFS(%s): %s\n", sb->s_id, err_buf);
62 kfree(err_buf);
65 void
66 befs_debug(const struct super_block *sb, const char *fmt, ...)
68 #ifdef CONFIG_BEFS_DEBUG
70 va_list args;
71 char *err_buf = NULL;
73 if (BEFS_SB(sb)->mount_opts.debug) {
74 err_buf = (char *) kmalloc(ERRBUFSIZE, GFP_KERNEL);
75 if (err_buf == NULL) {
76 printk(KERN_ERR "could not allocate %d bytes\n",
77 ERRBUFSIZE);
78 return;
81 va_start(args, fmt);
82 vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
83 va_end(args);
85 printk(KERN_DEBUG "BeFS(%s): %s\n", sb->s_id, err_buf);
87 kfree(err_buf);
90 #endif //CONFIG_BEFS_DEBUG
93 void
94 befs_dump_inode(const struct super_block *sb, befs_inode * inode)
96 #ifdef CONFIG_BEFS_DEBUG
98 befs_block_run tmp_run;
100 befs_debug(sb, "befs_inode information");
102 befs_debug(sb, " magic1 %08x", fs32_to_cpu(sb, inode->magic1));
104 tmp_run = fsrun_to_cpu(sb, inode->inode_num);
105 befs_debug(sb, " inode_num %u, %hu, %hu",
106 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
108 befs_debug(sb, " uid %u", fs32_to_cpu(sb, inode->uid));
109 befs_debug(sb, " gid %u", fs32_to_cpu(sb, inode->gid));
110 befs_debug(sb, " mode %08x", fs32_to_cpu(sb, inode->mode));
111 befs_debug(sb, " flags %08x", fs32_to_cpu(sb, inode->flags));
112 befs_debug(sb, " create_time %Lu",
113 fs64_to_cpu(sb, inode->create_time));
114 befs_debug(sb, " last_modified_time %Lu",
115 fs64_to_cpu(sb, inode->last_modified_time));
117 tmp_run = fsrun_to_cpu(sb, inode->parent);
118 befs_debug(sb, " parent [%u, %hu, %hu]",
119 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
121 tmp_run = fsrun_to_cpu(sb, inode->attributes);
122 befs_debug(sb, " attributes [%u, %hu, %hu]",
123 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
125 befs_debug(sb, " type %08x", fs32_to_cpu(sb, inode->type));
126 befs_debug(sb, " inode_size %u", fs32_to_cpu(sb, inode->inode_size));
128 if (S_ISLNK(inode->mode)) {
129 befs_debug(sb, " Symbolic link [%s]", inode->data.symlink);
130 } else {
131 int i;
133 for (i = 0; i < BEFS_NUM_DIRECT_BLOCKS; i++) {
134 tmp_run =
135 fsrun_to_cpu(sb, inode->data.datastream.direct[i]);
136 befs_debug(sb, " direct %d [%u, %hu, %hu]", i,
137 tmp_run.allocation_group, tmp_run.start,
138 tmp_run.len);
140 befs_debug(sb, " max_direct_range %Lu",
141 fs64_to_cpu(sb,
142 inode->data.datastream.
143 max_direct_range));
145 tmp_run = fsrun_to_cpu(sb, inode->data.datastream.indirect);
146 befs_debug(sb, " indirect [%u, %hu, %hu]",
147 tmp_run.allocation_group,
148 tmp_run.start, tmp_run.len);
150 befs_debug(sb, " max_indirect_range %Lu",
151 fs64_to_cpu(sb,
152 inode->data.datastream.
153 max_indirect_range));
155 tmp_run =
156 fsrun_to_cpu(sb, inode->data.datastream.double_indirect);
157 befs_debug(sb, " double indirect [%u, %hu, %hu]",
158 tmp_run.allocation_group, tmp_run.start,
159 tmp_run.len);
161 befs_debug(sb, " max_double_indirect_range %Lu",
162 fs64_to_cpu(sb,
163 inode->data.datastream.
164 max_double_indirect_range));
166 befs_debug(sb, " size %Lu",
167 fs64_to_cpu(sb, inode->data.datastream.size));
170 #endif //CONFIG_BEFS_DEBUG
174 * Display super block structure for debug.
177 void
178 befs_dump_super_block(const struct super_block *sb, befs_super_block * sup)
180 #ifdef CONFIG_BEFS_DEBUG
182 befs_block_run tmp_run;
184 befs_debug(sb, "befs_super_block information");
186 befs_debug(sb, " name %s", sup->name);
187 befs_debug(sb, " magic1 %08x", fs32_to_cpu(sb, sup->magic1));
188 befs_debug(sb, " fs_byte_order %08x",
189 fs32_to_cpu(sb, sup->fs_byte_order));
191 befs_debug(sb, " block_size %u", fs32_to_cpu(sb, sup->block_size));
192 befs_debug(sb, " block_shift %u", fs32_to_cpu(sb, sup->block_shift));
194 befs_debug(sb, " num_blocks %Lu", fs64_to_cpu(sb, sup->num_blocks));
195 befs_debug(sb, " used_blocks %Lu", fs64_to_cpu(sb, sup->used_blocks));
197 befs_debug(sb, " magic2 %08x", fs32_to_cpu(sb, sup->magic2));
198 befs_debug(sb, " blocks_per_ag %u",
199 fs32_to_cpu(sb, sup->blocks_per_ag));
200 befs_debug(sb, " ag_shift %u", fs32_to_cpu(sb, sup->ag_shift));
201 befs_debug(sb, " num_ags %u", fs32_to_cpu(sb, sup->num_ags));
203 befs_debug(sb, " flags %08x", fs32_to_cpu(sb, sup->flags));
205 tmp_run = fsrun_to_cpu(sb, sup->log_blocks);
206 befs_debug(sb, " log_blocks %u, %hu, %hu",
207 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
209 befs_debug(sb, " log_start %Ld", fs64_to_cpu(sb, sup->log_start));
210 befs_debug(sb, " log_end %Ld", fs64_to_cpu(sb, sup->log_end));
212 befs_debug(sb, " magic3 %08x", fs32_to_cpu(sb, sup->magic3));
214 tmp_run = fsrun_to_cpu(sb, sup->root_dir);
215 befs_debug(sb, " root_dir %u, %hu, %hu",
216 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
218 tmp_run = fsrun_to_cpu(sb, sup->indices);
219 befs_debug(sb, " indices %u, %hu, %hu",
220 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
222 #endif //CONFIG_BEFS_DEBUG
225 #if 0
226 /* unused */
227 void
228 befs_dump_small_data(const struct super_block *sb, befs_small_data * sd)
232 /* unused */
233 void
234 befs_dump_run(const struct super_block *sb, befs_block_run run)
236 #ifdef CONFIG_BEFS_DEBUG
238 run = fsrun_to_cpu(sb, run);
240 befs_debug(sb, "[%u, %hu, %hu]",
241 run.allocation_group, run.start, run.len);
243 #endif //CONFIG_BEFS_DEBUG
245 #endif /* 0 */
247 void
248 befs_dump_index_entry(const struct super_block *sb, befs_btree_super * super)
250 #ifdef CONFIG_BEFS_DEBUG
252 befs_debug(sb, "Btree super structure");
253 befs_debug(sb, " magic %08x", fs32_to_cpu(sb, super->magic));
254 befs_debug(sb, " node_size %u", fs32_to_cpu(sb, super->node_size));
255 befs_debug(sb, " max_depth %08x", fs32_to_cpu(sb, super->max_depth));
257 befs_debug(sb, " data_type %08x", fs32_to_cpu(sb, super->data_type));
258 befs_debug(sb, " root_node_pointer %016LX",
259 fs64_to_cpu(sb, super->root_node_ptr));
260 befs_debug(sb, " free_node_pointer %016LX",
261 fs64_to_cpu(sb, super->free_node_ptr));
262 befs_debug(sb, " maximum size %016LX",
263 fs64_to_cpu(sb, super->max_size));
265 #endif //CONFIG_BEFS_DEBUG
268 void
269 befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead * node)
271 #ifdef CONFIG_BEFS_DEBUG
273 befs_debug(sb, "Btree node structure");
274 befs_debug(sb, " left %016LX", fs64_to_cpu(sb, node->left));
275 befs_debug(sb, " right %016LX", fs64_to_cpu(sb, node->right));
276 befs_debug(sb, " overflow %016LX", fs64_to_cpu(sb, node->overflow));
277 befs_debug(sb, " all_key_count %hu",
278 fs16_to_cpu(sb, node->all_key_count));
279 befs_debug(sb, " all_key_length %hu",
280 fs16_to_cpu(sb, node->all_key_length));
282 #endif //CONFIG_BEFS_DEBUG