aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/befs/Makefile2
-rw-r--r--fs/befs/befs.h3
-rw-r--r--fs/befs/btree.c93
-rw-r--r--fs/befs/datastream.c87
-rw-r--r--fs/befs/debug.c74
-rw-r--r--fs/befs/inode.c10
-rw-r--r--fs/befs/io.c24
-rw-r--r--fs/befs/linuxvfs.c106
8 files changed, 195 insertions, 204 deletions
diff --git a/fs/befs/Makefile b/fs/befs/Makefile
index 2f370bd7a50d..8b9f66642a83 100644
--- a/fs/befs/Makefile
+++ b/fs/befs/Makefile
@@ -3,5 +3,5 @@
3# 3#
4 4
5obj-$(CONFIG_BEFS_FS) += befs.o 5obj-$(CONFIG_BEFS_FS) += befs.o
6 6ccflags-$(CONFIG_BEFS_DEBUG) += -DDEBUG
7befs-objs := datastream.o btree.o super.o inode.o debug.o io.o linuxvfs.o 7befs-objs := datastream.o btree.o super.o inode.o debug.o io.o linuxvfs.o
diff --git a/fs/befs/befs.h b/fs/befs/befs.h
index b26642839156..3a7813ab8c95 100644
--- a/fs/befs/befs.h
+++ b/fs/befs/befs.h
@@ -88,8 +88,11 @@ enum befs_err {
88 88
89/****************************/ 89/****************************/
90/* debug.c */ 90/* debug.c */
91__printf(2, 3)
91void befs_error(const struct super_block *sb, const char *fmt, ...); 92void befs_error(const struct super_block *sb, const char *fmt, ...);
93__printf(2, 3)
92void befs_warning(const struct super_block *sb, const char *fmt, ...); 94void befs_warning(const struct super_block *sb, const char *fmt, ...);
95__printf(2, 3)
93void befs_debug(const struct super_block *sb, const char *fmt, ...); 96void befs_debug(const struct super_block *sb, const char *fmt, ...);
94 97
95void befs_dump_super_block(const struct super_block *sb, befs_super_block *); 98void befs_dump_super_block(const struct super_block *sb, befs_super_block *);
diff --git a/fs/befs/btree.c b/fs/befs/btree.c
index 74e397db0b8b..a2cd305a993a 100644
--- a/fs/befs/btree.c
+++ b/fs/befs/btree.c
@@ -137,7 +137,7 @@ befs_bt_read_super(struct super_block *sb, befs_data_stream * ds,
137 struct buffer_head *bh = NULL; 137 struct buffer_head *bh = NULL;
138 befs_disk_btree_super *od_sup = NULL; 138 befs_disk_btree_super *od_sup = NULL;
139 139
140 befs_debug(sb, "---> befs_btree_read_super()"); 140 befs_debug(sb, "---> %s", __func__);
141 141
142 bh = befs_read_datastream(sb, ds, 0, NULL); 142 bh = befs_read_datastream(sb, ds, 0, NULL);
143 143
@@ -162,11 +162,11 @@ befs_bt_read_super(struct super_block *sb, befs_data_stream * ds,
162 goto error; 162 goto error;
163 } 163 }
164 164
165 befs_debug(sb, "<--- befs_btree_read_super()"); 165 befs_debug(sb, "<--- %s", __func__);
166 return BEFS_OK; 166 return BEFS_OK;
167 167
168 error: 168 error:
169 befs_debug(sb, "<--- befs_btree_read_super() ERROR"); 169 befs_debug(sb, "<--- %s ERROR", __func__);
170 return BEFS_ERR; 170 return BEFS_ERR;
171} 171}
172 172
@@ -195,16 +195,16 @@ befs_bt_read_node(struct super_block *sb, befs_data_stream * ds,
195{ 195{
196 uint off = 0; 196 uint off = 0;
197 197
198 befs_debug(sb, "---> befs_bt_read_node()"); 198 befs_debug(sb, "---> %s", __func__);
199 199
200 if (node->bh) 200 if (node->bh)
201 brelse(node->bh); 201 brelse(node->bh);
202 202
203 node->bh = befs_read_datastream(sb, ds, node_off, &off); 203 node->bh = befs_read_datastream(sb, ds, node_off, &off);
204 if (!node->bh) { 204 if (!node->bh) {
205 befs_error(sb, "befs_bt_read_node() failed to read " 205 befs_error(sb, "%s failed to read "
206 "node at %Lu", node_off); 206 "node at %llu", __func__, node_off);
207 befs_debug(sb, "<--- befs_bt_read_node() ERROR"); 207 befs_debug(sb, "<--- %s ERROR", __func__);
208 208
209 return BEFS_ERR; 209 return BEFS_ERR;
210 } 210 }
@@ -221,7 +221,7 @@ befs_bt_read_node(struct super_block *sb, befs_data_stream * ds,
221 node->head.all_key_length = 221 node->head.all_key_length =
222 fs16_to_cpu(sb, node->od_node->all_key_length); 222 fs16_to_cpu(sb, node->od_node->all_key_length);
223 223
224 befs_debug(sb, "<--- befs_btree_read_node()"); 224 befs_debug(sb, "<--- %s", __func__);
225 return BEFS_OK; 225 return BEFS_OK;
226} 226}
227 227
@@ -252,7 +252,7 @@ befs_btree_find(struct super_block *sb, befs_data_stream * ds,
252 befs_off_t node_off; 252 befs_off_t node_off;
253 int res; 253 int res;
254 254
255 befs_debug(sb, "---> befs_btree_find() Key: %s", key); 255 befs_debug(sb, "---> %s Key: %s", __func__, key);
256 256
257 if (befs_bt_read_super(sb, ds, &bt_super) != BEFS_OK) { 257 if (befs_bt_read_super(sb, ds, &bt_super) != BEFS_OK) {
258 befs_error(sb, 258 befs_error(sb,
@@ -263,7 +263,7 @@ befs_btree_find(struct super_block *sb, befs_data_stream * ds,
263 this_node = kmalloc(sizeof (befs_btree_node), 263 this_node = kmalloc(sizeof (befs_btree_node),
264 GFP_NOFS); 264 GFP_NOFS);
265 if (!this_node) { 265 if (!this_node) {
266 befs_error(sb, "befs_btree_find() failed to allocate %u " 266 befs_error(sb, "befs_btree_find() failed to allocate %zu "
267 "bytes of memory", sizeof (befs_btree_node)); 267 "bytes of memory", sizeof (befs_btree_node));
268 goto error; 268 goto error;
269 } 269 }
@@ -274,7 +274,7 @@ befs_btree_find(struct super_block *sb, befs_data_stream * ds,
274 node_off = bt_super.root_node_ptr; 274 node_off = bt_super.root_node_ptr;
275 if (befs_bt_read_node(sb, ds, this_node, node_off) != BEFS_OK) { 275 if (befs_bt_read_node(sb, ds, this_node, node_off) != BEFS_OK) {
276 befs_error(sb, "befs_btree_find() failed to read " 276 befs_error(sb, "befs_btree_find() failed to read "
277 "node at %Lu", node_off); 277 "node at %llu", node_off);
278 goto error_alloc; 278 goto error_alloc;
279 } 279 }
280 280
@@ -285,7 +285,7 @@ befs_btree_find(struct super_block *sb, befs_data_stream * ds,
285 /* if no match, go to overflow node */ 285 /* if no match, go to overflow node */
286 if (befs_bt_read_node(sb, ds, this_node, node_off) != BEFS_OK) { 286 if (befs_bt_read_node(sb, ds, this_node, node_off) != BEFS_OK) {
287 befs_error(sb, "befs_btree_find() failed to read " 287 befs_error(sb, "befs_btree_find() failed to read "
288 "node at %Lu", node_off); 288 "node at %llu", node_off);
289 goto error_alloc; 289 goto error_alloc;
290 } 290 }
291 } 291 }
@@ -298,11 +298,11 @@ befs_btree_find(struct super_block *sb, befs_data_stream * ds,
298 kfree(this_node); 298 kfree(this_node);
299 299
300 if (res != BEFS_BT_MATCH) { 300 if (res != BEFS_BT_MATCH) {
301 befs_debug(sb, "<--- befs_btree_find() Key %s not found", key); 301 befs_debug(sb, "<--- %s Key %s not found", __func__, key);
302 *value = 0; 302 *value = 0;
303 return BEFS_BT_NOT_FOUND; 303 return BEFS_BT_NOT_FOUND;
304 } 304 }
305 befs_debug(sb, "<--- befs_btree_find() Found key %s, value %Lu", 305 befs_debug(sb, "<--- %s Found key %s, value %llu", __func__,
306 key, *value); 306 key, *value);
307 return BEFS_OK; 307 return BEFS_OK;
308 308
@@ -310,7 +310,7 @@ befs_btree_find(struct super_block *sb, befs_data_stream * ds,
310 kfree(this_node); 310 kfree(this_node);
311 error: 311 error:
312 *value = 0; 312 *value = 0;
313 befs_debug(sb, "<--- befs_btree_find() ERROR"); 313 befs_debug(sb, "<--- %s ERROR", __func__);
314 return BEFS_ERR; 314 return BEFS_ERR;
315} 315}
316 316
@@ -343,7 +343,7 @@ befs_find_key(struct super_block *sb, befs_btree_node * node,
343 char *thiskey; 343 char *thiskey;
344 fs64 *valarray; 344 fs64 *valarray;
345 345
346 befs_debug(sb, "---> befs_find_key() %s", findkey); 346 befs_debug(sb, "---> %s %s", __func__, findkey);
347 347
348 *value = 0; 348 *value = 0;
349 349
@@ -355,7 +355,7 @@ befs_find_key(struct super_block *sb, befs_btree_node * node,
355 355
356 eq = befs_compare_strings(thiskey, keylen, findkey, findkey_len); 356 eq = befs_compare_strings(thiskey, keylen, findkey, findkey_len);
357 if (eq < 0) { 357 if (eq < 0) {
358 befs_debug(sb, "<--- befs_find_key() %s not found", findkey); 358 befs_debug(sb, "<--- %s %s not found", __func__, findkey);
359 return BEFS_BT_NOT_FOUND; 359 return BEFS_BT_NOT_FOUND;
360 } 360 }
361 361
@@ -373,8 +373,8 @@ befs_find_key(struct super_block *sb, befs_btree_node * node,
373 findkey_len); 373 findkey_len);
374 374
375 if (eq == 0) { 375 if (eq == 0) {
376 befs_debug(sb, "<--- befs_find_key() found %s at %d", 376 befs_debug(sb, "<--- %s found %s at %d",
377 thiskey, mid); 377 __func__, thiskey, mid);
378 378
379 *value = fs64_to_cpu(sb, valarray[mid]); 379 *value = fs64_to_cpu(sb, valarray[mid]);
380 return BEFS_BT_MATCH; 380 return BEFS_BT_MATCH;
@@ -388,7 +388,7 @@ befs_find_key(struct super_block *sb, befs_btree_node * node,
388 *value = fs64_to_cpu(sb, valarray[mid + 1]); 388 *value = fs64_to_cpu(sb, valarray[mid + 1]);
389 else 389 else
390 *value = fs64_to_cpu(sb, valarray[mid]); 390 *value = fs64_to_cpu(sb, valarray[mid]);
391 befs_debug(sb, "<--- befs_find_key() found %s at %d", thiskey, mid); 391 befs_debug(sb, "<--- %s found %s at %d", __func__, thiskey, mid);
392 return BEFS_BT_PARMATCH; 392 return BEFS_BT_PARMATCH;
393} 393}
394 394
@@ -428,7 +428,7 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
428 428
429 uint key_sum = 0; 429 uint key_sum = 0;
430 430
431 befs_debug(sb, "---> befs_btree_read()"); 431 befs_debug(sb, "---> %s", __func__);
432 432
433 if (befs_bt_read_super(sb, ds, &bt_super) != BEFS_OK) { 433 if (befs_bt_read_super(sb, ds, &bt_super) != BEFS_OK) {
434 befs_error(sb, 434 befs_error(sb,
@@ -437,7 +437,7 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
437 } 437 }
438 438
439 if ((this_node = kmalloc(sizeof (befs_btree_node), GFP_NOFS)) == NULL) { 439 if ((this_node = kmalloc(sizeof (befs_btree_node), GFP_NOFS)) == NULL) {
440 befs_error(sb, "befs_btree_read() failed to allocate %u " 440 befs_error(sb, "befs_btree_read() failed to allocate %zu "
441 "bytes of memory", sizeof (befs_btree_node)); 441 "bytes of memory", sizeof (befs_btree_node));
442 goto error; 442 goto error;
443 } 443 }
@@ -452,7 +452,7 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
452 kfree(this_node); 452 kfree(this_node);
453 *value = 0; 453 *value = 0;
454 *keysize = 0; 454 *keysize = 0;
455 befs_debug(sb, "<--- befs_btree_read() Tree is EMPTY"); 455 befs_debug(sb, "<--- %s Tree is EMPTY", __func__);
456 return BEFS_BT_EMPTY; 456 return BEFS_BT_EMPTY;
457 } else if (res == BEFS_ERR) { 457 } else if (res == BEFS_ERR) {
458 goto error_alloc; 458 goto error_alloc;
@@ -467,7 +467,8 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
467 *keysize = 0; 467 *keysize = 0;
468 *value = 0; 468 *value = 0;
469 befs_debug(sb, 469 befs_debug(sb,
470 "<--- befs_btree_read() END of keys at %Lu", 470 "<--- %s END of keys at %llu", __func__,
471 (unsigned long long)
471 key_sum + this_node->head.all_key_count); 472 key_sum + this_node->head.all_key_count);
472 brelse(this_node->bh); 473 brelse(this_node->bh);
473 kfree(this_node); 474 kfree(this_node);
@@ -478,8 +479,8 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
478 node_off = this_node->head.right; 479 node_off = this_node->head.right;
479 480
480 if (befs_bt_read_node(sb, ds, this_node, node_off) != BEFS_OK) { 481 if (befs_bt_read_node(sb, ds, this_node, node_off) != BEFS_OK) {
481 befs_error(sb, "befs_btree_read() failed to read " 482 befs_error(sb, "%s failed to read node at %llu",
482 "node at %Lu", node_off); 483 __func__, (unsigned long long)node_off);
483 goto error_alloc; 484 goto error_alloc;
484 } 485 }
485 } 486 }
@@ -492,11 +493,13 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
492 493
493 keystart = befs_bt_get_key(sb, this_node, cur_key, &keylen); 494 keystart = befs_bt_get_key(sb, this_node, cur_key, &keylen);
494 495
495 befs_debug(sb, "Read [%Lu,%d]: keysize %d", node_off, cur_key, keylen); 496 befs_debug(sb, "Read [%llu,%d]: keysize %d",
497 (long long unsigned int)node_off, (int)cur_key,
498 (int)keylen);
496 499
497 if (bufsize < keylen + 1) { 500 if (bufsize < keylen + 1) {
498 befs_error(sb, "befs_btree_read() keybuf too small (%u) " 501 befs_error(sb, "%s keybuf too small (%zu) "
499 "for key of size %d", bufsize, keylen); 502 "for key of size %d", __func__, bufsize, keylen);
500 brelse(this_node->bh); 503 brelse(this_node->bh);
501 goto error_alloc; 504 goto error_alloc;
502 }; 505 };
@@ -506,13 +509,13 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
506 *keysize = keylen; 509 *keysize = keylen;
507 keybuf[keylen] = '\0'; 510 keybuf[keylen] = '\0';
508 511
509 befs_debug(sb, "Read [%Lu,%d]: Key \"%.*s\", Value %Lu", node_off, 512 befs_debug(sb, "Read [%llu,%d]: Key \"%.*s\", Value %llu", node_off,
510 cur_key, keylen, keybuf, *value); 513 cur_key, keylen, keybuf, *value);
511 514
512 brelse(this_node->bh); 515 brelse(this_node->bh);
513 kfree(this_node); 516 kfree(this_node);
514 517
515 befs_debug(sb, "<--- befs_btree_read()"); 518 befs_debug(sb, "<--- %s", __func__);
516 519
517 return BEFS_OK; 520 return BEFS_OK;
518 521
@@ -522,7 +525,7 @@ befs_btree_read(struct super_block *sb, befs_data_stream * ds,
522 error: 525 error:
523 *keysize = 0; 526 *keysize = 0;
524 *value = 0; 527 *value = 0;
525 befs_debug(sb, "<--- befs_btree_read() ERROR"); 528 befs_debug(sb, "<--- %s ERROR", __func__);
526 return BEFS_ERR; 529 return BEFS_ERR;
527} 530}
528 531
@@ -547,26 +550,26 @@ befs_btree_seekleaf(struct super_block *sb, befs_data_stream * ds,
547 befs_off_t * node_off) 550 befs_off_t * node_off)
548{ 551{
549 552
550 befs_debug(sb, "---> befs_btree_seekleaf()"); 553 befs_debug(sb, "---> %s", __func__);
551 554
552 if (befs_bt_read_node(sb, ds, this_node, *node_off) != BEFS_OK) { 555 if (befs_bt_read_node(sb, ds, this_node, *node_off) != BEFS_OK) {
553 befs_error(sb, "befs_btree_seekleaf() failed to read " 556 befs_error(sb, "%s failed to read "
554 "node at %Lu", *node_off); 557 "node at %llu", __func__, *node_off);
555 goto error; 558 goto error;
556 } 559 }
557 befs_debug(sb, "Seekleaf to root node %Lu", *node_off); 560 befs_debug(sb, "Seekleaf to root node %llu", *node_off);
558 561
559 if (this_node->head.all_key_count == 0 && befs_leafnode(this_node)) { 562 if (this_node->head.all_key_count == 0 && befs_leafnode(this_node)) {
560 befs_debug(sb, "<--- befs_btree_seekleaf() Tree is EMPTY"); 563 befs_debug(sb, "<--- %s Tree is EMPTY", __func__);
561 return BEFS_BT_EMPTY; 564 return BEFS_BT_EMPTY;
562 } 565 }
563 566
564 while (!befs_leafnode(this_node)) { 567 while (!befs_leafnode(this_node)) {
565 568
566 if (this_node->head.all_key_count == 0) { 569 if (this_node->head.all_key_count == 0) {
567 befs_debug(sb, "befs_btree_seekleaf() encountered " 570 befs_debug(sb, "%s encountered "
568 "an empty interior node: %Lu. Using Overflow " 571 "an empty interior node: %llu. Using Overflow "
569 "node: %Lu", *node_off, 572 "node: %llu", __func__, *node_off,
570 this_node->head.overflow); 573 this_node->head.overflow);
571 *node_off = this_node->head.overflow; 574 *node_off = this_node->head.overflow;
572 } else { 575 } else {
@@ -574,19 +577,19 @@ befs_btree_seekleaf(struct super_block *sb, befs_data_stream * ds,
574 *node_off = fs64_to_cpu(sb, valarray[0]); 577 *node_off = fs64_to_cpu(sb, valarray[0]);
575 } 578 }
576 if (befs_bt_read_node(sb, ds, this_node, *node_off) != BEFS_OK) { 579 if (befs_bt_read_node(sb, ds, this_node, *node_off) != BEFS_OK) {
577 befs_error(sb, "befs_btree_seekleaf() failed to read " 580 befs_error(sb, "%s failed to read "
578 "node at %Lu", *node_off); 581 "node at %llu", __func__, *node_off);
579 goto error; 582 goto error;
580 } 583 }
581 584
582 befs_debug(sb, "Seekleaf to child node %Lu", *node_off); 585 befs_debug(sb, "Seekleaf to child node %llu", *node_off);
583 } 586 }
584 befs_debug(sb, "Node %Lu is a leaf node", *node_off); 587 befs_debug(sb, "Node %llu is a leaf node", *node_off);
585 588
586 return BEFS_OK; 589 return BEFS_OK;
587 590
588 error: 591 error:
589 befs_debug(sb, "<--- befs_btree_seekleaf() ERROR"); 592 befs_debug(sb, "<--- %s ERROR", __func__);
590 return BEFS_ERR; 593 return BEFS_ERR;
591} 594}
592 595
diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c
index 59096b5e0fc7..c467bebd50af 100644
--- a/fs/befs/datastream.c
+++ b/fs/befs/datastream.c
@@ -52,26 +52,25 @@ befs_read_datastream(struct super_block *sb, befs_data_stream * ds,
52 befs_block_run run; 52 befs_block_run run;
53 befs_blocknr_t block; /* block coresponding to pos */ 53 befs_blocknr_t block; /* block coresponding to pos */
54 54
55 befs_debug(sb, "---> befs_read_datastream() %Lu", pos); 55 befs_debug(sb, "---> %s %llu", __func__, pos);
56 block = pos >> BEFS_SB(sb)->block_shift; 56 block = pos >> BEFS_SB(sb)->block_shift;
57 if (off) 57 if (off)
58 *off = pos - (block << BEFS_SB(sb)->block_shift); 58 *off = pos - (block << BEFS_SB(sb)->block_shift);
59 59
60 if (befs_fblock2brun(sb, ds, block, &run) != BEFS_OK) { 60 if (befs_fblock2brun(sb, ds, block, &run) != BEFS_OK) {
61 befs_error(sb, "BeFS: Error finding disk addr of block %lu", 61 befs_error(sb, "BeFS: Error finding disk addr of block %lu",
62 block); 62 (unsigned long)block);
63 befs_debug(sb, "<--- befs_read_datastream() ERROR"); 63 befs_debug(sb, "<--- %s ERROR", __func__);
64 return NULL; 64 return NULL;
65 } 65 }
66 bh = befs_bread_iaddr(sb, run); 66 bh = befs_bread_iaddr(sb, run);
67 if (!bh) { 67 if (!bh) {
68 befs_error(sb, "BeFS: Error reading block %lu from datastream", 68 befs_error(sb, "BeFS: Error reading block %lu from datastream",
69 block); 69 (unsigned long)block);
70 return NULL; 70 return NULL;
71 } 71 }
72 72
73 befs_debug(sb, "<--- befs_read_datastream() read data, starting at %Lu", 73 befs_debug(sb, "<--- %s read data, starting at %llu", __func__, pos);
74 pos);
75 74
76 return bh; 75 return bh;
77} 76}
@@ -106,7 +105,8 @@ befs_fblock2brun(struct super_block *sb, befs_data_stream * data,
106 } else { 105 } else {
107 befs_error(sb, 106 befs_error(sb,
108 "befs_fblock2brun() was asked to find block %lu, " 107 "befs_fblock2brun() was asked to find block %lu, "
109 "which is not mapped by the datastream\n", fblock); 108 "which is not mapped by the datastream\n",
109 (unsigned long)fblock);
110 err = BEFS_ERR; 110 err = BEFS_ERR;
111 } 111 }
112 return err; 112 return err;
@@ -128,14 +128,14 @@ befs_read_lsymlink(struct super_block * sb, befs_data_stream * ds, void *buff,
128 befs_off_t bytes_read = 0; /* bytes readed */ 128 befs_off_t bytes_read = 0; /* bytes readed */
129 u16 plen; 129 u16 plen;
130 struct buffer_head *bh = NULL; 130 struct buffer_head *bh = NULL;
131 befs_debug(sb, "---> befs_read_lsymlink() length: %Lu", len); 131 befs_debug(sb, "---> %s length: %llu", __func__, len);
132 132
133 while (bytes_read < len) { 133 while (bytes_read < len) {
134 bh = befs_read_datastream(sb, ds, bytes_read, NULL); 134 bh = befs_read_datastream(sb, ds, bytes_read, NULL);
135 if (!bh) { 135 if (!bh) {
136 befs_error(sb, "BeFS: Error reading datastream block " 136 befs_error(sb, "BeFS: Error reading datastream block "
137 "starting from %Lu", bytes_read); 137 "starting from %llu", bytes_read);
138 befs_debug(sb, "<--- befs_read_lsymlink() ERROR"); 138 befs_debug(sb, "<--- %s ERROR", __func__);
139 return bytes_read; 139 return bytes_read;
140 140
141 } 141 }
@@ -146,7 +146,8 @@ befs_read_lsymlink(struct super_block * sb, befs_data_stream * ds, void *buff,
146 bytes_read += plen; 146 bytes_read += plen;
147 } 147 }
148 148
149 befs_debug(sb, "<--- befs_read_lsymlink() read %u bytes", bytes_read); 149 befs_debug(sb, "<--- %s read %u bytes", __func__, (unsigned int)
150 bytes_read);
150 return bytes_read; 151 return bytes_read;
151} 152}
152 153
@@ -169,7 +170,7 @@ befs_count_blocks(struct super_block * sb, befs_data_stream * ds)
169 befs_blocknr_t metablocks; /* FS metadata blocks */ 170 befs_blocknr_t metablocks; /* FS metadata blocks */
170 befs_sb_info *befs_sb = BEFS_SB(sb); 171 befs_sb_info *befs_sb = BEFS_SB(sb);
171 172
172 befs_debug(sb, "---> befs_count_blocks()"); 173 befs_debug(sb, "---> %s", __func__);
173 174
174 datablocks = ds->size >> befs_sb->block_shift; 175 datablocks = ds->size >> befs_sb->block_shift;
175 if (ds->size & (befs_sb->block_size - 1)) 176 if (ds->size & (befs_sb->block_size - 1))
@@ -206,7 +207,7 @@ befs_count_blocks(struct super_block * sb, befs_data_stream * ds)
206 } 207 }
207 208
208 blocks = datablocks + metablocks; 209 blocks = datablocks + metablocks;
209 befs_debug(sb, "<--- befs_count_blocks() %u blocks", blocks); 210 befs_debug(sb, "<--- %s %u blocks", __func__, (unsigned int)blocks);
210 211
211 return blocks; 212 return blocks;
212} 213}
@@ -251,11 +252,11 @@ befs_find_brun_direct(struct super_block *sb, befs_data_stream * data,
251 befs_blocknr_t max_block = 252 befs_blocknr_t max_block =
252 data->max_direct_range >> BEFS_SB(sb)->block_shift; 253 data->max_direct_range >> BEFS_SB(sb)->block_shift;
253 254
254 befs_debug(sb, "---> befs_find_brun_direct(), find %lu", blockno); 255 befs_debug(sb, "---> %s, find %lu", __func__, (unsigned long)blockno);
255 256
256 if (blockno > max_block) { 257 if (blockno > max_block) {
257 befs_error(sb, "befs_find_brun_direct() passed block outside of" 258 befs_error(sb, "%s passed block outside of direct region",
258 "direct region"); 259 __func__);
259 return BEFS_ERR; 260 return BEFS_ERR;
260 } 261 }
261 262
@@ -267,13 +268,14 @@ befs_find_brun_direct(struct super_block *sb, befs_data_stream * data,
267 run->start = array[i].start + offset; 268 run->start = array[i].start + offset;
268 run->len = array[i].len - offset; 269 run->len = array[i].len - offset;
269 270
270 befs_debug(sb, "---> befs_find_brun_direct(), " 271 befs_debug(sb, "---> %s, "
271 "found %lu at direct[%d]", blockno, i); 272 "found %lu at direct[%d]", __func__,
273 (unsigned long)blockno, i);
272 return BEFS_OK; 274 return BEFS_OK;
273 } 275 }
274 } 276 }
275 277
276 befs_debug(sb, "---> befs_find_brun_direct() ERROR"); 278 befs_debug(sb, "---> %s ERROR", __func__);
277 return BEFS_ERR; 279 return BEFS_ERR;
278} 280}
279 281
@@ -316,7 +318,7 @@ befs_find_brun_indirect(struct super_block *sb,
316 befs_blocknr_t indirblockno = iaddr2blockno(sb, &indirect); 318 befs_blocknr_t indirblockno = iaddr2blockno(sb, &indirect);
317 int arraylen = befs_iaddrs_per_block(sb); 319 int arraylen = befs_iaddrs_per_block(sb);
318 320
319 befs_debug(sb, "---> befs_find_brun_indirect(), find %lu", blockno); 321 befs_debug(sb, "---> %s, find %lu", __func__, (unsigned long)blockno);
320 322
321 indir_start_blk = data->max_direct_range >> BEFS_SB(sb)->block_shift; 323 indir_start_blk = data->max_direct_range >> BEFS_SB(sb)->block_shift;
322 search_blk = blockno - indir_start_blk; 324 search_blk = blockno - indir_start_blk;
@@ -325,10 +327,9 @@ befs_find_brun_indirect(struct super_block *sb,
325 for (i = 0; i < indirect.len; i++) { 327 for (i = 0; i < indirect.len; i++) {
326 indirblock = befs_bread(sb, indirblockno + i); 328 indirblock = befs_bread(sb, indirblockno + i);
327 if (indirblock == NULL) { 329 if (indirblock == NULL) {
328 befs_debug(sb, 330 befs_debug(sb, "---> %s failed to read "
329 "---> befs_find_brun_indirect() failed to " 331 "disk block %lu from the indirect brun",
330 "read disk block %lu from the indirect brun", 332 __func__, (unsigned long)indirblockno + i);
331 indirblockno + i);
332 return BEFS_ERR; 333 return BEFS_ERR;
333 } 334 }
334 335
@@ -348,9 +349,10 @@ befs_find_brun_indirect(struct super_block *sb,
348 349
349 brelse(indirblock); 350 brelse(indirblock);
350 befs_debug(sb, 351 befs_debug(sb,
351 "<--- befs_find_brun_indirect() found " 352 "<--- %s found file block "
352 "file block %lu at indirect[%d]", 353 "%lu at indirect[%d]", __func__,
353 blockno, j + (i * arraylen)); 354 (unsigned long)blockno,
355 j + (i * arraylen));
354 return BEFS_OK; 356 return BEFS_OK;
355 } 357 }
356 sum += len; 358 sum += len;
@@ -360,10 +362,10 @@ befs_find_brun_indirect(struct super_block *sb,
360 } 362 }
361 363
362 /* Only fallthrough is an error */ 364 /* Only fallthrough is an error */
363 befs_error(sb, "BeFS: befs_find_brun_indirect() failed to find " 365 befs_error(sb, "BeFS: %s failed to find "
364 "file block %lu", blockno); 366 "file block %lu", __func__, (unsigned long)blockno);
365 367
366 befs_debug(sb, "<--- befs_find_brun_indirect() ERROR"); 368 befs_debug(sb, "<--- %s ERROR", __func__);
367 return BEFS_ERR; 369 return BEFS_ERR;
368} 370}
369 371
@@ -444,7 +446,7 @@ befs_find_brun_dblindirect(struct super_block *sb,
444 size_t diblklen = iblklen * befs_iaddrs_per_block(sb) 446 size_t diblklen = iblklen * befs_iaddrs_per_block(sb)
445 * BEFS_DBLINDIR_BRUN_LEN; 447 * BEFS_DBLINDIR_BRUN_LEN;
446 448
447 befs_debug(sb, "---> befs_find_brun_dblindirect() find %lu", blockno); 449 befs_debug(sb, "---> %s find %lu", __func__, (unsigned long)blockno);
448 450
449 /* First, discover which of the double_indir->indir blocks 451 /* First, discover which of the double_indir->indir blocks
450 * contains pos. Then figure out how much of pos that 452 * contains pos. Then figure out how much of pos that
@@ -460,8 +462,9 @@ befs_find_brun_dblindirect(struct super_block *sb,
460 dbl_which_block = dblindir_indx / befs_iaddrs_per_block(sb); 462 dbl_which_block = dblindir_indx / befs_iaddrs_per_block(sb);
461 if (dbl_which_block > data->double_indirect.len) { 463 if (dbl_which_block > data->double_indirect.len) {
462 befs_error(sb, "The double-indirect index calculated by " 464 befs_error(sb, "The double-indirect index calculated by "
463 "befs_read_brun_dblindirect(), %d, is outside the range " 465 "%s, %d, is outside the range "
464 "of the double-indirect block", dblindir_indx); 466 "of the double-indirect block", __func__,
467 dblindir_indx);
465 return BEFS_ERR; 468 return BEFS_ERR;
466 } 469 }
467 470
@@ -469,10 +472,10 @@ befs_find_brun_dblindirect(struct super_block *sb,
469 befs_bread(sb, iaddr2blockno(sb, &data->double_indirect) + 472 befs_bread(sb, iaddr2blockno(sb, &data->double_indirect) +
470 dbl_which_block); 473 dbl_which_block);
471 if (dbl_indir_block == NULL) { 474 if (dbl_indir_block == NULL) {
472 befs_error(sb, "befs_read_brun_dblindirect() couldn't read the " 475 befs_error(sb, "%s couldn't read the "
473 "double-indirect block at blockno %lu", 476 "double-indirect block at blockno %lu", __func__,
474 iaddr2blockno(sb, 477 (unsigned long)
475 &data->double_indirect) + 478 iaddr2blockno(sb, &data->double_indirect) +
476 dbl_which_block); 479 dbl_which_block);
477 brelse(dbl_indir_block); 480 brelse(dbl_indir_block);
478 return BEFS_ERR; 481 return BEFS_ERR;
@@ -489,16 +492,16 @@ befs_find_brun_dblindirect(struct super_block *sb,
489 which_block = indir_indx / befs_iaddrs_per_block(sb); 492 which_block = indir_indx / befs_iaddrs_per_block(sb);
490 if (which_block > indir_run.len) { 493 if (which_block > indir_run.len) {
491 befs_error(sb, "The indirect index calculated by " 494 befs_error(sb, "The indirect index calculated by "
492 "befs_read_brun_dblindirect(), %d, is outside the range " 495 "%s, %d, is outside the range "
493 "of the indirect block", indir_indx); 496 "of the indirect block", __func__, indir_indx);
494 return BEFS_ERR; 497 return BEFS_ERR;
495 } 498 }
496 499
497 indir_block = 500 indir_block =
498 befs_bread(sb, iaddr2blockno(sb, &indir_run) + which_block); 501 befs_bread(sb, iaddr2blockno(sb, &indir_run) + which_block);
499 if (indir_block == NULL) { 502 if (indir_block == NULL) {
500 befs_error(sb, "befs_read_brun_dblindirect() couldn't read the " 503 befs_error(sb, "%s couldn't read the indirect block "
501 "indirect block at blockno %lu", 504 "at blockno %lu", __func__, (unsigned long)
502 iaddr2blockno(sb, &indir_run) + which_block); 505 iaddr2blockno(sb, &indir_run) + which_block);
503 brelse(indir_block); 506 brelse(indir_block);
504 return BEFS_ERR; 507 return BEFS_ERR;
@@ -519,7 +522,7 @@ befs_find_brun_dblindirect(struct super_block *sb,
519 run->len -= offset; 522 run->len -= offset;
520 523
521 befs_debug(sb, "Found file block %lu in double_indirect[%d][%d]," 524 befs_debug(sb, "Found file block %lu in double_indirect[%d][%d],"
522 " double_indirect_leftover = %lu", 525 " double_indirect_leftover = %lu", (unsigned long)
523 blockno, dblindir_indx, indir_indx, dblindir_leftover); 526 blockno, dblindir_indx, indir_indx, dblindir_leftover);
524 527
525 return BEFS_OK; 528 return BEFS_OK;
diff --git a/fs/befs/debug.c b/fs/befs/debug.c
index 622e73775c83..4de7cffcd662 100644
--- a/fs/befs/debug.c
+++ b/fs/befs/debug.c
@@ -10,6 +10,7 @@
10 * debug functions 10 * debug functions
11 */ 11 */
12 12
13#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13#ifdef __KERNEL__ 14#ifdef __KERNEL__
14 15
15#include <stdarg.h> 16#include <stdarg.h>
@@ -23,43 +24,30 @@
23 24
24#include "befs.h" 25#include "befs.h"
25 26
26#define ERRBUFSIZE 1024
27
28void 27void
29befs_error(const struct super_block *sb, const char *fmt, ...) 28befs_error(const struct super_block *sb, const char *fmt, ...)
30{ 29{
30 struct va_format vaf;
31 va_list args; 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 32
38 va_start(args, fmt); 33 va_start(args, fmt);
39 vsnprintf(err_buf, ERRBUFSIZE, fmt, args); 34 vaf.fmt = fmt;
35 vaf.va = &args;
36 pr_err("(%s): %pV\n", sb->s_id, &vaf);
40 va_end(args); 37 va_end(args);
41
42 printk(KERN_ERR "BeFS(%s): %s\n", sb->s_id, err_buf);
43 kfree(err_buf);
44} 38}
45 39
46void 40void
47befs_warning(const struct super_block *sb, const char *fmt, ...) 41befs_warning(const struct super_block *sb, const char *fmt, ...)
48{ 42{
43 struct va_format vaf;
49 va_list args; 44 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 45
56 va_start(args, fmt); 46 va_start(args, fmt);
57 vsnprintf(err_buf, ERRBUFSIZE, fmt, args); 47 vaf.fmt = fmt;
48 vaf.va = &args;
49 pr_warn("(%s): %pV\n", sb->s_id, &vaf);
58 va_end(args); 50 va_end(args);
59
60 printk(KERN_WARNING "BeFS(%s): %s\n", sb->s_id, err_buf);
61
62 kfree(err_buf);
63} 51}
64 52
65void 53void
@@ -67,25 +55,13 @@ befs_debug(const struct super_block *sb, const char *fmt, ...)
67{ 55{
68#ifdef CONFIG_BEFS_DEBUG 56#ifdef CONFIG_BEFS_DEBUG
69 57
58 struct va_format vaf;
70 va_list args; 59 va_list args;
71 char *err_buf = NULL; 60 va_start(args, fmt);
72 61 vaf.fmt = fmt;
73 if (BEFS_SB(sb)->mount_opts.debug) { 62 vaf.va = &args;
74 err_buf = kmalloc(ERRBUFSIZE, GFP_KERNEL); 63 pr_debug("(%s): %pV\n", sb->s_id, &vaf);
75 if (err_buf == NULL) { 64 va_end(args);
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 65
90#endif //CONFIG_BEFS_DEBUG 66#endif //CONFIG_BEFS_DEBUG
91} 67}
@@ -109,9 +85,9 @@ befs_dump_inode(const struct super_block *sb, befs_inode * inode)
109 befs_debug(sb, " gid %u", fs32_to_cpu(sb, inode->gid)); 85 befs_debug(sb, " gid %u", fs32_to_cpu(sb, inode->gid));
110 befs_debug(sb, " mode %08x", fs32_to_cpu(sb, inode->mode)); 86 befs_debug(sb, " mode %08x", fs32_to_cpu(sb, inode->mode));
111 befs_debug(sb, " flags %08x", fs32_to_cpu(sb, inode->flags)); 87 befs_debug(sb, " flags %08x", fs32_to_cpu(sb, inode->flags));
112 befs_debug(sb, " create_time %Lu", 88 befs_debug(sb, " create_time %llu",
113 fs64_to_cpu(sb, inode->create_time)); 89 fs64_to_cpu(sb, inode->create_time));
114 befs_debug(sb, " last_modified_time %Lu", 90 befs_debug(sb, " last_modified_time %llu",
115 fs64_to_cpu(sb, inode->last_modified_time)); 91 fs64_to_cpu(sb, inode->last_modified_time));
116 92
117 tmp_run = fsrun_to_cpu(sb, inode->parent); 93 tmp_run = fsrun_to_cpu(sb, inode->parent);
@@ -137,7 +113,7 @@ befs_dump_inode(const struct super_block *sb, befs_inode * inode)
137 tmp_run.allocation_group, tmp_run.start, 113 tmp_run.allocation_group, tmp_run.start,
138 tmp_run.len); 114 tmp_run.len);
139 } 115 }
140 befs_debug(sb, " max_direct_range %Lu", 116 befs_debug(sb, " max_direct_range %llu",
141 fs64_to_cpu(sb, 117 fs64_to_cpu(sb,
142 inode->data.datastream. 118 inode->data.datastream.
143 max_direct_range)); 119 max_direct_range));
@@ -147,7 +123,7 @@ befs_dump_inode(const struct super_block *sb, befs_inode * inode)
147 tmp_run.allocation_group, 123 tmp_run.allocation_group,
148 tmp_run.start, tmp_run.len); 124 tmp_run.start, tmp_run.len);
149 125
150 befs_debug(sb, " max_indirect_range %Lu", 126 befs_debug(sb, " max_indirect_range %llu",
151 fs64_to_cpu(sb, 127 fs64_to_cpu(sb,
152 inode->data.datastream. 128 inode->data.datastream.
153 max_indirect_range)); 129 max_indirect_range));
@@ -158,12 +134,12 @@ befs_dump_inode(const struct super_block *sb, befs_inode * inode)
158 tmp_run.allocation_group, tmp_run.start, 134 tmp_run.allocation_group, tmp_run.start,
159 tmp_run.len); 135 tmp_run.len);
160 136
161 befs_debug(sb, " max_double_indirect_range %Lu", 137 befs_debug(sb, " max_double_indirect_range %llu",
162 fs64_to_cpu(sb, 138 fs64_to_cpu(sb,
163 inode->data.datastream. 139 inode->data.datastream.
164 max_double_indirect_range)); 140 max_double_indirect_range));
165 141
166 befs_debug(sb, " size %Lu", 142 befs_debug(sb, " size %llu",
167 fs64_to_cpu(sb, inode->data.datastream.size)); 143 fs64_to_cpu(sb, inode->data.datastream.size));
168 } 144 }
169 145
@@ -191,8 +167,8 @@ befs_dump_super_block(const struct super_block *sb, befs_super_block * sup)
191 befs_debug(sb, " block_size %u", fs32_to_cpu(sb, sup->block_size)); 167 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)); 168 befs_debug(sb, " block_shift %u", fs32_to_cpu(sb, sup->block_shift));
193 169
194 befs_debug(sb, " num_blocks %Lu", fs64_to_cpu(sb, sup->num_blocks)); 170 befs_debug(sb, " num_blocks %llu", fs64_to_cpu(sb, sup->num_blocks));
195 befs_debug(sb, " used_blocks %Lu", fs64_to_cpu(sb, sup->used_blocks)); 171 befs_debug(sb, " used_blocks %llu", fs64_to_cpu(sb, sup->used_blocks));
196 172
197 befs_debug(sb, " magic2 %08x", fs32_to_cpu(sb, sup->magic2)); 173 befs_debug(sb, " magic2 %08x", fs32_to_cpu(sb, sup->magic2));
198 befs_debug(sb, " blocks_per_ag %u", 174 befs_debug(sb, " blocks_per_ag %u",
@@ -206,8 +182,8 @@ befs_dump_super_block(const struct super_block *sb, befs_super_block * sup)
206 befs_debug(sb, " log_blocks %u, %hu, %hu", 182 befs_debug(sb, " log_blocks %u, %hu, %hu",
207 tmp_run.allocation_group, tmp_run.start, tmp_run.len); 183 tmp_run.allocation_group, tmp_run.start, tmp_run.len);
208 184
209 befs_debug(sb, " log_start %Ld", fs64_to_cpu(sb, sup->log_start)); 185 befs_debug(sb, " log_start %lld", fs64_to_cpu(sb, sup->log_start));
210 befs_debug(sb, " log_end %Ld", fs64_to_cpu(sb, sup->log_end)); 186 befs_debug(sb, " log_end %lld", fs64_to_cpu(sb, sup->log_end));
211 187
212 befs_debug(sb, " magic3 %08x", fs32_to_cpu(sb, sup->magic3)); 188 befs_debug(sb, " magic3 %08x", fs32_to_cpu(sb, sup->magic3));
213 189
diff --git a/fs/befs/inode.c b/fs/befs/inode.c
index 94c17f9a9576..fa4b718de597 100644
--- a/fs/befs/inode.c
+++ b/fs/befs/inode.c
@@ -25,7 +25,8 @@ befs_check_inode(struct super_block *sb, befs_inode * raw_inode,
25 /* check magic header. */ 25 /* check magic header. */
26 if (magic1 != BEFS_INODE_MAGIC1) { 26 if (magic1 != BEFS_INODE_MAGIC1) {
27 befs_error(sb, 27 befs_error(sb,
28 "Inode has a bad magic header - inode = %lu", inode); 28 "Inode has a bad magic header - inode = %lu",
29 (unsigned long)inode);
29 return BEFS_BAD_INODE; 30 return BEFS_BAD_INODE;
30 } 31 }
31 32
@@ -34,8 +35,8 @@ befs_check_inode(struct super_block *sb, befs_inode * raw_inode,
34 */ 35 */
35 if (inode != iaddr2blockno(sb, &ino_num)) { 36 if (inode != iaddr2blockno(sb, &ino_num)) {
36 befs_error(sb, "inode blocknr field disagrees with vfs " 37 befs_error(sb, "inode blocknr field disagrees with vfs "
37 "VFS: %lu, Inode %lu", 38 "VFS: %lu, Inode %lu", (unsigned long)
38 inode, iaddr2blockno(sb, &ino_num)); 39 inode, (unsigned long)iaddr2blockno(sb, &ino_num));
39 return BEFS_BAD_INODE; 40 return BEFS_BAD_INODE;
40 } 41 }
41 42
@@ -44,7 +45,8 @@ befs_check_inode(struct super_block *sb, befs_inode * raw_inode,
44 */ 45 */
45 46
46 if (!(flags & BEFS_INODE_IN_USE)) { 47 if (!(flags & BEFS_INODE_IN_USE)) {
47 befs_error(sb, "inode is not used - inode = %lu", inode); 48 befs_error(sb, "inode is not used - inode = %lu",
49 (unsigned long)inode);
48 return BEFS_BAD_INODE; 50 return BEFS_BAD_INODE;
49 } 51 }
50 52
diff --git a/fs/befs/io.c b/fs/befs/io.c
index ddef98aa255d..0408a3d601d0 100644
--- a/fs/befs/io.c
+++ b/fs/befs/io.c
@@ -30,9 +30,9 @@ befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr)
30 befs_blocknr_t block = 0; 30 befs_blocknr_t block = 0;
31 befs_sb_info *befs_sb = BEFS_SB(sb); 31 befs_sb_info *befs_sb = BEFS_SB(sb);
32 32
33 befs_debug(sb, "---> Enter befs_read_iaddr() " 33 befs_debug(sb, "---> Enter %s "
34 "[%u, %hu, %hu]", 34 "[%u, %hu, %hu]", __func__, iaddr.allocation_group,
35 iaddr.allocation_group, iaddr.start, iaddr.len); 35 iaddr.start, iaddr.len);
36 36
37 if (iaddr.allocation_group > befs_sb->num_ags) { 37 if (iaddr.allocation_group > befs_sb->num_ags) {
38 befs_error(sb, "BEFS: Invalid allocation group %u, max is %u", 38 befs_error(sb, "BEFS: Invalid allocation group %u, max is %u",
@@ -42,20 +42,21 @@ befs_bread_iaddr(struct super_block *sb, befs_inode_addr iaddr)
42 42
43 block = iaddr2blockno(sb, &iaddr); 43 block = iaddr2blockno(sb, &iaddr);
44 44
45 befs_debug(sb, "befs_read_iaddr: offset = %lu", block); 45 befs_debug(sb, "%s: offset = %lu", __func__, (unsigned long)block);
46 46
47 bh = sb_bread(sb, block); 47 bh = sb_bread(sb, block);
48 48
49 if (bh == NULL) { 49 if (bh == NULL) {
50 befs_error(sb, "Failed to read block %lu", block); 50 befs_error(sb, "Failed to read block %lu",
51 (unsigned long)block);
51 goto error; 52 goto error;
52 } 53 }
53 54
54 befs_debug(sb, "<--- befs_read_iaddr()"); 55 befs_debug(sb, "<--- %s", __func__);
55 return bh; 56 return bh;
56 57
57 error: 58 error:
58 befs_debug(sb, "<--- befs_read_iaddr() ERROR"); 59 befs_debug(sb, "<--- %s ERROR", __func__);
59 return NULL; 60 return NULL;
60} 61}
61 62
@@ -64,20 +65,21 @@ befs_bread(struct super_block *sb, befs_blocknr_t block)
64{ 65{
65 struct buffer_head *bh = NULL; 66 struct buffer_head *bh = NULL;
66 67
67 befs_debug(sb, "---> Enter befs_read() %Lu", block); 68 befs_debug(sb, "---> Enter %s %lu", __func__, (unsigned long)block);
68 69
69 bh = sb_bread(sb, block); 70 bh = sb_bread(sb, block);
70 71
71 if (bh == NULL) { 72 if (bh == NULL) {
72 befs_error(sb, "Failed to read block %lu", block); 73 befs_error(sb, "Failed to read block %lu",
74 (unsigned long)block);
73 goto error; 75 goto error;
74 } 76 }
75 77
76 befs_debug(sb, "<--- befs_read()"); 78 befs_debug(sb, "<--- %s", __func__);
77 79
78 return bh; 80 return bh;
79 81
80 error: 82 error:
81 befs_debug(sb, "<--- befs_read() ERROR"); 83 befs_debug(sb, "<--- %s ERROR", __func__);
82 return NULL; 84 return NULL;
83} 85}
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 079872d61f75..5188f1222987 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -5,6 +5,8 @@
5 * 5 *
6 */ 6 */
7 7
8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9
8#include <linux/module.h> 10#include <linux/module.h>
9#include <linux/slab.h> 11#include <linux/slab.h>
10#include <linux/fs.h> 12#include <linux/fs.h>
@@ -130,26 +132,28 @@ befs_get_block(struct inode *inode, sector_t block,
130 ulong disk_off; 132 ulong disk_off;
131 133
132 befs_debug(sb, "---> befs_get_block() for inode %lu, block %ld", 134 befs_debug(sb, "---> befs_get_block() for inode %lu, block %ld",
133 inode->i_ino, block); 135 (unsigned long)inode->i_ino, (long)block);
134 136
135 if (block < 0) { 137 if (block < 0) {
136 befs_error(sb, "befs_get_block() was asked for a block " 138 befs_error(sb, "befs_get_block() was asked for a block "
137 "number less than zero: block %ld in inode %lu", 139 "number less than zero: block %ld in inode %lu",
138 block, inode->i_ino); 140 (long)block, (unsigned long)inode->i_ino);
139 return -EIO; 141 return -EIO;
140 } 142 }
141 143
142 if (create) { 144 if (create) {
143 befs_error(sb, "befs_get_block() was asked to write to " 145 befs_error(sb, "befs_get_block() was asked to write to "
144 "block %ld in inode %lu", block, inode->i_ino); 146 "block %ld in inode %lu", (long)block,
147 (unsigned long)inode->i_ino);
145 return -EPERM; 148 return -EPERM;
146 } 149 }
147 150
148 res = befs_fblock2brun(sb, ds, block, &run); 151 res = befs_fblock2brun(sb, ds, block, &run);
149 if (res != BEFS_OK) { 152 if (res != BEFS_OK) {
150 befs_error(sb, 153 befs_error(sb,
151 "<--- befs_get_block() for inode %lu, block " 154 "<--- %s for inode %lu, block %ld ERROR",
152 "%ld ERROR", inode->i_ino, block); 155 __func__, (unsigned long)inode->i_ino,
156 (long)block);
153 return -EFBIG; 157 return -EFBIG;
154 } 158 }
155 159
@@ -157,8 +161,9 @@ befs_get_block(struct inode *inode, sector_t block,
157 161
158 map_bh(bh_result, inode->i_sb, disk_off); 162 map_bh(bh_result, inode->i_sb, disk_off);
159 163
160 befs_debug(sb, "<--- befs_get_block() for inode %lu, block %ld, " 164 befs_debug(sb, "<--- %s for inode %lu, block %ld, disk address %lu",
161 "disk address %lu", inode->i_ino, block, disk_off); 165 __func__, (unsigned long)inode->i_ino, (long)block,
166 (unsigned long)disk_off);
162 167
163 return 0; 168 return 0;
164} 169}
@@ -175,15 +180,15 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
175 char *utfname; 180 char *utfname;
176 const char *name = dentry->d_name.name; 181 const char *name = dentry->d_name.name;
177 182
178 befs_debug(sb, "---> befs_lookup() " 183 befs_debug(sb, "---> %s name %s inode %ld", __func__,
179 "name %s inode %ld", dentry->d_name.name, dir->i_ino); 184 dentry->d_name.name, dir->i_ino);
180 185
181 /* Convert to UTF-8 */ 186 /* Convert to UTF-8 */
182 if (BEFS_SB(sb)->nls) { 187 if (BEFS_SB(sb)->nls) {
183 ret = 188 ret =
184 befs_nls2utf(sb, name, strlen(name), &utfname, &utfnamelen); 189 befs_nls2utf(sb, name, strlen(name), &utfname, &utfnamelen);
185 if (ret < 0) { 190 if (ret < 0) {
186 befs_debug(sb, "<--- befs_lookup() ERROR"); 191 befs_debug(sb, "<--- %s ERROR", __func__);
187 return ERR_PTR(ret); 192 return ERR_PTR(ret);
188 } 193 }
189 ret = befs_btree_find(sb, ds, utfname, &offset); 194 ret = befs_btree_find(sb, ds, utfname, &offset);
@@ -194,12 +199,12 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
194 } 199 }
195 200
196 if (ret == BEFS_BT_NOT_FOUND) { 201 if (ret == BEFS_BT_NOT_FOUND) {
197 befs_debug(sb, "<--- befs_lookup() %s not found", 202 befs_debug(sb, "<--- %s %s not found", __func__,
198 dentry->d_name.name); 203 dentry->d_name.name);
199 return ERR_PTR(-ENOENT); 204 return ERR_PTR(-ENOENT);
200 205
201 } else if (ret != BEFS_OK || offset == 0) { 206 } else if (ret != BEFS_OK || offset == 0) {
202 befs_warning(sb, "<--- befs_lookup() Error"); 207 befs_warning(sb, "<--- %s Error", __func__);
203 return ERR_PTR(-ENODATA); 208 return ERR_PTR(-ENODATA);
204 } 209 }
205 210
@@ -209,7 +214,7 @@ befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
209 214
210 d_add(dentry, inode); 215 d_add(dentry, inode);
211 216
212 befs_debug(sb, "<--- befs_lookup()"); 217 befs_debug(sb, "<--- %s", __func__);
213 218
214 return NULL; 219 return NULL;
215} 220}
@@ -227,26 +232,25 @@ befs_readdir(struct file *file, struct dir_context *ctx)
227 char keybuf[BEFS_NAME_LEN + 1]; 232 char keybuf[BEFS_NAME_LEN + 1];
228 const char *dirname = file->f_path.dentry->d_name.name; 233 const char *dirname = file->f_path.dentry->d_name.name;
229 234
230 befs_debug(sb, "---> befs_readdir() " 235 befs_debug(sb, "---> %s name %s, inode %ld, ctx->pos %lld",
231 "name %s, inode %ld, ctx->pos %Ld", 236 __func__, dirname, inode->i_ino, ctx->pos);
232 dirname, inode->i_ino, ctx->pos);
233 237
234more: 238more:
235 result = befs_btree_read(sb, ds, ctx->pos, BEFS_NAME_LEN + 1, 239 result = befs_btree_read(sb, ds, ctx->pos, BEFS_NAME_LEN + 1,
236 keybuf, &keysize, &value); 240 keybuf, &keysize, &value);
237 241
238 if (result == BEFS_ERR) { 242 if (result == BEFS_ERR) {
239 befs_debug(sb, "<--- befs_readdir() ERROR"); 243 befs_debug(sb, "<--- %s ERROR", __func__);
240 befs_error(sb, "IO error reading %s (inode %lu)", 244 befs_error(sb, "IO error reading %s (inode %lu)",
241 dirname, inode->i_ino); 245 dirname, inode->i_ino);
242 return -EIO; 246 return -EIO;
243 247
244 } else if (result == BEFS_BT_END) { 248 } else if (result == BEFS_BT_END) {
245 befs_debug(sb, "<--- befs_readdir() END"); 249 befs_debug(sb, "<--- %s END", __func__);
246 return 0; 250 return 0;
247 251
248 } else if (result == BEFS_BT_EMPTY) { 252 } else if (result == BEFS_BT_EMPTY) {
249 befs_debug(sb, "<--- befs_readdir() Empty directory"); 253 befs_debug(sb, "<--- %s Empty directory", __func__);
250 return 0; 254 return 0;
251 } 255 }
252 256
@@ -259,7 +263,7 @@ more:
259 result = 263 result =
260 befs_utf2nls(sb, keybuf, keysize, &nlsname, &nlsnamelen); 264 befs_utf2nls(sb, keybuf, keysize, &nlsname, &nlsnamelen);
261 if (result < 0) { 265 if (result < 0) {
262 befs_debug(sb, "<--- befs_readdir() ERROR"); 266 befs_debug(sb, "<--- %s ERROR", __func__);
263 return result; 267 return result;
264 } 268 }
265 if (!dir_emit(ctx, nlsname, nlsnamelen, 269 if (!dir_emit(ctx, nlsname, nlsnamelen,
@@ -276,7 +280,7 @@ more:
276 ctx->pos++; 280 ctx->pos++;
277 goto more; 281 goto more;
278 282
279 befs_debug(sb, "<--- befs_readdir() pos %Ld", ctx->pos); 283 befs_debug(sb, "<--- %s pos %lld", __func__, ctx->pos);
280 284
281 return 0; 285 return 0;
282} 286}
@@ -320,7 +324,7 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
320 struct inode *inode; 324 struct inode *inode;
321 long ret = -EIO; 325 long ret = -EIO;
322 326
323 befs_debug(sb, "---> befs_read_inode() " "inode = %lu", ino); 327 befs_debug(sb, "---> %s inode = %lu", __func__, ino);
324 328
325 inode = iget_locked(sb, ino); 329 inode = iget_locked(sb, ino);
326 if (!inode) 330 if (!inode)
@@ -427,7 +431,7 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
427 } 431 }
428 432
429 brelse(bh); 433 brelse(bh);
430 befs_debug(sb, "<--- befs_read_inode()"); 434 befs_debug(sb, "<--- %s", __func__);
431 unlock_new_inode(inode); 435 unlock_new_inode(inode);
432 return inode; 436 return inode;
433 437
@@ -436,7 +440,7 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
436 440
437 unacquire_none: 441 unacquire_none:
438 iget_failed(inode); 442 iget_failed(inode);
439 befs_debug(sb, "<--- befs_read_inode() - Bad inode"); 443 befs_debug(sb, "<--- %s - Bad inode", __func__);
440 return ERR_PTR(ret); 444 return ERR_PTR(ret);
441} 445}
442 446
@@ -453,11 +457,9 @@ befs_init_inodecache(void)
453 SLAB_MEM_SPREAD), 457 SLAB_MEM_SPREAD),
454 init_once); 458 init_once);
455 if (befs_inode_cachep == NULL) { 459 if (befs_inode_cachep == NULL) {
456 printk(KERN_ERR "befs_init_inodecache: " 460 pr_err("%s: Couldn't initialize inode slabcache\n", __func__);
457 "Couldn't initialize inode slabcache\n");
458 return -ENOMEM; 461 return -ENOMEM;
459 } 462 }
460
461 return 0; 463 return 0;
462} 464}
463 465
@@ -543,16 +545,16 @@ befs_utf2nls(struct super_block *sb, const char *in,
543 */ 545 */
544 int maxlen = in_len + 1; 546 int maxlen = in_len + 1;
545 547
546 befs_debug(sb, "---> utf2nls()"); 548 befs_debug(sb, "---> %s", __func__);
547 549
548 if (!nls) { 550 if (!nls) {
549 befs_error(sb, "befs_utf2nls called with no NLS table loaded"); 551 befs_error(sb, "%s called with no NLS table loaded", __func__);
550 return -EINVAL; 552 return -EINVAL;
551 } 553 }
552 554
553 *out = result = kmalloc(maxlen, GFP_NOFS); 555 *out = result = kmalloc(maxlen, GFP_NOFS);
554 if (!*out) { 556 if (!*out) {
555 befs_error(sb, "befs_utf2nls() cannot allocate memory"); 557 befs_error(sb, "%s cannot allocate memory", __func__);
556 *out_len = 0; 558 *out_len = 0;
557 return -ENOMEM; 559 return -ENOMEM;
558 } 560 }
@@ -574,14 +576,14 @@ befs_utf2nls(struct super_block *sb, const char *in,
574 result[o] = '\0'; 576 result[o] = '\0';
575 *out_len = o; 577 *out_len = o;
576 578
577 befs_debug(sb, "<--- utf2nls()"); 579 befs_debug(sb, "<--- %s", __func__);
578 580
579 return o; 581 return o;
580 582
581 conv_err: 583 conv_err:
582 befs_error(sb, "Name using character set %s contains a character that " 584 befs_error(sb, "Name using character set %s contains a character that "
583 "cannot be converted to unicode.", nls->charset); 585 "cannot be converted to unicode.", nls->charset);
584 befs_debug(sb, "<--- utf2nls()"); 586 befs_debug(sb, "<--- %s", __func__);
585 kfree(result); 587 kfree(result);
586 return -EILSEQ; 588 return -EILSEQ;
587} 589}
@@ -622,16 +624,17 @@ befs_nls2utf(struct super_block *sb, const char *in,
622 * in special cases */ 624 * in special cases */
623 int maxlen = (3 * in_len) + 1; 625 int maxlen = (3 * in_len) + 1;
624 626
625 befs_debug(sb, "---> nls2utf()\n"); 627 befs_debug(sb, "---> %s\n", __func__);
626 628
627 if (!nls) { 629 if (!nls) {
628 befs_error(sb, "befs_nls2utf called with no NLS table loaded."); 630 befs_error(sb, "%s called with no NLS table loaded.",
631 __func__);
629 return -EINVAL; 632 return -EINVAL;
630 } 633 }
631 634
632 *out = result = kmalloc(maxlen, GFP_NOFS); 635 *out = result = kmalloc(maxlen, GFP_NOFS);
633 if (!*out) { 636 if (!*out) {
634 befs_error(sb, "befs_nls2utf() cannot allocate memory"); 637 befs_error(sb, "%s cannot allocate memory", __func__);
635 *out_len = 0; 638 *out_len = 0;
636 return -ENOMEM; 639 return -ENOMEM;
637 } 640 }
@@ -652,14 +655,14 @@ befs_nls2utf(struct super_block *sb, const char *in,
652 result[o] = '\0'; 655 result[o] = '\0';
653 *out_len = o; 656 *out_len = o;
654 657
655 befs_debug(sb, "<--- nls2utf()"); 658 befs_debug(sb, "<--- %s", __func__);
656 659
657 return i; 660 return i;
658 661
659 conv_err: 662 conv_err:
660 befs_error(sb, "Name using charecter set %s contains a charecter that " 663 befs_error(sb, "Name using charecter set %s contains a charecter that "
661 "cannot be converted to unicode.", nls->charset); 664 "cannot be converted to unicode.", nls->charset);
662 befs_debug(sb, "<--- nls2utf()"); 665 befs_debug(sb, "<--- %s", __func__);
663 kfree(result); 666 kfree(result);
664 return -EILSEQ; 667 return -EILSEQ;
665} 668}
@@ -714,8 +717,8 @@ parse_options(char *options, befs_mount_options * opts)
714 if (option >= 0) 717 if (option >= 0)
715 uid = make_kuid(current_user_ns(), option); 718 uid = make_kuid(current_user_ns(), option);
716 if (!uid_valid(uid)) { 719 if (!uid_valid(uid)) {
717 printk(KERN_ERR "BeFS: Invalid uid %d, " 720 pr_err("Invalid uid %d, "
718 "using default\n", option); 721 "using default\n", option);
719 break; 722 break;
720 } 723 }
721 opts->uid = uid; 724 opts->uid = uid;
@@ -728,8 +731,8 @@ parse_options(char *options, befs_mount_options * opts)
728 if (option >= 0) 731 if (option >= 0)
729 gid = make_kgid(current_user_ns(), option); 732 gid = make_kgid(current_user_ns(), option);
730 if (!gid_valid(gid)) { 733 if (!gid_valid(gid)) {
731 printk(KERN_ERR "BeFS: Invalid gid %d, " 734 pr_err("Invalid gid %d, "
732 "using default\n", option); 735 "using default\n", option);
733 break; 736 break;
734 } 737 }
735 opts->gid = gid; 738 opts->gid = gid;
@@ -739,8 +742,8 @@ parse_options(char *options, befs_mount_options * opts)
739 kfree(opts->iocharset); 742 kfree(opts->iocharset);
740 opts->iocharset = match_strdup(&args[0]); 743 opts->iocharset = match_strdup(&args[0]);
741 if (!opts->iocharset) { 744 if (!opts->iocharset) {
742 printk(KERN_ERR "BeFS: allocation failure for " 745 pr_err("allocation failure for "
743 "iocharset string\n"); 746 "iocharset string\n");
744 return 0; 747 return 0;
745 } 748 }
746 break; 749 break;
@@ -748,8 +751,8 @@ parse_options(char *options, befs_mount_options * opts)
748 opts->debug = 1; 751 opts->debug = 1;
749 break; 752 break;
750 default: 753 default:
751 printk(KERN_ERR "BeFS: Unrecognized mount option \"%s\" " 754 pr_err("Unrecognized mount option \"%s\" "
752 "or missing value\n", p); 755 "or missing value\n", p);
753 return 0; 756 return 0;
754 } 757 }
755 } 758 }
@@ -792,8 +795,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
792 795
793 sb->s_fs_info = kzalloc(sizeof(*befs_sb), GFP_KERNEL); 796 sb->s_fs_info = kzalloc(sizeof(*befs_sb), GFP_KERNEL);
794 if (sb->s_fs_info == NULL) { 797 if (sb->s_fs_info == NULL) {
795 printk(KERN_ERR 798 pr_err("(%s): Unable to allocate memory for private "
796 "BeFS(%s): Unable to allocate memory for private "
797 "portion of superblock. Bailing.\n", sb->s_id); 799 "portion of superblock. Bailing.\n", sb->s_id);
798 goto unacquire_none; 800 goto unacquire_none;
799 } 801 }
@@ -804,7 +806,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
804 goto unacquire_priv_sbp; 806 goto unacquire_priv_sbp;
805 } 807 }
806 808
807 befs_debug(sb, "---> befs_fill_super()"); 809 befs_debug(sb, "---> %s", __func__);
808 810
809#ifndef CONFIG_BEFS_RW 811#ifndef CONFIG_BEFS_RW
810 if (!(sb->s_flags & MS_RDONLY)) { 812 if (!(sb->s_flags & MS_RDONLY)) {
@@ -852,7 +854,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
852 goto unacquire_priv_sbp; 854 goto unacquire_priv_sbp;
853 855
854 if( befs_sb->num_blocks > ~((sector_t)0) ) { 856 if( befs_sb->num_blocks > ~((sector_t)0) ) {
855 befs_error(sb, "blocks count: %Lu " 857 befs_error(sb, "blocks count: %llu "
856 "is larger than the host can use", 858 "is larger than the host can use",
857 befs_sb->num_blocks); 859 befs_sb->num_blocks);
858 goto unacquire_priv_sbp; 860 goto unacquire_priv_sbp;
@@ -922,7 +924,7 @@ befs_statfs(struct dentry *dentry, struct kstatfs *buf)
922 struct super_block *sb = dentry->d_sb; 924 struct super_block *sb = dentry->d_sb;
923 u64 id = huge_encode_dev(sb->s_bdev->bd_dev); 925 u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
924 926
925 befs_debug(sb, "---> befs_statfs()"); 927 befs_debug(sb, "---> %s", __func__);
926 928
927 buf->f_type = BEFS_SUPER_MAGIC; 929 buf->f_type = BEFS_SUPER_MAGIC;
928 buf->f_bsize = sb->s_blocksize; 930 buf->f_bsize = sb->s_blocksize;
@@ -935,7 +937,7 @@ befs_statfs(struct dentry *dentry, struct kstatfs *buf)
935 buf->f_fsid.val[1] = (u32)(id >> 32); 937 buf->f_fsid.val[1] = (u32)(id >> 32);
936 buf->f_namelen = BEFS_NAME_LEN; 938 buf->f_namelen = BEFS_NAME_LEN;
937 939
938 befs_debug(sb, "<--- befs_statfs()"); 940 befs_debug(sb, "<--- %s", __func__);
939 941
940 return 0; 942 return 0;
941} 943}
@@ -961,7 +963,7 @@ init_befs_fs(void)
961{ 963{
962 int err; 964 int err;
963 965
964 printk(KERN_INFO "BeFS version: %s\n", BEFS_VERSION); 966 pr_info("version: %s\n", BEFS_VERSION);
965 967
966 err = befs_init_inodecache(); 968 err = befs_init_inodecache();
967 if (err) 969 if (err)