From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "struct" |
|---|
| subject | "Format:LMDB database file" |
|---|
| claim | "MDB_db, the per-database record stored twice in the meta page (free-page DB first, main DB second) and as the value of each named-database record in the main DB." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:LMDB database file" |
|---|
| observed_in | |
|---|
|
|---|
| data | | name | "MDB_db" |
|---|
| size | 48 |
|---|
| abi | "64-bit native endian, pgno_t and mdb_size_t 8 bytes" |
|---|
| fields | | offset | "0x0" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "md_pad" |
|---|
| bits | "page size in the free DB (mm_psize); key size for LEAF2 pages" |
|---|
|
| offset | "0x4" |
|---|
| size | 2 |
|---|
| type | "uint16_t" |
|---|
| name | "md_flags" |
|---|
|
| offset | "0x6" |
|---|
| size | 2 |
|---|
| type | "uint16_t" |
|---|
| name | "md_depth" |
|---|
|
| offset | "0x8" |
|---|
| size | 8 |
|---|
| type | "pgno_t" |
|---|
| name | "md_branch_pages" |
|---|
|
| offset | "0x10" |
|---|
| size | 8 |
|---|
| type | "pgno_t" |
|---|
| name | "md_leaf_pages" |
|---|
|
| offset | "0x18" |
|---|
| size | 8 |
|---|
| type | "pgno_t" |
|---|
| name | "md_overflow_pages" |
|---|
|
| offset | "0x20" |
|---|
| size | 8 |
|---|
| type | "mdb_size_t" |
|---|
| name | "md_entries" |
|---|
|
| offset | "0x28" |
|---|
| size | 8 |
|---|
| type | "pgno_t" |
|---|
| name | "md_root" |
|---|
| bits | "P_INVALID (all ones) for an empty tree" |
|---|
|
|
|---|
| endianness | "native" |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "struct MDB_db; init_meta0 sets both md_root to P_INVALID; mm_psize and mm_flags are macros on mm_dbs[FREE_DBI].md_pad/md_flags (1388-1390)." |
|---|
| repo | "https://github.com/LMDB/lmdb" |
|---|
| commit | "253ba5219172531b719bc14fee6b4aa1a2a5c4a5" |
|---|
| path | "libraries/liblmdb/mdb.c" |
|---|
| lines | "1339-1349, 4800-4801" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "MDB_db" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-19T11:32:06.859Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T11:54:42.981Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read mdb.c 1339-1349 at the cited commit: md_pad u32, md_flags u16, md_depth u16, three pgno_t counts, md_entries mdb_size_t, md_root pgno_t; 4+2+2+40 = 48 with 8-byte pgno_t." |
|---|
|
|
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-19T12:40:33.158Z" |
|---|
| summary | "Set byte order native: LMDB writes its C structs in host byte order (files are not portable across endianness)." |
|---|
| changed | |
|---|
|
|
|---|