#include <arpa/inet.h>#include <errno.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/stat.h>#include <sys/types.h>#include <unistd.h>#include <db.h>#include <atalk/cnid.h>#include <atalk/errchk.h>#include <atalk/logger.h>#include <atalk/util.h>#include "db_param.h"#include "dbif.h"#include "pack.h"Macros | |
| #define | DB_ERRLOGFILE "db_errlog" |
| #define | UNINTIALIZED_DB UINT32_MAX |
| Upgrade CNID database versions, initialize rootinfo key as as necessary in dbif_setversion(). | |
Functions | |
| static int | dbif_stamp (DBD *dbd, void *buffer, int size) |
| Get the db stamp which is the st_ctime of the file "cnid2.db" and store it in buffer. | |
| static int | dbif_init_rootinfo (DBD *dbd, int version) |
| Inititialize rootinfo key (which has CNID 0 as key). | |
| static int | dbif_getversion (DBD *dbd, uint32_t *version) |
| Return CNID database version number. | |
| static int | dbif_setversion (DBD *dbd, uint32_t version) |
| Set CNID database version number. | |
| static int | dbif_upgrade (DBD *dbd) |
| static int | dbif_openlog (DBD *dbd) |
| static int | dbif_logautorem (DBD *dbd) |
| DBD * | dbif_init (const char *envhome, const char *filename) |
| int | dbif_env_open (DBD *dbd, struct db_param *dbp, uint32_t dbenv_oflags) |
| int | dbif_open (DBD *dbd, struct db_param *dbp, int reindex) |
| static int | dbif_closedb (DBD *dbd) |
| int | dbif_close (DBD *dbd) |
| int | dbif_env_remove (const char *path) |
| int | dbif_get (DBD *dbd, const int dbi, DBT *key, DBT *val, uint32_t flags) |
| int | dbif_put (DBD *dbd, const int dbi, DBT *key, DBT *val, uint32_t flags) |
| int | dbif_del (DBD *dbd, const int dbi, DBT *key, uint32_t flags) |
| int | dbif_search (DBD *dbd, DBT *key, char *resbuf) |
| Search the database by name. | |
| int | dbif_txn_begin (DBD *dbd) |
| int | dbif_txn_commit (DBD *dbd) |
| int | dbif_txn_abort (DBD *dbd) |
| int | dbif_txn_close (DBD *dbd, int ret) |
| Close a transaction based on ret code. | |
| int | dbif_txn_checkpoint (DBD *dbd, uint32_t kbyte, uint32_t min, uint32_t flags) |
| int | dbif_count (DBD *dbd, const int dbi, uint32_t *count) |
| int | dbif_copy_rootinfokey (DBD *srcdbd, DBD *destdbd) |
| int | dbif_dump (DBD *dbd, int dumpindexes) |
| int | dbif_idwalk (DBD *dbd, cnid_t *cnid, int close) |
| Iterates over dbd, returning cnids. | |
| #define DB_ERRLOGFILE "db_errlog" |
| #define UNINTIALIZED_DB UINT32_MAX |
Upgrade CNID database versions, initialize rootinfo key as as necessary in dbif_setversion().
For now this does nothing, as upgrading from ver. 0 to 1 is done in dbif_open
| int dbif_close | ( | DBD * | dbd | ) |
|
static |
| int dbif_count | ( | DBD * | dbd, |
| const int | dbi, | ||
| uint32_t * | count ) |
| int dbif_del | ( | DBD * | dbd, |
| const int | dbi, | ||
| DBT * | key, | ||
| uint32_t | flags ) |
| int dbif_dump | ( | DBD * | dbd, |
| int | dumpindexes ) |
We must open the db_env with an absolute pathname, as 'dbd' keeps chdir'ing, which breaks e.g. bdb logfile-rotation with relative pathnames. But still we use relative paths with DB_ERRLOGFILE in order to avoid creating absolute paths by copying. Both have no problem with a relative path.
| int dbif_env_remove | ( | const char * | path | ) |
| int dbif_get | ( | DBD * | dbd, |
| const int | dbi, | ||
| DBT * | key, | ||
| DBT * | val, | ||
| uint32_t | flags ) |
|
static |
Return CNID database version number.
Returns version in *version
Iterates over dbd, returning cnids.
Uses in-value of cnid to seek to that cnid, then gets next and return that in cnid. If close=1, close cursor.
| DBD * dbif_init | ( | const char * | envhome, |
| const char * | filename ) |
|
static |
Inititialize rootinfo key (which has CNID 0 as key).
| [in,out] | dbd | database handle |
| [in] | version | database version number |
|
static |
|
static |
| int dbif_put | ( | DBD * | dbd, |
| const int | dbi, | ||
| DBT * | key, | ||
| DBT * | val, | ||
| uint32_t | flags ) |
| int dbif_search | ( | DBD * | dbd, |
| DBT * | key, | ||
| char * | resbuf ) |
Search the database by name.
| [in] | dbd | database handle |
| [in] | key | key to search for, must be initialized with name to search for (key->data, key->size) |
| [out] | resbuf | buffer for search results CNIDs, maxsize is assumed to be DBD_MAX_SRCH_RSLTS * sizefof(cnid_t) |
|
static |
Set CNID database version number.
Initializes rootinfo key as neccessary
|
static |
Get the db stamp which is the st_ctime of the file "cnid2.db" and store it in buffer.
| int dbif_txn_abort | ( | DBD * | dbd | ) |
| int dbif_txn_begin | ( | DBD * | dbd | ) |
| int dbif_txn_checkpoint | ( | DBD * | dbd, |
| uint32_t | kbyte, | ||
| uint32_t | min, | ||
| uint32_t | flags ) |
| int dbif_txn_close | ( | DBD * | dbd, |
| int | ret ) |
Close a transaction based on ret code.
| int dbif_txn_commit | ( | DBD * | dbd | ) |
|
static |