00001
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 "txn.h"
00017
00018 int CDB___db_addrem_log(dbenv, txnid, ret_lsnp, flags,
00019 opcode, fileid, pgno, indx, nbytes, hdr,
00020 dbt, pagelsn)
00021 DB_ENV *dbenv;
00022 DB_TXN *txnid;
00023 DB_LSN *ret_lsnp;
00024 u_int32_t flags;
00025 u_int32_t opcode;
00026 int32_t fileid;
00027 db_pgno_t pgno;
00028 u_int32_t indx;
00029 size_t nbytes;
00030 const DBT *hdr;
00031 const DBT *dbt;
00032 DB_LSN * pagelsn;
00033 {
00034 DBT logrec;
00035 DB_LSN *lsnp, null_lsn;
00036 u_int32_t zero;
00037 u_int32_t rectype, txn_num;
00038 int ret;
00039 u_int8_t *bp;
00040
00041 if (txnid != NULL &&
00042 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00043 return (CDB___db_child_active_err(dbenv));
00044 rectype = DB_db_addrem;
00045 txn_num = txnid == NULL ? 0 : txnid->txnid;
00046 if (txnid == NULL) {
00047 ZERO_LSN(null_lsn);
00048 lsnp = &null_lsn;
00049 } else
00050 lsnp = &txnid->last_lsn;
00051 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00052 + sizeof(opcode)
00053 + sizeof(fileid)
00054 + sizeof(pgno)
00055 + sizeof(indx)
00056 + sizeof(nbytes)
00057 + sizeof(u_int32_t) + (hdr == NULL ? 0 : hdr->size)
00058 + sizeof(u_int32_t) + (dbt == NULL ? 0 : dbt->size)
00059 + sizeof(*pagelsn);
00060 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00061 return (ret);
00062
00063 bp = logrec.data;
00064 memcpy(bp, &rectype, sizeof(rectype));
00065 bp += sizeof(rectype);
00066 memcpy(bp, &txn_num, sizeof(txn_num));
00067 bp += sizeof(txn_num);
00068 memcpy(bp, lsnp, sizeof(DB_LSN));
00069 bp += sizeof(DB_LSN);
00070 memcpy(bp, &opcode, sizeof(opcode));
00071 bp += sizeof(opcode);
00072 memcpy(bp, &fileid, sizeof(fileid));
00073 bp += sizeof(fileid);
00074 memcpy(bp, &pgno, sizeof(pgno));
00075 bp += sizeof(pgno);
00076 memcpy(bp, &indx, sizeof(indx));
00077 bp += sizeof(indx);
00078 memcpy(bp, &nbytes, sizeof(nbytes));
00079 bp += sizeof(nbytes);
00080 if (hdr == NULL) {
00081 zero = 0;
00082 memcpy(bp, &zero, sizeof(u_int32_t));
00083 bp += sizeof(u_int32_t);
00084 } else {
00085 memcpy(bp, &hdr->size, sizeof(hdr->size));
00086 bp += sizeof(hdr->size);
00087 memcpy(bp, hdr->data, hdr->size);
00088 bp += hdr->size;
00089 }
00090 if (dbt == NULL) {
00091 zero = 0;
00092 memcpy(bp, &zero, sizeof(u_int32_t));
00093 bp += sizeof(u_int32_t);
00094 } else {
00095 memcpy(bp, &dbt->size, sizeof(dbt->size));
00096 bp += sizeof(dbt->size);
00097 memcpy(bp, dbt->data, dbt->size);
00098 bp += dbt->size;
00099 }
00100 if (pagelsn != NULL)
00101 memcpy(bp, pagelsn, sizeof(*pagelsn));
00102 else
00103 memset(bp, 0, sizeof(*pagelsn));
00104 bp += sizeof(*pagelsn);
00105 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00106 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00107 if (txnid != NULL)
00108 txnid->last_lsn = *ret_lsnp;
00109 CDB___os_free(logrec.data, logrec.size);
00110 return (ret);
00111 }
00112
00113 int
00114 CDB___db_addrem_print(dbenv, dbtp, lsnp, notused2, notused3)
00115 DB_ENV *dbenv;
00116 DBT *dbtp;
00117 DB_LSN *lsnp;
00118 db_recops notused2;
00119 void *notused3;
00120 {
00121 __db_addrem_args *argp;
00122 u_int32_t i;
00123 u_int ch;
00124 int ret;
00125
00126 i = 0;
00127 ch = 0;
00128 notused2 = 0;
00129 notused3 = NULL;
00130
00131 if ((ret = CDB___db_addrem_read(dbenv, dbtp->data, &argp)) != 0)
00132 return (ret);
00133 printf("[%lu][%lu]db_addrem: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00134 (u_long)lsnp->file,
00135 (u_long)lsnp->offset,
00136 (u_long)argp->type,
00137 (u_long)argp->txnid->txnid,
00138 (u_long)argp->prev_lsn.file,
00139 (u_long)argp->prev_lsn.offset);
00140 printf("\topcode: %lu\n", (u_long)argp->opcode);
00141 printf("\tfileid: %ld\n", (long)argp->fileid);
00142 printf("\tpgno: %lu\n", (u_long)argp->pgno);
00143 printf("\tindx: %lu\n", (u_long)argp->indx);
00144 printf("\tnbytes: %lu\n", (u_long)argp->nbytes);
00145 printf("\thdr: ");
00146 for (i = 0; i < argp->hdr.size; i++) {
00147 ch = ((u_int8_t *)argp->hdr.data)[i];
00148 if (isprint(ch) || ch == 0xa)
00149 putchar(ch);
00150 else
00151 printf("%#x ", ch);
00152 }
00153 printf("\n");
00154 printf("\tdbt: ");
00155 for (i = 0; i < argp->dbt.size; i++) {
00156 ch = ((u_int8_t *)argp->dbt.data)[i];
00157 if (isprint(ch) || ch == 0xa)
00158 putchar(ch);
00159 else
00160 printf("%#x ", ch);
00161 }
00162 printf("\n");
00163 printf("\tpagelsn: [%lu][%lu]\n",
00164 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
00165 printf("\n");
00166 CDB___os_free(argp, 0);
00167 return (0);
00168 }
00169
00170 int
00171 CDB___db_addrem_read(dbenv, recbuf, argpp)
00172 DB_ENV *dbenv;
00173 void *recbuf;
00174 __db_addrem_args **argpp;
00175 {
00176 __db_addrem_args *argp;
00177 u_int8_t *bp;
00178 int ret;
00179
00180 ret = CDB___os_malloc(dbenv, sizeof(__db_addrem_args) +
00181 sizeof(DB_TXN), NULL, &argp);
00182 if (ret != 0)
00183 return (ret);
00184 argp->txnid = (DB_TXN *)&argp[1];
00185 bp = recbuf;
00186 memcpy(&argp->type, bp, sizeof(argp->type));
00187 bp += sizeof(argp->type);
00188 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00189 bp += sizeof(argp->txnid->txnid);
00190 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00191 bp += sizeof(DB_LSN);
00192 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
00193 bp += sizeof(argp->opcode);
00194 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00195 bp += sizeof(argp->fileid);
00196 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00197 bp += sizeof(argp->pgno);
00198 memcpy(&argp->indx, bp, sizeof(argp->indx));
00199 bp += sizeof(argp->indx);
00200 memcpy(&argp->nbytes, bp, sizeof(argp->nbytes));
00201 bp += sizeof(argp->nbytes);
00202 memset(&argp->hdr, 0, sizeof(argp->hdr));
00203 memcpy(&argp->hdr.size, bp, sizeof(u_int32_t));
00204 bp += sizeof(u_int32_t);
00205 argp->hdr.data = bp;
00206 bp += argp->hdr.size;
00207 memset(&argp->dbt, 0, sizeof(argp->dbt));
00208 memcpy(&argp->dbt.size, bp, sizeof(u_int32_t));
00209 bp += sizeof(u_int32_t);
00210 argp->dbt.data = bp;
00211 bp += argp->dbt.size;
00212 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
00213 bp += sizeof(argp->pagelsn);
00214 *argpp = argp;
00215 return (0);
00216 }
00217
00218 int
00219 CDB___db_split_print(dbenv, dbtp, lsnp, notused2, notused3)
00220 DB_ENV *dbenv;
00221 DBT *dbtp;
00222 DB_LSN *lsnp;
00223 db_recops notused2;
00224 void *notused3;
00225 {
00226 __db_split_args *argp;
00227 u_int32_t i;
00228 u_int ch;
00229 int ret;
00230
00231 i = 0;
00232 ch = 0;
00233 notused2 = 0;
00234 notused3 = NULL;
00235
00236 if ((ret = CDB___db_split_read(dbenv, dbtp->data, &argp)) != 0)
00237 return (ret);
00238 printf("[%lu][%lu]db_split: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00239 (u_long)lsnp->file,
00240 (u_long)lsnp->offset,
00241 (u_long)argp->type,
00242 (u_long)argp->txnid->txnid,
00243 (u_long)argp->prev_lsn.file,
00244 (u_long)argp->prev_lsn.offset);
00245 printf("\topcode: %lu\n", (u_long)argp->opcode);
00246 printf("\tfileid: %ld\n", (long)argp->fileid);
00247 printf("\tpgno: %lu\n", (u_long)argp->pgno);
00248 printf("\tpageimage: ");
00249 for (i = 0; i < argp->pageimage.size; i++) {
00250 ch = ((u_int8_t *)argp->pageimage.data)[i];
00251 if (isprint(ch) || ch == 0xa)
00252 putchar(ch);
00253 else
00254 printf("%#x ", ch);
00255 }
00256 printf("\n");
00257 printf("\tpagelsn: [%lu][%lu]\n",
00258 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
00259 printf("\n");
00260 CDB___os_free(argp, 0);
00261 return (0);
00262 }
00263
00264 int
00265 CDB___db_split_read(dbenv, recbuf, argpp)
00266 DB_ENV *dbenv;
00267 void *recbuf;
00268 __db_split_args **argpp;
00269 {
00270 __db_split_args *argp;
00271 u_int8_t *bp;
00272 int ret;
00273
00274 ret = CDB___os_malloc(dbenv, sizeof(__db_split_args) +
00275 sizeof(DB_TXN), NULL, &argp);
00276 if (ret != 0)
00277 return (ret);
00278 argp->txnid = (DB_TXN *)&argp[1];
00279 bp = recbuf;
00280 memcpy(&argp->type, bp, sizeof(argp->type));
00281 bp += sizeof(argp->type);
00282 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00283 bp += sizeof(argp->txnid->txnid);
00284 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00285 bp += sizeof(DB_LSN);
00286 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
00287 bp += sizeof(argp->opcode);
00288 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00289 bp += sizeof(argp->fileid);
00290 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00291 bp += sizeof(argp->pgno);
00292 memset(&argp->pageimage, 0, sizeof(argp->pageimage));
00293 memcpy(&argp->pageimage.size, bp, sizeof(u_int32_t));
00294 bp += sizeof(u_int32_t);
00295 argp->pageimage.data = bp;
00296 bp += argp->pageimage.size;
00297 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
00298 bp += sizeof(argp->pagelsn);
00299 *argpp = argp;
00300 return (0);
00301 }
00302
00303 int CDB___db_big_log(dbenv, txnid, ret_lsnp, flags,
00304 opcode, fileid, pgno, prev_pgno, next_pgno, dbt,
00305 pagelsn, prevlsn, nextlsn)
00306 DB_ENV *dbenv;
00307 DB_TXN *txnid;
00308 DB_LSN *ret_lsnp;
00309 u_int32_t flags;
00310 u_int32_t opcode;
00311 int32_t fileid;
00312 db_pgno_t pgno;
00313 db_pgno_t prev_pgno;
00314 db_pgno_t next_pgno;
00315 const DBT *dbt;
00316 DB_LSN * pagelsn;
00317 DB_LSN * prevlsn;
00318 DB_LSN * nextlsn;
00319 {
00320 DBT logrec;
00321 DB_LSN *lsnp, null_lsn;
00322 u_int32_t zero;
00323 u_int32_t rectype, txn_num;
00324 int ret;
00325 u_int8_t *bp;
00326
00327 if (txnid != NULL &&
00328 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00329 return (CDB___db_child_active_err(dbenv));
00330 rectype = DB_db_big;
00331 txn_num = txnid == NULL ? 0 : txnid->txnid;
00332 if (txnid == NULL) {
00333 ZERO_LSN(null_lsn);
00334 lsnp = &null_lsn;
00335 } else
00336 lsnp = &txnid->last_lsn;
00337 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00338 + sizeof(opcode)
00339 + sizeof(fileid)
00340 + sizeof(pgno)
00341 + sizeof(prev_pgno)
00342 + sizeof(next_pgno)
00343 + sizeof(u_int32_t) + (dbt == NULL ? 0 : dbt->size)
00344 + sizeof(*pagelsn)
00345 + sizeof(*prevlsn)
00346 + sizeof(*nextlsn);
00347 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00348 return (ret);
00349
00350 bp = logrec.data;
00351 memcpy(bp, &rectype, sizeof(rectype));
00352 bp += sizeof(rectype);
00353 memcpy(bp, &txn_num, sizeof(txn_num));
00354 bp += sizeof(txn_num);
00355 memcpy(bp, lsnp, sizeof(DB_LSN));
00356 bp += sizeof(DB_LSN);
00357 memcpy(bp, &opcode, sizeof(opcode));
00358 bp += sizeof(opcode);
00359 memcpy(bp, &fileid, sizeof(fileid));
00360 bp += sizeof(fileid);
00361 memcpy(bp, &pgno, sizeof(pgno));
00362 bp += sizeof(pgno);
00363 memcpy(bp, &prev_pgno, sizeof(prev_pgno));
00364 bp += sizeof(prev_pgno);
00365 memcpy(bp, &next_pgno, sizeof(next_pgno));
00366 bp += sizeof(next_pgno);
00367 if (dbt == NULL) {
00368 zero = 0;
00369 memcpy(bp, &zero, sizeof(u_int32_t));
00370 bp += sizeof(u_int32_t);
00371 } else {
00372 memcpy(bp, &dbt->size, sizeof(dbt->size));
00373 bp += sizeof(dbt->size);
00374 memcpy(bp, dbt->data, dbt->size);
00375 bp += dbt->size;
00376 }
00377 if (pagelsn != NULL)
00378 memcpy(bp, pagelsn, sizeof(*pagelsn));
00379 else
00380 memset(bp, 0, sizeof(*pagelsn));
00381 bp += sizeof(*pagelsn);
00382 if (prevlsn != NULL)
00383 memcpy(bp, prevlsn, sizeof(*prevlsn));
00384 else
00385 memset(bp, 0, sizeof(*prevlsn));
00386 bp += sizeof(*prevlsn);
00387 if (nextlsn != NULL)
00388 memcpy(bp, nextlsn, sizeof(*nextlsn));
00389 else
00390 memset(bp, 0, sizeof(*nextlsn));
00391 bp += sizeof(*nextlsn);
00392 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00393 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00394 if (txnid != NULL)
00395 txnid->last_lsn = *ret_lsnp;
00396 CDB___os_free(logrec.data, logrec.size);
00397 return (ret);
00398 }
00399
00400 int
00401 CDB___db_big_print(dbenv, dbtp, lsnp, notused2, notused3)
00402 DB_ENV *dbenv;
00403 DBT *dbtp;
00404 DB_LSN *lsnp;
00405 db_recops notused2;
00406 void *notused3;
00407 {
00408 __db_big_args *argp;
00409 u_int32_t i;
00410 u_int ch;
00411 int ret;
00412
00413 i = 0;
00414 ch = 0;
00415 notused2 = 0;
00416 notused3 = NULL;
00417
00418 if ((ret = CDB___db_big_read(dbenv, dbtp->data, &argp)) != 0)
00419 return (ret);
00420 printf("[%lu][%lu]db_big: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00421 (u_long)lsnp->file,
00422 (u_long)lsnp->offset,
00423 (u_long)argp->type,
00424 (u_long)argp->txnid->txnid,
00425 (u_long)argp->prev_lsn.file,
00426 (u_long)argp->prev_lsn.offset);
00427 printf("\topcode: %lu\n", (u_long)argp->opcode);
00428 printf("\tfileid: %ld\n", (long)argp->fileid);
00429 printf("\tpgno: %lu\n", (u_long)argp->pgno);
00430 printf("\tprev_pgno: %lu\n", (u_long)argp->prev_pgno);
00431 printf("\tnext_pgno: %lu\n", (u_long)argp->next_pgno);
00432 printf("\tdbt: ");
00433 for (i = 0; i < argp->dbt.size; i++) {
00434 ch = ((u_int8_t *)argp->dbt.data)[i];
00435 if (isprint(ch) || ch == 0xa)
00436 putchar(ch);
00437 else
00438 printf("%#x ", ch);
00439 }
00440 printf("\n");
00441 printf("\tpagelsn: [%lu][%lu]\n",
00442 (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset);
00443 printf("\tprevlsn: [%lu][%lu]\n",
00444 (u_long)argp->prevlsn.file, (u_long)argp->prevlsn.offset);
00445 printf("\tnextlsn: [%lu][%lu]\n",
00446 (u_long)argp->nextlsn.file, (u_long)argp->nextlsn.offset);
00447 printf("\n");
00448 CDB___os_free(argp, 0);
00449 return (0);
00450 }
00451
00452 int
00453 CDB___db_big_read(dbenv, recbuf, argpp)
00454 DB_ENV *dbenv;
00455 void *recbuf;
00456 __db_big_args **argpp;
00457 {
00458 __db_big_args *argp;
00459 u_int8_t *bp;
00460 int ret;
00461
00462 ret = CDB___os_malloc(dbenv, sizeof(__db_big_args) +
00463 sizeof(DB_TXN), NULL, &argp);
00464 if (ret != 0)
00465 return (ret);
00466 argp->txnid = (DB_TXN *)&argp[1];
00467 bp = recbuf;
00468 memcpy(&argp->type, bp, sizeof(argp->type));
00469 bp += sizeof(argp->type);
00470 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00471 bp += sizeof(argp->txnid->txnid);
00472 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00473 bp += sizeof(DB_LSN);
00474 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
00475 bp += sizeof(argp->opcode);
00476 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00477 bp += sizeof(argp->fileid);
00478 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00479 bp += sizeof(argp->pgno);
00480 memcpy(&argp->prev_pgno, bp, sizeof(argp->prev_pgno));
00481 bp += sizeof(argp->prev_pgno);
00482 memcpy(&argp->next_pgno, bp, sizeof(argp->next_pgno));
00483 bp += sizeof(argp->next_pgno);
00484 memset(&argp->dbt, 0, sizeof(argp->dbt));
00485 memcpy(&argp->dbt.size, bp, sizeof(u_int32_t));
00486 bp += sizeof(u_int32_t);
00487 argp->dbt.data = bp;
00488 bp += argp->dbt.size;
00489 memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn));
00490 bp += sizeof(argp->pagelsn);
00491 memcpy(&argp->prevlsn, bp, sizeof(argp->prevlsn));
00492 bp += sizeof(argp->prevlsn);
00493 memcpy(&argp->nextlsn, bp, sizeof(argp->nextlsn));
00494 bp += sizeof(argp->nextlsn);
00495 *argpp = argp;
00496 return (0);
00497 }
00498
00499 int CDB___db_ovref_log(dbenv, txnid, ret_lsnp, flags,
00500 fileid, pgno, adjust, lsn)
00501 DB_ENV *dbenv;
00502 DB_TXN *txnid;
00503 DB_LSN *ret_lsnp;
00504 u_int32_t flags;
00505 int32_t fileid;
00506 db_pgno_t pgno;
00507 int32_t adjust;
00508 DB_LSN * lsn;
00509 {
00510 DBT logrec;
00511 DB_LSN *lsnp, null_lsn;
00512 u_int32_t rectype, txn_num;
00513 int ret;
00514 u_int8_t *bp;
00515
00516 if (txnid != NULL &&
00517 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00518 return (CDB___db_child_active_err(dbenv));
00519 rectype = DB_db_ovref;
00520 txn_num = txnid == NULL ? 0 : txnid->txnid;
00521 if (txnid == NULL) {
00522 ZERO_LSN(null_lsn);
00523 lsnp = &null_lsn;
00524 } else
00525 lsnp = &txnid->last_lsn;
00526 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00527 + sizeof(fileid)
00528 + sizeof(pgno)
00529 + sizeof(adjust)
00530 + sizeof(*lsn);
00531 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00532 return (ret);
00533
00534 bp = logrec.data;
00535 memcpy(bp, &rectype, sizeof(rectype));
00536 bp += sizeof(rectype);
00537 memcpy(bp, &txn_num, sizeof(txn_num));
00538 bp += sizeof(txn_num);
00539 memcpy(bp, lsnp, sizeof(DB_LSN));
00540 bp += sizeof(DB_LSN);
00541 memcpy(bp, &fileid, sizeof(fileid));
00542 bp += sizeof(fileid);
00543 memcpy(bp, &pgno, sizeof(pgno));
00544 bp += sizeof(pgno);
00545 memcpy(bp, &adjust, sizeof(adjust));
00546 bp += sizeof(adjust);
00547 if (lsn != NULL)
00548 memcpy(bp, lsn, sizeof(*lsn));
00549 else
00550 memset(bp, 0, sizeof(*lsn));
00551 bp += sizeof(*lsn);
00552 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00553 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00554 if (txnid != NULL)
00555 txnid->last_lsn = *ret_lsnp;
00556 CDB___os_free(logrec.data, logrec.size);
00557 return (ret);
00558 }
00559
00560 int
00561 CDB___db_ovref_print(dbenv, dbtp, lsnp, notused2, notused3)
00562 DB_ENV *dbenv;
00563 DBT *dbtp;
00564 DB_LSN *lsnp;
00565 db_recops notused2;
00566 void *notused3;
00567 {
00568 __db_ovref_args *argp;
00569 u_int32_t i;
00570 u_int ch;
00571 int ret;
00572
00573 i = 0;
00574 ch = 0;
00575 notused2 = 0;
00576 notused3 = NULL;
00577
00578 if ((ret = CDB___db_ovref_read(dbenv, dbtp->data, &argp)) != 0)
00579 return (ret);
00580 printf("[%lu][%lu]db_ovref: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00581 (u_long)lsnp->file,
00582 (u_long)lsnp->offset,
00583 (u_long)argp->type,
00584 (u_long)argp->txnid->txnid,
00585 (u_long)argp->prev_lsn.file,
00586 (u_long)argp->prev_lsn.offset);
00587 printf("\tfileid: %ld\n", (long)argp->fileid);
00588 printf("\tpgno: %lu\n", (u_long)argp->pgno);
00589 printf("\tadjust: %ld\n", (long)argp->adjust);
00590 printf("\tlsn: [%lu][%lu]\n",
00591 (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
00592 printf("\n");
00593 CDB___os_free(argp, 0);
00594 return (0);
00595 }
00596
00597 int
00598 CDB___db_ovref_read(dbenv, recbuf, argpp)
00599 DB_ENV *dbenv;
00600 void *recbuf;
00601 __db_ovref_args **argpp;
00602 {
00603 __db_ovref_args *argp;
00604 u_int8_t *bp;
00605 int ret;
00606
00607 ret = CDB___os_malloc(dbenv, sizeof(__db_ovref_args) +
00608 sizeof(DB_TXN), NULL, &argp);
00609 if (ret != 0)
00610 return (ret);
00611 argp->txnid = (DB_TXN *)&argp[1];
00612 bp = recbuf;
00613 memcpy(&argp->type, bp, sizeof(argp->type));
00614 bp += sizeof(argp->type);
00615 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00616 bp += sizeof(argp->txnid->txnid);
00617 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00618 bp += sizeof(DB_LSN);
00619 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00620 bp += sizeof(argp->fileid);
00621 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00622 bp += sizeof(argp->pgno);
00623 memcpy(&argp->adjust, bp, sizeof(argp->adjust));
00624 bp += sizeof(argp->adjust);
00625 memcpy(&argp->lsn, bp, sizeof(argp->lsn));
00626 bp += sizeof(argp->lsn);
00627 *argpp = argp;
00628 return (0);
00629 }
00630
00631 int CDB___db_relink_log(dbenv, txnid, ret_lsnp, flags,
00632 opcode, fileid, pgno, lsn, prev, lsn_prev,
00633 next, lsn_next)
00634 DB_ENV *dbenv;
00635 DB_TXN *txnid;
00636 DB_LSN *ret_lsnp;
00637 u_int32_t flags;
00638 u_int32_t opcode;
00639 int32_t fileid;
00640 db_pgno_t pgno;
00641 DB_LSN * lsn;
00642 db_pgno_t prev;
00643 DB_LSN * lsn_prev;
00644 db_pgno_t next;
00645 DB_LSN * lsn_next;
00646 {
00647 DBT logrec;
00648 DB_LSN *lsnp, null_lsn;
00649 u_int32_t rectype, txn_num;
00650 int ret;
00651 u_int8_t *bp;
00652
00653 if (txnid != NULL &&
00654 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00655 return (CDB___db_child_active_err(dbenv));
00656 rectype = DB_db_relink;
00657 txn_num = txnid == NULL ? 0 : txnid->txnid;
00658 if (txnid == NULL) {
00659 ZERO_LSN(null_lsn);
00660 lsnp = &null_lsn;
00661 } else
00662 lsnp = &txnid->last_lsn;
00663 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00664 + sizeof(opcode)
00665 + sizeof(fileid)
00666 + sizeof(pgno)
00667 + sizeof(*lsn)
00668 + sizeof(prev)
00669 + sizeof(*lsn_prev)
00670 + sizeof(next)
00671 + sizeof(*lsn_next);
00672 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00673 return (ret);
00674
00675 bp = logrec.data;
00676 memcpy(bp, &rectype, sizeof(rectype));
00677 bp += sizeof(rectype);
00678 memcpy(bp, &txn_num, sizeof(txn_num));
00679 bp += sizeof(txn_num);
00680 memcpy(bp, lsnp, sizeof(DB_LSN));
00681 bp += sizeof(DB_LSN);
00682 memcpy(bp, &opcode, sizeof(opcode));
00683 bp += sizeof(opcode);
00684 memcpy(bp, &fileid, sizeof(fileid));
00685 bp += sizeof(fileid);
00686 memcpy(bp, &pgno, sizeof(pgno));
00687 bp += sizeof(pgno);
00688 if (lsn != NULL)
00689 memcpy(bp, lsn, sizeof(*lsn));
00690 else
00691 memset(bp, 0, sizeof(*lsn));
00692 bp += sizeof(*lsn);
00693 memcpy(bp, &prev, sizeof(prev));
00694 bp += sizeof(prev);
00695 if (lsn_prev != NULL)
00696 memcpy(bp, lsn_prev, sizeof(*lsn_prev));
00697 else
00698 memset(bp, 0, sizeof(*lsn_prev));
00699 bp += sizeof(*lsn_prev);
00700 memcpy(bp, &next, sizeof(next));
00701 bp += sizeof(next);
00702 if (lsn_next != NULL)
00703 memcpy(bp, lsn_next, sizeof(*lsn_next));
00704 else
00705 memset(bp, 0, sizeof(*lsn_next));
00706 bp += sizeof(*lsn_next);
00707 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00708 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00709 if (txnid != NULL)
00710 txnid->last_lsn = *ret_lsnp;
00711 CDB___os_free(logrec.data, logrec.size);
00712 return (ret);
00713 }
00714
00715 int
00716 CDB___db_relink_print(dbenv, dbtp, lsnp, notused2, notused3)
00717 DB_ENV *dbenv;
00718 DBT *dbtp;
00719 DB_LSN *lsnp;
00720 db_recops notused2;
00721 void *notused3;
00722 {
00723 __db_relink_args *argp;
00724 u_int32_t i;
00725 u_int ch;
00726 int ret;
00727
00728 i = 0;
00729 ch = 0;
00730 notused2 = 0;
00731 notused3 = NULL;
00732
00733 if ((ret = CDB___db_relink_read(dbenv, dbtp->data, &argp)) != 0)
00734 return (ret);
00735 printf("[%lu][%lu]db_relink: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00736 (u_long)lsnp->file,
00737 (u_long)lsnp->offset,
00738 (u_long)argp->type,
00739 (u_long)argp->txnid->txnid,
00740 (u_long)argp->prev_lsn.file,
00741 (u_long)argp->prev_lsn.offset);
00742 printf("\topcode: %lu\n", (u_long)argp->opcode);
00743 printf("\tfileid: %ld\n", (long)argp->fileid);
00744 printf("\tpgno: %lu\n", (u_long)argp->pgno);
00745 printf("\tlsn: [%lu][%lu]\n",
00746 (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
00747 printf("\tprev: %lu\n", (u_long)argp->prev);
00748 printf("\tlsn_prev: [%lu][%lu]\n",
00749 (u_long)argp->lsn_prev.file, (u_long)argp->lsn_prev.offset);
00750 printf("\tnext: %lu\n", (u_long)argp->next);
00751 printf("\tlsn_next: [%lu][%lu]\n",
00752 (u_long)argp->lsn_next.file, (u_long)argp->lsn_next.offset);
00753 printf("\n");
00754 CDB___os_free(argp, 0);
00755 return (0);
00756 }
00757
00758 int
00759 CDB___db_relink_read(dbenv, recbuf, argpp)
00760 DB_ENV *dbenv;
00761 void *recbuf;
00762 __db_relink_args **argpp;
00763 {
00764 __db_relink_args *argp;
00765 u_int8_t *bp;
00766 int ret;
00767
00768 ret = CDB___os_malloc(dbenv, sizeof(__db_relink_args) +
00769 sizeof(DB_TXN), NULL, &argp);
00770 if (ret != 0)
00771 return (ret);
00772 argp->txnid = (DB_TXN *)&argp[1];
00773 bp = recbuf;
00774 memcpy(&argp->type, bp, sizeof(argp->type));
00775 bp += sizeof(argp->type);
00776 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00777 bp += sizeof(argp->txnid->txnid);
00778 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00779 bp += sizeof(DB_LSN);
00780 memcpy(&argp->opcode, bp, sizeof(argp->opcode));
00781 bp += sizeof(argp->opcode);
00782 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00783 bp += sizeof(argp->fileid);
00784 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00785 bp += sizeof(argp->pgno);
00786 memcpy(&argp->lsn, bp, sizeof(argp->lsn));
00787 bp += sizeof(argp->lsn);
00788 memcpy(&argp->prev, bp, sizeof(argp->prev));
00789 bp += sizeof(argp->prev);
00790 memcpy(&argp->lsn_prev, bp, sizeof(argp->lsn_prev));
00791 bp += sizeof(argp->lsn_prev);
00792 memcpy(&argp->next, bp, sizeof(argp->next));
00793 bp += sizeof(argp->next);
00794 memcpy(&argp->lsn_next, bp, sizeof(argp->lsn_next));
00795 bp += sizeof(argp->lsn_next);
00796 *argpp = argp;
00797 return (0);
00798 }
00799
00800 int
00801 CDB___db_addpage_print(dbenv, dbtp, lsnp, notused2, notused3)
00802 DB_ENV *dbenv;
00803 DBT *dbtp;
00804 DB_LSN *lsnp;
00805 db_recops notused2;
00806 void *notused3;
00807 {
00808 __db_addpage_args *argp;
00809 u_int32_t i;
00810 u_int ch;
00811 int ret;
00812
00813 i = 0;
00814 ch = 0;
00815 notused2 = 0;
00816 notused3 = NULL;
00817
00818 if ((ret = CDB___db_addpage_read(dbenv, dbtp->data, &argp)) != 0)
00819 return (ret);
00820 printf("[%lu][%lu]db_addpage: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00821 (u_long)lsnp->file,
00822 (u_long)lsnp->offset,
00823 (u_long)argp->type,
00824 (u_long)argp->txnid->txnid,
00825 (u_long)argp->prev_lsn.file,
00826 (u_long)argp->prev_lsn.offset);
00827 printf("\tfileid: %ld\n", (long)argp->fileid);
00828 printf("\tpgno: %lu\n", (u_long)argp->pgno);
00829 printf("\tlsn: [%lu][%lu]\n",
00830 (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
00831 printf("\tnextpgno: %lu\n", (u_long)argp->nextpgno);
00832 printf("\tnextlsn: [%lu][%lu]\n",
00833 (u_long)argp->nextlsn.file, (u_long)argp->nextlsn.offset);
00834 printf("\n");
00835 CDB___os_free(argp, 0);
00836 return (0);
00837 }
00838
00839 int
00840 CDB___db_addpage_read(dbenv, recbuf, argpp)
00841 DB_ENV *dbenv;
00842 void *recbuf;
00843 __db_addpage_args **argpp;
00844 {
00845 __db_addpage_args *argp;
00846 u_int8_t *bp;
00847 int ret;
00848
00849 ret = CDB___os_malloc(dbenv, sizeof(__db_addpage_args) +
00850 sizeof(DB_TXN), NULL, &argp);
00851 if (ret != 0)
00852 return (ret);
00853 argp->txnid = (DB_TXN *)&argp[1];
00854 bp = recbuf;
00855 memcpy(&argp->type, bp, sizeof(argp->type));
00856 bp += sizeof(argp->type);
00857 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
00858 bp += sizeof(argp->txnid->txnid);
00859 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
00860 bp += sizeof(DB_LSN);
00861 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
00862 bp += sizeof(argp->fileid);
00863 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
00864 bp += sizeof(argp->pgno);
00865 memcpy(&argp->lsn, bp, sizeof(argp->lsn));
00866 bp += sizeof(argp->lsn);
00867 memcpy(&argp->nextpgno, bp, sizeof(argp->nextpgno));
00868 bp += sizeof(argp->nextpgno);
00869 memcpy(&argp->nextlsn, bp, sizeof(argp->nextlsn));
00870 bp += sizeof(argp->nextlsn);
00871 *argpp = argp;
00872 return (0);
00873 }
00874
00875 int CDB___db_debug_log(dbenv, txnid, ret_lsnp, flags,
00876 op, fileid, key, data, arg_flags)
00877 DB_ENV *dbenv;
00878 DB_TXN *txnid;
00879 DB_LSN *ret_lsnp;
00880 u_int32_t flags;
00881 const DBT *op;
00882 int32_t fileid;
00883 const DBT *key;
00884 const DBT *data;
00885 u_int32_t arg_flags;
00886 {
00887 DBT logrec;
00888 DB_LSN *lsnp, null_lsn;
00889 u_int32_t zero;
00890 u_int32_t rectype, txn_num;
00891 int ret;
00892 u_int8_t *bp;
00893
00894 if (txnid != NULL &&
00895 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
00896 return (CDB___db_child_active_err(dbenv));
00897 rectype = DB_db_debug;
00898 txn_num = txnid == NULL ? 0 : txnid->txnid;
00899 if (txnid == NULL) {
00900 ZERO_LSN(null_lsn);
00901 lsnp = &null_lsn;
00902 } else
00903 lsnp = &txnid->last_lsn;
00904 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
00905 + sizeof(u_int32_t) + (op == NULL ? 0 : op->size)
00906 + sizeof(fileid)
00907 + sizeof(u_int32_t) + (key == NULL ? 0 : key->size)
00908 + sizeof(u_int32_t) + (data == NULL ? 0 : data->size)
00909 + sizeof(arg_flags);
00910 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
00911 return (ret);
00912
00913 bp = logrec.data;
00914 memcpy(bp, &rectype, sizeof(rectype));
00915 bp += sizeof(rectype);
00916 memcpy(bp, &txn_num, sizeof(txn_num));
00917 bp += sizeof(txn_num);
00918 memcpy(bp, lsnp, sizeof(DB_LSN));
00919 bp += sizeof(DB_LSN);
00920 if (op == NULL) {
00921 zero = 0;
00922 memcpy(bp, &zero, sizeof(u_int32_t));
00923 bp += sizeof(u_int32_t);
00924 } else {
00925 memcpy(bp, &op->size, sizeof(op->size));
00926 bp += sizeof(op->size);
00927 memcpy(bp, op->data, op->size);
00928 bp += op->size;
00929 }
00930 memcpy(bp, &fileid, sizeof(fileid));
00931 bp += sizeof(fileid);
00932 if (key == NULL) {
00933 zero = 0;
00934 memcpy(bp, &zero, sizeof(u_int32_t));
00935 bp += sizeof(u_int32_t);
00936 } else {
00937 memcpy(bp, &key->size, sizeof(key->size));
00938 bp += sizeof(key->size);
00939 memcpy(bp, key->data, key->size);
00940 bp += key->size;
00941 }
00942 if (data == NULL) {
00943 zero = 0;
00944 memcpy(bp, &zero, sizeof(u_int32_t));
00945 bp += sizeof(u_int32_t);
00946 } else {
00947 memcpy(bp, &data->size, sizeof(data->size));
00948 bp += sizeof(data->size);
00949 memcpy(bp, data->data, data->size);
00950 bp += data->size;
00951 }
00952 memcpy(bp, &arg_flags, sizeof(arg_flags));
00953 bp += sizeof(arg_flags);
00954 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
00955 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
00956 if (txnid != NULL)
00957 txnid->last_lsn = *ret_lsnp;
00958 CDB___os_free(logrec.data, logrec.size);
00959 return (ret);
00960 }
00961
00962 int
00963 CDB___db_debug_print(dbenv, dbtp, lsnp, notused2, notused3)
00964 DB_ENV *dbenv;
00965 DBT *dbtp;
00966 DB_LSN *lsnp;
00967 db_recops notused2;
00968 void *notused3;
00969 {
00970 __db_debug_args *argp;
00971 u_int32_t i;
00972 u_int ch;
00973 int ret;
00974
00975 i = 0;
00976 ch = 0;
00977 notused2 = 0;
00978 notused3 = NULL;
00979
00980 if ((ret = CDB___db_debug_read(dbenv, dbtp->data, &argp)) != 0)
00981 return (ret);
00982 printf("[%lu][%lu]db_debug: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
00983 (u_long)lsnp->file,
00984 (u_long)lsnp->offset,
00985 (u_long)argp->type,
00986 (u_long)argp->txnid->txnid,
00987 (u_long)argp->prev_lsn.file,
00988 (u_long)argp->prev_lsn.offset);
00989 printf("\top: ");
00990 for (i = 0; i < argp->op.size; i++) {
00991 ch = ((u_int8_t *)argp->op.data)[i];
00992 if (isprint(ch) || ch == 0xa)
00993 putchar(ch);
00994 else
00995 printf("%#x ", ch);
00996 }
00997 printf("\n");
00998 printf("\tfileid: %ld\n", (long)argp->fileid);
00999 printf("\tkey: ");
01000 for (i = 0; i < argp->key.size; i++) {
01001 ch = ((u_int8_t *)argp->key.data)[i];
01002 if (isprint(ch) || ch == 0xa)
01003 putchar(ch);
01004 else
01005 printf("%#x ", ch);
01006 }
01007 printf("\n");
01008 printf("\tdata: ");
01009 for (i = 0; i < argp->data.size; i++) {
01010 ch = ((u_int8_t *)argp->data.data)[i];
01011 if (isprint(ch) || ch == 0xa)
01012 putchar(ch);
01013 else
01014 printf("%#x ", ch);
01015 }
01016 printf("\n");
01017 printf("\targ_flags: %lu\n", (u_long)argp->arg_flags);
01018 printf("\n");
01019 CDB___os_free(argp, 0);
01020 return (0);
01021 }
01022
01023 int
01024 CDB___db_debug_read(dbenv, recbuf, argpp)
01025 DB_ENV *dbenv;
01026 void *recbuf;
01027 __db_debug_args **argpp;
01028 {
01029 __db_debug_args *argp;
01030 u_int8_t *bp;
01031 int ret;
01032
01033 ret = CDB___os_malloc(dbenv, sizeof(__db_debug_args) +
01034 sizeof(DB_TXN), NULL, &argp);
01035 if (ret != 0)
01036 return (ret);
01037 argp->txnid = (DB_TXN *)&argp[1];
01038 bp = recbuf;
01039 memcpy(&argp->type, bp, sizeof(argp->type));
01040 bp += sizeof(argp->type);
01041 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
01042 bp += sizeof(argp->txnid->txnid);
01043 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
01044 bp += sizeof(DB_LSN);
01045 memset(&argp->op, 0, sizeof(argp->op));
01046 memcpy(&argp->op.size, bp, sizeof(u_int32_t));
01047 bp += sizeof(u_int32_t);
01048 argp->op.data = bp;
01049 bp += argp->op.size;
01050 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
01051 bp += sizeof(argp->fileid);
01052 memset(&argp->key, 0, sizeof(argp->key));
01053 memcpy(&argp->key.size, bp, sizeof(u_int32_t));
01054 bp += sizeof(u_int32_t);
01055 argp->key.data = bp;
01056 bp += argp->key.size;
01057 memset(&argp->data, 0, sizeof(argp->data));
01058 memcpy(&argp->data.size, bp, sizeof(u_int32_t));
01059 bp += sizeof(u_int32_t);
01060 argp->data.data = bp;
01061 bp += argp->data.size;
01062 memcpy(&argp->arg_flags, bp, sizeof(argp->arg_flags));
01063 bp += sizeof(argp->arg_flags);
01064 *argpp = argp;
01065 return (0);
01066 }
01067
01068 int CDB___db_noop_log(dbenv, txnid, ret_lsnp, flags,
01069 fileid, pgno, prevlsn)
01070 DB_ENV *dbenv;
01071 DB_TXN *txnid;
01072 DB_LSN *ret_lsnp;
01073 u_int32_t flags;
01074 int32_t fileid;
01075 db_pgno_t pgno;
01076 DB_LSN * prevlsn;
01077 {
01078 DBT logrec;
01079 DB_LSN *lsnp, null_lsn;
01080 u_int32_t rectype, txn_num;
01081 int ret;
01082 u_int8_t *bp;
01083
01084 if (txnid != NULL &&
01085 TAILQ_FIRST(&txnid->kids) != NULL && CDB___txn_activekids(txnid) != 0)
01086 return (CDB___db_child_active_err(dbenv));
01087 rectype = DB_db_noop;
01088 txn_num = txnid == NULL ? 0 : txnid->txnid;
01089 if (txnid == NULL) {
01090 ZERO_LSN(null_lsn);
01091 lsnp = &null_lsn;
01092 } else
01093 lsnp = &txnid->last_lsn;
01094 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
01095 + sizeof(fileid)
01096 + sizeof(pgno)
01097 + sizeof(*prevlsn);
01098 if ((ret = CDB___os_malloc(dbenv, logrec.size, NULL, &logrec.data)) != 0)
01099 return (ret);
01100
01101 bp = logrec.data;
01102 memcpy(bp, &rectype, sizeof(rectype));
01103 bp += sizeof(rectype);
01104 memcpy(bp, &txn_num, sizeof(txn_num));
01105 bp += sizeof(txn_num);
01106 memcpy(bp, lsnp, sizeof(DB_LSN));
01107 bp += sizeof(DB_LSN);
01108 memcpy(bp, &fileid, sizeof(fileid));
01109 bp += sizeof(fileid);
01110 memcpy(bp, &pgno, sizeof(pgno));
01111 bp += sizeof(pgno);
01112 if (prevlsn != NULL)
01113 memcpy(bp, prevlsn, sizeof(*prevlsn));
01114 else
01115 memset(bp, 0, sizeof(*prevlsn));
01116 bp += sizeof(*prevlsn);
01117 DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
01118 ret = CDB_log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
01119 if (txnid != NULL)
01120 txnid->last_lsn = *ret_lsnp;
01121 CDB___os_free(logrec.data, logrec.size);
01122 return (ret);
01123 }
01124
01125 int
01126 CDB___db_noop_print(dbenv, dbtp, lsnp, notused2, notused3)
01127 DB_ENV *dbenv;
01128 DBT *dbtp;
01129 DB_LSN *lsnp;
01130 db_recops notused2;
01131 void *notused3;
01132 {
01133 __db_noop_args *argp;
01134 u_int32_t i;
01135 u_int ch;
01136 int ret;
01137
01138 i = 0;
01139 ch = 0;
01140 notused2 = 0;
01141 notused3 = NULL;
01142
01143 if ((ret = CDB___db_noop_read(dbenv, dbtp->data, &argp)) != 0)
01144 return (ret);
01145 printf("[%lu][%lu]db_noop: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
01146 (u_long)lsnp->file,
01147 (u_long)lsnp->offset,
01148 (u_long)argp->type,
01149 (u_long)argp->txnid->txnid,
01150 (u_long)argp->prev_lsn.file,
01151 (u_long)argp->prev_lsn.offset);
01152 printf("\tfileid: %ld\n", (long)argp->fileid);
01153 printf("\tpgno: %lu\n", (u_long)argp->pgno);
01154 printf("\tprevlsn: [%lu][%lu]\n",
01155 (u_long)argp->prevlsn.file, (u_long)argp->prevlsn.offset);
01156 printf("\n");
01157 CDB___os_free(argp, 0);
01158 return (0);
01159 }
01160
01161 int
01162 CDB___db_noop_read(dbenv, recbuf, argpp)
01163 DB_ENV *dbenv;
01164 void *recbuf;
01165 __db_noop_args **argpp;
01166 {
01167 __db_noop_args *argp;
01168 u_int8_t *bp;
01169 int ret;
01170
01171 ret = CDB___os_malloc(dbenv, sizeof(__db_noop_args) +
01172 sizeof(DB_TXN), NULL, &argp);
01173 if (ret != 0)
01174 return (ret);
01175 argp->txnid = (DB_TXN *)&argp[1];
01176 bp = recbuf;
01177 memcpy(&argp->type, bp, sizeof(argp->type));
01178 bp += sizeof(argp->type);
01179 memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid));
01180 bp += sizeof(argp->txnid->txnid);
01181 memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
01182 bp += sizeof(DB_LSN);
01183 memcpy(&argp->fileid, bp, sizeof(argp->fileid));
01184 bp += sizeof(argp->fileid);
01185 memcpy(&argp->pgno, bp, sizeof(argp->pgno));
01186 bp += sizeof(argp->pgno);
01187 memcpy(&argp->prevlsn, bp, sizeof(argp->prevlsn));
01188 bp += sizeof(argp->prevlsn);
01189 *argpp = argp;
01190 return (0);
01191 }
01192
01193 int
01194 CDB___db_init_print(dbenv)
01195 DB_ENV *dbenv;
01196 {
01197 int ret;
01198
01199 if ((ret = CDB___db_add_recovery(dbenv,
01200 CDB___db_addrem_print, DB_db_addrem)) != 0)
01201 return (ret);
01202 if ((ret = CDB___db_add_recovery(dbenv,
01203 CDB___db_split_print, DB_db_split)) != 0)
01204 return (ret);
01205 if ((ret = CDB___db_add_recovery(dbenv,
01206 CDB___db_big_print, DB_db_big)) != 0)
01207 return (ret);
01208 if ((ret = CDB___db_add_recovery(dbenv,
01209 CDB___db_ovref_print, DB_db_ovref)) != 0)
01210 return (ret);
01211 if ((ret = CDB___db_add_recovery(dbenv,
01212 CDB___db_relink_print, DB_db_relink)) != 0)
01213 return (ret);
01214 if ((ret = CDB___db_add_recovery(dbenv,
01215 CDB___db_addpage_print, DB_db_addpage)) != 0)
01216 return (ret);
01217 if ((ret = CDB___db_add_recovery(dbenv,
01218 CDB___db_debug_print, DB_db_debug)) != 0)
01219 return (ret);
01220 if ((ret = CDB___db_add_recovery(dbenv,
01221 CDB___db_noop_print, DB_db_noop)) != 0)
01222 return (ret);
01223 return (0);
01224 }
01225
01226 int
01227 CDB___db_init_recover(dbenv)
01228 DB_ENV *dbenv;
01229 {
01230 int ret;
01231
01232 if ((ret = CDB___db_add_recovery(dbenv,
01233 CDB___db_addrem_recover, DB_db_addrem)) != 0)
01234 return (ret);
01235 if ((ret = CDB___db_add_recovery(dbenv,
01236 CDB___deprecated_recover, DB_db_split)) != 0)
01237 return (ret);
01238 if ((ret = CDB___db_add_recovery(dbenv,
01239 CDB___db_big_recover, DB_db_big)) != 0)
01240 return (ret);
01241 if ((ret = CDB___db_add_recovery(dbenv,
01242 CDB___db_ovref_recover, DB_db_ovref)) != 0)
01243 return (ret);
01244 if ((ret = CDB___db_add_recovery(dbenv,
01245 CDB___db_relink_recover, DB_db_relink)) != 0)
01246 return (ret);
01247 if ((ret = CDB___db_add_recovery(dbenv,
01248 CDB___deprecated_recover, DB_db_addpage)) != 0)
01249 return (ret);
01250 if ((ret = CDB___db_add_recovery(dbenv,
01251 CDB___db_debug_recover, DB_db_debug)) != 0)
01252 return (ret);
01253 if ((ret = CDB___db_add_recovery(dbenv,
01254 CDB___db_noop_recover, DB_db_noop)) != 0)
01255 return (ret);
01256 return (0);
01257 }
01258