X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibmdb%2Fmdb_stat.c;h=a5f484d0637ac873c66532bc4dac85a2e6f9b2c1;hb=334099c0db09f03e71e97721d3728a87acc97bc3;hp=2fd10f3bb0644a8db96b3bc489fee20057807f04;hpb=4fd0f278d28b363ade419eb5b991c924a03e125d;p=openldap diff --git a/libraries/libmdb/mdb_stat.c b/libraries/libmdb/mdb_stat.c index 2fd10f3bb0..a5f484d063 100644 --- a/libraries/libmdb/mdb_stat.c +++ b/libraries/libmdb/mdb_stat.c @@ -1,3 +1,16 @@ +/* mdb_stat.c - memory-mapped database status tool */ +/* + * Copyright 2011 Howard Chu, Symas Corp. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in the file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ #include #include #include @@ -13,16 +26,19 @@ int main(int argc,char * argv[]) char *envname = argv[1]; char *subname = NULL; - if (argc > 2) + rc = mdb_env_create(&env); + + if (argc > 2) { + mdb_env_set_maxdbs(env, 4); subname = argv[2]; - - rc = mdbenv_create(&env); - rc = mdbenv_open(env, envname, MDB_RDONLY, 0); + } + + rc = mdb_env_open(env, envname, MDB_RDONLY, 0); if (rc) { - printf("mdbenv_open failed, error %d\n", rc); + printf("mdb_env_open failed, error %d\n", rc); exit(1); } - rc = mdb_txn_begin(env, 1, &txn); + rc = mdb_txn_begin(env, NULL, 1, &txn); if (rc) { printf("mdb_txn_begin failed, error %d\n", rc); exit(1); @@ -36,13 +52,13 @@ int main(int argc,char * argv[]) rc = mdb_stat(txn, dbi, &mst); printf("Page size: %u\n", mst.ms_psize); printf("Tree depth: %u\n", mst.ms_depth); - printf("Branch pages: %lu\n", mst.ms_branch_pages); - printf("Leaf pages: %lu\n", mst.ms_leaf_pages); - printf("Overflow pages: %lu\n", mst.ms_overflow_pages); - printf("Entries: %lu\n", mst.ms_entries); - mdb_close(txn, dbi); + printf("Branch pages: %zu\n", mst.ms_branch_pages); + printf("Leaf pages: %zu\n", mst.ms_leaf_pages); + printf("Overflow pages: %zu\n", mst.ms_overflow_pages); + printf("Entries: %zu\n", mst.ms_entries); + mdb_close(env, dbi); mdb_txn_abort(txn); - mdbenv_close(env); + mdb_env_close(env); return 0; }