btree_auto.c

Go to the documentation of this file.
00001 /* Do not edit: automatically built by gen_rec.awk. */
00002 #include "config.h"
00003 
00004 #ifndef NO_SYSTEM_INCLUDES
00005 #include <sys/types.h>
00006 
00007 #include <ctype.h>
00008 #include <errno.h>
00009 #include <string.h>
00010 #endif
00011 
00012 #include "db_int.h"
00013 #include "db_page.h"
00014 #include "db_dispatch.h"
00015 #include "db_am.h"
00016 #include "btree.h"
00017 #include "txn.h"
00018 
00019 int
00020 CDB___bam_pg_alloc1_print(dbenv, dbtp, lsnp, notused2, notused3)
00021         DB_ENV *dbenv;
00022         DBT *dbtp;
00023         DB_LSN *lsnp;
00024         db_recops notused2;
00025         void *notused3;
00026 {
00027         __bam_pg_alloc1_args *argp;
00028         u_int32_t i;
00029         u_int ch;
00030         int ret;
00031 
00032         i = 0;
00033         ch = 0;
00034         notused2 = 0;
00035         notused3 = NULL;
00036 
00037         if ((ret = CDB___bam_pg_alloc1_read(dbenv, dbtp->data, &argp)) != 0)
00038                 return (ret);
00039         printf("[%lu][%lu]bam_pg_alloc1: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00040             (u_long)lsnp->file,
00041             (u_long)lsnp->offset,
00042             (u_long)argp->type,
00043             (u_long)argp->txnid->txnid,
00044             (u_long)argp->prev_lsn.file,
00045             (u_long)argp->prev_lsn.offset);
00046         printf("\tfileid: %ld\n", (long)argp->fileid);
00047         printf("\tmeta_lsn: [%lu][%lu]\n",
00048             (u_long)argp->meta_lsn.file, (u_long)argp->meta_lsn.offset);
00049         printf("\tpage_lsn: [%lu][%lu]\n",
00050             (u_long)argp->page_lsn.file, (u_long)argp->page_lsn.offset);
00051         printf("\tpgno: %lu\n", (u_long)argp->pgno);
00052         printf("\tptype: %lu\n", (u_long)argp->ptype);
00053         printf("\tnext: %lu\n", (u_long)argp->next);
00054         printf("\n");
00055         CDB___os_free(argp, 0);
00056         return (0);
00057 }
00058 
00059 int
00060 CDB___bam_pg_alloc1_read(dbenv, recbuf, argpp)
00061         DB_ENV *dbenv;
00062         void *recbuf;
00063         __bam_pg_alloc1_args **argpp;
00064 {
00065         __bam_pg_alloc1_args *argp;
00066         u_int8_t *bp;
00067         int ret;
00068 
00069         ret = CDB___os_malloc(dbenv, sizeof(__bam_pg_alloc1_args) +
00070             sizeof(DB_TXN), NULL, &argp);
00071         if (ret != 0)
00072                 return (ret);
00073         argp->txnid = (DB_TXN *)&argp[1];
00074         bp = recbuf;
00075         memcpy(&argp->type, bp, sizeof(argp->type));
00076         bp += sizeof(argp->type);
00077         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
00078         bp += sizeof(argp->txnid->txnid);
00079         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00080         bp += sizeof(DB_LSN);
00081         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00082         bp += sizeof(argp->fileid);
00083         memcpy(&argp->meta_lsn, bp,  sizeof(argp->meta_lsn));
00084         bp += sizeof(argp->meta_lsn);
00085         memcpy(&argp->page_lsn, bp,  sizeof(argp->page_lsn));
00086         bp += sizeof(argp->page_lsn);
00087         memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00088         bp += sizeof(argp->pgno);
00089         memcpy(&argp->ptype, bp, sizeof(argp->ptype));
00090         bp += sizeof(argp->ptype);
00091         memcpy(&argp->next, bp, sizeof(argp->next));
00092         bp += sizeof(argp->next);
00093         *argpp = argp;
00094         return (0);
00095 }
00096 
00097 int CDB___bam_pg_alloc_log(dbenv, txnid, ret_lsnp, flags,
00098         fileid, meta_lsn, alloc_lsn, page_lsn, pgno, ptype,
00099         next)
00100         DB_ENV *dbenv;
00101         DB_TXN *txnid;
00102         DB_LSN *ret_lsnp;
00103         u_int32_t flags;
00104         int32_t fileid;
00105         DB_LSN * meta_lsn;
00106         DB_LSN * alloc_lsn;
00107         DB_LSN * page_lsn;
00108         db_pgno_t pgno;
00109         u_int32_t ptype;
00110         db_pgno_t next;
00111 {
00112         DBT logrec;
00113         DB_LSN *lsnp, null_lsn;
00114         u_int32_t rectype, txn_num;
00115         int ret;
00116         u_int8_t *bp;
00117 
00118         if (txnid != NULL &&
00119             TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00120                 return (CDB___db_child_active_err(dbenv));
00121         rectype = DB_bam_pg_alloc;
00122         txn_num = txnid == NULL ? 0 : txnid->txnid;
00123         if (txnid == NULL) {
00124                 ZERO_LSN(null_lsn);
00125                 lsnp = &null_lsn;
00126         } else
00127                 lsnp = &txnid->last_lsn;
00128         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00129             + sizeof(fileid)
00130             + sizeof(*meta_lsn)
00131             + sizeof(*alloc_lsn)
00132             + sizeof(*page_lsn)
00133             + sizeof(pgno)
00134             + sizeof(ptype)
00135             + sizeof(next);
00136         if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00137                 return (ret);
00138 
00139         bp = logrec.data;
00140         memcpy(bp, &rectype, sizeof(rectype));
00141         bp += sizeof(rectype);
00142         memcpy(bp, &txn_num, sizeof(txn_num));
00143         bp += sizeof(txn_num);
00144         memcpy(bp, lsnp, sizeof(DB_LSN));
00145         bp += sizeof(DB_LSN);
00146         memcpy(bp, &fileid, sizeof(fileid));
00147         bp += sizeof(fileid);
00148         if (meta_lsn != NULL)
00149                 memcpy(bp, meta_lsn, sizeof(*meta_lsn));
00150         else
00151                 memset(bp, 0, sizeof(*meta_lsn));
00152         bp += sizeof(*meta_lsn);
00153         if (alloc_lsn != NULL)
00154                 memcpy(bp, alloc_lsn, sizeof(*alloc_lsn));
00155         else
00156                 memset(bp, 0, sizeof(*alloc_lsn));
00157         bp += sizeof(*alloc_lsn);
00158         if (page_lsn != NULL)
00159                 memcpy(bp, page_lsn, sizeof(*page_lsn));
00160         else
00161                 memset(bp, 0, sizeof(*page_lsn));
00162         bp += sizeof(*page_lsn);
00163         memcpy(bp, &pgno, sizeof(pgno));
00164         bp += sizeof(pgno);
00165         memcpy(bp, &ptype, sizeof(ptype));
00166         bp += sizeof(ptype);
00167         memcpy(bp, &next, sizeof(next));
00168         bp += sizeof(next);
00169         DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00170         ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00171         if (txnid != NULL)
00172                 txnid->last_lsn = *ret_lsnp;
00173         CDB___os_free(logrec.data, logrec.size);
00174         return (ret);
00175 }
00176 
00177 int
00178 CDB___bam_pg_alloc_print(dbenv, dbtp, lsnp, notused2, notused3)
00179         DB_ENV *dbenv;
00180         DBT *dbtp;
00181         DB_LSN *lsnp;
00182         db_recops notused2;
00183         void *notused3;
00184 {
00185         __bam_pg_alloc_args *argp;
00186         u_int32_t i;
00187         u_int ch;
00188         int ret;
00189 
00190         i = 0;
00191         ch = 0;
00192         notused2 = 0;
00193         notused3 = NULL;
00194 
00195         if ((ret = CDB___bam_pg_alloc_read(dbenv, dbtp->data, &argp)) != 0)
00196                 return (ret);
00197         printf("[%lu][%lu]bam_pg_alloc: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00198             (u_long)lsnp->file,
00199             (u_long)lsnp->offset,
00200             (u_long)argp->type,
00201             (u_long)argp->txnid->txnid,
00202             (u_long)argp->prev_lsn.file,
00203             (u_long)argp->prev_lsn.offset);
00204         printf("\tfileid: %ld\n", (long)argp->fileid);
00205         printf("\tmeta_lsn: [%lu][%lu]\n",
00206             (u_long)argp->meta_lsn.file, (u_long)argp->meta_lsn.offset);
00207         printf("\talloc_lsn: [%lu][%lu]\n",
00208             (u_long)argp->alloc_lsn.file, (u_long)argp->alloc_lsn.offset);
00209         printf("\tpage_lsn: [%lu][%lu]\n",
00210             (u_long)argp->page_lsn.file, (u_long)argp->page_lsn.offset);
00211         printf("\tpgno: %lu\n", (u_long)argp->pgno);
00212         printf("\tptype: %lu\n", (u_long)argp->ptype);
00213         printf("\tnext: %lu\n", (u_long)argp->next);
00214         printf("\n");
00215         CDB___os_free(argp, 0);
00216         return (0);
00217 }
00218 
00219 int
00220 CDB___bam_pg_alloc_read(dbenv, recbuf, argpp)
00221         DB_ENV *dbenv;
00222         void *recbuf;
00223         __bam_pg_alloc_args **argpp;
00224 {
00225         __bam_pg_alloc_args *argp;
00226         u_int8_t *bp;
00227         int ret;
00228 
00229         ret = CDB___os_malloc(dbenv, sizeof(__bam_pg_alloc_args) +
00230             sizeof(DB_TXN), NULL, &argp);
00231         if (ret != 0)
00232                 return (ret);
00233         argp->txnid = (DB_TXN *)&argp[1];
00234         bp = recbuf;
00235         memcpy(&argp->type, bp, sizeof(argp->type));
00236         bp += sizeof(argp->type);
00237         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
00238         bp += sizeof(argp->txnid->txnid);
00239         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00240         bp += sizeof(DB_LSN);
00241         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00242         bp += sizeof(argp->fileid);
00243         memcpy(&argp->meta_lsn, bp,  sizeof(argp->meta_lsn));
00244         bp += sizeof(argp->meta_lsn);
00245         memcpy(&argp->alloc_lsn, bp,  sizeof(argp->alloc_lsn));
00246         bp += sizeof(argp->alloc_lsn);
00247         memcpy(&argp->page_lsn, bp,  sizeof(argp->page_lsn));
00248         bp += sizeof(argp->page_lsn);
00249         memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00250         bp += sizeof(argp->pgno);
00251         memcpy(&argp->ptype, bp, sizeof(argp->ptype));
00252         bp += sizeof(argp->ptype);
00253         memcpy(&argp->next, bp, sizeof(argp->next));
00254         bp += sizeof(argp->next);
00255         *argpp = argp;
00256         return (0);
00257 }
00258 
00259 int
00260 CDB___bam_pg_free1_print(dbenv, dbtp, lsnp, notused2, notused3)
00261         DB_ENV *dbenv;
00262         DBT *dbtp;
00263         DB_LSN *lsnp;
00264         db_recops notused2;
00265         void *notused3;
00266 {
00267         __bam_pg_free1_args *argp;
00268         u_int32_t i;
00269         u_int ch;
00270         int ret;
00271 
00272         i = 0;
00273         ch = 0;
00274         notused2 = 0;
00275         notused3 = NULL;
00276 
00277         if ((ret = CDB___bam_pg_free1_read(dbenv, dbtp->data, &argp)) != 0)
00278                 return (ret);
00279         printf("[%lu][%lu]bam_pg_free1: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00280             (u_long)lsnp->file,
00281             (u_long)lsnp->offset,
00282             (u_long)argp->type,
00283             (u_long)argp->txnid->txnid,
00284             (u_long)argp->prev_lsn.file,
00285             (u_long)argp->prev_lsn.offset);
00286         printf("\tfileid: %ld\n", (long)argp->fileid);
00287         printf("\tpgno: %lu\n", (u_long)argp->pgno);
00288         printf("\tmeta_lsn: [%lu][%lu]\n",
00289             (u_long)argp->meta_lsn.file, (u_long)argp->meta_lsn.offset);
00290         printf("\theader: ");
00291         for (i = 0; i < argp->header.size; i++) {
00292                 ch = ((u_int8_t *)argp->header.data)[i];
00293                 if (isprint(ch) || ch == 0xa)
00294                         putchar(ch);
00295                 else
00296                         printf("%#x ", ch);
00297         }
00298         printf("\n");
00299         printf("\tnext: %lu\n", (u_long)argp->next);
00300         printf("\n");
00301         CDB___os_free(argp, 0);
00302         return (0);
00303 }
00304 
00305 int
00306 CDB___bam_pg_free1_read(dbenv, recbuf, argpp)
00307         DB_ENV *dbenv;
00308         void *recbuf;
00309         __bam_pg_free1_args **argpp;
00310 {
00311         __bam_pg_free1_args *argp;
00312         u_int8_t *bp;
00313         int ret;
00314 
00315         ret = CDB___os_malloc(dbenv, sizeof(__bam_pg_free1_args) +
00316             sizeof(DB_TXN), NULL, &argp);
00317         if (ret != 0)
00318                 return (ret);
00319         argp->txnid = (DB_TXN *)&argp[1];
00320         bp = recbuf;
00321         memcpy(&argp->type, bp, sizeof(argp->type));
00322         bp += sizeof(argp->type);
00323         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
00324         bp += sizeof(argp->txnid->txnid);
00325         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00326         bp += sizeof(DB_LSN);
00327         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00328         bp += sizeof(argp->fileid);
00329         memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00330         bp += sizeof(argp->pgno);
00331         memcpy(&argp->meta_lsn, bp,  sizeof(argp->meta_lsn));
00332         bp += sizeof(argp->meta_lsn);
00333         memset(&argp->header, 0, sizeof(argp->header));
00334         memcpy(&argp->header.size, bp, sizeof(u_int32_t));
00335         bp += sizeof(u_int32_t);
00336         argp->header.data = bp;
00337         bp += argp->header.size;
00338         memcpy(&argp->next, bp, sizeof(argp->next));
00339         bp += sizeof(argp->next);
00340         *argpp = argp;
00341         return (0);
00342 }
00343 
00344 int CDB___bam_pg_free_log(dbenv, txnid, ret_lsnp, flags,
00345         fileid, pgno, meta_lsn, alloc_lsn, header, next)
00346         DB_ENV *dbenv;
00347         DB_TXN *txnid;
00348         DB_LSN *ret_lsnp;
00349         u_int32_t flags;
00350         int32_t fileid;
00351         db_pgno_t pgno;
00352         DB_LSN * meta_lsn;
00353         DB_LSN * alloc_lsn;
00354         const DBT *header;
00355         db_pgno_t next;
00356 {
00357         DBT logrec;
00358         DB_LSN *lsnp, null_lsn;
00359         u_int32_t zero;
00360         u_int32_t rectype, txn_num;
00361         int ret;
00362         u_int8_t *bp;
00363 
00364         if (txnid != NULL &&
00365             TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00366                 return (CDB___db_child_active_err(dbenv));
00367         rectype = DB_bam_pg_free;
00368         txn_num = txnid == NULL ? 0 : txnid->txnid;
00369         if (txnid == NULL) {
00370                 ZERO_LSN(null_lsn);
00371                 lsnp = &null_lsn;
00372         } else
00373                 lsnp = &txnid->last_lsn;
00374         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00375             + sizeof(fileid)
00376             + sizeof(pgno)
00377             + sizeof(*meta_lsn)
00378             + sizeof(*alloc_lsn)
00379             + sizeof(u_int32_t) + (header == NULL ? 0 : header->size)
00380             + sizeof(next);
00381         if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00382                 return (ret);
00383 
00384         bp = logrec.data;
00385         memcpy(bp, &rectype, sizeof(rectype));
00386         bp += sizeof(rectype);
00387         memcpy(bp, &txn_num, sizeof(txn_num));
00388         bp += sizeof(txn_num);
00389         memcpy(bp, lsnp, sizeof(DB_LSN));
00390         bp += sizeof(DB_LSN);
00391         memcpy(bp, &fileid, sizeof(fileid));
00392         bp += sizeof(fileid);
00393         memcpy(bp, &pgno, sizeof(pgno));
00394         bp += sizeof(pgno);
00395         if (meta_lsn != NULL)
00396                 memcpy(bp, meta_lsn, sizeof(*meta_lsn));
00397         else
00398                 memset(bp, 0, sizeof(*meta_lsn));
00399         bp += sizeof(*meta_lsn);
00400         if (alloc_lsn != NULL)
00401                 memcpy(bp, alloc_lsn, sizeof(*alloc_lsn));
00402         else
00403                 memset(bp, 0, sizeof(*alloc_lsn));
00404         bp += sizeof(*alloc_lsn);
00405         if (header == NULL) {
00406                 zero = 0;
00407                 memcpy(bp, &zero, sizeof(u_int32_t));
00408                 bp += sizeof(u_int32_t);
00409         } else {
00410                 memcpy(bp, &header->size, sizeof(header->size));
00411                 bp += sizeof(header->size);
00412                 memcpy(bp, header->data, header->size);
00413                 bp += header->size;
00414         }
00415         memcpy(bp, &next, sizeof(next));
00416         bp += sizeof(next);
00417         DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00418         ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00419         if (txnid != NULL)
00420                 txnid->last_lsn = *ret_lsnp;
00421         CDB___os_free(logrec.data, logrec.size);
00422         return (ret);
00423 }
00424 
00425 int
00426 CDB___bam_pg_free_print(dbenv, dbtp, lsnp, notused2, notused3)
00427         DB_ENV *dbenv;
00428         DBT *dbtp;
00429         DB_LSN *lsnp;
00430         db_recops notused2;
00431         void *notused3;
00432 {
00433         __bam_pg_free_args *argp;
00434         u_int32_t i;
00435         u_int ch;
00436         int ret;
00437 
00438         i = 0;
00439         ch = 0;
00440         notused2 = 0;
00441         notused3 = NULL;
00442 
00443         if ((ret = CDB___bam_pg_free_read(dbenv, dbtp->data, &argp)) != 0)
00444                 return (ret);
00445         printf("[%lu][%lu]bam_pg_free: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00446             (u_long)lsnp->file,
00447             (u_long)lsnp->offset,
00448             (u_long)argp->type,
00449             (u_long)argp->txnid->txnid,
00450             (u_long)argp->prev_lsn.file,
00451             (u_long)argp->prev_lsn.offset);
00452         printf("\tfileid: %ld\n", (long)argp->fileid);
00453         printf("\tpgno: %lu\n", (u_long)argp->pgno);
00454         printf("\tmeta_lsn: [%lu][%lu]\n",
00455             (u_long)argp->meta_lsn.file, (u_long)argp->meta_lsn.offset);
00456         printf("\talloc_lsn: [%lu][%lu]\n",
00457             (u_long)argp->alloc_lsn.file, (u_long)argp->alloc_lsn.offset);
00458         printf("\theader: ");
00459         for (i = 0; i < argp->header.size; i++) {
00460                 ch = ((u_int8_t *)argp->header.data)[i];
00461                 if (isprint(ch) || ch == 0xa)
00462                         putchar(ch);
00463                 else
00464                         printf("%#x ", ch);
00465         }
00466         printf("\n");
00467         printf("\tnext: %lu\n", (u_long)argp->next);
00468         printf("\n");
00469         CDB___os_free(argp, 0);
00470         return (0);
00471 }
00472 
00473 int
00474 CDB___bam_pg_free_read(dbenv, recbuf, argpp)
00475         DB_ENV *dbenv;
00476         void *recbuf;
00477         __bam_pg_free_args **argpp;
00478 {
00479         __bam_pg_free_args *argp;
00480         u_int8_t *bp;
00481         int ret;
00482 
00483         ret = CDB___os_malloc(dbenv, sizeof(__bam_pg_free_args) +
00484             sizeof(DB_TXN), NULL, &argp);
00485         if (ret != 0)
00486                 return (ret);
00487         argp->txnid = (DB_TXN *)&argp[1];
00488         bp = recbuf;
00489         memcpy(&argp->type, bp, sizeof(argp->type));
00490         bp += sizeof(argp->type);
00491         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
00492         bp += sizeof(argp->txnid->txnid);
00493         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00494         bp += sizeof(DB_LSN);
00495         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00496         bp += sizeof(argp->fileid);
00497         memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00498         bp += sizeof(argp->pgno);
00499         memcpy(&argp->meta_lsn, bp,  sizeof(argp->meta_lsn));
00500         bp += sizeof(argp->meta_lsn);
00501         memcpy(&argp->alloc_lsn, bp,  sizeof(argp->alloc_lsn));
00502         bp += sizeof(argp->alloc_lsn);
00503         memset(&argp->header, 0, sizeof(argp->header));
00504         memcpy(&argp->header.size, bp, sizeof(u_int32_t));
00505         bp += sizeof(u_int32_t);
00506         argp->header.data = bp;
00507         bp += argp->header.size;
00508         memcpy(&argp->next, bp, sizeof(argp->next));
00509         bp += sizeof(argp->next);
00510         *argpp = argp;
00511         return (0);
00512 }
00513 
00514 int
00515 CDB___bam_split1_print(dbenv, dbtp, lsnp, notused2, notused3)
00516         DB_ENV *dbenv;
00517         DBT *dbtp;
00518         DB_LSN *lsnp;
00519         db_recops notused2;
00520         void *notused3;
00521 {
00522         __bam_split1_args *argp;
00523         u_int32_t i;
00524         u_int ch;
00525         int ret;
00526 
00527         i = 0;
00528         ch = 0;
00529         notused2 = 0;
00530         notused3 = NULL;
00531 
00532         if ((ret = CDB___bam_split1_read(dbenv, dbtp->data, &argp)) != 0)
00533                 return (ret);
00534         printf("[%lu][%lu]bam_split1: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00535             (u_long)lsnp->file,
00536             (u_long)lsnp->offset,
00537             (u_long)argp->type,
00538             (u_long)argp->txnid->txnid,
00539             (u_long)argp->prev_lsn.file,
00540             (u_long)argp->prev_lsn.offset);
00541         printf("\tfileid: %ld\n", (long)argp->fileid);
00542         printf("\tleft: %lu\n", (u_long)argp->left);
00543         printf("\tllsn: [%lu][%lu]\n",
00544             (u_long)argp->llsn.file, (u_long)argp->llsn.offset);
00545         printf("\tright: %lu\n", (u_long)argp->right);
00546         printf("\trlsn: [%lu][%lu]\n",
00547             (u_long)argp->rlsn.file, (u_long)argp->rlsn.offset);
00548         printf("\tindx: %lu\n", (u_long)argp->indx);
00549         printf("\tnpgno: %lu\n", (u_long)argp->npgno);
00550         printf("\tnlsn: [%lu][%lu]\n",
00551             (u_long)argp->nlsn.file, (u_long)argp->nlsn.offset);
00552         printf("\tpg: ");
00553         for (i = 0; i < argp->pg.size; i++) {
00554                 ch = ((u_int8_t *)argp->pg.data)[i];
00555                 if (isprint(ch) || ch == 0xa)
00556                         putchar(ch);
00557                 else
00558                         printf("%#x ", ch);
00559         }
00560         printf("\n");
00561         printf("\n");
00562         CDB___os_free(argp, 0);
00563         return (0);
00564 }
00565 
00566 int
00567 CDB___bam_split1_read(dbenv, recbuf, argpp)
00568         DB_ENV *dbenv;
00569         void *recbuf;
00570         __bam_split1_args **argpp;
00571 {
00572         __bam_split1_args *argp;
00573         u_int8_t *bp;
00574         int ret;
00575 
00576         ret = CDB___os_malloc(dbenv, sizeof(__bam_split1_args) +
00577             sizeof(DB_TXN), NULL, &argp);
00578         if (ret != 0)
00579                 return (ret);
00580         argp->txnid = (DB_TXN *)&argp[1];
00581         bp = recbuf;
00582         memcpy(&argp->type, bp, sizeof(argp->type));
00583         bp += sizeof(argp->type);
00584         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
00585         bp += sizeof(argp->txnid->txnid);
00586         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00587         bp += sizeof(DB_LSN);
00588         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00589         bp += sizeof(argp->fileid);
00590         memcpy(&argp->left, bp, sizeof(argp->left));
00591         bp += sizeof(argp->left);
00592         memcpy(&argp->llsn, bp,  sizeof(argp->llsn));
00593         bp += sizeof(argp->llsn);
00594         memcpy(&argp->right, bp, sizeof(argp->right));
00595         bp += sizeof(argp->right);
00596         memcpy(&argp->rlsn, bp,  sizeof(argp->rlsn));
00597         bp += sizeof(argp->rlsn);
00598         memcpy(&argp->indx, bp, sizeof(argp->indx));
00599         bp += sizeof(argp->indx);
00600         memcpy(&argp->npgno, bp, sizeof(argp->npgno));
00601         bp += sizeof(argp->npgno);
00602         memcpy(&argp->nlsn, bp,  sizeof(argp->nlsn));
00603         bp += sizeof(argp->nlsn);
00604         memset(&argp->pg, 0, sizeof(argp->pg));
00605         memcpy(&argp->pg.size, bp, sizeof(u_int32_t));
00606         bp += sizeof(u_int32_t);
00607         argp->pg.data = bp;
00608         bp += argp->pg.size;
00609         *argpp = argp;
00610         return (0);
00611 }
00612 
00613 int CDB___bam_split_log(dbenv, txnid, ret_lsnp, flags,
00614         fileid, left, llsn, right, rlsn, indx,
00615         npgno, nlsn, root_pgno, pg, opflags)
00616         DB_ENV *dbenv;
00617         DB_TXN *txnid;
00618         DB_LSN *ret_lsnp;
00619         u_int32_t flags;
00620         int32_t fileid;
00621         db_pgno_t left;
00622         DB_LSN * llsn;
00623         db_pgno_t right;
00624         DB_LSN * rlsn;
00625         u_int32_t indx;
00626         db_pgno_t npgno;
00627         DB_LSN * nlsn;
00628         db_pgno_t root_pgno;
00629         const DBT *pg;
00630         u_int32_t opflags;
00631 {
00632         DBT logrec;
00633         DB_LSN *lsnp, null_lsn;
00634         u_int32_t zero;
00635         u_int32_t rectype, txn_num;
00636         int ret;
00637         u_int8_t *bp;
00638 
00639         if (txnid != NULL &&
00640             TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00641                 return (CDB___db_child_active_err(dbenv));
00642         rectype = DB_bam_split;
00643         txn_num = txnid == NULL ? 0 : txnid->txnid;
00644         if (txnid == NULL) {
00645                 ZERO_LSN(null_lsn);
00646                 lsnp = &null_lsn;
00647         } else
00648                 lsnp = &txnid->last_lsn;
00649         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00650             + sizeof(fileid)
00651             + sizeof(left)
00652             + sizeof(*llsn)
00653             + sizeof(right)
00654             + sizeof(*rlsn)
00655             + sizeof(indx)
00656             + sizeof(npgno)
00657             + sizeof(*nlsn)
00658             + sizeof(root_pgno)
00659             + sizeof(u_int32_t) + (pg == NULL ? 0 : pg->size)
00660             + sizeof(opflags);
00661         if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00662                 return (ret);
00663 
00664         bp = logrec.data;
00665         memcpy(bp, &rectype, sizeof(rectype));
00666         bp += sizeof(rectype);
00667         memcpy(bp, &txn_num, sizeof(txn_num));
00668         bp += sizeof(txn_num);
00669         memcpy(bp, lsnp, sizeof(DB_LSN));
00670         bp += sizeof(DB_LSN);
00671         memcpy(bp, &fileid, sizeof(fileid));
00672         bp += sizeof(fileid);
00673         memcpy(bp, &left, sizeof(left));
00674         bp += sizeof(left);
00675         if (llsn != NULL)
00676                 memcpy(bp, llsn, sizeof(*llsn));
00677         else
00678                 memset(bp, 0, sizeof(*llsn));
00679         bp += sizeof(*llsn);
00680         memcpy(bp, &right, sizeof(right));
00681         bp += sizeof(right);
00682         if (rlsn != NULL)
00683                 memcpy(bp, rlsn, sizeof(*rlsn));
00684         else
00685                 memset(bp, 0, sizeof(*rlsn));
00686         bp += sizeof(*rlsn);
00687         memcpy(bp, &indx, sizeof(indx));
00688         bp += sizeof(indx);
00689         memcpy(bp, &npgno, sizeof(npgno));
00690         bp += sizeof(npgno);
00691         if (nlsn != NULL)
00692                 memcpy(bp, nlsn, sizeof(*nlsn));
00693         else
00694                 memset(bp, 0, sizeof(*nlsn));
00695         bp += sizeof(*nlsn);
00696         memcpy(bp, &root_pgno, sizeof(root_pgno));
00697         bp += sizeof(root_pgno);
00698         if (pg == NULL) {
00699                 zero = 0;
00700                 memcpy(bp, &zero, sizeof(u_int32_t));
00701                 bp += sizeof(u_int32_t);
00702         } else {
00703                 memcpy(bp, &pg->size, sizeof(pg->size));
00704                 bp += sizeof(pg->size);
00705                 memcpy(bp, pg->data, pg->size);
00706                 bp += pg->size;
00707         }
00708         memcpy(bp, &opflags, sizeof(opflags));
00709         bp += sizeof(opflags);
00710         DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00711         ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00712         if (txnid != NULL)
00713                 txnid->last_lsn = *ret_lsnp;
00714         CDB___os_free(logrec.data, logrec.size);
00715         return (ret);
00716 }
00717 
00718 int
00719 CDB___bam_split_print(dbenv, dbtp, lsnp, notused2, notused3)
00720         DB_ENV *dbenv;
00721         DBT *dbtp;
00722         DB_LSN *lsnp;
00723         db_recops notused2;
00724         void *notused3;
00725 {
00726         __bam_split_args *argp;
00727         u_int32_t i;
00728         u_int ch;
00729         int ret;
00730 
00731         i = 0;
00732         ch = 0;
00733         notused2 = 0;
00734         notused3 = NULL;
00735 
00736         if ((ret = CDB___bam_split_read(dbenv, dbtp->data, &argp)) != 0)
00737                 return (ret);
00738         printf("[%lu][%lu]bam_split: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00739             (u_long)lsnp->file,
00740             (u_long)lsnp->offset,
00741             (u_long)argp->type,
00742             (u_long)argp->txnid->txnid,
00743             (u_long)argp->prev_lsn.file,
00744             (u_long)argp->prev_lsn.offset);
00745         printf("\tfileid: %ld\n", (long)argp->fileid);
00746         printf("\tleft: %lu\n", (u_long)argp->left);
00747         printf("\tllsn: [%lu][%lu]\n",
00748             (u_long)argp->llsn.file, (u_long)argp->llsn.offset);
00749         printf("\tright: %lu\n", (u_long)argp->right);
00750         printf("\trlsn: [%lu][%lu]\n",
00751             (u_long)argp->rlsn.file, (u_long)argp->rlsn.offset);
00752         printf("\tindx: %lu\n", (u_long)argp->indx);
00753         printf("\tnpgno: %lu\n", (u_long)argp->npgno);
00754         printf("\tnlsn: [%lu][%lu]\n",
00755             (u_long)argp->nlsn.file, (u_long)argp->nlsn.offset);
00756         printf("\troot_pgno: %lu\n", (u_long)argp->root_pgno);
00757         printf("\tpg: ");
00758         for (i = 0; i < argp->pg.size; i++) {
00759                 ch = ((u_int8_t *)argp->pg.data)[i];
00760                 if (isprint(ch) || ch == 0xa)
00761                         putchar(ch);
00762                 else
00763                         printf("%#x ", ch);
00764         }
00765         printf("\n");
00766         printf("\topflags: %lu\n", (u_long)argp->opflags);
00767         printf("\n");
00768         CDB___os_free(argp, 0);
00769         return (0);
00770 }
00771 
00772 int
00773 CDB___bam_split_read(dbenv, recbuf, argpp)
00774         DB_ENV *dbenv;
00775         void *recbuf;
00776         __bam_split_args **argpp;
00777 {
00778         __bam_split_args *argp;
00779         u_int8_t *bp;
00780         int ret;
00781 
00782         ret = CDB___os_malloc(dbenv, sizeof(__bam_split_args) +
00783             sizeof(DB_TXN), NULL, &argp);
00784         if (ret != 0)
00785                 return (ret);
00786         argp->txnid = (DB_TXN *)&argp[1];
00787         bp = recbuf;
00788         memcpy(&argp->type, bp, sizeof(argp->type));
00789         bp += sizeof(argp->type);
00790         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
00791         bp += sizeof(argp->txnid->txnid);
00792         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00793         bp += sizeof(DB_LSN);
00794         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00795         bp += sizeof(argp->fileid);
00796         memcpy(&argp->left, bp, sizeof(argp->left));
00797         bp += sizeof(argp->left);
00798         memcpy(&argp->llsn, bp,  sizeof(argp->llsn));
00799         bp += sizeof(argp->llsn);
00800         memcpy(&argp->right, bp, sizeof(argp->right));
00801         bp += sizeof(argp->right);
00802         memcpy(&argp->rlsn, bp,  sizeof(argp->rlsn));
00803         bp += sizeof(argp->rlsn);
00804         memcpy(&argp->indx, bp, sizeof(argp->indx));
00805         bp += sizeof(argp->indx);
00806         memcpy(&argp->npgno, bp, sizeof(argp->npgno));
00807         bp += sizeof(argp->npgno);
00808         memcpy(&argp->nlsn, bp,  sizeof(argp->nlsn));
00809         bp += sizeof(argp->nlsn);
00810         memcpy(&argp->root_pgno, bp, sizeof(argp->root_pgno));
00811         bp += sizeof(argp->root_pgno);
00812         memset(&argp->pg, 0, sizeof(argp->pg));
00813         memcpy(&argp->pg.size, bp, sizeof(u_int32_t));
00814         bp += sizeof(u_int32_t);
00815         argp->pg.data = bp;
00816         bp += argp->pg.size;
00817         memcpy(&argp->opflags, bp, sizeof(argp->opflags));
00818         bp += sizeof(argp->opflags);
00819         *argpp = argp;
00820         return (0);
00821 }
00822 
00823 int
00824 CDB___bam_rsplit1_print(dbenv, dbtp, lsnp, notused2, notused3)
00825         DB_ENV *dbenv;
00826         DBT *dbtp;
00827         DB_LSN *lsnp;
00828         db_recops notused2;
00829         void *notused3;
00830 {
00831         __bam_rsplit1_args *argp;
00832         u_int32_t i;
00833         u_int ch;
00834         int ret;
00835 
00836         i = 0;
00837         ch = 0;
00838         notused2 = 0;
00839         notused3 = NULL;
00840 
00841         if ((ret = CDB___bam_rsplit1_read(dbenv, dbtp->data, &argp)) != 0)
00842                 return (ret);
00843         printf("[%lu][%lu]bam_rsplit1: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00844             (u_long)lsnp->file,
00845             (u_long)lsnp->offset,
00846             (u_long)argp->type,
00847             (u_long)argp->txnid->txnid,
00848             (u_long)argp->prev_lsn.file,
00849             (u_long)argp->prev_lsn.offset);
00850         printf("\tfileid: %ld\n", (long)argp->fileid);
00851         printf("\tpgno: %lu\n", (u_long)argp->pgno);
00852         printf("\tpgdbt: ");
00853         for (i = 0; i < argp->pgdbt.size; i++) {
00854                 ch = ((u_int8_t *)argp->pgdbt.data)[i];
00855                 if (isprint(ch) || ch == 0xa)
00856                         putchar(ch);
00857                 else
00858                         printf("%#x ", ch);
00859         }
00860         printf("\n");
00861         printf("\tnrec: %lu\n", (u_long)argp->nrec);
00862         printf("\trootent: ");
00863         for (i = 0; i < argp->rootent.size; i++) {
00864                 ch = ((u_int8_t *)argp->rootent.data)[i];
00865                 if (isprint(ch) || ch == 0xa)
00866                         putchar(ch);
00867                 else
00868                         printf("%#x ", ch);
00869         }
00870         printf("\n");
00871         printf("\trootlsn: [%lu][%lu]\n",
00872             (u_long)argp->rootlsn.file, (u_long)argp->rootlsn.offset);
00873         printf("\n");
00874         CDB___os_free(argp, 0);
00875         return (0);
00876 }
00877 
00878 int
00879 CDB___bam_rsplit1_read(dbenv, recbuf, argpp)
00880         DB_ENV *dbenv;
00881         void *recbuf;
00882         __bam_rsplit1_args **argpp;
00883 {
00884         __bam_rsplit1_args *argp;
00885         u_int8_t *bp;
00886         int ret;
00887 
00888         ret = CDB___os_malloc(dbenv, sizeof(__bam_rsplit1_args) +
00889             sizeof(DB_TXN), NULL, &argp);
00890         if (ret != 0)
00891                 return (ret);
00892         argp->txnid = (DB_TXN *)&argp[1];
00893         bp = recbuf;
00894         memcpy(&argp->type, bp, sizeof(argp->type));
00895         bp += sizeof(argp->type);
00896         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
00897         bp += sizeof(argp->txnid->txnid);
00898         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00899         bp += sizeof(DB_LSN);
00900         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00901         bp += sizeof(argp->fileid);
00902         memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00903         bp += sizeof(argp->pgno);
00904         memset(&argp->pgdbt, 0, sizeof(argp->pgdbt));
00905         memcpy(&argp->pgdbt.size, bp, sizeof(u_int32_t));
00906         bp += sizeof(u_int32_t);
00907         argp->pgdbt.data = bp;
00908         bp += argp->pgdbt.size;
00909         memcpy(&argp->nrec, bp, sizeof(argp->nrec));
00910         bp += sizeof(argp->nrec);
00911         memset(&argp->rootent, 0, sizeof(argp->rootent));
00912         memcpy(&argp->rootent.size, bp, sizeof(u_int32_t));
00913         bp += sizeof(u_int32_t);
00914         argp->rootent.data = bp;
00915         bp += argp->rootent.size;
00916         memcpy(&argp->rootlsn, bp,  sizeof(argp->rootlsn));
00917         bp += sizeof(argp->rootlsn);
00918         *argpp = argp;
00919         return (0);
00920 }
00921 
00922 int CDB___bam_rsplit_log(dbenv, txnid, ret_lsnp, flags,
00923         fileid, pgno, pgdbt, root_pgno, nrec, rootent,
00924         rootlsn)
00925         DB_ENV *dbenv;
00926         DB_TXN *txnid;
00927         DB_LSN *ret_lsnp;
00928         u_int32_t flags;
00929         int32_t fileid;
00930         db_pgno_t pgno;
00931         const DBT *pgdbt;
00932         db_pgno_t root_pgno;
00933         db_pgno_t nrec;
00934         const DBT *rootent;
00935         DB_LSN * rootlsn;
00936 {
00937         DBT logrec;
00938         DB_LSN *lsnp, null_lsn;
00939         u_int32_t zero;
00940         u_int32_t rectype, txn_num;
00941         int ret;
00942         u_int8_t *bp;
00943 
00944         if (txnid != NULL &&
00945             TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00946                 return (CDB___db_child_active_err(dbenv));
00947         rectype = DB_bam_rsplit;
00948         txn_num = txnid == NULL ? 0 : txnid->txnid;
00949         if (txnid == NULL) {
00950                 ZERO_LSN(null_lsn);
00951                 lsnp = &null_lsn;
00952         } else
00953                 lsnp = &txnid->last_lsn;
00954         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00955             + sizeof(fileid)
00956             + sizeof(pgno)
00957             + sizeof(u_int32_t) + (pgdbt == NULL ? 0 : pgdbt->size)
00958             + sizeof(root_pgno)
00959             + sizeof(nrec)
00960             + sizeof(u_int32_t) + (rootent == NULL ? 0 : rootent->size)
00961             + sizeof(*rootlsn);
00962         if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00963                 return (ret);
00964 
00965         bp = logrec.data;
00966         memcpy(bp, &rectype, sizeof(rectype));
00967         bp += sizeof(rectype);
00968         memcpy(bp, &txn_num, sizeof(txn_num));
00969         bp += sizeof(txn_num);
00970         memcpy(bp, lsnp, sizeof(DB_LSN));
00971         bp += sizeof(DB_LSN);
00972         memcpy(bp, &fileid, sizeof(fileid));
00973         bp += sizeof(fileid);
00974         memcpy(bp, &pgno, sizeof(pgno));
00975         bp += sizeof(pgno);
00976         if (pgdbt == NULL) {
00977                 zero = 0;
00978                 memcpy(bp, &zero, sizeof(u_int32_t));
00979                 bp += sizeof(u_int32_t);
00980         } else {
00981                 memcpy(bp, &pgdbt->size, sizeof(pgdbt->size));
00982                 bp += sizeof(pgdbt->size);
00983                 memcpy(bp, pgdbt->data, pgdbt->size);
00984                 bp += pgdbt->size;
00985         }
00986         memcpy(bp, &root_pgno, sizeof(root_pgno));
00987         bp += sizeof(root_pgno);
00988         memcpy(bp, &nrec, sizeof(nrec));
00989         bp += sizeof(nrec);
00990         if (rootent == NULL) {
00991                 zero = 0;
00992                 memcpy(bp, &zero, sizeof(u_int32_t));
00993                 bp += sizeof(u_int32_t);
00994         } else {
00995                 memcpy(bp, &rootent->size, sizeof(rootent->size));
00996                 bp += sizeof(rootent->size);
00997                 memcpy(bp, rootent->data, rootent->size);
00998                 bp += rootent->size;
00999         }
01000         if (rootlsn != NULL)
01001                 memcpy(bp, rootlsn, sizeof(*rootlsn));
01002         else
01003                 memset(bp, 0, sizeof(*rootlsn));
01004         bp += sizeof(*rootlsn);
01005         DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
01006         ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
01007         if (txnid != NULL)
01008                 txnid->last_lsn = *ret_lsnp;
01009         CDB___os_free(logrec.data, logrec.size);
01010         return (ret);
01011 }
01012 
01013 int
01014 CDB___bam_rsplit_print(dbenv, dbtp, lsnp, notused2, notused3)
01015         DB_ENV *dbenv;
01016         DBT *dbtp;
01017         DB_LSN *lsnp;
01018         db_recops notused2;
01019         void *notused3;
01020 {
01021         __bam_rsplit_args *argp;
01022         u_int32_t i;
01023         u_int ch;
01024         int ret;
01025 
01026         i = 0;
01027         ch = 0;
01028         notused2 = 0;
01029         notused3 = NULL;
01030 
01031         if ((ret = CDB___bam_rsplit_read(dbenv, dbtp->data, &argp)) != 0)
01032                 return (ret);
01033         printf("[%lu][%lu]bam_rsplit: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
01034             (u_long)lsnp->file,
01035             (u_long)lsnp->offset,
01036             (u_long)argp->type,
01037             (u_long)argp->txnid->txnid,
01038             (u_long)argp->prev_lsn.file,
01039             (u_long)argp->prev_lsn.offset);
01040         printf("\tfileid: %ld\n", (long)argp->fileid);
01041         printf("\tpgno: %lu\n", (u_long)argp->pgno);
01042         printf("\tpgdbt: ");
01043         for (i = 0; i < argp->pgdbt.size; i++) {
01044                 ch = ((u_int8_t *)argp->pgdbt.data)[i];
01045                 if (isprint(ch) || ch == 0xa)
01046                         putchar(ch);
01047                 else
01048                         printf("%#x ", ch);
01049         }
01050         printf("\n");
01051         printf("\troot_pgno: %lu\n", (u_long)argp->root_pgno);
01052         printf("\tnrec: %lu\n", (u_long)argp->nrec);
01053         printf("\trootent: ");
01054         for (i = 0; i < argp->rootent.size; i++) {
01055                 ch = ((u_int8_t *)argp->rootent.data)[i];
01056                 if (isprint(ch) || ch == 0xa)
01057                         putchar(ch);
01058                 else
01059                         printf("%#x ", ch);
01060         }
01061         printf("\n");
01062         printf("\trootlsn: [%lu][%lu]\n",
01063             (u_long)argp->rootlsn.file, (u_long)argp->rootlsn.offset);
01064         printf("\n");
01065         CDB___os_free(argp, 0);
01066         return (0);
01067 }
01068 
01069 int
01070 CDB___bam_rsplit_read(dbenv, recbuf, argpp)
01071         DB_ENV *dbenv;
01072         void *recbuf;
01073         __bam_rsplit_args **argpp;
01074 {
01075         __bam_rsplit_args *argp;
01076         u_int8_t *bp;
01077         int ret;
01078 
01079         ret = CDB___os_malloc(dbenv, sizeof(__bam_rsplit_args) +
01080             sizeof(DB_TXN), NULL, &argp);
01081         if (ret != 0)
01082                 return (ret);
01083         argp->txnid = (DB_TXN *)&argp[1];
01084         bp = recbuf;
01085         memcpy(&argp->type, bp, sizeof(argp->type));
01086         bp += sizeof(argp->type);
01087         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
01088         bp += sizeof(argp->txnid->txnid);
01089         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
01090         bp += sizeof(DB_LSN);
01091         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
01092         bp += sizeof(argp->fileid);
01093         memcpy(&argp->pgno, bp, sizeof(argp->pgno));
01094         bp += sizeof(argp->pgno);
01095         memset(&argp->pgdbt, 0, sizeof(argp->pgdbt));
01096         memcpy(&argp->pgdbt.size, bp, sizeof(u_int32_t));
01097         bp += sizeof(u_int32_t);
01098         argp->pgdbt.data = bp;
01099         bp += argp->pgdbt.size;
01100         memcpy(&argp->root_pgno, bp, sizeof(argp->root_pgno));
01101         bp += sizeof(argp->root_pgno);
01102         memcpy(&argp->nrec, bp, sizeof(argp->nrec));
01103         bp += sizeof(argp->nrec);
01104         memset(&argp->rootent, 0, sizeof(argp->rootent));
01105         memcpy(&argp->rootent.size, bp, sizeof(u_int32_t));
01106         bp += sizeof(u_int32_t);
01107         argp->rootent.data = bp;
01108         bp += argp->rootent.size;
01109         memcpy(&argp->rootlsn, bp,  sizeof(argp->rootlsn));
01110         bp += sizeof(argp->rootlsn);
01111         *argpp = argp;
01112         return (0);
01113 }
01114 
01115 int CDB___bam_adj_log(dbenv, txnid, ret_lsnp, flags,
01116         fileid, pgno, lsn, indx, indx_copy, is_insert)
01117         DB_ENV *dbenv;
01118         DB_TXN *txnid;
01119         DB_LSN *ret_lsnp;
01120         u_int32_t flags;
01121         int32_t fileid;
01122         db_pgno_t pgno;
01123         DB_LSN * lsn;
01124         u_int32_t indx;
01125         u_int32_t indx_copy;
01126         u_int32_t is_insert;
01127 {
01128         DBT logrec;
01129         DB_LSN *lsnp, null_lsn;
01130         u_int32_t rectype, txn_num;
01131         int ret;
01132         u_int8_t *bp;
01133 
01134         if (txnid != NULL &&
01135             TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
01136                 return (CDB___db_child_active_err(dbenv));
01137         rectype = DB_bam_adj;
01138         txn_num = txnid == NULL ? 0 : txnid->txnid;
01139         if (txnid == NULL) {
01140                 ZERO_LSN(null_lsn);
01141                 lsnp = &null_lsn;
01142         } else
01143                 lsnp = &txnid->last_lsn;
01144         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
01145             + sizeof(fileid)
01146             + sizeof(pgno)
01147             + sizeof(*lsn)
01148             + sizeof(indx)
01149             + sizeof(indx_copy)
01150             + sizeof(is_insert);
01151         if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
01152                 return (ret);
01153 
01154         bp = logrec.data;
01155         memcpy(bp, &rectype, sizeof(rectype));
01156         bp += sizeof(rectype);
01157         memcpy(bp, &txn_num, sizeof(txn_num));
01158         bp += sizeof(txn_num);
01159         memcpy(bp, lsnp, sizeof(DB_LSN));
01160         bp += sizeof(DB_LSN);
01161         memcpy(bp, &fileid, sizeof(fileid));
01162         bp += sizeof(fileid);
01163         memcpy(bp, &pgno, sizeof(pgno));
01164         bp += sizeof(pgno);
01165         if (lsn != NULL)
01166                 memcpy(bp, lsn, sizeof(*lsn));
01167         else
01168                 memset(bp, 0, sizeof(*lsn));
01169         bp += sizeof(*lsn);
01170         memcpy(bp, &indx, sizeof(indx));
01171         bp += sizeof(indx);
01172         memcpy(bp, &indx_copy, sizeof(indx_copy));
01173         bp += sizeof(indx_copy);
01174         memcpy(bp, &is_insert, sizeof(is_insert));
01175         bp += sizeof(is_insert);
01176         DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
01177         ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
01178         if (txnid != NULL)
01179                 txnid->last_lsn = *ret_lsnp;
01180         CDB___os_free(logrec.data, logrec.size);
01181         return (ret);
01182 }
01183 
01184 int
01185 CDB___bam_adj_print(dbenv, dbtp, lsnp, notused2, notused3)
01186         DB_ENV *dbenv;
01187         DBT *dbtp;
01188         DB_LSN *lsnp;
01189         db_recops notused2;
01190         void *notused3;
01191 {
01192         __bam_adj_args *argp;
01193         u_int32_t i;
01194         u_int ch;
01195         int ret;
01196 
01197         i = 0;
01198         ch = 0;
01199         notused2 = 0;
01200         notused3 = NULL;
01201 
01202         if ((ret = CDB___bam_adj_read(dbenv, dbtp->data, &argp)) != 0)
01203                 return (ret);
01204         printf("[%lu][%lu]bam_adj: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
01205             (u_long)lsnp->file,
01206             (u_long)lsnp->offset,
01207             (u_long)argp->type,
01208             (u_long)argp->txnid->txnid,
01209             (u_long)argp->prev_lsn.file,
01210             (u_long)argp->prev_lsn.offset);
01211         printf("\tfileid: %ld\n", (long)argp->fileid);
01212         printf("\tpgno: %lu\n", (u_long)argp->pgno);
01213         printf("\tlsn: [%lu][%lu]\n",
01214             (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
01215         printf("\tindx: %lu\n", (u_long)argp->indx);
01216         printf("\tindx_copy: %lu\n", (u_long)argp->indx_copy);
01217         printf("\tis_insert: %lu\n", (u_long)argp->is_insert);
01218         printf("\n");
01219         CDB___os_free(argp, 0);
01220         return (0);
01221 }
01222 
01223 int
01224 CDB___bam_adj_read(dbenv, recbuf, argpp)
01225         DB_ENV *dbenv;
01226         void *recbuf;
01227         __bam_adj_args **argpp;
01228 {
01229         __bam_adj_args *argp;
01230         u_int8_t *bp;
01231         int ret;
01232 
01233         ret = CDB___os_malloc(dbenv, sizeof(__bam_adj_args) +
01234             sizeof(DB_TXN), NULL, &argp);
01235         if (ret != 0)
01236                 return (ret);
01237         argp->txnid = (DB_TXN *)&argp[1];
01238         bp = recbuf;
01239         memcpy(&argp->type, bp, sizeof(argp->type));
01240         bp += sizeof(argp->type);
01241         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
01242         bp += sizeof(argp->txnid->txnid);
01243         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
01244         bp += sizeof(DB_LSN);
01245         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
01246         bp += sizeof(argp->fileid);
01247         memcpy(&argp->pgno, bp, sizeof(argp->pgno));
01248         bp += sizeof(argp->pgno);
01249         memcpy(&argp->lsn, bp,  sizeof(argp->lsn));
01250         bp += sizeof(argp->lsn);
01251         memcpy(&argp->indx, bp, sizeof(argp->indx));
01252         bp += sizeof(argp->indx);
01253         memcpy(&argp->indx_copy, bp, sizeof(argp->indx_copy));
01254         bp += sizeof(argp->indx_copy);
01255         memcpy(&argp->is_insert, bp, sizeof(argp->is_insert));
01256         bp += sizeof(argp->is_insert);
01257         *argpp = argp;
01258         return (0);
01259 }
01260 
01261 int CDB___bam_cadjust_log(dbenv, txnid, ret_lsnp, flags,
01262         fileid, pgno, lsn, indx, adjust, opflags)
01263         DB_ENV *dbenv;
01264         DB_TXN *txnid;
01265         DB_LSN *ret_lsnp;
01266         u_int32_t flags;
01267         int32_t fileid;
01268         db_pgno_t pgno;
01269         DB_LSN * lsn;
01270         u_int32_t indx;
01271         int32_t adjust;
01272         u_int32_t opflags;
01273 {
01274         DBT logrec;
01275         DB_LSN *lsnp, null_lsn;
01276         u_int32_t rectype, txn_num;
01277         int ret;
01278         u_int8_t *bp;
01279 
01280         if (txnid != NULL &&
01281             TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
01282                 return (CDB___db_child_active_err(dbenv));
01283         rectype = DB_bam_cadjust;
01284         txn_num = txnid == NULL ? 0 : txnid->txnid;
01285         if (txnid == NULL) {
01286                 ZERO_LSN(null_lsn);
01287                 lsnp = &null_lsn;
01288         } else
01289                 lsnp = &txnid->last_lsn;
01290         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
01291             + sizeof(fileid)
01292             + sizeof(pgno)
01293             + sizeof(*lsn)
01294             + sizeof(indx)
01295             + sizeof(adjust)
01296             + sizeof(opflags);
01297         if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
01298                 return (ret);
01299 
01300         bp = logrec.data;
01301         memcpy(bp, &rectype, sizeof(rectype));
01302         bp += sizeof(rectype);
01303         memcpy(bp, &txn_num, sizeof(txn_num));
01304         bp += sizeof(txn_num);
01305         memcpy(bp, lsnp, sizeof(DB_LSN));
01306         bp += sizeof(DB_LSN);
01307         memcpy(bp, &fileid, sizeof(fileid));
01308         bp += sizeof(fileid);
01309         memcpy(bp, &pgno, sizeof(pgno));
01310         bp += sizeof(pgno);
01311         if (lsn != NULL)
01312                 memcpy(bp, lsn, sizeof(*lsn));
01313         else
01314                 memset(bp, 0, sizeof(*lsn));
01315         bp += sizeof(*lsn);
01316         memcpy(bp, &indx, sizeof(indx));
01317         bp += sizeof(indx);
01318         memcpy(bp, &adjust, sizeof(adjust));
01319         bp += sizeof(adjust);
01320         memcpy(bp, &opflags, sizeof(opflags));
01321         bp += sizeof(opflags);
01322         DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
01323         ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
01324         if (txnid != NULL)
01325                 txnid->last_lsn = *ret_lsnp;
01326         CDB___os_free(logrec.data, logrec.size);
01327         return (ret);
01328 }
01329 
01330 int
01331 CDB___bam_cadjust_print(dbenv, dbtp, lsnp, notused2, notused3)
01332         DB_ENV *dbenv;
01333         DBT *dbtp;
01334         DB_LSN *lsnp;
01335         db_recops notused2;
01336         void *notused3;
01337 {
01338         __bam_cadjust_args *argp;
01339         u_int32_t i;
01340         u_int ch;
01341         int ret;
01342 
01343         i = 0;
01344         ch = 0;
01345         notused2 = 0;
01346         notused3 = NULL;
01347 
01348         if ((ret = CDB___bam_cadjust_read(dbenv, dbtp->data, &argp)) != 0)
01349                 return (ret);
01350         printf("[%lu][%lu]bam_cadjust: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
01351             (u_long)lsnp->file,
01352             (u_long)lsnp->offset,
01353             (u_long)argp->type,
01354             (u_long)argp->txnid->txnid,
01355             (u_long)argp->prev_lsn.file,
01356             (u_long)argp->prev_lsn.offset);
01357         printf("\tfileid: %ld\n", (long)argp->fileid);
01358         printf("\tpgno: %lu\n", (u_long)argp->pgno);
01359         printf("\tlsn: [%lu][%lu]\n",
01360             (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
01361         printf("\tindx: %lu\n", (u_long)argp->indx);
01362         printf("\tadjust: %ld\n", (long)argp->adjust);
01363         printf("\topflags: %lu\n", (u_long)argp->opflags);
01364         printf("\n");
01365         CDB___os_free(argp, 0);
01366         return (0);
01367 }
01368 
01369 int
01370 CDB___bam_cadjust_read(dbenv, recbuf, argpp)
01371         DB_ENV *dbenv;
01372         void *recbuf;
01373         __bam_cadjust_args **argpp;
01374 {
01375         __bam_cadjust_args *argp;
01376         u_int8_t *bp;
01377         int ret;
01378 
01379         ret = CDB___os_malloc(dbenv, sizeof(__bam_cadjust_args) +
01380             sizeof(DB_TXN), NULL, &argp);
01381         if (ret != 0)
01382                 return (ret);
01383         argp->txnid = (DB_TXN *)&argp[1];
01384         bp = recbuf;
01385         memcpy(&argp->type, bp, sizeof(argp->type));
01386         bp += sizeof(argp->type);
01387         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
01388         bp += sizeof(argp->txnid->txnid);
01389         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
01390         bp += sizeof(DB_LSN);
01391         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
01392         bp += sizeof(argp->fileid);
01393         memcpy(&argp->pgno, bp, sizeof(argp->pgno));
01394         bp += sizeof(argp->pgno);
01395         memcpy(&argp->lsn, bp,  sizeof(argp->lsn));
01396         bp += sizeof(argp->lsn);
01397         memcpy(&argp->indx, bp, sizeof(argp->indx));
01398         bp += sizeof(argp->indx);
01399         memcpy(&argp->adjust, bp, sizeof(argp->adjust));
01400         bp += sizeof(argp->adjust);
01401         memcpy(&argp->opflags, bp, sizeof(argp->opflags));
01402         bp += sizeof(argp->opflags);
01403         *argpp = argp;
01404         return (0);
01405 }
01406 
01407 int CDB___bam_cdel_log(dbenv, txnid, ret_lsnp, flags,
01408         fileid, pgno, lsn, indx)
01409         DB_ENV *dbenv;
01410         DB_TXN *txnid;
01411         DB_LSN *ret_lsnp;
01412         u_int32_t flags;
01413         int32_t fileid;
01414         db_pgno_t pgno;
01415         DB_LSN * lsn;
01416         u_int32_t indx;
01417 {
01418         DBT logrec;
01419         DB_LSN *lsnp, null_lsn;
01420         u_int32_t rectype, txn_num;
01421         int ret;
01422         u_int8_t *bp;
01423 
01424         if (txnid != NULL &&
01425             TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
01426                 return (CDB___db_child_active_err(dbenv));
01427         rectype = DB_bam_cdel;
01428         txn_num = txnid == NULL ? 0 : txnid->txnid;
01429         if (txnid == NULL) {
01430                 ZERO_LSN(null_lsn);
01431                 lsnp = &null_lsn;
01432         } else
01433                 lsnp = &txnid->last_lsn;
01434         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
01435             + sizeof(fileid)
01436             + sizeof(pgno)
01437             + sizeof(*lsn)
01438             + sizeof(indx);
01439         if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
01440                 return (ret);
01441 
01442         bp = logrec.data;
01443         memcpy(bp, &rectype, sizeof(rectype));
01444         bp += sizeof(rectype);
01445         memcpy(bp, &txn_num, sizeof(txn_num));
01446         bp += sizeof(txn_num);
01447         memcpy(bp, lsnp, sizeof(DB_LSN));
01448         bp += sizeof(DB_LSN);
01449         memcpy(bp, &fileid, sizeof(fileid));
01450         bp += sizeof(fileid);
01451         memcpy(bp, &pgno, sizeof(pgno));
01452         bp += sizeof(pgno);
01453         if (lsn != NULL)
01454                 memcpy(bp, lsn, sizeof(*lsn));
01455         else
01456                 memset(bp, 0, sizeof(*lsn));
01457         bp += sizeof(*lsn);
01458         memcpy(bp, &indx, sizeof(indx));
01459         bp += sizeof(indx);
01460         DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
01461         ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
01462         if (txnid != NULL)
01463                 txnid->last_lsn = *ret_lsnp;
01464         CDB___os_free(logrec.data, logrec.size);
01465         return (ret);
01466 }
01467 
01468 int
01469 CDB___bam_cdel_print(dbenv, dbtp, lsnp, notused2, notused3)
01470         DB_ENV *dbenv;
01471         DBT *dbtp;
01472         DB_LSN *lsnp;
01473         db_recops notused2;
01474         void *notused3;
01475 {
01476         __bam_cdel_args *argp;
01477         u_int32_t i;
01478         u_int ch;
01479         int ret;
01480 
01481         i = 0;
01482         ch = 0;
01483         notused2 = 0;
01484         notused3 = NULL;
01485 
01486         if ((ret = CDB___bam_cdel_read(dbenv, dbtp->data, &argp)) != 0)
01487                 return (ret);
01488         printf("[%lu][%lu]bam_cdel: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
01489             (u_long)lsnp->file,
01490             (u_long)lsnp->offset,
01491             (u_long)argp->type,
01492             (u_long)argp->txnid->txnid,
01493             (u_long)argp->prev_lsn.file,
01494             (u_long)argp->prev_lsn.offset);
01495         printf("\tfileid: %ld\n", (long)argp->fileid);
01496         printf("\tpgno: %lu\n", (u_long)argp->pgno);
01497         printf("\tlsn: [%lu][%lu]\n",
01498             (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
01499         printf("\tindx: %lu\n", (u_long)argp->indx);
01500         printf("\n");
01501         CDB___os_free(argp, 0);
01502         return (0);
01503 }
01504 
01505 int
01506 CDB___bam_cdel_read(dbenv, recbuf, argpp)
01507         DB_ENV *dbenv;
01508         void *recbuf;
01509         __bam_cdel_args **argpp;
01510 {
01511         __bam_cdel_args *argp;
01512         u_int8_t *bp;
01513         int ret;
01514 
01515         ret = CDB___os_malloc(dbenv, sizeof(__bam_cdel_args) +
01516             sizeof(DB_TXN), NULL, &argp);
01517         if (ret != 0)
01518                 return (ret);
01519         argp->txnid = (DB_TXN *)&argp[1];
01520         bp = recbuf;
01521         memcpy(&argp->type, bp, sizeof(argp->type));
01522         bp += sizeof(argp->type);
01523         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
01524         bp += sizeof(argp->txnid->txnid);
01525         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
01526         bp += sizeof(DB_LSN);
01527         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
01528         bp += sizeof(argp->fileid);
01529         memcpy(&argp->pgno, bp, sizeof(argp->pgno));
01530         bp += sizeof(argp->pgno);
01531         memcpy(&argp->lsn, bp,  sizeof(argp->lsn));
01532         bp += sizeof(argp->lsn);
01533         memcpy(&argp->indx, bp, sizeof(argp->indx));
01534         bp += sizeof(argp->indx);
01535         *argpp = argp;
01536         return (0);
01537 }
01538 
01539 int CDB___bam_repl_log(dbenv, txnid, ret_lsnp, flags,
01540         fileid, pgno, lsn, indx, isdeleted, orig,
01541         repl, prefix, suffix)
01542         DB_ENV *dbenv;
01543         DB_TXN *txnid;
01544         DB_LSN *ret_lsnp;
01545         u_int32_t flags;
01546         int32_t fileid;
01547         db_pgno_t pgno;
01548         DB_LSN * lsn;
01549         u_int32_t indx;
01550         u_int32_t isdeleted;
01551         const DBT *orig;
01552         const DBT *repl;
01553         u_int32_t prefix;
01554         u_int32_t suffix;
01555 {
01556         DBT logrec;
01557         DB_LSN *lsnp, null_lsn;
01558         u_int32_t zero;
01559         u_int32_t rectype, txn_num;
01560         int ret;
01561         u_int8_t *bp;
01562 
01563         if (txnid != NULL &&
01564             TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
01565                 return (CDB___db_child_active_err(dbenv));
01566         rectype = DB_bam_repl;
01567         txn_num = txnid == NULL ? 0 : txnid->txnid;
01568         if (txnid == NULL) {
01569                 ZERO_LSN(null_lsn);
01570                 lsnp = &null_lsn;
01571         } else
01572                 lsnp = &txnid->last_lsn;
01573         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
01574             + sizeof(fileid)
01575             + sizeof(pgno)
01576             + sizeof(*lsn)
01577             + sizeof(indx)
01578             + sizeof(isdeleted)
01579             + sizeof(u_int32_t) + (orig == NULL ? 0 : orig->size)
01580             + sizeof(u_int32_t) + (repl == NULL ? 0 : repl->size)
01581             + sizeof(prefix)
01582             + sizeof(suffix);
01583         if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
01584                 return (ret);
01585 
01586         bp = logrec.data;
01587         memcpy(bp, &rectype, sizeof(rectype));
01588         bp += sizeof(rectype);
01589         memcpy(bp, &txn_num, sizeof(txn_num));
01590         bp += sizeof(txn_num);
01591         memcpy(bp, lsnp, sizeof(DB_LSN));
01592         bp += sizeof(DB_LSN);
01593         memcpy(bp, &fileid, sizeof(fileid));
01594         bp += sizeof(fileid);
01595         memcpy(bp, &pgno, sizeof(pgno));
01596         bp += sizeof(pgno);
01597         if (lsn != NULL)
01598                 memcpy(bp, lsn, sizeof(*lsn));
01599         else
01600                 memset(bp, 0, sizeof(*lsn));
01601         bp += sizeof(*lsn);
01602         memcpy(bp, &indx, sizeof(indx));
01603         bp += sizeof(indx);
01604         memcpy(bp, &isdeleted, sizeof(isdeleted));
01605         bp += sizeof(isdeleted);
01606         if (orig == NULL) {
01607                 zero = 0;
01608                 memcpy(bp, &zero, sizeof(u_int32_t));
01609                 bp += sizeof(u_int32_t);
01610         } else {
01611                 memcpy(bp, &orig->size, sizeof(orig->size));
01612                 bp += sizeof(orig->size);
01613                 memcpy(bp, orig->data, orig->size);
01614                 bp += orig->size;
01615         }
01616         if (repl == NULL) {
01617                 zero = 0;
01618                 memcpy(bp, &zero, sizeof(u_int32_t));
01619                 bp += sizeof(u_int32_t);
01620         } else {
01621                 memcpy(bp, &repl->size, sizeof(repl->size));
01622                 bp += sizeof(repl->size);
01623                 memcpy(bp, repl->data, repl->size);
01624                 bp += repl->size;
01625         }
01626         memcpy(bp, &prefix, sizeof(prefix));
01627         bp += sizeof(prefix);
01628         memcpy(bp, &suffix, sizeof(suffix));
01629         bp += sizeof(suffix);
01630         DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
01631         ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
01632         if (txnid != NULL)
01633                 txnid->last_lsn = *ret_lsnp;
01634         CDB___os_free(logrec.data, logrec.size);
01635         return (ret);
01636 }
01637 
01638 int
01639 CDB___bam_repl_print(dbenv, dbtp, lsnp, notused2, notused3)
01640         DB_ENV *dbenv;
01641         DBT *dbtp;
01642         DB_LSN *lsnp;
01643         db_recops notused2;
01644         void *notused3;
01645 {
01646         __bam_repl_args *argp;
01647         u_int32_t i;
01648         u_int ch;
01649         int ret;
01650 
01651         i = 0;
01652         ch = 0;
01653         notused2 = 0;
01654         notused3 = NULL;
01655 
01656         if ((ret = CDB___bam_repl_read(dbenv, dbtp->data, &argp)) != 0)
01657                 return (ret);
01658         printf("[%lu][%lu]bam_repl: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
01659             (u_long)lsnp->file,
01660             (u_long)lsnp->offset,
01661             (u_long)argp->type,
01662             (u_long)argp->txnid->txnid,
01663             (u_long)argp->prev_lsn.file,
01664             (u_long)argp->prev_lsn.offset);
01665         printf("\tfileid: %ld\n", (long)argp->fileid);
01666         printf("\tpgno: %lu\n", (u_long)argp->pgno);
01667         printf("\tlsn: [%lu][%lu]\n",
01668             (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
01669         printf("\tindx: %lu\n", (u_long)argp->indx);
01670         printf("\tisdeleted: %lu\n", (u_long)argp->isdeleted);
01671         printf("\torig: ");
01672         for (i = 0; i < argp->orig.size; i++) {
01673                 ch = ((u_int8_t *)argp->orig.data)[i];
01674                 if (isprint(ch) || ch == 0xa)
01675                         putchar(ch);
01676                 else
01677                         printf("%#x ", ch);
01678         }
01679         printf("\n");
01680         printf("\trepl: ");
01681         for (i = 0; i < argp->repl.size; i++) {
01682                 ch = ((u_int8_t *)argp->repl.data)[i];
01683                 if (isprint(ch) || ch == 0xa)
01684                         putchar(ch);
01685                 else
01686                         printf("%#x ", ch);
01687         }
01688         printf("\n");
01689         printf("\tprefix: %lu\n", (u_long)argp->prefix);
01690         printf("\tsuffix: %lu\n", (u_long)argp->suffix);
01691         printf("\n");
01692         CDB___os_free(argp, 0);
01693         return (0);
01694 }
01695 
01696 int
01697 CDB___bam_repl_read(dbenv, recbuf, argpp)
01698         DB_ENV *dbenv;
01699         void *recbuf;
01700         __bam_repl_args **argpp;
01701 {
01702         __bam_repl_args *argp;
01703         u_int8_t *bp;
01704         int ret;
01705 
01706         ret = CDB___os_malloc(dbenv, sizeof(__bam_repl_args) +
01707             sizeof(DB_TXN), NULL, &argp);
01708         if (ret != 0)
01709                 return (ret);
01710         argp->txnid = (DB_TXN *)&argp[1];
01711         bp = recbuf;
01712         memcpy(&argp->type, bp, sizeof(argp->type));
01713         bp += sizeof(argp->type);
01714         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
01715         bp += sizeof(argp->txnid->txnid);
01716         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
01717         bp += sizeof(DB_LSN);
01718         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
01719         bp += sizeof(argp->fileid);
01720         memcpy(&argp->pgno, bp, sizeof(argp->pgno));
01721         bp += sizeof(argp->pgno);
01722         memcpy(&argp->lsn, bp,  sizeof(argp->lsn));
01723         bp += sizeof(argp->lsn);
01724         memcpy(&argp->indx, bp, sizeof(argp->indx));
01725         bp += sizeof(argp->indx);
01726         memcpy(&argp->isdeleted, bp, sizeof(argp->isdeleted));
01727         bp += sizeof(argp->isdeleted);
01728         memset(&argp->orig, 0, sizeof(argp->orig));
01729         memcpy(&argp->orig.size, bp, sizeof(u_int32_t));
01730         bp += sizeof(u_int32_t);
01731         argp->orig.data = bp;
01732         bp += argp->orig.size;
01733         memset(&argp->repl, 0, sizeof(argp->repl));
01734         memcpy(&argp->repl.size, bp, sizeof(u_int32_t));
01735         bp += sizeof(u_int32_t);
01736         argp->repl.data = bp;
01737         bp += argp->repl.size;
01738         memcpy(&argp->prefix, bp, sizeof(argp->prefix));
01739         bp += sizeof(argp->prefix);
01740         memcpy(&argp->suffix, bp, sizeof(argp->suffix));
01741         bp += sizeof(argp->suffix);
01742         *argpp = argp;
01743         return (0);
01744 }
01745 
01746 int CDB___bam_root_log(dbenv, txnid, ret_lsnp, flags,
01747         fileid, meta_pgno, root_pgno, meta_lsn)
01748         DB_ENV *dbenv;
01749         DB_TXN *txnid;
01750         DB_LSN *ret_lsnp;
01751         u_int32_t flags;
01752         int32_t fileid;
01753         db_pgno_t meta_pgno;
01754         db_pgno_t root_pgno;
01755         DB_LSN * meta_lsn;
01756 {
01757         DBT logrec;
01758         DB_LSN *lsnp, null_lsn;
01759         u_int32_t rectype, txn_num;
01760         int ret;
01761         u_int8_t *bp;
01762 
01763         if (txnid != NULL &&
01764             TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
01765                 return (CDB___db_child_active_err(dbenv));
01766         rectype = DB_bam_root;
01767         txn_num = txnid == NULL ? 0 : txnid->txnid;
01768         if (txnid == NULL) {
01769                 ZERO_LSN(null_lsn);
01770                 lsnp = &null_lsn;
01771         } else
01772                 lsnp = &txnid->last_lsn;
01773         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
01774             + sizeof(fileid)
01775             + sizeof(meta_pgno)
01776             + sizeof(root_pgno)
01777             + sizeof(*meta_lsn);
01778         if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
01779                 return (ret);
01780 
01781         bp = logrec.data;
01782         memcpy(bp, &rectype, sizeof(rectype));
01783         bp += sizeof(rectype);
01784         memcpy(bp, &txn_num, sizeof(txn_num));
01785         bp += sizeof(txn_num);
01786         memcpy(bp, lsnp, sizeof(DB_LSN));
01787         bp += sizeof(DB_LSN);
01788         memcpy(bp, &fileid, sizeof(fileid));
01789         bp += sizeof(fileid);
01790         memcpy(bp, &meta_pgno, sizeof(meta_pgno));
01791         bp += sizeof(meta_pgno);
01792         memcpy(bp, &root_pgno, sizeof(root_pgno));
01793         bp += sizeof(root_pgno);
01794         if (meta_lsn != NULL)
01795                 memcpy(bp, meta_lsn, sizeof(*meta_lsn));
01796         else
01797                 memset(bp, 0, sizeof(*meta_lsn));
01798         bp += sizeof(*meta_lsn);
01799         DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
01800         ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
01801         if (txnid != NULL)
01802                 txnid->last_lsn = *ret_lsnp;
01803         CDB___os_free(logrec.data, logrec.size);
01804         return (ret);
01805 }
01806 
01807 int
01808 CDB___bam_root_print(dbenv, dbtp, lsnp, notused2, notused3)
01809         DB_ENV *dbenv;
01810         DBT *dbtp;
01811         DB_LSN *lsnp;
01812         db_recops notused2;
01813         void *notused3;
01814 {
01815         __bam_root_args *argp;
01816         u_int32_t i;
01817         u_int ch;
01818         int ret;
01819 
01820         i = 0;
01821         ch = 0;
01822         notused2 = 0;
01823         notused3 = NULL;
01824 
01825         if ((ret = CDB___bam_root_read(dbenv, dbtp->data, &argp)) != 0)
01826                 return (ret);
01827         printf("[%lu][%lu]bam_root: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
01828             (u_long)lsnp->file,
01829             (u_long)lsnp->offset,
01830             (u_long)argp->type,
01831             (u_long)argp->txnid->txnid,
01832             (u_long)argp->prev_lsn.file,
01833             (u_long)argp->prev_lsn.offset);
01834         printf("\tfileid: %ld\n", (long)argp->fileid);
01835         printf("\tmeta_pgno: %lu\n", (u_long)argp->meta_pgno);
01836         printf("\troot_pgno: %lu\n", (u_long)argp->root_pgno);
01837         printf("\tmeta_lsn: [%lu][%lu]\n",
01838             (u_long)argp->meta_lsn.file, (u_long)argp->meta_lsn.offset);
01839         printf("\n");
01840         CDB___os_free(argp, 0);
01841         return (0);
01842 }
01843 
01844 int
01845 CDB___bam_root_read(dbenv, recbuf, argpp)
01846         DB_ENV *dbenv;
01847         void *recbuf;
01848         __bam_root_args **argpp;
01849 {
01850         __bam_root_args *argp;
01851         u_int8_t *bp;
01852         int ret;
01853 
01854         ret = CDB___os_malloc(dbenv, sizeof(__bam_root_args) +
01855             sizeof(DB_TXN), NULL, &argp);
01856         if (ret != 0)
01857                 return (ret);
01858         argp->txnid = (DB_TXN *)&argp[1];
01859         bp = recbuf;
01860         memcpy(&argp->type, bp, sizeof(argp->type));
01861         bp += sizeof(argp->type);
01862         memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
01863         bp += sizeof(argp->txnid->txnid);
01864         memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
01865         bp += sizeof(DB_LSN);
01866         memcpy(&argp->fileid, bp, sizeof(argp->fileid));
01867         bp += sizeof(argp->fileid);
01868         memcpy(&argp->meta_pgno, bp, sizeof(argp->meta_pgno));
01869         bp += sizeof(argp->meta_pgno);
01870         memcpy(&argp->root_pgno, bp, sizeof(argp->root_pgno));
01871         bp += sizeof(argp->root_pgno);
01872         memcpy(&argp->meta_lsn, bp,  sizeof(argp->meta_lsn));
01873         bp += sizeof(argp->meta_lsn);
01874         *argpp = argp;
01875         return (0);
01876 }
01877 
01878 int
01879 CDB___bam_init_print(dbenv)
01880         DB_ENV *dbenv;
01881 {
01882         int ret;
01883 
01884         if ((ret = CDB___db_add_recovery(dbenv,
01885             CDB___bam_pg_alloc1_print, DB_bam_pg_alloc1)) != 0)
01886                 return (ret);
01887         if ((ret = CDB___db_add_recovery(dbenv,
01888             CDB___bam_pg_alloc_print, DB_bam_pg_alloc)) != 0)
01889                 return (ret);
01890         if ((ret = CDB___db_add_recovery(dbenv,
01891             CDB___bam_pg_free1_print, DB_bam_pg_free1)) != 0)
01892                 return (ret);
01893         if ((ret = CDB___db_add_recovery(dbenv,
01894             CDB___bam_pg_free_print, DB_bam_pg_free)) != 0)
01895                 return (ret);
01896         if ((ret = CDB___db_add_recovery(dbenv,
01897             CDB___bam_split1_print, DB_bam_split1)) != 0)
01898                 return (ret);
01899         if ((ret = CDB___db_add_recovery(dbenv,
01900             CDB___bam_split_print, DB_bam_split)) != 0)
01901                 return (ret);
01902         if ((ret = CDB___db_add_recovery(dbenv,
01903             CDB___bam_rsplit1_print, DB_bam_rsplit1)) != 0)
01904                 return (ret);
01905         if ((ret = CDB___db_add_recovery(dbenv,
01906             CDB___bam_rsplit_print, DB_bam_rsplit)) != 0)
01907                 return (ret);
01908         if ((ret = CDB___db_add_recovery(dbenv,
01909             CDB___bam_adj_print, DB_bam_adj)) != 0)
01910                 return (ret);
01911         if ((ret = CDB___db_add_recovery(dbenv,
01912             CDB___bam_cadjust_print, DB_bam_cadjust)) != 0)
01913                 return (ret);
01914         if ((ret = CDB___db_add_recovery(dbenv,
01915             CDB___bam_cdel_print, DB_bam_cdel)) != 0)
01916                 return (ret);
01917         if ((ret = CDB___db_add_recovery(dbenv,
01918             CDB___bam_repl_print, DB_bam_repl)) != 0)
01919                 return (ret);
01920         if ((ret = CDB___db_add_recovery(dbenv,
01921             CDB___bam_root_print, DB_bam_root)) != 0)
01922                 return (ret);
01923         return (0);
01924 }
01925 
01926 int
01927 CDB___bam_init_recover(dbenv)
01928         DB_ENV *dbenv;
01929 {
01930         int ret;
01931 
01932         if ((ret = CDB___db_add_recovery(dbenv,
01933             CDB___deprecated_recover, DB_bam_pg_alloc1)) != 0)
01934                 return (ret);
01935         if ((ret = CDB___db_add_recovery(dbenv,
01936             CDB___bam_pg_alloc_recover, DB_bam_pg_alloc)) != 0)
01937                 return (ret);
01938         if ((ret = CDB___db_add_recovery(dbenv,
01939             CDB___deprecated_recover, DB_bam_pg_free1)) != 0)
01940                 return (ret);
01941         if ((ret = CDB___db_add_recovery(dbenv,
01942             CDB___bam_pg_free_recover, DB_bam_pg_free)) != 0)
01943                 return (ret);
01944         if ((ret = CDB___db_add_recovery(dbenv,
01945             CDB___deprecated_recover, DB_bam_split1)) != 0)
01946                 return (ret);
01947         if ((ret = CDB___db_add_recovery(dbenv,
01948             CDB___bam_split_recover, DB_bam_split)) != 0)
01949                 return (ret);
01950         if ((ret = CDB___db_add_recovery(dbenv,
01951             CDB___deprecated_recover, DB_bam_rsplit1)) != 0)
01952                 return (ret);
01953         if ((ret = CDB___db_add_recovery(dbenv,
01954             CDB___bam_rsplit_recover, DB_bam_rsplit)) != 0)
01955                 return (ret);
01956         if ((ret = CDB___db_add_recovery(dbenv,
01957             CDB___bam_adj_recover, DB_bam_adj)) != 0)
01958                 return (ret);
01959         if ((ret = CDB___db_add_recovery(dbenv,
01960             CDB___bam_cadjust_recover, DB_bam_cadjust)) != 0)
01961                 return (ret);
01962         if ((ret = CDB___db_add_recovery(dbenv,
01963             CDB___bam_cdel_recover, DB_bam_cdel)) != 0)
01964                 return (ret);
01965         if ((ret = CDB___db_add_recovery(dbenv,
01966             CDB___bam_repl_recover, DB_bam_repl)) != 0)
01967                 return (ret);
01968         if ((ret = CDB___db_add_recovery(dbenv,
01969             CDB___bam_root_recover, DB_bam_root)) != 0)
01970                 return (ret);
01971         return (0);
01972 }
01973 

Generated on Sun Jun 8 10:56:35 2008 for GNUmifluz by  doxygen 1.5.5