Blame view

fs/befs/debug.c 7.56 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  /*
   *  linux/fs/befs/debug.c
   * 
   * Copyright (C) 2001 Will Dyson (will_dyson at pobox.com)
   *
   * With help from the ntfs-tng driver by Anton Altparmakov
   *
   * Copyright (C) 1999  Makoto Kato (m_kato@ga2.so-net.ne.jp)
   *
   * debug functions
   */
  
  #ifdef __KERNEL__
  
  #include <stdarg.h>
  #include <linux/string.h>
  #include <linux/spinlock.h>
  #include <linux/kernel.h>
  #include <linux/fs.h>
c325962b6   Pekka Enberg   kmemtrace, befs: ...
20
  #include <linux/slab.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21
22
23
24
  
  #endif				/* __KERNEL__ */
  
  #include "befs.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
25
26
27
28
29
30
31
  
  #define ERRBUFSIZE 1024
  
  void
  befs_error(const struct super_block *sb, const char *fmt, ...)
  {
  	va_list args;
5cbded585   Robert P. J. Day   [PATCH] getting r...
32
  	char *err_buf = kmalloc(ERRBUFSIZE, GFP_KERNEL);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  	if (err_buf == NULL) {
  		printk(KERN_ERR "could not allocate %d bytes
  ", ERRBUFSIZE);
  		return;
  	}
  
  	va_start(args, fmt);
  	vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
  	va_end(args);
  
  	printk(KERN_ERR "BeFS(%s): %s
  ", sb->s_id, err_buf);
  	kfree(err_buf);
  }
  
  void
  befs_warning(const struct super_block *sb, const char *fmt, ...)
  {
  	va_list args;
5cbded585   Robert P. J. Day   [PATCH] getting r...
52
  	char *err_buf = kmalloc(ERRBUFSIZE, GFP_KERNEL);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  	if (err_buf == NULL) {
  		printk(KERN_ERR "could not allocate %d bytes
  ", ERRBUFSIZE);
  		return;
  	}
  
  	va_start(args, fmt);
  	vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
  	va_end(args);
  
  	printk(KERN_WARNING "BeFS(%s): %s
  ", sb->s_id, err_buf);
  
  	kfree(err_buf);
  }
  
  void
  befs_debug(const struct super_block *sb, const char *fmt, ...)
  {
  #ifdef CONFIG_BEFS_DEBUG
  
  	va_list args;
  	char *err_buf = NULL;
  
  	if (BEFS_SB(sb)->mount_opts.debug) {
5cbded585   Robert P. J. Day   [PATCH] getting r...
78
  		err_buf = kmalloc(ERRBUFSIZE, GFP_KERNEL);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
  		if (err_buf == NULL) {
  			printk(KERN_ERR "could not allocate %d bytes
  ",
  				ERRBUFSIZE);
  			return;
  		}
  
  		va_start(args, fmt);
  		vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
  		va_end(args);
  
  		printk(KERN_DEBUG "BeFS(%s): %s
  ", sb->s_id, err_buf);
  
  		kfree(err_buf);
  	}
  
  #endif				//CONFIG_BEFS_DEBUG
  }
  
  void
  befs_dump_inode(const struct super_block *sb, befs_inode * inode)
  {
  #ifdef CONFIG_BEFS_DEBUG
  
  	befs_block_run tmp_run;
  
  	befs_debug(sb, "befs_inode information");
  
  	befs_debug(sb, "  magic1 %08x", fs32_to_cpu(sb, inode->magic1));
  
  	tmp_run = fsrun_to_cpu(sb, inode->inode_num);
  	befs_debug(sb, "  inode_num %u, %hu, %hu",
  		   tmp_run.allocation_group, tmp_run.start, tmp_run.len);
  
  	befs_debug(sb, "  uid %u", fs32_to_cpu(sb, inode->uid));
  	befs_debug(sb, "  gid %u", fs32_to_cpu(sb, inode->gid));
  	befs_debug(sb, "  mode %08x", fs32_to_cpu(sb, inode->mode));
  	befs_debug(sb, "  flags %08x", fs32_to_cpu(sb, inode->flags));
  	befs_debug(sb, "  create_time %Lu",
  		   fs64_to_cpu(sb, inode->create_time));
  	befs_debug(sb, "  last_modified_time %Lu",
  		   fs64_to_cpu(sb, inode->last_modified_time));
  
  	tmp_run = fsrun_to_cpu(sb, inode->parent);
  	befs_debug(sb, "  parent [%u, %hu, %hu]",
  		   tmp_run.allocation_group, tmp_run.start, tmp_run.len);
  
  	tmp_run = fsrun_to_cpu(sb, inode->attributes);
  	befs_debug(sb, "  attributes [%u, %hu, %hu]",
  		   tmp_run.allocation_group, tmp_run.start, tmp_run.len);
  
  	befs_debug(sb, "  type %08x", fs32_to_cpu(sb, inode->type));
  	befs_debug(sb, "  inode_size %u", fs32_to_cpu(sb, inode->inode_size));
e5201c58c   Al Viro   [PATCH] befs: mis...
133
  	if (S_ISLNK(fs32_to_cpu(sb, inode->mode))) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
  		befs_debug(sb, "  Symbolic link [%s]", inode->data.symlink);
  	} else {
  		int i;
  
  		for (i = 0; i < BEFS_NUM_DIRECT_BLOCKS; i++) {
  			tmp_run =
  			    fsrun_to_cpu(sb, inode->data.datastream.direct[i]);
  			befs_debug(sb, "  direct %d [%u, %hu, %hu]", i,
  				   tmp_run.allocation_group, tmp_run.start,
  				   tmp_run.len);
  		}
  		befs_debug(sb, "  max_direct_range %Lu",
  			   fs64_to_cpu(sb,
  				       inode->data.datastream.
  				       max_direct_range));
  
  		tmp_run = fsrun_to_cpu(sb, inode->data.datastream.indirect);
  		befs_debug(sb, "  indirect [%u, %hu, %hu]",
  			   tmp_run.allocation_group,
  			   tmp_run.start, tmp_run.len);
  
  		befs_debug(sb, "  max_indirect_range %Lu",
  			   fs64_to_cpu(sb,
  				       inode->data.datastream.
  				       max_indirect_range));
  
  		tmp_run =
  		    fsrun_to_cpu(sb, inode->data.datastream.double_indirect);
  		befs_debug(sb, "  double indirect [%u, %hu, %hu]",
  			   tmp_run.allocation_group, tmp_run.start,
  			   tmp_run.len);
  
  		befs_debug(sb, "  max_double_indirect_range %Lu",
  			   fs64_to_cpu(sb,
  				       inode->data.datastream.
  				       max_double_indirect_range));
  
  		befs_debug(sb, "  size %Lu",
  			   fs64_to_cpu(sb, inode->data.datastream.size));
  	}
  
  #endif				//CONFIG_BEFS_DEBUG
  }
  
  /*
   * Display super block structure for debug.
   */
  
  void
  befs_dump_super_block(const struct super_block *sb, befs_super_block * sup)
  {
  #ifdef CONFIG_BEFS_DEBUG
  
  	befs_block_run tmp_run;
  
  	befs_debug(sb, "befs_super_block information");
  
  	befs_debug(sb, "  name %s", sup->name);
  	befs_debug(sb, "  magic1 %08x", fs32_to_cpu(sb, sup->magic1));
  	befs_debug(sb, "  fs_byte_order %08x",
  		   fs32_to_cpu(sb, sup->fs_byte_order));
  
  	befs_debug(sb, "  block_size %u", fs32_to_cpu(sb, sup->block_size));
  	befs_debug(sb, "  block_shift %u", fs32_to_cpu(sb, sup->block_shift));
  
  	befs_debug(sb, "  num_blocks %Lu", fs64_to_cpu(sb, sup->num_blocks));
  	befs_debug(sb, "  used_blocks %Lu", fs64_to_cpu(sb, sup->used_blocks));
  
  	befs_debug(sb, "  magic2 %08x", fs32_to_cpu(sb, sup->magic2));
  	befs_debug(sb, "  blocks_per_ag %u",
  		   fs32_to_cpu(sb, sup->blocks_per_ag));
  	befs_debug(sb, "  ag_shift %u", fs32_to_cpu(sb, sup->ag_shift));
  	befs_debug(sb, "  num_ags %u", fs32_to_cpu(sb, sup->num_ags));
  
  	befs_debug(sb, "  flags %08x", fs32_to_cpu(sb, sup->flags));
  
  	tmp_run = fsrun_to_cpu(sb, sup->log_blocks);
  	befs_debug(sb, "  log_blocks %u, %hu, %hu",
  		   tmp_run.allocation_group, tmp_run.start, tmp_run.len);
  
  	befs_debug(sb, "  log_start %Ld", fs64_to_cpu(sb, sup->log_start));
  	befs_debug(sb, "  log_end %Ld", fs64_to_cpu(sb, sup->log_end));
  
  	befs_debug(sb, "  magic3 %08x", fs32_to_cpu(sb, sup->magic3));
  
  	tmp_run = fsrun_to_cpu(sb, sup->root_dir);
  	befs_debug(sb, "  root_dir %u, %hu, %hu",
  		   tmp_run.allocation_group, tmp_run.start, tmp_run.len);
  
  	tmp_run = fsrun_to_cpu(sb, sup->indices);
  	befs_debug(sb, "  indices %u, %hu, %hu",
  		   tmp_run.allocation_group, tmp_run.start, tmp_run.len);
  
  #endif				//CONFIG_BEFS_DEBUG
  }
  
  #if 0
  /* unused */
  void
  befs_dump_small_data(const struct super_block *sb, befs_small_data * sd)
  {
  }
  
  /* unused */
  void
a9721f315   Al Viro   [PATCH] befs: end...
239
  befs_dump_run(const struct super_block *sb, befs_disk_block_run run)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
240
241
  {
  #ifdef CONFIG_BEFS_DEBUG
a9721f315   Al Viro   [PATCH] befs: end...
242
  	befs_block_run n = fsrun_to_cpu(sb, run);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
243

a9721f315   Al Viro   [PATCH] befs: end...
244
  	befs_debug(sb, "[%u, %hu, %hu]", n.allocation_group, n.start, n.len);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
245
246
247
248
249
250
  
  #endif				//CONFIG_BEFS_DEBUG
  }
  #endif  /*  0  */
  
  void
a9721f315   Al Viro   [PATCH] befs: end...
251
  befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super * super)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
  {
  #ifdef CONFIG_BEFS_DEBUG
  
  	befs_debug(sb, "Btree super structure");
  	befs_debug(sb, "  magic %08x", fs32_to_cpu(sb, super->magic));
  	befs_debug(sb, "  node_size %u", fs32_to_cpu(sb, super->node_size));
  	befs_debug(sb, "  max_depth %08x", fs32_to_cpu(sb, super->max_depth));
  
  	befs_debug(sb, "  data_type %08x", fs32_to_cpu(sb, super->data_type));
  	befs_debug(sb, "  root_node_pointer %016LX",
  		   fs64_to_cpu(sb, super->root_node_ptr));
  	befs_debug(sb, "  free_node_pointer %016LX",
  		   fs64_to_cpu(sb, super->free_node_ptr));
  	befs_debug(sb, "  maximum size %016LX",
  		   fs64_to_cpu(sb, super->max_size));
  
  #endif				//CONFIG_BEFS_DEBUG
  }
  
  void
  befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead * node)
  {
  #ifdef CONFIG_BEFS_DEBUG
  
  	befs_debug(sb, "Btree node structure");
  	befs_debug(sb, "  left %016LX", fs64_to_cpu(sb, node->left));
  	befs_debug(sb, "  right %016LX", fs64_to_cpu(sb, node->right));
  	befs_debug(sb, "  overflow %016LX", fs64_to_cpu(sb, node->overflow));
  	befs_debug(sb, "  all_key_count %hu",
  		   fs16_to_cpu(sb, node->all_key_count));
  	befs_debug(sb, "  all_key_length %hu",
  		   fs16_to_cpu(sb, node->all_key_length));
  
  #endif				//CONFIG_BEFS_DEBUG
  }