Esempio n. 1
0
static int compare_nodes (tree_s *a_tree, tree_s *b_tree, u64 a_blk, u64 b_blk)
{
	head_s	*a;
	head_s	*b;
	int	rc;

	a = tau_bget(tree_inode(a_tree), a_blk);
	if (!a) {
		eprintk("compare_nodes couldn't get 'a' blk %llx", a_blk);
		return qERR_BAD_TREE;
	}
	b = tau_bget(tree_inode(b_tree), b_blk);
	if (!b) {
		eprintk("compare_nodes couldn't get 'b' blk %llx", b_blk);
		return qERR_BAD_TREE;
	}
	if (memcmp(a, b, BLK_SIZE) != 0) {
		eprintk("a and b are not binary identical\n");
	}

	if (a->h_magic != b->h_magic) {
		eprintk("Magic doesn't match %x!=%x\n",
			a->h_magic, b->h_magic);
		tau_bput(a);
		tau_bput(b);
		return qERR_BAD_TREE;
	}
	if (a->h_blknum != b->h_blknum) {
		eprintk("Blknum doesn't match %llx!=%llx\n",
			a->h_blknum, b->h_blknum);
		tau_bput(a);
		tau_bput(b);
		return qERR_BAD_TREE;
	}
	switch (a->h_magic) {
	case LEAF:	rc = compare_leaves(a_tree, b_tree,
					(leaf_s *)a, (leaf_s *)b);
			break;
	case BRANCH:	rc = compare_branches(a_tree, b_tree,
					(branch_s *)a, (branch_s *)b);
			break;
	default:	eprintk("compare_nodes niether leaf nor branch");
			rc = qERR_BAD_TREE;
			break;
	}
	tau_bput(a);
	tau_bput(b);
	return rc;
}
Esempio n. 2
0
File: mtree.c Progetto: taysom/tau
static int compare_nodes (tree_s *a, tree_s *b, head_s *ahead, head_s *bhead)
{
    int	rc;

    if (!ahead) {
        if (bhead) return qERR_BAD_TREE;
        else return 0;
    } else if (!bhead) return qERR_BAD_TREE;

    if (memcmp(ahead, bhead, PAGE_SIZE) != 0) {
        eprintf("a and b are not binary identical\n");
    }

    if (ahead->h_magic != bhead->h_magic) {
        eprintf("Magic doesn't match %x!=%x\n",
                ahead->h_magic, bhead->h_magic);
        return qERR_BAD_TREE;
    }
    if (ahead->h_node != bhead->h_node) {
        eprintf("Blknum doesn't match %llx!=%llx\n",
                ahead->h_node, bhead->h_node);
        return qERR_BAD_TREE;
    }
    switch (ahead->h_magic) {
    case LEAF:
        rc = compare_leaves(a, b,
                            (leaf_s *)ahead, (leaf_s *)bhead);
        break;
    case BRANCH:
        rc = compare_branches(a, b,
                              (branch_s *)ahead, (branch_s *)bhead);
        break;
    default:
        eprintf("compare_nodes niether leaf nor branch");
        rc = qERR_BAD_TREE;
        break;
    }
    return rc;
}