Licensing Information
Open Source Used In Cisco FXOS 1.1(4) 952
* Note: this software is also available under the Gnu Public License
* version 2 or later.
*/
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include "tdb.h"
#define TDB_VERSION (0x26011967 + 1)
#define TDB_MAGIC (0x26011999U)
#define TDB_FREE_MAGIC (~TDB_MAGIC)
#define TDB_ALIGN 4
#define MIN_REC_SIZE (2*sizeof(struct list_struct) + TDB_ALIGN)
#define DEFAULT_HASH_SIZE 128
#define TDB_PAGE_SIZE 0x2000
#define TDB_LEN_MULTIPLIER 10
#define FREELIST_TOP (sizeof(struct tdb_header))
#define LOCK_SET 1
#define LOCK_CLEAR 0
/* lock offsets */
#define GLOBAL_LOCK 0
#define ACTIVE_LOCK 4
#define LIST_LOCK_BASE 1024
#define BUCKET(hash) ((hash) % tdb->header.hash_size)
#ifndef MAP_FILE
#define MAP_FILE 0
#endif
/* the body of the database is made of one list_struct for the free space
plus a separate data list for each hash value */
struct list_struct {
tdb_len rec_len; /* total byte length of record */
tdb_off next; /* offset of the next record in the list */
tdb_len key_len; /* byte length of key */
tdb_len data_len; /* byte length of data */
unsigned full_hash; /* the full 32 bit hash of the key */
unsigned magic; /* try to catch errors */