Beispiel #1
0
int ps3_repository_read_bus_id(unsigned int bus_index, u64 *bus_id)
{
	int result;

	result = read_node(PS3_LPAR_ID_PME,
		make_first_field("bus", bus_index),
		make_field("id", 0),
		0, 0,
		bus_id, NULL);
	return result;
}
Beispiel #2
0
/*
 * The format of a node is as follows:
 *   { 
 *	...node definitions...
 *	{ child node 1 }
 *	{ child node 2 }
 *	...
 *   }
 */
static mol_device_node_t *
read_node( char **rbuf, mol_device_node_t *parent ) 
{
	char *buf, *child, *start, *end;
	mol_device_node_t **next_sib;
	mol_device_node_t *retsib=NULL;

	buf = *rbuf;
	next_sib = &retsib;

	for(;;) {
		mol_device_node_t	*dn;

		if( !(start=strstr( buf, "{" )) )
			break;
		if( !(end=strstr( buf, "}" )) ) {
			printm("Parse error: Missing '{'\n");
			break;
		}

		/* end this hierarchy level if '}' precede '{' */
		if( start > end ) {
			buf = end+1;
			break;
		}

		/* replace next '}' and any child marker '{' with 0 */
		*end = 0;
		if( (child=strstr( start+1, "{")) )
			*child = 0;

		dn = build_node( start+1 );

		dn->parent = parent;
		*end++ = '}';

		/* read children */
		if( child ){
			*child = '{';
			end = child;
			dn->child = read_node( &end, dn );  /* child */
		}

		dn->allnext = oftree.allnext;
		oftree.allnext = dn;

		/* prepare for next sibling */
		*next_sib = dn;
		next_sib = &dn->sibling;		/* sibling */
		buf = end;
	}
	*rbuf = buf;
	return retsib;
}
Beispiel #3
0
/*************************************************************************
 * Read a tree from New Hampshire parentheses format from an open
 * FILE structure.
 *************************************************************************/
void read_tree
  (FILE *    tree_file,
   TREE_T ** a_tree)
{
  char one_char;

  get_non_blank(tree_file, &one_char);
  read_node(&one_char, tree_file, a_tree);
  fscanf(tree_file, "%*[^\n]");
  getc(tree_file);
}
Beispiel #4
0
void
read_and_print(int pos)
{
    struct node a;
    read_node(pos, &a);
    if (a.right_idx) {
        read_and_print(a.right_idx);
    }
    printf("%d ", a.key);
    if (a.left_idx)
        read_and_print(a.left_idx);
}
void print_node_info(char* filename, bool print_children, char* parent){
	//char *filename = "node_000001_root.dat";
	node_t *node = read_node(filename);
	printf("Node ID: %i\nNode filepath: %s\nParent: %s\nNode fanout: %i\nNode child_num: %i\n\n", node->id, node->filepath, parent, node->fanout, node->child_num );
	int i;
	

	if(print_children && !node->is_leaf) {
		for (i = 0; i < node->child_num; i++){
			print_node_info(node->children[i], true, node->filepath);
		}
	}
}
Beispiel #6
0
int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id)
{
	int result;
	u64 v1 = 0;

	result = read_node(PS3_LPAR_ID_CURRENT,
		make_first_field("bi", 0),
		make_field("spursvn", 0),
		0, 0,
		&v1, NULL);
	*num_resource_id = v1;
	return result;
}
Beispiel #7
0
/*
 * Reads the nodes into the given array.
 *
 * Return 0 on success and 1 on failure.
 */
