[GFS2] Get rid of useless "found" variable in quota.c
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / fs / befs / debug.c
blobb8e304a0661e473ba7b44ca74ceebd3e8f228c52
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"
25 #define ERRBUFSIZE 1024
27 void
28 befs_error(const struct super_block *sb, const char *fmt, ...)
30 va_list args;
31 char *err_buf = kmalloc(ERRBUFSIZE, GFP_KERNEL);
32 if (err_buf == NULL) {
33 printk(KERN_ERR "could not allocate %d bytes\n", ERRBUFSIZE);
34 return;
37 va_start(args, fmt);
38 vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
39 va_end(args);
41 printk(KERN_ERR "BeFS(%s): %s\n", sb->s_id, err_buf);
42 kfree(err_buf);
45 void
46 befs_warning(const struct super_block *sb, const char *fmt, ...)
48 va_list args;
49 char *err_buf = kmalloc(ERRBUFSIZE, GFP_KERNEL);
50 if (err_buf == NULL) {
51 printk(KERN_ERR "could not allocate %d bytes\n", ERRBUFSIZE);
52 return;
55 va_start(args, fmt);
56 vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
57 va_end(args);
59 printk(KERN_WARNING "BeFS(%s): %s\n", sb->s_id, err_buf);
61 kfree(err_buf);
64 void
65 befs_debug(const struct super_block *sb, const char *fmt, ...)
67 #ifdef CONFIG_BEFS_DEBUG
69 va_list args;
70 char *err_buf = NULL;
72 if (BEFS_SB(sb)->mount_opts.debug) {
73 err_buf = kmalloc(ERRBUFSIZE, GFP_KERNEL);
74 if (err_buf == NULL) {
75 printk(KERN_ERR "could not allocate %d bytes\n",
76 ERRBUFSIZE);
77 return;
80 va_start(args, fmt);
81 vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
82 va_end(args);
84 printk(KERN_DEBUG "BeFS(%s): %s\n", sb->s_id, err_buf);
86 kfree(err_buf);
89 #endif //CONFIG_BEFS_DEBUG
92 void
93 befs_dump_inode(const struct super_block *sb, befs_inode * inode)
95 #ifdef CONFIG_BEFS_DEBUG
97 befs_block_run tmp_run;
99 befs_debug(sb, "befs_inode information");
101 befs_debug(sb, " magic1 %08x", fs32_to_cpu(sb, inode->magic1));
103 tmp_run = fsrun_to_cpu(sb, inode->inode_num);
104 befs_debug(sb, " inode_num %u, %hu, %hu",
105 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
107 befs_debug(sb, " uid %u", fs32_to_cpu(sb, inode->uid));
108 befs_debug(sb, " gid %u", fs32_to_cpu(sb, inode->gid));
109 befs_debug(sb, " mode %08x", fs32_to_cpu(sb, inode->mode));
110 befs_debug(sb, " flags %08x", fs32_to_cpu(sb, inode->flags));
111 befs_debug(sb, " create_time %Lu",
112 fs64_to_cpu(sb, inode->create_time));
113 befs_debug(sb, " last_modified_time %Lu",
114 fs64_to_cpu(sb, inode->last_modified_time));
116 tmp_run = fsrun_to_cpu(sb, inode->parent);
117 befs_debug(sb, " parent [%u, %hu, %hu]",
118 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
120 tmp_run = fsrun_to_cpu(sb, inode->attributes);
121 befs_debug(sb, " attributes [%u, %hu, %hu]",
122 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
124 befs_debug(sb, " type %08x", fs32_to_cpu(sb, inode->type));
125 befs_debug(sb, " inode_size %u", fs32_to_cpu(sb, inode->inode_size));
127 if (S_ISLNK(fs32_to_cpu(sb, inode->mode))) {
128 befs_debug(sb, " Symbolic link [%s]", inode->data.symlink);
129 } else {
130 int i;
132 for (i = 0; i < BEFS_NUM_DIRECT_BLOCKS; i++) {
133 tmp_run =
134 fsrun_to_cpu(sb, inode->data.datastream.direct[i]);
135 befs_debug(sb, " direct %d [%u, %hu, %hu]", i,
136 tmp_run.allocation_group, tmp_run.start,
137 tmp_run.len);
139 befs_debug(sb, " max_direct_range %Lu",
140 fs64_to_cpu(sb,
141 inode->data.datastream.
142 max_direct_range));
144 tmp_run = fsrun_to_cpu(sb, inode->data.datastream.indirect);
145 befs_debug(sb, " indirect [%u, %hu, %hu]",
146 tmp_run.allocation_group,
147 tmp_run.start, tmp_run.len);
149 befs_debug(sb, " max_indirect_range %Lu",
150 fs64_to_cpu(sb,
151 inode->data.datastream.
152 max_indirect_range));
154 tmp_run =
155 fsrun_to_cpu(sb, inode->data.datastream.double_indirect);
156 befs_debug(sb, " double indirect [%u, %hu, %hu]",
157 tmp_run.allocation_group, tmp_run.start,
158 tmp_run.len);
160 befs_debug(sb, " max_double_indirect_range %Lu",
161 fs64_to_cpu(sb,
162 inode->data.datastream.
163 max_double_indirect_range));
165 befs_debug(sb, " size %Lu",
166 fs64_to_cpu(sb, inode->data.datastream.size));
169 #endif //CONFIG_BEFS_DEBUG
173 * Display super block structure for debug.
176 void
177 befs_dump_super_block(const struct super_block *sb, befs_super_block * sup)
179 #ifdef CONFIG_BEFS_DEBUG
181 befs_block_run tmp_run;
183 befs_debug(sb, "befs_super_block information");
185 befs_debug(sb, " name %s", sup->name);
186 befs_debug(sb, " magic1 %08x", fs32_to_cpu(sb, sup->magic1));
187 befs_debug(sb, " fs_byte_order %08x",
188 fs32_to_cpu(sb, sup->fs_byte_order));
190 befs_debug(sb, " block_size %u", fs32_to_cpu(sb, sup->block_size));
191 befs_debug(sb, " block_shift %u", fs32_to_cpu(sb, sup->block_shift));
193 befs_debug(sb, " num_blocks %Lu", fs64_to_cpu(sb, sup->num_blocks));
194 befs_debug(sb, " used_blocks %Lu", fs64_to_cpu(sb, sup->used_blocks));
196 befs_debug(sb, " magic2 %08x", fs32_to_cpu(sb, sup->magic2));
197 befs_debug(sb, " blocks_per_ag %u",
198 fs32_to_cpu(sb, sup->blocks_per_ag));
199 befs_debug(sb, " ag_shift %u", fs32_to_cpu(sb, sup->ag_shift));
200 befs_debug(sb, " num_ags %u", fs32_to_cpu(sb, sup->num_ags));
202 befs_debug(sb, " flags %08x", fs32_to_cpu(sb, sup->flags));
204 tmp_run = fsrun_to_cpu(sb, sup->log_blocks);
205 befs_debug(sb, " log_blocks %u, %hu, %hu",
206 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
208 befs_debug(sb, " log_start %Ld", fs64_to_cpu(sb, sup->log_start));
209 befs_debug(sb, " log_end %Ld", fs64_to_cpu(sb, sup->log_end));
211 befs_debug(sb, " magic3 %08x", fs32_to_cpu(sb, sup->magic3));
213 tmp_run = fsrun_to_cpu(sb, sup->root_dir);
214 befs_debug(sb, " root_dir %u, %hu, %hu",
215 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
217 tmp_run = fsrun_to_cpu(sb, sup->indices);
218 befs_debug(sb, " indices %u, %hu, %hu",
219 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
221 #endif //CONFIG_BEFS_DEBUG
224 #if 0
225 /* unused */
226 void
227 befs_dump_small_data(const struct super_block *sb, befs_small_data * sd)
231 /* unused */
232 void
233 befs_dump_run(const struct super_block *sb, befs_disk_block_run run)
235 #ifdef CONFIG_BEFS_DEBUG
237 befs_block_run n = fsrun_to_cpu(sb, run);
239 befs_debug(sb, "[%u, %hu, %hu]", n.allocation_group, n.start, n.len);
241 #endif //CONFIG_BEFS_DEBUG
243 #endif /* 0 */
245 void
246 befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super * super)
248 #ifdef CONFIG_BEFS_DEBUG
250 befs_debug(sb, "Btree super structure");
251 befs_debug(sb, " magic %08x", fs32_to_cpu(sb, super->magic));
252 befs_debug(sb, " node_size %u", fs32_to_cpu(sb, super->node_size));
253 befs_debug(sb, " max_depth %08x", fs32_to_cpu(sb, super->max_depth));
255 befs_debug(sb, " data_type %08x", fs32_to_cpu(sb, super->data_type));
256 befs_debug(sb, " root_node_pointer %016LX",
257 fs64_to_cpu(sb, super->root_node_ptr));
258 befs_debug(sb, " free_node_pointer %016LX",
259 fs64_to_cpu(sb, super->free_node_ptr));
260 befs_debug(sb, " maximum size %016LX",
261 fs64_to_cpu(sb, super->max_size));
263 #endif //CONFIG_BEFS_DEBUG
266 void
267 befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead * node)
269 #ifdef CONFIG_BEFS_DEBUG
271 befs_debug(sb, "Btree node structure");
272 befs_debug(sb, " left %016LX", fs64_to_cpu(sb, node->left));
273 befs_debug(sb, " right %016LX", fs64_to_cpu(sb, node->right));
274 befs_debug(sb, " overflow %016LX", fs64_to_cpu(sb, node->overflow));
275 befs_debug(sb, " all_key_count %hu",
276 fs16_to_cpu(sb, node->all_key_count));
277 befs_debug(sb, " all_key_length %hu",
278 fs16_to_cpu(sb, node->all_key_length));
280 #endif //CONFIG_BEFS_DEBUG