Пример #1
0
void
tdb_close(TDB *db)
{
	/* Unmapping can be done from process context. */
	tdb_file_close(db);

	kfree(db);
}
Пример #2
0
static void
__do_close_table(TDB *db)
{
	/* Unmapping can be done from process context. */
	tdb_file_close(db);

	tdb_htrie_exit(db->hdr);

	TDB_LOG("Close table '%s'\n", db->tbl_name);

	kfree(db);
}
Пример #3
0
/**
 * Open database file and @return its descriptor.
 * If the database is already opened, then returns the handler.
 *
 * The function must not be called from softirq!
 */
TDB *
tdb_open(const char *path, size_t fsize, unsigned int rec_size, int node)
{
	TDB *db;

	if ((fsize & ~TDB_EXT_MASK) || fsize < TDB_EXT_SZ) {
		TDB_ERR("Bad table size: %lu\n", fsize);
		return NULL;
	}

	db = tdb_get_db(path, node);
	if (!db)
		return NULL;

	db->node = node;

	if (tdb_file_open(db, fsize)) {
		TDB_ERR("Cannot open db\n");
		goto err;
	}

	db->hdr = tdb_htrie_init(db->hdr, db->filp->f_inode->i_size, rec_size);
	if (!db->hdr) {
		TDB_ERR("Cannot initialize db header\n");
		goto err_init;
	}

	tdb_tbl_enumerate(db);

	TDB_LOG("Opened table %s: size=%lu rec_size=%u base=%p\n",
		path, fsize, rec_size, db->hdr);

	return db;
err_init:
	tdb_file_close(db);
err:
	tdb_put(db);
	return NULL;
}