Exemplo n.º 1
0
static void test_remove(struct btree *btree, struct ileaf *leaf, inum_t inum, int less)
{
	unsigned size = 0;
	char *attrs = ileaf_lookup(btree, inum, leaf, &size);
	printf("attrs %p, attrs size = %i\n", attrs, size);
	attrs = ileaf_resize(btree, inum, leaf, size - less);
}
Exemplo n.º 2
0
static void test_append(struct btree *btree, struct ileaf *leaf, inum_t inum, int more, char fill)
{
	unsigned size = 0;
	char *attrs = ileaf_lookup(btree, inum, leaf, &size);
	printf("attrs %p, attrs size = %i\n", attrs, size);
	attrs = ileaf_resize(btree, inum, leaf, size + more);
	memset(attrs + size, fill, more);
}
Exemplo n.º 3
0
Arquivo: ileaf.c Projeto: Zkin/tux3
static int ileaf_read(struct btree *btree, tuxkey_t key_bottom,
		      tuxkey_t key_limit,
		      void *leaf, struct btree_key_range *key)
{
	struct ileaf_req *rq = container_of(key, struct ileaf_req, key);
	struct ileaf_attr_ops *attr_ops = btree->ops->private_ops;
	struct ileaf *ileaf = leaf;
	void *attrs;
	unsigned size;

	attrs = ileaf_lookup(btree, key->start, ileaf, &size);
	if (attrs == NULL)
		return -ENOENT;

	return attr_ops->decode(btree, rq->data, attrs, size);
}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
	printf("--- test inode table leaf methods ---\n");
	struct sb *sb = &(struct sb){ .blocksize = 4096 };
	struct btree *btree = &(struct btree){
		.sb = sb,
		.ops = &itable_ops,
		.entries_per_leaf = 64, // !!! should depend on blocksize
	};
	struct ileaf *leaf = ileaf_create(btree);
	struct ileaf *dest = ileaf_create(btree);
	leaf->ibase = to_be_u64(0x10);
	ileaf_dump(btree, leaf);
	test_append(btree, leaf, 0x13, 2, 'a');
	test_append(btree, leaf, 0x14, 4, 'b');
	test_append(btree, leaf, 0x16, 6, 'c');
	ileaf_dump(btree, leaf);
	ileaf_split(btree, 0x10, leaf, dest);
	ileaf_dump(btree, leaf);
	ileaf_dump(btree, dest);
	ileaf_merge(btree, leaf, dest);
	ileaf_dump(btree, leaf);
	test_append(btree, leaf, 0x13, 3, 'x');
	ileaf_dump(btree, leaf);
	test_append(btree, leaf, 0x18, 3, 'y');
	ileaf_dump(btree, leaf);
	test_remove(btree, leaf, 0x16, 5);
	ileaf_dump(btree, leaf);
	unsigned size = 0;
	char *inode = ileaf_lookup(btree, 0x13, leaf, &size);
	hexdump(inode, size);
	for (int i = 0x11; i <= 0x20; i++)
		printf("goal 0x%x => 0x%Lx\n", i, (L)find_empty_inode(btree, leaf, i));
	ileaf_purge(btree, 0x14, leaf);
	ileaf_purge(btree, 0x18, leaf);
	ileaf_check(btree, leaf);
	ileaf_dump(btree, leaf);
	ileaf_destroy(btree, leaf);
	ileaf_destroy(btree, dest);
	exit(0);
}