static int read_nodes(FILE *f, struct node *nodes, unsigned int nnodes){
  unsigned int i;
  int err;

  for (i = 0; i < nnodes; i += 1) {
    err = read_node(f, nodes+i);
    if (err) {
      break;
    }
    nodes[i].dist = INFINITY;
  }
  return err;
}
Beispiel #8
0
int ps3_repository_read_num_be(unsigned int *num_be)
{
	int result;
	u64 v1 = 0;

	result = read_node(PS3_LPAR_ID_PME,
		make_first_field("ben", 0),
		0,
		0,
		0,
		&v1, NULL);
	*num_be = v1;
	return result;
}
Beispiel #9
0
int ps3_repository_read_vuart_sysmgr_port(unsigned int *port)
{
	int result;
	u64 v1 = 0;

	result = read_node(PS3_LPAR_ID_CURRENT,
		make_first_field("bi", 0),
		make_field("vir_uart", 0),
		make_field("port", 0),
		make_field("sysmgr", 0),
		&v1, NULL);
	*port = v1;
	return result;
}
Beispiel #10
0
int ps3_repository_read_boot_dat_size(unsigned int *size)
{
	int result;
	u64 v1 = 0;

	result = read_node(PS3_LPAR_ID_CURRENT,
		make_first_field("bi", 0),
		make_field("boot_dat", 0),
		make_field("size", 0),
		0,
		&v1, NULL);
	*size = v1;
	return result;
}
Beispiel #11
0
int ps3_repository_read_stor_dev_num_regions(unsigned int bus_index,
	unsigned int dev_index, unsigned int *num_regions)
{
	int result;
	u64 v1 = 0;

	result = read_node(PS3_LPAR_ID_PME,
		make_first_field("bus", bus_index),
		make_field("dev", dev_index),
		make_field("n_regs", 0),
		0, &v1, NULL);
	*num_regions = v1;
	return result;
}
Beispiel #12
0
int ps3_repository_read_bus_num_dev(unsigned int bus_index,
	unsigned int *num_dev)
{
	int result;
	u64 v1 = 0;

	result = read_node(PS3_LPAR_ID_PME,
		make_first_field("bus", bus_index),
		make_field("num_dev", 0),
		0, 0,
		&v1, NULL);
	*num_dev = v1;
	return result;
}
Beispiel #13
0
int ps3_repository_read_bus_type(unsigned int bus_index,
	enum ps3_bus_type *bus_type)
{
	int result;
	u64 v1 = 0;

	result = read_node(PS3_LPAR_ID_PME,
		make_first_field("bus", bus_index),
		make_field("type", 0),
		0, 0,
		&v1, NULL);
	*bus_type = v1;
	return result;
}
Beispiel #14
0
int ps3_repository_read_highmem_region_count(unsigned int *region_count)
{
	int result;
	u64 v1 = 0;

	result = read_node(PS3_LPAR_ID_CURRENT,
		make_first_field("highmem", 0),
		make_field("region", 0),
		make_field("count", 0),
		0,
		&v1, NULL);
	*region_count = v1;
	return result;
}
int dump_bptree_sequential(bptree_session *bps, uuid_t failed_node)
{
	int ksize, vsize, rv;
	unsigned char k[BPTREE_MAX_VALUE_SIZE], v[BPTREE_MAX_VALUE_SIZE];
	char uuid_out[40];
	char s1[512];
	char path[128];
    sprintf(path, "/tmp/%d.out", bps->bpt_id);
    FILE *fp = fopen(path,"w");
	//printf("Dumping bpt_id %d:\n",bps->bpt_id);
	//fflush(stdout);
	if (!uuid_is_null(failed_node))
	{
		bps->cursor_node = read_node(bps, failed_node, &rv);
		if(rv == BPTREE_OP_TAPIOCA_NOT_READY) return rv;
		bps->cursor_pos = 0;
		rv = bptree_index_next(bps, k, &ksize, v, &vsize);
		if (rv != BPTREE_OP_KEY_FOUND) return rv;
	}
	else
	{
		bptree_index_first(bps, k, &ksize, v, &vsize);
	}

	for(rv = 0;;)
	{
		bptree_key_value_to_string(bps, k,v,ksize,vsize,s1);
		uuid_unparse(bpnode_get_id(bps->cursor_node), uuid_out);
		fprintf(fp, "Node->Cell %s -> %d \t Key: %s \n",
				uuid_out, bps->cursor_pos, s1);
		rv = bptree_index_next(bps, k, &ksize, v, &vsize);
		if (rv != BPTREE_OP_KEY_FOUND) break;
	}
	if (rv == BPTREE_OP_EOF)
	{
		fprintf(fp, "\n\n");
		fflush(stdout);
		rv = BPTREE_OP_SUCCESS;
	}
	else if (rv == BPTREE_OP_TAPIOCA_NOT_READY)
	{
		uuid_copy(failed_node, bpnode_get_id(bps->cursor_node));
		//uuid_copy(failed_node, bps->cursor_node->self_key);
	}
	return rv;
	fflush(fp);
	fclose(fp);
}
Beispiel #16
0
/*
 * Reads the nodes into the given array.
 *
 * Return 0 on success and 1 on failure.
 */
