00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "db_config.h"
00011
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <sys/types.h>
00014 #endif
00015
00016 #include "db_int.h"
00017 #include "dbinc/db_page.h"
00018 #include "dbinc/hash.h"
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 int
00033 __ham_reclaim(dbp, txn)
00034 DB *dbp;
00035 DB_TXN *txn;
00036 {
00037 DBC *dbc;
00038 HASH_CURSOR *hcp;
00039 int ret;
00040
00041
00042 if ((ret = __db_cursor(dbp, txn, &dbc, 0)) != 0)
00043 return (ret);
00044 hcp = (HASH_CURSOR *)dbc->internal;
00045
00046 if ((ret = __ham_get_meta(dbc)) != 0)
00047 goto err;
00048
00049 if ((ret = __ham_traverse(dbc,
00050 DB_LOCK_WRITE, __db_reclaim_callback, dbc, 1)) != 0)
00051 goto err;
00052 if ((ret = __db_c_close(dbc)) != 0)
00053 goto err;
00054 if ((ret = __ham_release_meta(dbc)) != 0)
00055 goto err;
00056 return (0);
00057
00058 err: if (hcp->hdr != NULL)
00059 (void)__ham_release_meta(dbc);
00060 (void)__db_c_close(dbc);
00061 return (ret);
00062 }
00063
00064
00065
00066
00067
00068
00069
00070
00071 int
00072 __ham_truncate(dbc, countp)
00073 DBC *dbc;
00074 u_int32_t *countp;
00075 {
00076 db_trunc_param trunc;
00077 int ret, t_ret;
00078
00079 if ((ret = __ham_get_meta(dbc)) != 0)
00080 return (ret);
00081
00082 trunc.count = 0;
00083 trunc.dbc = dbc;
00084
00085 ret = __ham_traverse(dbc,
00086 DB_LOCK_WRITE, __db_truncate_callback, &trunc, 1);
00087
00088 if ((t_ret = __ham_release_meta(dbc)) != 0 && ret == 0)
00089 ret = t_ret;
00090
00091 if (countp != NULL)
00092 *countp = trunc.count;
00093 return (ret);
00094 }