commit.c (527491885554002837b5742202adc0ab5f536e54) | commit.c (17c2f9f85c896b48a5d74a9155d99ec5b241a0e6) |
---|---|
1/* 2 * This file is part of UBIFS. 3 * 4 * Copyright (C) 2006-2008 Nokia Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 as published by 8 * the Free Software Foundation. --- 456 unchanged lines hidden (view full) --- 465 * next old index check i.e. 'dbg_check_old_index()'. 466 * 467 * This function returns %0 on success and a negative error code on failure. 468 */ 469int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot) 470{ 471 struct ubifs_idx_node *idx; 472 int lnum, offs, len, err = 0; | 1/* 2 * This file is part of UBIFS. 3 * 4 * Copyright (C) 2006-2008 Nokia Corporation. 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 as published by 8 * the Free Software Foundation. --- 456 unchanged lines hidden (view full) --- 465 * next old index check i.e. 'dbg_check_old_index()'. 466 * 467 * This function returns %0 on success and a negative error code on failure. 468 */ 469int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot) 470{ 471 struct ubifs_idx_node *idx; 472 int lnum, offs, len, err = 0; |
473 struct ubifs_debug_info *d = c->dbg; |
|
473 | 474 |
474 c->old_zroot = *zroot; | 475 d->old_zroot = *zroot; 476 lnum = d->old_zroot.lnum; 477 offs = d->old_zroot.offs; 478 len = d->old_zroot.len; |
475 | 479 |
476 lnum = c->old_zroot.lnum; 477 offs = c->old_zroot.offs; 478 len = c->old_zroot.len; 479 | |
480 idx = kmalloc(c->max_idx_node_sz, GFP_NOFS); 481 if (!idx) 482 return -ENOMEM; 483 484 err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs); 485 if (err) 486 goto out; 487 | 480 idx = kmalloc(c->max_idx_node_sz, GFP_NOFS); 481 if (!idx) 482 return -ENOMEM; 483 484 err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs); 485 if (err) 486 goto out; 487 |
488 c->old_zroot_level = le16_to_cpu(idx->level); 489 c->old_zroot_sqnum = le64_to_cpu(idx->ch.sqnum); | 488 d->old_zroot_level = le16_to_cpu(idx->level); 489 d->old_zroot_sqnum = le64_to_cpu(idx->ch.sqnum); |
490out: 491 kfree(idx); 492 return err; 493} 494 495/** 496 * dbg_check_old_index - check the old copy of the index. 497 * @c: UBIFS file-system description object --- 6 unchanged lines hidden (view full) --- 504 * that the old index does indeed exist completely intact. 505 * 506 * This function returns %0 on success and a negative error code on failure. 507 */ 508int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot) 509{ 510 int lnum, offs, len, err = 0, uninitialized_var(last_level), child_cnt; 511 int first = 1, iip; | 490out: 491 kfree(idx); 492 return err; 493} 494 495/** 496 * dbg_check_old_index - check the old copy of the index. 497 * @c: UBIFS file-system description object --- 6 unchanged lines hidden (view full) --- 504 * that the old index does indeed exist completely intact. 505 * 506 * This function returns %0 on success and a negative error code on failure. 507 */ 508int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot) 509{ 510 int lnum, offs, len, err = 0, uninitialized_var(last_level), child_cnt; 511 int first = 1, iip; |
512 struct ubifs_debug_info *d = c->dbg; |
|
512 union ubifs_key lower_key, upper_key, l_key, u_key; 513 unsigned long long uninitialized_var(last_sqnum); 514 struct ubifs_idx_node *idx; 515 struct list_head list; 516 struct idx_node *i; 517 size_t sz; 518 519 if (!(ubifs_chk_flags & UBIFS_CHK_OLD_IDX)) 520 goto out; 521 522 INIT_LIST_HEAD(&list); 523 524 sz = sizeof(struct idx_node) + ubifs_idx_node_sz(c, c->fanout) - 525 UBIFS_IDX_NODE_SZ; 526 527 /* Start at the old zroot */ | 513 union ubifs_key lower_key, upper_key, l_key, u_key; 514 unsigned long long uninitialized_var(last_sqnum); 515 struct ubifs_idx_node *idx; 516 struct list_head list; 517 struct idx_node *i; 518 size_t sz; 519 520 if (!(ubifs_chk_flags & UBIFS_CHK_OLD_IDX)) 521 goto out; 522 523 INIT_LIST_HEAD(&list); 524 525 sz = sizeof(struct idx_node) + ubifs_idx_node_sz(c, c->fanout) - 526 UBIFS_IDX_NODE_SZ; 527 528 /* Start at the old zroot */ |
528 lnum = c->old_zroot.lnum; 529 offs = c->old_zroot.offs; 530 len = c->old_zroot.len; | 529 lnum = d->old_zroot.lnum; 530 offs = d->old_zroot.offs; 531 len = d->old_zroot.len; |
531 iip = 0; 532 533 /* 534 * Traverse the index tree preorder depth-first i.e. do a node and then 535 * its subtrees from left to right. 536 */ 537 while (1) { 538 struct ubifs_branch *br; --- 16 unchanged lines hidden (view full) --- 555 child_cnt = le16_to_cpu(idx->child_cnt); 556 if (child_cnt < 1 || child_cnt > c->fanout) { 557 err = 1; 558 goto out_dump; 559 } 560 if (first) { 561 first = 0; 562 /* Check root level and sqnum */ | 532 iip = 0; 533 534 /* 535 * Traverse the index tree preorder depth-first i.e. do a node and then 536 * its subtrees from left to right. 537 */ 538 while (1) { 539 struct ubifs_branch *br; --- 16 unchanged lines hidden (view full) --- 556 child_cnt = le16_to_cpu(idx->child_cnt); 557 if (child_cnt < 1 || child_cnt > c->fanout) { 558 err = 1; 559 goto out_dump; 560 } 561 if (first) { 562 first = 0; 563 /* Check root level and sqnum */ |
563 if (le16_to_cpu(idx->level) != c->old_zroot_level) { | 564 if (le16_to_cpu(idx->level) != d->old_zroot_level) { |
564 err = 2; 565 goto out_dump; 566 } | 565 err = 2; 566 goto out_dump; 567 } |
567 if (le64_to_cpu(idx->ch.sqnum) != c->old_zroot_sqnum) { | 568 if (le64_to_cpu(idx->ch.sqnum) != d->old_zroot_sqnum) { |
568 err = 3; 569 goto out_dump; 570 } 571 /* Set last values as though root had a parent */ 572 last_level = le16_to_cpu(idx->level) + 1; 573 last_sqnum = le64_to_cpu(idx->ch.sqnum) + 1; 574 key_read(c, ubifs_idx_key(c, idx), &lower_key); 575 highest_ino_key(c, &upper_key, INUM_WATERMARK); --- 103 unchanged lines hidden --- | 569 err = 3; 570 goto out_dump; 571 } 572 /* Set last values as though root had a parent */ 573 last_level = le16_to_cpu(idx->level) + 1; 574 last_sqnum = le64_to_cpu(idx->ch.sqnum) + 1; 575 key_read(c, ubifs_idx_key(c, idx), &lower_key); 576 highest_ino_key(c, &upper_key, INUM_WATERMARK); --- 103 unchanged lines hidden --- |