static int read_nodes(FILE *f, struct node nodes[], unsigned int nnodes)
{
	unsigned int i;
	int err;

	for (i = 0; i < nnodes; i += 1) {
		err = read_node(f, &nodes[i]);
		if (err)
			break;
                nodes[i].parent = NULL;
                nodes[i].dist = INFINITY;
                nodes[i].heap_index = i;
	}

	return err;
}
Beispiel #17
0
int ps3_repository_read_stor_dev_region_id(unsigned int bus_index,
	unsigned int dev_index, unsigned int region_index,
	unsigned int *region_id)
{
	int result;
	u64 v1 = 0;

	result = read_node(PS3_LPAR_ID_PME,
	    make_first_field("bus", bus_index),
	    make_field("dev", dev_index),
	    make_field("region", region_index),
	    make_field("id", 0),
	    &v1, NULL);
	*region_id = v1;
	return result;
}
Beispiel #18
0
int ps3_repository_read_dev_reg_type(unsigned int bus_index,
	unsigned int dev_index, unsigned int reg_index,
	enum ps3_reg_type *reg_type)
{
	int result;
	u64 v1 = 0;

	result = read_node(PS3_LPAR_ID_PME,
		make_first_field("bus", bus_index),
		make_field("dev", dev_index),
		make_field("reg", reg_index),
		make_field("type", 0),
		&v1, NULL);
	*reg_type = v1;
	return result;
}
Beispiel #19
0
int ps3_repository_read_lpm_privileges(unsigned int be_index, u64 *lpar,
	u64 *rights)
{
	int result;
	u64 node_id;

	*lpar = 0;
	*rights = 0;
	result = ps3_repository_read_be_node_id(be_index, &node_id);
	return result ? result
		: read_node(PS3_LPAR_ID_PME,
			    make_first_field("be", 0),
			    node_id,
			    make_field("lpm", 0),
			    make_field("priv", 0),
			    lpar, rights);
}
Beispiel #20
0
int ps3_repository_read_spu_resource_id(unsigned int res_index,
	enum ps3_spu_resource_type *resource_type, unsigned int *resource_id)
{
	int result;
	u64 v1 = 0;
	u64 v2 = 0;

	result = read_node(PS3_LPAR_ID_CURRENT,
		make_first_field("bi", 0),
		make_field("spursv", 0),
		res_index,
		0,
		&v1, &v2);
	*resource_type = v1;
	*resource_id = v2;
	return result;
}
Beispiel #21
0
// Finds and dumps exact match, returns false if nothing can be found
bool find_exact_match (uint32_t offset, uint16_t* search_str, int str_len) {
	bool result = false;
	
	int searchResult = do_find_exact_match(offset, search_str, str_len);
	if (searchResult != 0) {
		doseek(searchResult);
		Node node;
		read_node(node);

		if (node.valueArticle != 0) {
			result = true;
			dump_article(node.valueArticle);
		}
	}

	return result;
}
Beispiel #22
0
int ps3_repository_read_dev_intr(unsigned int bus_index,
	unsigned int dev_index, unsigned int intr_index,
	enum ps3_interrupt_type *intr_type, unsigned int *interrupt_id)
{
	int result;
	u64 v1 = 0;
	u64 v2 = 0;

