Licensing Information
Open Source Used In Cisco FXOS 1.1(4) 964
{TDB_ERR_CORRUPT, "Corrupt database"},
{TDB_ERR_IO, "IO Error"},
{TDB_ERR_LOCK, "Locking error"},
{TDB_ERR_OOM, "Out of memory"},
{TDB_ERR_EXISTS, "Record exists"},
{-1, NULL}};
if (tdb != NULL) {
for (i=0;emap[i].estring;i++) {
if (tdb->ecode == emap[i].ecode) return emap[i].estring;
}
} else {
return "Invalid tdb context";
}
return "Invalid error code";
}
/* update an entry in place - this only works if the new data size
is <= the old data size and the key exists.
on failure return -1
*/
int tdb_update(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf)
{
unsigned hash;
struct list_struct rec;
tdb_off rec_ptr;
int ret = -1;
info("Enter: tdb_update.");
if (tdb == NULL) {
#ifdef TDB_DEBUG
printf("tdb_update() called with null context\n");
#endif
return -1;
}
/* find which hash bucket it is in */
hash = tdb_hash(&key);
tdb_lock(tdb, BUCKET(hash));
rec_ptr = tdb_find(tdb, key, hash, &rec);
if (!rec_ptr)
goto out;
/* must be long enough */
if (rec.rec_len < key.dsize + dbuf.dsize)
goto out;