db_mem.c revision 18c2aff776a775d34a4c9893a4c72e0434d68e36
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <string.h>
#include <stdlib.h>
#include "vold.h"
static void memdb_lookup(vvnode_t *);
static void memdb_root(void);
static bool_t memdb_testkey(char *, char *, char *);
/*
* Note that this mem id business is a bit of a hack,
* and assumes that TMPID_BASE in vold_node.c will not
* collide with this id space.
*
* The core trouble here is that we are not using any form
* of permanent storage to keep our id numbers (or objects, of course)
* in.
*/
#define MEMID_BASE 0x4000000000000000ull
memdb_lookup, /* dop_lookup */
memdb_root, /* dop_root */
memdb_update, /* dop_update */
memdb_add, /* dop_add */
memdb_remove, /* dop_remove */
memdb_findlabel, /* dop_findlabel */
memdb_testkey, /* dop_testkey */
"mem", /* dop_name */
};
#define MEMDB_ID_HASH_SIZE 64
#define MEMDB_LABEL_HASH_SIZE 64
static struct q memdb_id_hash[MEMDB_ID_HASH_SIZE];
static struct q memdb_key_hash[MEMDB_LABEL_HASH_SIZE];
struct mdbobj; /* forward decl */
struct id_hash {
struct q q; /* hash queue */
};
struct key_hash {
struct q q; /* hash queue */
char *kh_key; /* key from label_key */
char *kh_mtype; /* media type */
};
struct mdbobj {
};
db_init(void)
{
/*
* We're always here.
*/
return (TRUE); /* always have a database */
}
static void
{
/* mark all of our objects as "seen" */
}
static void
memdb_root(void)
{
/* we never have root modes stored away, so... */
}
static bool_t
{
extern size_t label_size(int);
debug(1,
"memdb: couldn't find object id %llu in database (%s)\n",
return (FALSE);
}
}
}
}
}
}
}
}
}
}
}
if (nv->v_location) {
}
}
char *key;
/*
* if the keys are different, move us to the right
* hash queue.
*/
}
}
}
return (TRUE);
}
static bool_t
{
vol_t *v;
/* put it in our id hash list */
/* if it's a volume, add it to our key hash */
#ifdef DEBUG_DB
#endif
% MEMDB_LABEL_HASH_SIZE], key);
}
return (TRUE);
}
static bool_t
{
debug(1,
"memdb: couldn't find object id %llu in database (%s)\n",
return (FALSE);
}
/*
* Free the various things we've allocated and remove things
* from hash chains.
*/
}
return (TRUE);
}
static vol_t *
{
char *key;
while (kh) {
}
}
return (NULL);
}
/*
* test the supplied key to see if it already exists
*/
static bool_t
{
vol_t *v;
#ifdef DEBUG_DB
#endif
#ifdef DEBUG_DB
#endif
while (kh) {
#ifdef DEBUG_DB
#endif
#ifdef DEBUG_DB
debug(3,
"memdb_testkey: returning TRUE (key found)\n");
#endif
return (TRUE);
}
}
#ifdef DEBUG_DB
#endif
return (FALSE);
}
static struct mdbobj *
{
while (id) {
}
}
return (NULL);
}