Linux Audio

Check our new training course

Loading...
v3.5.6
  1/*
  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
 
 13#ifdef __KERNEL__
 14
 15#include <stdarg.h>
 16#include <linux/string.h>
 17#include <linux/spinlock.h>
 18#include <linux/kernel.h>
 19#include <linux/fs.h>
 20#include <linux/slab.h>
 21
 22#endif				/* __KERNEL__ */
 23
 24#include "befs.h"
 25
 26#define ERRBUFSIZE 1024
 27
 28void
 29befs_error(const struct super_block *sb, const char *fmt, ...)
 30{
 
 31	va_list args;
 32	char *err_buf = kmalloc(ERRBUFSIZE, GFP_KERNEL);
 33	if (err_buf == NULL) {
 34		printk(KERN_ERR "could not allocate %d bytes\n", ERRBUFSIZE);
 35		return;
 36	}
 37
 38	va_start(args, fmt);
 39	vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
 
 
 40	va_end(args);
 41
 42	printk(KERN_ERR "BeFS(%s): %s\n", sb->s_id, err_buf);
 43	kfree(err_buf);
 44}
 45
 46void
 47befs_warning(const struct super_block *sb, const char *fmt, ...)
 48{
 
 49	va_list args;
 50	char *err_buf = kmalloc(ERRBUFSIZE, GFP_KERNEL);
 51	if (err_buf == NULL) {
 52		printk(KERN_ERR "could not allocate %d bytes\n", ERRBUFSIZE);
 53		return;
 54	}
 55
 56	va_start(args, fmt);
 57	vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
 
 
 58	va_end(args);
 59
 60	printk(KERN_WARNING "BeFS(%s): %s\n", sb->s_id, err_buf);
 61
 62	kfree(err_buf);
 63}
 64
 65void
 66befs_debug(const struct super_block *sb, const char *fmt, ...)
 67{
 68#ifdef CONFIG_BEFS_DEBUG
 69
 
 70	va_list args;
 71	char *err_buf = NULL;
 72
 73	if (BEFS_SB(sb)->mount_opts.debug) {
 74		err_buf = kmalloc(ERRBUFSIZE, GFP_KERNEL);
 75		if (err_buf == NULL) {
 76			printk(KERN_ERR "could not allocate %d bytes\n",
 77				ERRBUFSIZE);
 78			return;
 79		}
 80
 81		va_start(args, fmt);
 82		vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
 83		va_end(args);
 84
 85		printk(KERN_DEBUG "BeFS(%s): %s\n", sb->s_id, err_buf);
 86
 87		kfree(err_buf);
 88	}
 89
 90#endif				//CONFIG_BEFS_DEBUG
 91}
 92
 93void
 94befs_dump_inode(const struct super_block *sb, befs_inode * inode)
 95{
 96#ifdef CONFIG_BEFS_DEBUG
 97
 98	befs_block_run tmp_run;
 99
100	befs_debug(sb, "befs_inode information");
101
102	befs_debug(sb, "  magic1 %08x", fs32_to_cpu(sb, inode->magic1));
103
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);
107
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));
116
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);
120
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);
124
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));
127
128	if (S_ISLNK(fs32_to_cpu(sb, inode->mode))) {
129		befs_debug(sb, "  Symbolic link [%s]", inode->data.symlink);
130	} else {
131		int i;
132
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);
139		}
140		befs_debug(sb, "  max_direct_range %Lu",
141			   fs64_to_cpu(sb,
142				       inode->data.datastream.
143				       max_direct_range));
144
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);
149
150		befs_debug(sb, "  max_indirect_range %Lu",
151			   fs64_to_cpu(sb,
152				       inode->data.datastream.
153				       max_indirect_range));
154
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);
160
161		befs_debug(sb, "  max_double_indirect_range %Lu",
162			   fs64_to_cpu(sb,
163				       inode->data.datastream.
164				       max_double_indirect_range));
165
166		befs_debug(sb, "  size %Lu",
167			   fs64_to_cpu(sb, inode->data.datastream.size));
168	}
169
170#endif				//CONFIG_BEFS_DEBUG
171}
172
173/*
174 * Display super block structure for debug.
175 */
176
177void
178befs_dump_super_block(const struct super_block *sb, befs_super_block * sup)
179{
180#ifdef CONFIG_BEFS_DEBUG
181
182	befs_block_run tmp_run;
183
184	befs_debug(sb, "befs_super_block information");
185
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));
190
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));
193
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));
196
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));
202
203	befs_debug(sb, "  flags %08x", fs32_to_cpu(sb, sup->flags));
204
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);
208
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));
211
212	befs_debug(sb, "  magic3 %08x", fs32_to_cpu(sb, sup->magic3));
213
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);
217
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);
221
222#endif				//CONFIG_BEFS_DEBUG
223}
224
225#if 0
226/* unused */
227void
228befs_dump_small_data(const struct super_block *sb, befs_small_data * sd)
229{
230}
231
232/* unused */
233void
234befs_dump_run(const struct super_block *sb, befs_disk_block_run run)
235{
236#ifdef CONFIG_BEFS_DEBUG
237
238	befs_block_run n = fsrun_to_cpu(sb, run);
239
240	befs_debug(sb, "[%u, %hu, %hu]", n.allocation_group, n.start, n.len);
241
242#endif				//CONFIG_BEFS_DEBUG
243}
244#endif  /*  0  */
245
246void
247befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super * super)
248{
249#ifdef CONFIG_BEFS_DEBUG
250
251	befs_debug(sb, "Btree super structure");
252	befs_debug(sb, "  magic %08x", fs32_to_cpu(sb, super->magic));
253	befs_debug(sb, "  node_size %u", fs32_to_cpu(sb, super->node_size));
254	befs_debug(sb, "  max_depth %08x", fs32_to_cpu(sb, super->max_depth));
255
256	befs_debug(sb, "  data_type %08x", fs32_to_cpu(sb, super->data_type));
257	befs_debug(sb, "  root_node_pointer %016LX",
258		   fs64_to_cpu(sb, super->root_node_ptr));
259	befs_debug(sb, "  free_node_pointer %016LX",
260		   fs64_to_cpu(sb, super->free_node_ptr));
261	befs_debug(sb, "  maximum size %016LX",
262		   fs64_to_cpu(sb, super->max_size));
263
264#endif				//CONFIG_BEFS_DEBUG
265}
266
267void
268befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead * node)
269{
270#ifdef CONFIG_BEFS_DEBUG
271
272	befs_debug(sb, "Btree node structure");
273	befs_debug(sb, "  left %016LX", fs64_to_cpu(sb, node->left));
274	befs_debug(sb, "  right %016LX", fs64_to_cpu(sb, node->right));
275	befs_debug(sb, "  overflow %016LX", fs64_to_cpu(sb, node->overflow));
276	befs_debug(sb, "  all_key_count %hu",
277		   fs16_to_cpu(sb, node->all_key_count));
278	befs_debug(sb, "  all_key_length %hu",
279		   fs16_to_cpu(sb, node->all_key_length));
280
281#endif				//CONFIG_BEFS_DEBUG
282}
v3.15
  1/*
  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
 13#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 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>
 21#include <linux/slab.h>
 22
 23#endif				/* __KERNEL__ */
 24
 25#include "befs.h"
 26
 
 
 27void
 28befs_error(const struct super_block *sb, const char *fmt, ...)
 29{
 30	struct va_format vaf;
 31	va_list args;
 
 
 
 
 
 32
 33	va_start(args, fmt);
 34	vaf.fmt = fmt;
 35	vaf.va = &args;
 36	pr_err("(%s): %pV\n", sb->s_id, &vaf);
 37	va_end(args);
 
 
 
 38}
 39
 40void
 41befs_warning(const struct super_block *sb, const char *fmt, ...)
 42{
 43	struct va_format vaf;
 44	va_list args;
 
 
 
 
 
 45
 46	va_start(args, fmt);
 47	vaf.fmt = fmt;
 48	vaf.va = &args;
 49	pr_warn("(%s): %pV\n", sb->s_id, &vaf);
 50	va_end(args);
 
 
 
 
 51}
 52
 53void
 54befs_debug(const struct super_block *sb, const char *fmt, ...)
 55{
 56#ifdef CONFIG_BEFS_DEBUG
 57
 58	struct va_format vaf;
 59	va_list args;
 60	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);
 
 
 
 
 
 
 
 
 
 
 
 
 
 65
 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));
 88	befs_debug(sb, "  create_time %llu",
 89		   fs64_to_cpu(sb, inode->create_time));
 90	befs_debug(sb, "  last_modified_time %llu",
 91		   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
104	if (S_ISLNK(fs32_to_cpu(sb, inode->mode))) {
105		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		}
116		befs_debug(sb, "  max_direct_range %llu",
117			   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
126		befs_debug(sb, "  max_indirect_range %llu",
127			   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
137		befs_debug(sb, "  max_double_indirect_range %llu",
138			   fs64_to_cpu(sb,
139				       inode->data.datastream.
140				       max_double_indirect_range));
141
142		befs_debug(sb, "  size %llu",
143			   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
170	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));
172
173	befs_debug(sb, "  magic2 %08x", fs32_to_cpu(sb, sup->magic2));
174	befs_debug(sb, "  blocks_per_ag %u",
175		   fs32_to_cpu(sb, sup->blocks_per_ag));
176	befs_debug(sb, "  ag_shift %u", fs32_to_cpu(sb, sup->ag_shift));
177	befs_debug(sb, "  num_ags %u", fs32_to_cpu(sb, sup->num_ags));
178
179	befs_debug(sb, "  flags %08x", fs32_to_cpu(sb, sup->flags));
180
181	tmp_run = fsrun_to_cpu(sb, sup->log_blocks);
182	befs_debug(sb, "  log_blocks %u, %hu, %hu",
183		   tmp_run.allocation_group, tmp_run.start, tmp_run.len);
184
185	befs_debug(sb, "  log_start %lld", fs64_to_cpu(sb, sup->log_start));
186	befs_debug(sb, "  log_end %lld", fs64_to_cpu(sb, sup->log_end));
187
188	befs_debug(sb, "  magic3 %08x", fs32_to_cpu(sb, sup->magic3));
189
190	tmp_run = fsrun_to_cpu(sb, sup->root_dir);
191	befs_debug(sb, "  root_dir %u, %hu, %hu",
192		   tmp_run.allocation_group, tmp_run.start, tmp_run.len);
193
194	tmp_run = fsrun_to_cpu(sb, sup->indices);
195	befs_debug(sb, "  indices %u, %hu, %hu",
196		   tmp_run.allocation_group, tmp_run.start, tmp_run.len);
197
198#endif				//CONFIG_BEFS_DEBUG
199}
200
201#if 0
202/* unused */
203void
204befs_dump_small_data(const struct super_block *sb, befs_small_data * sd)
205{
206}
207
208/* unused */
209void
210befs_dump_run(const struct super_block *sb, befs_disk_block_run run)
211{
212#ifdef CONFIG_BEFS_DEBUG
213
214	befs_block_run n = fsrun_to_cpu(sb, run);
215
216	befs_debug(sb, "[%u, %hu, %hu]", n.allocation_group, n.start, n.len);
217
218#endif				//CONFIG_BEFS_DEBUG
219}
220#endif  /*  0  */
221
222void
223befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super * super)
224{
225#ifdef CONFIG_BEFS_DEBUG
226
227	befs_debug(sb, "Btree super structure");
228	befs_debug(sb, "  magic %08x", fs32_to_cpu(sb, super->magic));
229	befs_debug(sb, "  node_size %u", fs32_to_cpu(sb, super->node_size));
230	befs_debug(sb, "  max_depth %08x", fs32_to_cpu(sb, super->max_depth));
231
232	befs_debug(sb, "  data_type %08x", fs32_to_cpu(sb, super->data_type));
233	befs_debug(sb, "  root_node_pointer %016LX",
234		   fs64_to_cpu(sb, super->root_node_ptr));
235	befs_debug(sb, "  free_node_pointer %016LX",
236		   fs64_to_cpu(sb, super->free_node_ptr));
237	befs_debug(sb, "  maximum size %016LX",
238		   fs64_to_cpu(sb, super->max_size));
239
240#endif				//CONFIG_BEFS_DEBUG
241}
242
243void
244befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead * node)
245{
246#ifdef CONFIG_BEFS_DEBUG
247
248	befs_debug(sb, "Btree node structure");
249	befs_debug(sb, "  left %016LX", fs64_to_cpu(sb, node->left));
250	befs_debug(sb, "  right %016LX", fs64_to_cpu(sb, node->right));
251	befs_debug(sb, "  overflow %016LX", fs64_to_cpu(sb, node->overflow));
252	befs_debug(sb, "  all_key_count %hu",
253		   fs16_to_cpu(sb, node->all_key_count));
254	befs_debug(sb, "  all_key_length %hu",
255		   fs16_to_cpu(sb, node->all_key_length));
256
257#endif				//CONFIG_BEFS_DEBUG
258}