Macros | Functions
Data Integrity Group

The Data Integrity Group contain the API to check the state of internal structures, or to control general data access. More...

Macros

#define MDBM_CHECK_HEADER   0
 Check MDBM header for integrity. More...
 
#define MDBM_CHECK_CHUNKS   1
 Check MDBM header and chunks (page structure) More...
 
#define MDBM_CHECK_DIRECTORY   2
 Check MDBM header, chunks, and directory. More...
 
#define MDBM_CHECK_ALL   3
 Check MDBM header, chunks, directory, and data. More...
 
#define MDBM_PROT_NONE   0
 Page no access. More...
 
#define MDBM_PROT_READ   1
 Page read access. More...
 
#define MDBM_PROT_WRITE   2
 Page write access. More...
 
#define MDBM_PROT_NOACCESS   MDBM_PROT_NONE
 Page no access. More...
 
#define MDBM_PROT_ACCESS   4
 Page protection mask. More...
 

Functions

int mdbm_check (MDBM *db, int level, int verbose)
 Checks an MDBM's integrity, and displays information on standard output. More...
 
void mdbm_chk_error (MDBM *db, int pagenum, int mapped_pagenum, int index)
 Checks integrity of an entry on a page. More...
 
int mdbm_chk_page (MDBM *db, int pagenum)
 Checks the specified page for errors. More...
 
int mdbm_chk_all_page (MDBM *db)
 Checks the database for errors. More...
 
int mdbm_protect (MDBM *db, int protect)
 Sets all database pages to protect permission. More...
 

Detailed Description

The Data Integrity Group contain the API to check the state of internal structures, or to control general data access.

Macro Definition Documentation

#define MDBM_CHECK_HEADER   0

Check MDBM header for integrity.

#define MDBM_CHECK_CHUNKS   1

Check MDBM header and chunks (page structure)

#define MDBM_CHECK_DIRECTORY   2

Check MDBM header, chunks, and directory.

#define MDBM_CHECK_ALL   3

Check MDBM header, chunks, directory, and data.

#define MDBM_PROT_NONE   0

Page no access.

#define MDBM_PROT_READ   1

Page read access.

#define MDBM_PROT_WRITE   2

Page write access.

#define MDBM_PROT_NOACCESS   MDBM_PROT_NONE

Page no access.

#define MDBM_PROT_ACCESS   4

Page protection mask.

Function Documentation

int mdbm_check ( MDBM db,
int  level,
int  verbose 
)

Checks an MDBM's integrity, and displays information on standard output.

Parameters
[in,out]dbDatabase handle
[in]levelDepth of checks
[in]verboseWhether to display verbose information while checking
Returns
Check status
Return values
-1Error
0Success
void mdbm_chk_error ( MDBM db,
int  pagenum,
int  mapped_pagenum,
int  index 
)

Checks integrity of an entry on a page.

NOTE: This has not been implemented.

Parameters
[in,out]dbDatabase handle
[in]pagenumPage number
[in]mapped_pagenumMapped page number
[in]indexEntry number on a page
int mdbm_chk_page ( MDBM db,
int  pagenum 
)

Checks the specified page for errors.

It will print errors found on the page, including bad key size, bad val size, and bad offsets of various fields.

V2: Prints found errors to stdout. If no errors, then no printing performed. When it detects errors, it returns -1 and mdbm_get_errno returns EFAULT.

V3: Prints found errors via mdbm_log targeting LOG_CRITICAL. If no errors, then no logging performed. When it detects errors, it returns -1 and errno is set to EFAULT.

Parameters
[in,out]dbDatabase handle
[in]pagenumPage to check for errors
Returns
Check page status
Return values
-1Errors detected, and errno is set. This could be due to a locking error. For v2, the caller must call mdbm_get_errno and check against EFAULT. For v3, the caller must check errno against EFAULT.
0Success
int mdbm_chk_all_page ( MDBM db)

Checks the database for errors.

It will report same as mdbm_chk_page for all pages in the database. See v2 and v3 in mdbm_chk_page to determine if errors detected in the database.

Parameters
[in,out]dbDatabase handle
Returns
Check all pages status
Return values
-1Errors detected, and errno is set. This could be due to a locking error. For v2, the caller must call mdbm_get_errno and check against EFAULT. For v3, the caller must check errno against EFAULT.
0success
int mdbm_protect ( MDBM db,
int  protect 
)

Sets all database pages to protect permission.

This function is for advanced users only. Users that want to use the built-in protect feature should specify MDBM_PROTECT in their mdbm_open flags.

Parameters
[in,out]dbDatabase handle
[in]protectPermission mask
Returns
Protect status
Return values
-1Error, and errno is set
0Success

Values for protect mask:

  • MDBM_PROT_NONE - no access
  • MDBM_PROT_READ - read access
  • MDBM_PROT_WRITE - write access
  • MDBM_PROT_ACCESS - all access
  • MDBM_PROT_NOACCESS - no access (same as MDBM_PROT_NONE)

NOTE: RHEL is unable to set MDBM_PROT_WRITE without MDBM_PROT_READ, so specifying MDBM_PROT_WRITE does not protect against reads.