	result = read_node(PS3_LPAR_ID_PME,
		make_first_field("bus", bus_index),
		make_field("dev", dev_index),
		make_field("intr", intr_index),
		0,
		&v1, &v2);
	*intr_type = v1;
	*interrupt_id = v2;
	return result;
}
static int get_range_info(struct device_node* np,
		struct hisi_iommu_domain *domain,
		struct iommu_domain_capablity *data)
{
	int ret;
	ret = read_node(np,&domain->range,"linear");
	if(ret){
		printk("%s: read linear device node error \n",__func__);
	}

	/*save address range for ion allocator*/
	data->iova_start = domain->range.iova_start;
	data->iova_end  = domain->range.iova_start + domain->range.iova_size;
	data->iova_align = domain->range.align;
	printk("%s:iova_start=0x%x,iova_end=0x%x, iova_align=0x%x \n",
			__func__,data->iova_start,data->iova_end, data->iova_align);
	return 0;
}
Beispiel #24
0
static mol_device_node_t *
import_node( const char *filename, mol_device_node_t *par )
{
	mol_device_node_t *node;
	char *buf, *rbuf;
	int fd;
	off_t size;
	
	if( (fd=open(filename, O_RDONLY)) == -1 ) {
		printm("Failed opening '%s'\n", filename );
		return NULL;
	}
	size = lseek( fd, 0, SEEK_END );
	lseek( fd, 0, SEEK_SET );

	if( !(buf=malloc( size+1 )) ) {
		close(fd);
		return NULL;
	}
	
	if(read( fd, (void*)buf, size ) < size) {
		free(buf);
		close(fd);
		return NULL;
	}

	buf[size]=0;
	
	rbuf = buf;
	node = read_node( &rbuf, NULL );

	free(buf);
	close( fd );

	if( par && node ) {
		mol_device_node_t *last_sib;
		for( last_sib = node; last_sib->sibling; last_sib = last_sib->sibling )
			;
		last_sib->sibling = par->child;
		par->child = node;
		node->parent = par;
	}
     	return node;
}
int CVQlib::read_node(
	dssa_params *dssa,
	struct class_tree_node **node,
	FILE *fil_nodes,
	unsigned int *node_cnt
){
	int cv_cnt;


	/*Allocate memory for node.*/
	*node = (struct class_tree_node *)malloc(sizeof(struct class_tree_node));
	if( *node == NULL )
	{
		#ifndef REALTIME
		perror("dssa_detect:read_node:error allocating vector buffer");
		#endif
		return NOT_OK;
	}

	if( fread(*node,sizeof(struct class_tree_node),1,fil_nodes) != 1)
	{
		#ifndef REALTIME
		perror("dssa_detect:read_node:error reading node:");
		#endif
		return NOT_OK;
	}

	*node_cnt += 1;

	for(cv_cnt=0; cv_cnt<(int)dssa->cbk_size; cv_cnt++)
	{
		if( (*node)->child[cv_cnt] != NULL )
		{
			read_node(dssa,&((*node)->child[cv_cnt]),fil_nodes,node_cnt);
		}
	}

	return OK;

}/*read_node*/
Beispiel #26
0
FBXSceneImporter::FBXSceneImporter(std::string file_name)
{
	std::string log_file_name = file_name;
	log_file_name.append("log.txt");
	myfile.open(log_file_name.c_str());

	// Initialize the SDK manager. This object handles memory management.
	lSdkManager = FbxManager::Create();

	FbxIOSettings *ios = FbxIOSettings::Create(lSdkManager, IOSROOT);
	lSdkManager->SetIOSettings(ios);

	// Create an importer using the SDK manager.
	FbxImporter* lImporter = FbxImporter::Create(lSdkManager, "");

	// Use the first argument as the filename for the importer.
	if (!lImporter->Initialize(file_name.c_str(), -1, lSdkManager->GetIOSettings())) {
		myfile << "Call to FbxImporter::Initialize() failed.\n";
		myfile << "Error returned: " <<  lImporter->GetStatus().GetErrorString() << "";
		myfile.close();
		exit(-1);
	}

	// Create a new scene so that it can be populated by the imported file.
	lScene = FbxScene::Create(lSdkManager, "myScene");

	// Import the contents of the file into the scene.
	lImporter->Import(lScene);

	// The file is imported, so get rid of the importer.
	lImporter->Destroy();

	FbxGeometryConverter converter(lSdkManager);
	converter.Triangulate(lScene, true);

	scene_to_fill = new Scene(Utilities::get_file_name_from_path_wo_extension(file_name));
	resource_manager.add_scene(scene_to_fill);

	// Print the nodes of the scene and their attributes recursively.
	// Note that we are not printing the root node because it should
	// not contain any attributes.
	FbxNode* lRootNode = lScene->GetRootNode();
	if (lRootNode) 
	{
		for (int i = 0; i < lRootNode->GetChildCount(); i++)
		{
			read_node(lRootNode->GetChild(i));
		}
	}

	if (lRootNode)
	{
		for (int i = 0; i < lRootNode->GetChildCount(); i++)
		{
			PrintNode(lRootNode->GetChild(i));
		}
	}

	// Destroy the SDK manager and all the other objects it was handling.
	myfile.close();
	lSdkManager->Destroy();

}
Beispiel #27
0
void read(context_t* context, const reader_t* reader)
{
    read_node(context, &reader->root);
}
int output_bptree_recursive(bptree_session *bps,bptree_node* n,
		int level, FILE *fp) {
	int k,c, rv;
	char uuid_out_n[40], uuid_out_c[40];
	char uuid_upper[9];
	char s1[512], s2[512];
	bptree_key_val kv;
	char *key_str;
	assert (bpnode_size(n) <= 2*BPTREE_MIN_DEGREE-1);
	uuid_unparse(bpnode_get_id(n), uuid_out_n);
	fprintf(fp, "\n\n");
	fprintf(fp, "\"N-%s\" [ label = < ", uuid_out_n);
	// use the first 8 chars of the uuid as the label
	strncpy(uuid_upper, uuid_out_n, 8);
	char ch = 'I';
	if(bpnode_is_leaf(n)) ch = 'L';
	uuid_upper[8] = '\0';
//	fprintf(fp, "%s (%d) [%d] %c :  ", uuid_upper, bpnode_size(n), n->tapioca_client_id, ch);
	if (bpnode_size(n) > 0) {
		bpnode_get_kv_ref(n, 0, &kv);
		bptree_key_value_to_string_kv(bps, &kv, s1);
		//	free(key_str);
		fprintf(fp, "  %s  ", s1);
		bpnode_get_kv_ref(n, bpnode_size(n)-1, &kv);
		bptree_key_value_to_string_kv(bps, &kv, s2);
		//	free(key_str);
		fprintf(fp, " %s ", s2);

	}
	fprintf(fp, " > ");
	if (uuid_is_null(bpnode_get_parent_id(n))) fprintf(fp, " , shape=\"diamond\"");
	else if (!bpnode_is_leaf(n)) fprintf(fp, " , shape=\"rect\"");
	fprintf(fp, " ] \n");
	if (!bpnode_is_leaf(n)) {
		for (c = 0; c <= bpnode_size(n); c++) {
			uuid_unparse(bpnode_get_child_id(n, c), uuid_out_c);
			fprintf(fp, "\"N-%s\" -> \"N-%s\"\n [color=\"#CC0000\"] ",
					uuid_out_n, uuid_out_c);
		}
		for (c = 0; c <= bpnode_size(n); c++) {
			bptree_node *next;
			next = read_node(bps,bpnode_get_child_id(n, c), &rv);
			if ( next == NULL) return -1;
			output_bptree_recursive(bps, next, level+1, fp);
		}
	} else {
		uuid_unparse(bpnode_get_next_id(n), uuid_out_c);
		if (!uuid_is_null(bpnode_get_next_id(n)))
			fprintf(fp, "\"N-%s\" -> \"N-%s\"\n ", uuid_out_n, uuid_out_c);
//		if (!uuid_is_null(n->prev_node))
//			uuid_unparse(n->prev_node, uuid_out_c);
//		fprintf(fp, "\"N-%s\" -> \"N-%s\" [weight = 100.0]\n ", uuid_out_n, uuid_out_c);
	}
//	// Print parent link
//	uuid_unparse(bpnode_get_parent_id(n), uuid_out_c);
//	if (!uuid_is_null(bpnode_get_parent_id(n)))
//		fprintf(fp, "\"N-%s\" -> \"N-%s\" [color=\"#CC0000\"] \n ",
//			uuid_out_n, uuid_out_c);
//
	return BPTREE_OP_SUCCESS;
}
//int
bptree_key_val *
verify_bptree_recursive_read(bptree_session *bps,bptree_node *n,
		int dump_to_text, FILE *fp, int level, int *rv)
{
	int c, rv2, invalid = 1;
	bptree_key_val loc_max;
	char s1[512], s2[512], uuid_out[40];
	bptree_key_val *subtree_max = malloc(sizeof(bptree_key_val));

	bpnode_get_kv_ref(n, bpnode_size(n) - 1, &loc_max);

	if (is_node_ordered(bps, n) != 0)
	{
		printf("Bpt %d cell %ld was not ordered!\n", 
		       bps->bpt_id, bpnode_get_id(n));
		*rv = 0;
		return NULL;
	}

	if (!bpnode_is_leaf(n))
	{
		for (c = 0; c <= bpnode_size(n); c++)
		{
			bptree_node *child;
			bptree_key_val *kv;
			child = read_node(bps,bpnode_get_child_id(n, c), &rv2);
			int rv3 = is_valid_traversal(bps, n, child, c);
			if (rv3 != 0) {
				
				printf ("Caught invalid traversal pos %d!\n", c);
				dump_node_info(bps,n);
				printf("\nchild:\n");
				dump_node_info(bps,child);
				*rv = rv3;
				return NULL;
			}
			if (rv2 != BPTREE_OP_NODE_FOUND)
			{
				*rv = rv2;
				return NULL;
			}
			if (dump_to_text && c < bpnode_size(n))
			{
				int i;
				bptree_key_val kv_out;
				bpnode_get_kv_ref(n,c, &kv_out);
				bptree_key_value_to_string_kv(bps, &kv_out, s1);
				uuid_unparse(bpnode_get_id(n),uuid_out);
				fprintf(fp,"%d",level);
				for (i = 0 ; i<level; i++) fprintf(fp, "-");
				fprintf(fp, " Node->Cell %s -> %d \t Key: %s \t chld_sz %d \n",
						uuid_out, c, s1, bpnode_size(child));
			}
			kv = verify_bptree_recursive_read(bps, child, dump_to_text,fp, level+1, &rv2);
			if (rv2 != BPTREE_OP_SUCCESS)
			{
				*rv = rv2;
				return NULL;
			}

			// The max key in this node should be greater than all child maxes
			// other than the final node
			invalid = 0;
			if (c < bpnode_size(n) && bptree_compar_keys(bps, kv, &loc_max) > 0)
			{
				invalid = 1;
			}
			else if (c>= bpnode_size(n))
			{
				if(bptree_compar_keys(bps,kv,&loc_max) < 0) invalid = 2;
				copy_key_val(subtree_max, kv);
			}

			if (invalid)
			{
				bptree_key_value_to_string_kv(bps,kv, s1);
				bptree_key_value_to_string_kv(bps,&loc_max, s2),
				printf("B+Tree recursive validation failed, %s , %s, inv %d\n",
						s1, s2, invalid);
				fflush(stdout);
				*rv = 0;
				return NULL;
			}
			free_key_val(&kv);
			free_node(&child);
		}
	}
	else {
		copy_key_val(subtree_max, &loc_max);
		if (dump_to_text)
		{
			int c;
			for (c = 0; c < bpnode_size(n); c++) {
				int i;
				bptree_key_val kv_out;
				bpnode_get_kv_ref(n,c, &kv_out);
				bptree_key_value_to_string_kv(bps, &kv_out, s1);
				uuid_unparse(bpnode_get_id(n),uuid_out);
				fprintf(fp,"%d",level);
				for (i = 0 ; i<level; i++) fprintf(fp, "-");
				fprintf(fp, " Node->Cell %s -> %d \t Key: %s \t chld_sz %d \n",
						uuid_out, c, s1, 0);
			}
			// Don't dump the leaf nodes for now, we have them sequentially */
			//bptree_key_value_to_string_kv(bps, loc, s1);
			//uuid_unparse(bps->cursor_node->self_key,uuid_out);
			//fprintf(fp, "Leaf  Node->Cell %s -> %d \t Key: %s \n",
					//uuid_out, bps->cursor_pos, s1);
		}
	}
	*rv = BPTREE_OP_SUCCESS;
	return subtree_max;
}
// TODO Something in this function is messing up cursor positioning for a
// successive call to bptree_first
int verify_bptree_sequential(bptree_session *bps, uuid_t failed_node)
{
	int ksize_p, vsize_p, ksize_c, vsize_c, rv;
	const int BUF_SZ = 1024;
	unsigned char kcur[BUF_SZ], kprev[BUF_SZ], vcur[BUF_SZ], vprev[BUF_SZ];
	char s1[512], s2[512];
	int elements = 1;
	bzero(kcur, BUF_SZ);
	bzero(vcur, BUF_SZ);
	bzero(kprev, BUF_SZ);
	bzero(vprev, BUF_SZ);

	if (!uuid_is_null(failed_node))
	{
//		uuid_copy(bps->cursor_cell_id, failed_node);
		bps->cursor_node = read_node(bps, failed_node, &rv);
		if(rv == BPTREE_OP_TAPIOCA_NOT_READY) return rv;
		bps->cursor_pos = 0;

		rv = bptree_index_next(bps, kprev, &ksize_p, vprev, &vsize_p);
//		if (rv == BPTREE_OP_TAPIOCA_NOT_READY)
//			uuid_copy(failed_node, bps->cursor_node->self_key);
		if (rv != BPTREE_OP_KEY_FOUND) return rv;
	}
	else
	{
		rv = bptree_index_first(bps, kprev, &ksize_p, vprev, &vsize_p);
	}
	if (rv < 0) return rv;
	if (rv == BPTREE_OP_TAPIOCA_NOT_READY) return BPTREE_OP_TAPIOCA_NOT_READY;

	for(rv =0;;)
	{
		rv = bptree_index_next(bps, kcur, &ksize_c, vcur, &vsize_c);
		if (rv != BPTREE_OP_KEY_FOUND) break;
		elements++;
		if (bptree_compar(bps,kprev, kcur, vprev, vcur, vsize_p, vsize_c, 
			bps->num_fields) > 0)
		{
			bptree_key_value_to_string(bps,kprev,vprev,ksize_p,vsize_p,s1);
			bptree_key_value_to_string(bps,kcur,vcur,ksize_c,vsize_c,s2);
			printf("B+Tree validation failed, %s > %s\n", s1, s2);
			fflush(stdout);
			return BPTREE_OP_TREE_ERROR;
		}
		bzero(kprev, BUF_SZ);
		bzero(vprev, BUF_SZ);
		memcpy(kprev, kcur, BUF_SZ);
		memcpy(vprev, vcur, BUF_SZ);
		bzero(kcur, BUF_SZ);
		bzero(vcur, BUF_SZ);
	}
	if (rv == BPTREE_OP_TAPIOCA_NOT_READY)
	{
		// TODO Rethink this - will probably segfault on multi-node
		uuid_copy(failed_node, bpnode_get_id(bps->cursor_node));
	}
	printf("Sequential scan returned %d elements\n", elements);
	return BPTREE_OP_SUCCESS;

}