1*7c478bd9Sstevel@tonic-gate /* Do not edit: automatically built by dist/db_gen.sh. */ 2*7c478bd9Sstevel@tonic-gate #include "config.h" 3*7c478bd9Sstevel@tonic-gate 4*7c478bd9Sstevel@tonic-gate #ifndef NO_SYSTEM_INCLUDES 5*7c478bd9Sstevel@tonic-gate #include <ctype.h> 6*7c478bd9Sstevel@tonic-gate #include <errno.h> 7*7c478bd9Sstevel@tonic-gate #include <stddef.h> 8*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 9*7c478bd9Sstevel@tonic-gate #include <string.h> 10*7c478bd9Sstevel@tonic-gate #endif 11*7c478bd9Sstevel@tonic-gate 12*7c478bd9Sstevel@tonic-gate #include "db_int.h" 13*7c478bd9Sstevel@tonic-gate #include "db_page.h" 14*7c478bd9Sstevel@tonic-gate #include "db_dispatch.h" 15*7c478bd9Sstevel@tonic-gate #include "hash.h" 16*7c478bd9Sstevel@tonic-gate #include "db_am.h" 17*7c478bd9Sstevel@tonic-gate /* 18*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_insdel_log 19*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, 20*7c478bd9Sstevel@tonic-gate * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, u_int32_t, 21*7c478bd9Sstevel@tonic-gate * PUBLIC: DB_LSN *, const DBT *, const DBT *)); 22*7c478bd9Sstevel@tonic-gate */ 23*7c478bd9Sstevel@tonic-gate int __ham_insdel_log(logp, txnid, ret_lsnp, flags, 24*7c478bd9Sstevel@tonic-gate opcode, fileid, pgno, ndx, pagelsn, key, 25*7c478bd9Sstevel@tonic-gate data) 26*7c478bd9Sstevel@tonic-gate DB_LOG *logp; 27*7c478bd9Sstevel@tonic-gate DB_TXN *txnid; 28*7c478bd9Sstevel@tonic-gate DB_LSN *ret_lsnp; 29*7c478bd9Sstevel@tonic-gate u_int32_t flags; 30*7c478bd9Sstevel@tonic-gate u_int32_t opcode; 31*7c478bd9Sstevel@tonic-gate u_int32_t fileid; 32*7c478bd9Sstevel@tonic-gate db_pgno_t pgno; 33*7c478bd9Sstevel@tonic-gate u_int32_t ndx; 34*7c478bd9Sstevel@tonic-gate DB_LSN * pagelsn; 35*7c478bd9Sstevel@tonic-gate const DBT *key; 36*7c478bd9Sstevel@tonic-gate const DBT *data; 37*7c478bd9Sstevel@tonic-gate { 38*7c478bd9Sstevel@tonic-gate DBT logrec; 39*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp, null_lsn; 40*7c478bd9Sstevel@tonic-gate u_int32_t zero; 41*7c478bd9Sstevel@tonic-gate u_int32_t rectype, txn_num; 42*7c478bd9Sstevel@tonic-gate int ret; 43*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate rectype = DB_ham_insdel; 46*7c478bd9Sstevel@tonic-gate txn_num = txnid == NULL ? 0 : txnid->txnid; 47*7c478bd9Sstevel@tonic-gate if (txnid == NULL) { 48*7c478bd9Sstevel@tonic-gate ZERO_LSN(null_lsn); 49*7c478bd9Sstevel@tonic-gate lsnp = &null_lsn; 50*7c478bd9Sstevel@tonic-gate } else 51*7c478bd9Sstevel@tonic-gate lsnp = &txnid->last_lsn; 52*7c478bd9Sstevel@tonic-gate logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN) 53*7c478bd9Sstevel@tonic-gate + sizeof(opcode) 54*7c478bd9Sstevel@tonic-gate + sizeof(fileid) 55*7c478bd9Sstevel@tonic-gate + sizeof(pgno) 56*7c478bd9Sstevel@tonic-gate + sizeof(ndx) 57*7c478bd9Sstevel@tonic-gate + sizeof(*pagelsn) 58*7c478bd9Sstevel@tonic-gate + sizeof(u_int32_t) + (key == NULL ? 0 : key->size) 59*7c478bd9Sstevel@tonic-gate + sizeof(u_int32_t) + (data == NULL ? 0 : data->size); 60*7c478bd9Sstevel@tonic-gate if ((ret = __os_malloc(logrec.size, NULL, &logrec.data)) != 0) 61*7c478bd9Sstevel@tonic-gate return (ret); 62*7c478bd9Sstevel@tonic-gate 63*7c478bd9Sstevel@tonic-gate bp = logrec.data; 64*7c478bd9Sstevel@tonic-gate memcpy(bp, &rectype, sizeof(rectype)); 65*7c478bd9Sstevel@tonic-gate bp += sizeof(rectype); 66*7c478bd9Sstevel@tonic-gate memcpy(bp, &txn_num, sizeof(txn_num)); 67*7c478bd9Sstevel@tonic-gate bp += sizeof(txn_num); 68*7c478bd9Sstevel@tonic-gate memcpy(bp, lsnp, sizeof(DB_LSN)); 69*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 70*7c478bd9Sstevel@tonic-gate memcpy(bp, &opcode, sizeof(opcode)); 71*7c478bd9Sstevel@tonic-gate bp += sizeof(opcode); 72*7c478bd9Sstevel@tonic-gate memcpy(bp, &fileid, sizeof(fileid)); 73*7c478bd9Sstevel@tonic-gate bp += sizeof(fileid); 74*7c478bd9Sstevel@tonic-gate memcpy(bp, &pgno, sizeof(pgno)); 75*7c478bd9Sstevel@tonic-gate bp += sizeof(pgno); 76*7c478bd9Sstevel@tonic-gate memcpy(bp, &ndx, sizeof(ndx)); 77*7c478bd9Sstevel@tonic-gate bp += sizeof(ndx); 78*7c478bd9Sstevel@tonic-gate if (pagelsn != NULL) 79*7c478bd9Sstevel@tonic-gate memcpy(bp, pagelsn, sizeof(*pagelsn)); 80*7c478bd9Sstevel@tonic-gate else 81*7c478bd9Sstevel@tonic-gate memset(bp, 0, sizeof(*pagelsn)); 82*7c478bd9Sstevel@tonic-gate bp += sizeof(*pagelsn); 83*7c478bd9Sstevel@tonic-gate if (key == NULL) { 84*7c478bd9Sstevel@tonic-gate zero = 0; 85*7c478bd9Sstevel@tonic-gate memcpy(bp, &zero, sizeof(u_int32_t)); 86*7c478bd9Sstevel@tonic-gate bp += sizeof(u_int32_t); 87*7c478bd9Sstevel@tonic-gate } else { 88*7c478bd9Sstevel@tonic-gate memcpy(bp, &key->size, sizeof(key->size)); 89*7c478bd9Sstevel@tonic-gate bp += sizeof(key->size); 90*7c478bd9Sstevel@tonic-gate memcpy(bp, key->data, key->size); 91*7c478bd9Sstevel@tonic-gate bp += key->size; 92*7c478bd9Sstevel@tonic-gate } 93*7c478bd9Sstevel@tonic-gate if (data == NULL) { 94*7c478bd9Sstevel@tonic-gate zero = 0; 95*7c478bd9Sstevel@tonic-gate memcpy(bp, &zero, sizeof(u_int32_t)); 96*7c478bd9Sstevel@tonic-gate bp += sizeof(u_int32_t); 97*7c478bd9Sstevel@tonic-gate } else { 98*7c478bd9Sstevel@tonic-gate memcpy(bp, &data->size, sizeof(data->size)); 99*7c478bd9Sstevel@tonic-gate bp += sizeof(data->size); 100*7c478bd9Sstevel@tonic-gate memcpy(bp, data->data, data->size); 101*7c478bd9Sstevel@tonic-gate bp += data->size; 102*7c478bd9Sstevel@tonic-gate } 103*7c478bd9Sstevel@tonic-gate #ifdef DIAGNOSTIC 104*7c478bd9Sstevel@tonic-gate if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size) 105*7c478bd9Sstevel@tonic-gate fprintf(stderr, "Error in log record length"); 106*7c478bd9Sstevel@tonic-gate #endif 107*7c478bd9Sstevel@tonic-gate ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags); 108*7c478bd9Sstevel@tonic-gate if (txnid != NULL) 109*7c478bd9Sstevel@tonic-gate txnid->last_lsn = *ret_lsnp; 110*7c478bd9Sstevel@tonic-gate __os_free(logrec.data, 0); 111*7c478bd9Sstevel@tonic-gate return (ret); 112*7c478bd9Sstevel@tonic-gate } 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate /* 115*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_insdel_print 116*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); 117*7c478bd9Sstevel@tonic-gate */ 118*7c478bd9Sstevel@tonic-gate int 119*7c478bd9Sstevel@tonic-gate __ham_insdel_print(notused1, dbtp, lsnp, notused2, notused3) 120*7c478bd9Sstevel@tonic-gate DB_LOG *notused1; 121*7c478bd9Sstevel@tonic-gate DBT *dbtp; 122*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp; 123*7c478bd9Sstevel@tonic-gate int notused2; 124*7c478bd9Sstevel@tonic-gate void *notused3; 125*7c478bd9Sstevel@tonic-gate { 126*7c478bd9Sstevel@tonic-gate __ham_insdel_args *argp; 127*7c478bd9Sstevel@tonic-gate u_int32_t i; 128*7c478bd9Sstevel@tonic-gate u_int ch; 129*7c478bd9Sstevel@tonic-gate int ret; 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate i = 0; 132*7c478bd9Sstevel@tonic-gate ch = 0; 133*7c478bd9Sstevel@tonic-gate notused1 = NULL; 134*7c478bd9Sstevel@tonic-gate notused2 = 0; 135*7c478bd9Sstevel@tonic-gate notused3 = NULL; 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate if ((ret = __ham_insdel_read(dbtp->data, &argp)) != 0) 138*7c478bd9Sstevel@tonic-gate return (ret); 139*7c478bd9Sstevel@tonic-gate printf("[%lu][%lu]ham_insdel: rec: %lu txnid %lx prevlsn [%lu][%lu]\n", 140*7c478bd9Sstevel@tonic-gate (u_long)lsnp->file, 141*7c478bd9Sstevel@tonic-gate (u_long)lsnp->offset, 142*7c478bd9Sstevel@tonic-gate (u_long)argp->type, 143*7c478bd9Sstevel@tonic-gate (u_long)argp->txnid->txnid, 144*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.file, 145*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.offset); 146*7c478bd9Sstevel@tonic-gate printf("\topcode: %lu\n", (u_long)argp->opcode); 147*7c478bd9Sstevel@tonic-gate printf("\tfileid: %lu\n", (u_long)argp->fileid); 148*7c478bd9Sstevel@tonic-gate printf("\tpgno: %lu\n", (u_long)argp->pgno); 149*7c478bd9Sstevel@tonic-gate printf("\tndx: %lu\n", (u_long)argp->ndx); 150*7c478bd9Sstevel@tonic-gate printf("\tpagelsn: [%lu][%lu]\n", 151*7c478bd9Sstevel@tonic-gate (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset); 152*7c478bd9Sstevel@tonic-gate printf("\tkey: "); 153*7c478bd9Sstevel@tonic-gate for (i = 0; i < argp->key.size; i++) { 154*7c478bd9Sstevel@tonic-gate ch = ((u_int8_t *)argp->key.data)[i]; 155*7c478bd9Sstevel@tonic-gate if (isprint(ch) || ch == 0xa) 156*7c478bd9Sstevel@tonic-gate putchar(ch); 157*7c478bd9Sstevel@tonic-gate else 158*7c478bd9Sstevel@tonic-gate printf("%#x ", ch); 159*7c478bd9Sstevel@tonic-gate } 160*7c478bd9Sstevel@tonic-gate printf("\n"); 161*7c478bd9Sstevel@tonic-gate printf("\tdata: "); 162*7c478bd9Sstevel@tonic-gate for (i = 0; i < argp->data.size; i++) { 163*7c478bd9Sstevel@tonic-gate ch = ((u_int8_t *)argp->data.data)[i]; 164*7c478bd9Sstevel@tonic-gate if (isprint(ch) || ch == 0xa) 165*7c478bd9Sstevel@tonic-gate putchar(ch); 166*7c478bd9Sstevel@tonic-gate else 167*7c478bd9Sstevel@tonic-gate printf("%#x ", ch); 168*7c478bd9Sstevel@tonic-gate } 169*7c478bd9Sstevel@tonic-gate printf("\n"); 170*7c478bd9Sstevel@tonic-gate printf("\n"); 171*7c478bd9Sstevel@tonic-gate __os_free(argp, 0); 172*7c478bd9Sstevel@tonic-gate return (0); 173*7c478bd9Sstevel@tonic-gate } 174*7c478bd9Sstevel@tonic-gate 175*7c478bd9Sstevel@tonic-gate /* 176*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_insdel_read __P((void *, __ham_insdel_args **)); 177*7c478bd9Sstevel@tonic-gate */ 178*7c478bd9Sstevel@tonic-gate int 179*7c478bd9Sstevel@tonic-gate __ham_insdel_read(recbuf, argpp) 180*7c478bd9Sstevel@tonic-gate void *recbuf; 181*7c478bd9Sstevel@tonic-gate __ham_insdel_args **argpp; 182*7c478bd9Sstevel@tonic-gate { 183*7c478bd9Sstevel@tonic-gate __ham_insdel_args *argp; 184*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 185*7c478bd9Sstevel@tonic-gate int ret; 186*7c478bd9Sstevel@tonic-gate 187*7c478bd9Sstevel@tonic-gate ret = __os_malloc(sizeof(__ham_insdel_args) + 188*7c478bd9Sstevel@tonic-gate sizeof(DB_TXN), NULL, &argp); 189*7c478bd9Sstevel@tonic-gate if (ret != 0) 190*7c478bd9Sstevel@tonic-gate return (ret); 191*7c478bd9Sstevel@tonic-gate argp->txnid = (DB_TXN *)&argp[1]; 192*7c478bd9Sstevel@tonic-gate bp = recbuf; 193*7c478bd9Sstevel@tonic-gate memcpy(&argp->type, bp, sizeof(argp->type)); 194*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->type); 195*7c478bd9Sstevel@tonic-gate memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid)); 196*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->txnid->txnid); 197*7c478bd9Sstevel@tonic-gate memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN)); 198*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 199*7c478bd9Sstevel@tonic-gate memcpy(&argp->opcode, bp, sizeof(argp->opcode)); 200*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->opcode); 201*7c478bd9Sstevel@tonic-gate memcpy(&argp->fileid, bp, sizeof(argp->fileid)); 202*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->fileid); 203*7c478bd9Sstevel@tonic-gate memcpy(&argp->pgno, bp, sizeof(argp->pgno)); 204*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->pgno); 205*7c478bd9Sstevel@tonic-gate memcpy(&argp->ndx, bp, sizeof(argp->ndx)); 206*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->ndx); 207*7c478bd9Sstevel@tonic-gate memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn)); 208*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->pagelsn); 209*7c478bd9Sstevel@tonic-gate memcpy(&argp->key.size, bp, sizeof(u_int32_t)); 210*7c478bd9Sstevel@tonic-gate bp += sizeof(u_int32_t); 211*7c478bd9Sstevel@tonic-gate argp->key.data = bp; 212*7c478bd9Sstevel@tonic-gate bp += argp->key.size; 213*7c478bd9Sstevel@tonic-gate memcpy(&argp->data.size, bp, sizeof(u_int32_t)); 214*7c478bd9Sstevel@tonic-gate bp += sizeof(u_int32_t); 215*7c478bd9Sstevel@tonic-gate argp->data.data = bp; 216*7c478bd9Sstevel@tonic-gate bp += argp->data.size; 217*7c478bd9Sstevel@tonic-gate *argpp = argp; 218*7c478bd9Sstevel@tonic-gate return (0); 219*7c478bd9Sstevel@tonic-gate } 220*7c478bd9Sstevel@tonic-gate 221*7c478bd9Sstevel@tonic-gate /* 222*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_newpage_log 223*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, 224*7c478bd9Sstevel@tonic-gate * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, DB_LSN *, 225*7c478bd9Sstevel@tonic-gate * PUBLIC: db_pgno_t, DB_LSN *, db_pgno_t, DB_LSN *)); 226*7c478bd9Sstevel@tonic-gate */ 227*7c478bd9Sstevel@tonic-gate int __ham_newpage_log(logp, txnid, ret_lsnp, flags, 228*7c478bd9Sstevel@tonic-gate opcode, fileid, prev_pgno, prevlsn, new_pgno, pagelsn, 229*7c478bd9Sstevel@tonic-gate next_pgno, nextlsn) 230*7c478bd9Sstevel@tonic-gate DB_LOG *logp; 231*7c478bd9Sstevel@tonic-gate DB_TXN *txnid; 232*7c478bd9Sstevel@tonic-gate DB_LSN *ret_lsnp; 233*7c478bd9Sstevel@tonic-gate u_int32_t flags; 234*7c478bd9Sstevel@tonic-gate u_int32_t opcode; 235*7c478bd9Sstevel@tonic-gate u_int32_t fileid; 236*7c478bd9Sstevel@tonic-gate db_pgno_t prev_pgno; 237*7c478bd9Sstevel@tonic-gate DB_LSN * prevlsn; 238*7c478bd9Sstevel@tonic-gate db_pgno_t new_pgno; 239*7c478bd9Sstevel@tonic-gate DB_LSN * pagelsn; 240*7c478bd9Sstevel@tonic-gate db_pgno_t next_pgno; 241*7c478bd9Sstevel@tonic-gate DB_LSN * nextlsn; 242*7c478bd9Sstevel@tonic-gate { 243*7c478bd9Sstevel@tonic-gate DBT logrec; 244*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp, null_lsn; 245*7c478bd9Sstevel@tonic-gate u_int32_t rectype, txn_num; 246*7c478bd9Sstevel@tonic-gate int ret; 247*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 248*7c478bd9Sstevel@tonic-gate 249*7c478bd9Sstevel@tonic-gate rectype = DB_ham_newpage; 250*7c478bd9Sstevel@tonic-gate txn_num = txnid == NULL ? 0 : txnid->txnid; 251*7c478bd9Sstevel@tonic-gate if (txnid == NULL) { 252*7c478bd9Sstevel@tonic-gate ZERO_LSN(null_lsn); 253*7c478bd9Sstevel@tonic-gate lsnp = &null_lsn; 254*7c478bd9Sstevel@tonic-gate } else 255*7c478bd9Sstevel@tonic-gate lsnp = &txnid->last_lsn; 256*7c478bd9Sstevel@tonic-gate logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN) 257*7c478bd9Sstevel@tonic-gate + sizeof(opcode) 258*7c478bd9Sstevel@tonic-gate + sizeof(fileid) 259*7c478bd9Sstevel@tonic-gate + sizeof(prev_pgno) 260*7c478bd9Sstevel@tonic-gate + sizeof(*prevlsn) 261*7c478bd9Sstevel@tonic-gate + sizeof(new_pgno) 262*7c478bd9Sstevel@tonic-gate + sizeof(*pagelsn) 263*7c478bd9Sstevel@tonic-gate + sizeof(next_pgno) 264*7c478bd9Sstevel@tonic-gate + sizeof(*nextlsn); 265*7c478bd9Sstevel@tonic-gate if ((ret = __os_malloc(logrec.size, NULL, &logrec.data)) != 0) 266*7c478bd9Sstevel@tonic-gate return (ret); 267*7c478bd9Sstevel@tonic-gate 268*7c478bd9Sstevel@tonic-gate bp = logrec.data; 269*7c478bd9Sstevel@tonic-gate memcpy(bp, &rectype, sizeof(rectype)); 270*7c478bd9Sstevel@tonic-gate bp += sizeof(rectype); 271*7c478bd9Sstevel@tonic-gate memcpy(bp, &txn_num, sizeof(txn_num)); 272*7c478bd9Sstevel@tonic-gate bp += sizeof(txn_num); 273*7c478bd9Sstevel@tonic-gate memcpy(bp, lsnp, sizeof(DB_LSN)); 274*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 275*7c478bd9Sstevel@tonic-gate memcpy(bp, &opcode, sizeof(opcode)); 276*7c478bd9Sstevel@tonic-gate bp += sizeof(opcode); 277*7c478bd9Sstevel@tonic-gate memcpy(bp, &fileid, sizeof(fileid)); 278*7c478bd9Sstevel@tonic-gate bp += sizeof(fileid); 279*7c478bd9Sstevel@tonic-gate memcpy(bp, &prev_pgno, sizeof(prev_pgno)); 280*7c478bd9Sstevel@tonic-gate bp += sizeof(prev_pgno); 281*7c478bd9Sstevel@tonic-gate if (prevlsn != NULL) 282*7c478bd9Sstevel@tonic-gate memcpy(bp, prevlsn, sizeof(*prevlsn)); 283*7c478bd9Sstevel@tonic-gate else 284*7c478bd9Sstevel@tonic-gate memset(bp, 0, sizeof(*prevlsn)); 285*7c478bd9Sstevel@tonic-gate bp += sizeof(*prevlsn); 286*7c478bd9Sstevel@tonic-gate memcpy(bp, &new_pgno, sizeof(new_pgno)); 287*7c478bd9Sstevel@tonic-gate bp += sizeof(new_pgno); 288*7c478bd9Sstevel@tonic-gate if (pagelsn != NULL) 289*7c478bd9Sstevel@tonic-gate memcpy(bp, pagelsn, sizeof(*pagelsn)); 290*7c478bd9Sstevel@tonic-gate else 291*7c478bd9Sstevel@tonic-gate memset(bp, 0, sizeof(*pagelsn)); 292*7c478bd9Sstevel@tonic-gate bp += sizeof(*pagelsn); 293*7c478bd9Sstevel@tonic-gate memcpy(bp, &next_pgno, sizeof(next_pgno)); 294*7c478bd9Sstevel@tonic-gate bp += sizeof(next_pgno); 295*7c478bd9Sstevel@tonic-gate if (nextlsn != NULL) 296*7c478bd9Sstevel@tonic-gate memcpy(bp, nextlsn, sizeof(*nextlsn)); 297*7c478bd9Sstevel@tonic-gate else 298*7c478bd9Sstevel@tonic-gate memset(bp, 0, sizeof(*nextlsn)); 299*7c478bd9Sstevel@tonic-gate bp += sizeof(*nextlsn); 300*7c478bd9Sstevel@tonic-gate #ifdef DIAGNOSTIC 301*7c478bd9Sstevel@tonic-gate if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size) 302*7c478bd9Sstevel@tonic-gate fprintf(stderr, "Error in log record length"); 303*7c478bd9Sstevel@tonic-gate #endif 304*7c478bd9Sstevel@tonic-gate ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags); 305*7c478bd9Sstevel@tonic-gate if (txnid != NULL) 306*7c478bd9Sstevel@tonic-gate txnid->last_lsn = *ret_lsnp; 307*7c478bd9Sstevel@tonic-gate __os_free(logrec.data, 0); 308*7c478bd9Sstevel@tonic-gate return (ret); 309*7c478bd9Sstevel@tonic-gate } 310*7c478bd9Sstevel@tonic-gate 311*7c478bd9Sstevel@tonic-gate /* 312*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_newpage_print 313*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); 314*7c478bd9Sstevel@tonic-gate */ 315*7c478bd9Sstevel@tonic-gate int 316*7c478bd9Sstevel@tonic-gate __ham_newpage_print(notused1, dbtp, lsnp, notused2, notused3) 317*7c478bd9Sstevel@tonic-gate DB_LOG *notused1; 318*7c478bd9Sstevel@tonic-gate DBT *dbtp; 319*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp; 320*7c478bd9Sstevel@tonic-gate int notused2; 321*7c478bd9Sstevel@tonic-gate void *notused3; 322*7c478bd9Sstevel@tonic-gate { 323*7c478bd9Sstevel@tonic-gate __ham_newpage_args *argp; 324*7c478bd9Sstevel@tonic-gate u_int32_t i; 325*7c478bd9Sstevel@tonic-gate u_int ch; 326*7c478bd9Sstevel@tonic-gate int ret; 327*7c478bd9Sstevel@tonic-gate 328*7c478bd9Sstevel@tonic-gate i = 0; 329*7c478bd9Sstevel@tonic-gate ch = 0; 330*7c478bd9Sstevel@tonic-gate notused1 = NULL; 331*7c478bd9Sstevel@tonic-gate notused2 = 0; 332*7c478bd9Sstevel@tonic-gate notused3 = NULL; 333*7c478bd9Sstevel@tonic-gate 334*7c478bd9Sstevel@tonic-gate if ((ret = __ham_newpage_read(dbtp->data, &argp)) != 0) 335*7c478bd9Sstevel@tonic-gate return (ret); 336*7c478bd9Sstevel@tonic-gate printf("[%lu][%lu]ham_newpage: rec: %lu txnid %lx prevlsn [%lu][%lu]\n", 337*7c478bd9Sstevel@tonic-gate (u_long)lsnp->file, 338*7c478bd9Sstevel@tonic-gate (u_long)lsnp->offset, 339*7c478bd9Sstevel@tonic-gate (u_long)argp->type, 340*7c478bd9Sstevel@tonic-gate (u_long)argp->txnid->txnid, 341*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.file, 342*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.offset); 343*7c478bd9Sstevel@tonic-gate printf("\topcode: %lu\n", (u_long)argp->opcode); 344*7c478bd9Sstevel@tonic-gate printf("\tfileid: %lu\n", (u_long)argp->fileid); 345*7c478bd9Sstevel@tonic-gate printf("\tprev_pgno: %lu\n", (u_long)argp->prev_pgno); 346*7c478bd9Sstevel@tonic-gate printf("\tprevlsn: [%lu][%lu]\n", 347*7c478bd9Sstevel@tonic-gate (u_long)argp->prevlsn.file, (u_long)argp->prevlsn.offset); 348*7c478bd9Sstevel@tonic-gate printf("\tnew_pgno: %lu\n", (u_long)argp->new_pgno); 349*7c478bd9Sstevel@tonic-gate printf("\tpagelsn: [%lu][%lu]\n", 350*7c478bd9Sstevel@tonic-gate (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset); 351*7c478bd9Sstevel@tonic-gate printf("\tnext_pgno: %lu\n", (u_long)argp->next_pgno); 352*7c478bd9Sstevel@tonic-gate printf("\tnextlsn: [%lu][%lu]\n", 353*7c478bd9Sstevel@tonic-gate (u_long)argp->nextlsn.file, (u_long)argp->nextlsn.offset); 354*7c478bd9Sstevel@tonic-gate printf("\n"); 355*7c478bd9Sstevel@tonic-gate __os_free(argp, 0); 356*7c478bd9Sstevel@tonic-gate return (0); 357*7c478bd9Sstevel@tonic-gate } 358*7c478bd9Sstevel@tonic-gate 359*7c478bd9Sstevel@tonic-gate /* 360*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_newpage_read __P((void *, __ham_newpage_args **)); 361*7c478bd9Sstevel@tonic-gate */ 362*7c478bd9Sstevel@tonic-gate int 363*7c478bd9Sstevel@tonic-gate __ham_newpage_read(recbuf, argpp) 364*7c478bd9Sstevel@tonic-gate void *recbuf; 365*7c478bd9Sstevel@tonic-gate __ham_newpage_args **argpp; 366*7c478bd9Sstevel@tonic-gate { 367*7c478bd9Sstevel@tonic-gate __ham_newpage_args *argp; 368*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 369*7c478bd9Sstevel@tonic-gate int ret; 370*7c478bd9Sstevel@tonic-gate 371*7c478bd9Sstevel@tonic-gate ret = __os_malloc(sizeof(__ham_newpage_args) + 372*7c478bd9Sstevel@tonic-gate sizeof(DB_TXN), NULL, &argp); 373*7c478bd9Sstevel@tonic-gate if (ret != 0) 374*7c478bd9Sstevel@tonic-gate return (ret); 375*7c478bd9Sstevel@tonic-gate argp->txnid = (DB_TXN *)&argp[1]; 376*7c478bd9Sstevel@tonic-gate bp = recbuf; 377*7c478bd9Sstevel@tonic-gate memcpy(&argp->type, bp, sizeof(argp->type)); 378*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->type); 379*7c478bd9Sstevel@tonic-gate memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid)); 380*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->txnid->txnid); 381*7c478bd9Sstevel@tonic-gate memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN)); 382*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 383*7c478bd9Sstevel@tonic-gate memcpy(&argp->opcode, bp, sizeof(argp->opcode)); 384*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->opcode); 385*7c478bd9Sstevel@tonic-gate memcpy(&argp->fileid, bp, sizeof(argp->fileid)); 386*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->fileid); 387*7c478bd9Sstevel@tonic-gate memcpy(&argp->prev_pgno, bp, sizeof(argp->prev_pgno)); 388*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->prev_pgno); 389*7c478bd9Sstevel@tonic-gate memcpy(&argp->prevlsn, bp, sizeof(argp->prevlsn)); 390*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->prevlsn); 391*7c478bd9Sstevel@tonic-gate memcpy(&argp->new_pgno, bp, sizeof(argp->new_pgno)); 392*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->new_pgno); 393*7c478bd9Sstevel@tonic-gate memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn)); 394*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->pagelsn); 395*7c478bd9Sstevel@tonic-gate memcpy(&argp->next_pgno, bp, sizeof(argp->next_pgno)); 396*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->next_pgno); 397*7c478bd9Sstevel@tonic-gate memcpy(&argp->nextlsn, bp, sizeof(argp->nextlsn)); 398*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->nextlsn); 399*7c478bd9Sstevel@tonic-gate *argpp = argp; 400*7c478bd9Sstevel@tonic-gate return (0); 401*7c478bd9Sstevel@tonic-gate } 402*7c478bd9Sstevel@tonic-gate 403*7c478bd9Sstevel@tonic-gate /* 404*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_splitmeta_log 405*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, 406*7c478bd9Sstevel@tonic-gate * PUBLIC: u_int32_t, u_int32_t, u_int32_t, u_int32_t, 407*7c478bd9Sstevel@tonic-gate * PUBLIC: DB_LSN *)); 408*7c478bd9Sstevel@tonic-gate */ 409*7c478bd9Sstevel@tonic-gate int __ham_splitmeta_log(logp, txnid, ret_lsnp, flags, 410*7c478bd9Sstevel@tonic-gate fileid, bucket, ovflpoint, spares, metalsn) 411*7c478bd9Sstevel@tonic-gate DB_LOG *logp; 412*7c478bd9Sstevel@tonic-gate DB_TXN *txnid; 413*7c478bd9Sstevel@tonic-gate DB_LSN *ret_lsnp; 414*7c478bd9Sstevel@tonic-gate u_int32_t flags; 415*7c478bd9Sstevel@tonic-gate u_int32_t fileid; 416*7c478bd9Sstevel@tonic-gate u_int32_t bucket; 417*7c478bd9Sstevel@tonic-gate u_int32_t ovflpoint; 418*7c478bd9Sstevel@tonic-gate u_int32_t spares; 419*7c478bd9Sstevel@tonic-gate DB_LSN * metalsn; 420*7c478bd9Sstevel@tonic-gate { 421*7c478bd9Sstevel@tonic-gate DBT logrec; 422*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp, null_lsn; 423*7c478bd9Sstevel@tonic-gate u_int32_t rectype, txn_num; 424*7c478bd9Sstevel@tonic-gate int ret; 425*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 426*7c478bd9Sstevel@tonic-gate 427*7c478bd9Sstevel@tonic-gate rectype = DB_ham_splitmeta; 428*7c478bd9Sstevel@tonic-gate txn_num = txnid == NULL ? 0 : txnid->txnid; 429*7c478bd9Sstevel@tonic-gate if (txnid == NULL) { 430*7c478bd9Sstevel@tonic-gate ZERO_LSN(null_lsn); 431*7c478bd9Sstevel@tonic-gate lsnp = &null_lsn; 432*7c478bd9Sstevel@tonic-gate } else 433*7c478bd9Sstevel@tonic-gate lsnp = &txnid->last_lsn; 434*7c478bd9Sstevel@tonic-gate logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN) 435*7c478bd9Sstevel@tonic-gate + sizeof(fileid) 436*7c478bd9Sstevel@tonic-gate + sizeof(bucket) 437*7c478bd9Sstevel@tonic-gate + sizeof(ovflpoint) 438*7c478bd9Sstevel@tonic-gate + sizeof(spares) 439*7c478bd9Sstevel@tonic-gate + sizeof(*metalsn); 440*7c478bd9Sstevel@tonic-gate if ((ret = __os_malloc(logrec.size, NULL, &logrec.data)) != 0) 441*7c478bd9Sstevel@tonic-gate return (ret); 442*7c478bd9Sstevel@tonic-gate 443*7c478bd9Sstevel@tonic-gate bp = logrec.data; 444*7c478bd9Sstevel@tonic-gate memcpy(bp, &rectype, sizeof(rectype)); 445*7c478bd9Sstevel@tonic-gate bp += sizeof(rectype); 446*7c478bd9Sstevel@tonic-gate memcpy(bp, &txn_num, sizeof(txn_num)); 447*7c478bd9Sstevel@tonic-gate bp += sizeof(txn_num); 448*7c478bd9Sstevel@tonic-gate memcpy(bp, lsnp, sizeof(DB_LSN)); 449*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 450*7c478bd9Sstevel@tonic-gate memcpy(bp, &fileid, sizeof(fileid)); 451*7c478bd9Sstevel@tonic-gate bp += sizeof(fileid); 452*7c478bd9Sstevel@tonic-gate memcpy(bp, &bucket, sizeof(bucket)); 453*7c478bd9Sstevel@tonic-gate bp += sizeof(bucket); 454*7c478bd9Sstevel@tonic-gate memcpy(bp, &ovflpoint, sizeof(ovflpoint)); 455*7c478bd9Sstevel@tonic-gate bp += sizeof(ovflpoint); 456*7c478bd9Sstevel@tonic-gate memcpy(bp, &spares, sizeof(spares)); 457*7c478bd9Sstevel@tonic-gate bp += sizeof(spares); 458*7c478bd9Sstevel@tonic-gate if (metalsn != NULL) 459*7c478bd9Sstevel@tonic-gate memcpy(bp, metalsn, sizeof(*metalsn)); 460*7c478bd9Sstevel@tonic-gate else 461*7c478bd9Sstevel@tonic-gate memset(bp, 0, sizeof(*metalsn)); 462*7c478bd9Sstevel@tonic-gate bp += sizeof(*metalsn); 463*7c478bd9Sstevel@tonic-gate #ifdef DIAGNOSTIC 464*7c478bd9Sstevel@tonic-gate if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size) 465*7c478bd9Sstevel@tonic-gate fprintf(stderr, "Error in log record length"); 466*7c478bd9Sstevel@tonic-gate #endif 467*7c478bd9Sstevel@tonic-gate ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags); 468*7c478bd9Sstevel@tonic-gate if (txnid != NULL) 469*7c478bd9Sstevel@tonic-gate txnid->last_lsn = *ret_lsnp; 470*7c478bd9Sstevel@tonic-gate __os_free(logrec.data, 0); 471*7c478bd9Sstevel@tonic-gate return (ret); 472*7c478bd9Sstevel@tonic-gate } 473*7c478bd9Sstevel@tonic-gate 474*7c478bd9Sstevel@tonic-gate /* 475*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_splitmeta_print 476*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); 477*7c478bd9Sstevel@tonic-gate */ 478*7c478bd9Sstevel@tonic-gate int 479*7c478bd9Sstevel@tonic-gate __ham_splitmeta_print(notused1, dbtp, lsnp, notused2, notused3) 480*7c478bd9Sstevel@tonic-gate DB_LOG *notused1; 481*7c478bd9Sstevel@tonic-gate DBT *dbtp; 482*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp; 483*7c478bd9Sstevel@tonic-gate int notused2; 484*7c478bd9Sstevel@tonic-gate void *notused3; 485*7c478bd9Sstevel@tonic-gate { 486*7c478bd9Sstevel@tonic-gate __ham_splitmeta_args *argp; 487*7c478bd9Sstevel@tonic-gate u_int32_t i; 488*7c478bd9Sstevel@tonic-gate u_int ch; 489*7c478bd9Sstevel@tonic-gate int ret; 490*7c478bd9Sstevel@tonic-gate 491*7c478bd9Sstevel@tonic-gate i = 0; 492*7c478bd9Sstevel@tonic-gate ch = 0; 493*7c478bd9Sstevel@tonic-gate notused1 = NULL; 494*7c478bd9Sstevel@tonic-gate notused2 = 0; 495*7c478bd9Sstevel@tonic-gate notused3 = NULL; 496*7c478bd9Sstevel@tonic-gate 497*7c478bd9Sstevel@tonic-gate if ((ret = __ham_splitmeta_read(dbtp->data, &argp)) != 0) 498*7c478bd9Sstevel@tonic-gate return (ret); 499*7c478bd9Sstevel@tonic-gate printf("[%lu][%lu]ham_splitmeta: rec: %lu txnid %lx prevlsn [%lu][%lu]\n", 500*7c478bd9Sstevel@tonic-gate (u_long)lsnp->file, 501*7c478bd9Sstevel@tonic-gate (u_long)lsnp->offset, 502*7c478bd9Sstevel@tonic-gate (u_long)argp->type, 503*7c478bd9Sstevel@tonic-gate (u_long)argp->txnid->txnid, 504*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.file, 505*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.offset); 506*7c478bd9Sstevel@tonic-gate printf("\tfileid: %lu\n", (u_long)argp->fileid); 507*7c478bd9Sstevel@tonic-gate printf("\tbucket: %lu\n", (u_long)argp->bucket); 508*7c478bd9Sstevel@tonic-gate printf("\tovflpoint: %lu\n", (u_long)argp->ovflpoint); 509*7c478bd9Sstevel@tonic-gate printf("\tspares: %lu\n", (u_long)argp->spares); 510*7c478bd9Sstevel@tonic-gate printf("\tmetalsn: [%lu][%lu]\n", 511*7c478bd9Sstevel@tonic-gate (u_long)argp->metalsn.file, (u_long)argp->metalsn.offset); 512*7c478bd9Sstevel@tonic-gate printf("\n"); 513*7c478bd9Sstevel@tonic-gate __os_free(argp, 0); 514*7c478bd9Sstevel@tonic-gate return (0); 515*7c478bd9Sstevel@tonic-gate } 516*7c478bd9Sstevel@tonic-gate 517*7c478bd9Sstevel@tonic-gate /* 518*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_splitmeta_read __P((void *, __ham_splitmeta_args **)); 519*7c478bd9Sstevel@tonic-gate */ 520*7c478bd9Sstevel@tonic-gate int 521*7c478bd9Sstevel@tonic-gate __ham_splitmeta_read(recbuf, argpp) 522*7c478bd9Sstevel@tonic-gate void *recbuf; 523*7c478bd9Sstevel@tonic-gate __ham_splitmeta_args **argpp; 524*7c478bd9Sstevel@tonic-gate { 525*7c478bd9Sstevel@tonic-gate __ham_splitmeta_args *argp; 526*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 527*7c478bd9Sstevel@tonic-gate int ret; 528*7c478bd9Sstevel@tonic-gate 529*7c478bd9Sstevel@tonic-gate ret = __os_malloc(sizeof(__ham_splitmeta_args) + 530*7c478bd9Sstevel@tonic-gate sizeof(DB_TXN), NULL, &argp); 531*7c478bd9Sstevel@tonic-gate if (ret != 0) 532*7c478bd9Sstevel@tonic-gate return (ret); 533*7c478bd9Sstevel@tonic-gate argp->txnid = (DB_TXN *)&argp[1]; 534*7c478bd9Sstevel@tonic-gate bp = recbuf; 535*7c478bd9Sstevel@tonic-gate memcpy(&argp->type, bp, sizeof(argp->type)); 536*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->type); 537*7c478bd9Sstevel@tonic-gate memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid)); 538*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->txnid->txnid); 539*7c478bd9Sstevel@tonic-gate memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN)); 540*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 541*7c478bd9Sstevel@tonic-gate memcpy(&argp->fileid, bp, sizeof(argp->fileid)); 542*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->fileid); 543*7c478bd9Sstevel@tonic-gate memcpy(&argp->bucket, bp, sizeof(argp->bucket)); 544*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->bucket); 545*7c478bd9Sstevel@tonic-gate memcpy(&argp->ovflpoint, bp, sizeof(argp->ovflpoint)); 546*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->ovflpoint); 547*7c478bd9Sstevel@tonic-gate memcpy(&argp->spares, bp, sizeof(argp->spares)); 548*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->spares); 549*7c478bd9Sstevel@tonic-gate memcpy(&argp->metalsn, bp, sizeof(argp->metalsn)); 550*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->metalsn); 551*7c478bd9Sstevel@tonic-gate *argpp = argp; 552*7c478bd9Sstevel@tonic-gate return (0); 553*7c478bd9Sstevel@tonic-gate } 554*7c478bd9Sstevel@tonic-gate 555*7c478bd9Sstevel@tonic-gate /* 556*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_splitdata_log 557*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, 558*7c478bd9Sstevel@tonic-gate * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, const DBT *, 559*7c478bd9Sstevel@tonic-gate * PUBLIC: DB_LSN *)); 560*7c478bd9Sstevel@tonic-gate */ 561*7c478bd9Sstevel@tonic-gate int __ham_splitdata_log(logp, txnid, ret_lsnp, flags, 562*7c478bd9Sstevel@tonic-gate fileid, opcode, pgno, pageimage, pagelsn) 563*7c478bd9Sstevel@tonic-gate DB_LOG *logp; 564*7c478bd9Sstevel@tonic-gate DB_TXN *txnid; 565*7c478bd9Sstevel@tonic-gate DB_LSN *ret_lsnp; 566*7c478bd9Sstevel@tonic-gate u_int32_t flags; 567*7c478bd9Sstevel@tonic-gate u_int32_t fileid; 568*7c478bd9Sstevel@tonic-gate u_int32_t opcode; 569*7c478bd9Sstevel@tonic-gate db_pgno_t pgno; 570*7c478bd9Sstevel@tonic-gate const DBT *pageimage; 571*7c478bd9Sstevel@tonic-gate DB_LSN * pagelsn; 572*7c478bd9Sstevel@tonic-gate { 573*7c478bd9Sstevel@tonic-gate DBT logrec; 574*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp, null_lsn; 575*7c478bd9Sstevel@tonic-gate u_int32_t zero; 576*7c478bd9Sstevel@tonic-gate u_int32_t rectype, txn_num; 577*7c478bd9Sstevel@tonic-gate int ret; 578*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 579*7c478bd9Sstevel@tonic-gate 580*7c478bd9Sstevel@tonic-gate rectype = DB_ham_splitdata; 581*7c478bd9Sstevel@tonic-gate txn_num = txnid == NULL ? 0 : txnid->txnid; 582*7c478bd9Sstevel@tonic-gate if (txnid == NULL) { 583*7c478bd9Sstevel@tonic-gate ZERO_LSN(null_lsn); 584*7c478bd9Sstevel@tonic-gate lsnp = &null_lsn; 585*7c478bd9Sstevel@tonic-gate } else 586*7c478bd9Sstevel@tonic-gate lsnp = &txnid->last_lsn; 587*7c478bd9Sstevel@tonic-gate logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN) 588*7c478bd9Sstevel@tonic-gate + sizeof(fileid) 589*7c478bd9Sstevel@tonic-gate + sizeof(opcode) 590*7c478bd9Sstevel@tonic-gate + sizeof(pgno) 591*7c478bd9Sstevel@tonic-gate + sizeof(u_int32_t) + (pageimage == NULL ? 0 : pageimage->size) 592*7c478bd9Sstevel@tonic-gate + sizeof(*pagelsn); 593*7c478bd9Sstevel@tonic-gate if ((ret = __os_malloc(logrec.size, NULL, &logrec.data)) != 0) 594*7c478bd9Sstevel@tonic-gate return (ret); 595*7c478bd9Sstevel@tonic-gate 596*7c478bd9Sstevel@tonic-gate bp = logrec.data; 597*7c478bd9Sstevel@tonic-gate memcpy(bp, &rectype, sizeof(rectype)); 598*7c478bd9Sstevel@tonic-gate bp += sizeof(rectype); 599*7c478bd9Sstevel@tonic-gate memcpy(bp, &txn_num, sizeof(txn_num)); 600*7c478bd9Sstevel@tonic-gate bp += sizeof(txn_num); 601*7c478bd9Sstevel@tonic-gate memcpy(bp, lsnp, sizeof(DB_LSN)); 602*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 603*7c478bd9Sstevel@tonic-gate memcpy(bp, &fileid, sizeof(fileid)); 604*7c478bd9Sstevel@tonic-gate bp += sizeof(fileid); 605*7c478bd9Sstevel@tonic-gate memcpy(bp, &opcode, sizeof(opcode)); 606*7c478bd9Sstevel@tonic-gate bp += sizeof(opcode); 607*7c478bd9Sstevel@tonic-gate memcpy(bp, &pgno, sizeof(pgno)); 608*7c478bd9Sstevel@tonic-gate bp += sizeof(pgno); 609*7c478bd9Sstevel@tonic-gate if (pageimage == NULL) { 610*7c478bd9Sstevel@tonic-gate zero = 0; 611*7c478bd9Sstevel@tonic-gate memcpy(bp, &zero, sizeof(u_int32_t)); 612*7c478bd9Sstevel@tonic-gate bp += sizeof(u_int32_t); 613*7c478bd9Sstevel@tonic-gate } else { 614*7c478bd9Sstevel@tonic-gate memcpy(bp, &pageimage->size, sizeof(pageimage->size)); 615*7c478bd9Sstevel@tonic-gate bp += sizeof(pageimage->size); 616*7c478bd9Sstevel@tonic-gate memcpy(bp, pageimage->data, pageimage->size); 617*7c478bd9Sstevel@tonic-gate bp += pageimage->size; 618*7c478bd9Sstevel@tonic-gate } 619*7c478bd9Sstevel@tonic-gate if (pagelsn != NULL) 620*7c478bd9Sstevel@tonic-gate memcpy(bp, pagelsn, sizeof(*pagelsn)); 621*7c478bd9Sstevel@tonic-gate else 622*7c478bd9Sstevel@tonic-gate memset(bp, 0, sizeof(*pagelsn)); 623*7c478bd9Sstevel@tonic-gate bp += sizeof(*pagelsn); 624*7c478bd9Sstevel@tonic-gate #ifdef DIAGNOSTIC 625*7c478bd9Sstevel@tonic-gate if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size) 626*7c478bd9Sstevel@tonic-gate fprintf(stderr, "Error in log record length"); 627*7c478bd9Sstevel@tonic-gate #endif 628*7c478bd9Sstevel@tonic-gate ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags); 629*7c478bd9Sstevel@tonic-gate if (txnid != NULL) 630*7c478bd9Sstevel@tonic-gate txnid->last_lsn = *ret_lsnp; 631*7c478bd9Sstevel@tonic-gate __os_free(logrec.data, 0); 632*7c478bd9Sstevel@tonic-gate return (ret); 633*7c478bd9Sstevel@tonic-gate } 634*7c478bd9Sstevel@tonic-gate 635*7c478bd9Sstevel@tonic-gate /* 636*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_splitdata_print 637*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); 638*7c478bd9Sstevel@tonic-gate */ 639*7c478bd9Sstevel@tonic-gate int 640*7c478bd9Sstevel@tonic-gate __ham_splitdata_print(notused1, dbtp, lsnp, notused2, notused3) 641*7c478bd9Sstevel@tonic-gate DB_LOG *notused1; 642*7c478bd9Sstevel@tonic-gate DBT *dbtp; 643*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp; 644*7c478bd9Sstevel@tonic-gate int notused2; 645*7c478bd9Sstevel@tonic-gate void *notused3; 646*7c478bd9Sstevel@tonic-gate { 647*7c478bd9Sstevel@tonic-gate __ham_splitdata_args *argp; 648*7c478bd9Sstevel@tonic-gate u_int32_t i; 649*7c478bd9Sstevel@tonic-gate u_int ch; 650*7c478bd9Sstevel@tonic-gate int ret; 651*7c478bd9Sstevel@tonic-gate 652*7c478bd9Sstevel@tonic-gate i = 0; 653*7c478bd9Sstevel@tonic-gate ch = 0; 654*7c478bd9Sstevel@tonic-gate notused1 = NULL; 655*7c478bd9Sstevel@tonic-gate notused2 = 0; 656*7c478bd9Sstevel@tonic-gate notused3 = NULL; 657*7c478bd9Sstevel@tonic-gate 658*7c478bd9Sstevel@tonic-gate if ((ret = __ham_splitdata_read(dbtp->data, &argp)) != 0) 659*7c478bd9Sstevel@tonic-gate return (ret); 660*7c478bd9Sstevel@tonic-gate printf("[%lu][%lu]ham_splitdata: rec: %lu txnid %lx prevlsn [%lu][%lu]\n", 661*7c478bd9Sstevel@tonic-gate (u_long)lsnp->file, 662*7c478bd9Sstevel@tonic-gate (u_long)lsnp->offset, 663*7c478bd9Sstevel@tonic-gate (u_long)argp->type, 664*7c478bd9Sstevel@tonic-gate (u_long)argp->txnid->txnid, 665*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.file, 666*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.offset); 667*7c478bd9Sstevel@tonic-gate printf("\tfileid: %lu\n", (u_long)argp->fileid); 668*7c478bd9Sstevel@tonic-gate printf("\topcode: %lu\n", (u_long)argp->opcode); 669*7c478bd9Sstevel@tonic-gate printf("\tpgno: %lu\n", (u_long)argp->pgno); 670*7c478bd9Sstevel@tonic-gate printf("\tpageimage: "); 671*7c478bd9Sstevel@tonic-gate for (i = 0; i < argp->pageimage.size; i++) { 672*7c478bd9Sstevel@tonic-gate ch = ((u_int8_t *)argp->pageimage.data)[i]; 673*7c478bd9Sstevel@tonic-gate if (isprint(ch) || ch == 0xa) 674*7c478bd9Sstevel@tonic-gate putchar(ch); 675*7c478bd9Sstevel@tonic-gate else 676*7c478bd9Sstevel@tonic-gate printf("%#x ", ch); 677*7c478bd9Sstevel@tonic-gate } 678*7c478bd9Sstevel@tonic-gate printf("\n"); 679*7c478bd9Sstevel@tonic-gate printf("\tpagelsn: [%lu][%lu]\n", 680*7c478bd9Sstevel@tonic-gate (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset); 681*7c478bd9Sstevel@tonic-gate printf("\n"); 682*7c478bd9Sstevel@tonic-gate __os_free(argp, 0); 683*7c478bd9Sstevel@tonic-gate return (0); 684*7c478bd9Sstevel@tonic-gate } 685*7c478bd9Sstevel@tonic-gate 686*7c478bd9Sstevel@tonic-gate /* 687*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_splitdata_read __P((void *, __ham_splitdata_args **)); 688*7c478bd9Sstevel@tonic-gate */ 689*7c478bd9Sstevel@tonic-gate int 690*7c478bd9Sstevel@tonic-gate __ham_splitdata_read(recbuf, argpp) 691*7c478bd9Sstevel@tonic-gate void *recbuf; 692*7c478bd9Sstevel@tonic-gate __ham_splitdata_args **argpp; 693*7c478bd9Sstevel@tonic-gate { 694*7c478bd9Sstevel@tonic-gate __ham_splitdata_args *argp; 695*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 696*7c478bd9Sstevel@tonic-gate int ret; 697*7c478bd9Sstevel@tonic-gate 698*7c478bd9Sstevel@tonic-gate ret = __os_malloc(sizeof(__ham_splitdata_args) + 699*7c478bd9Sstevel@tonic-gate sizeof(DB_TXN), NULL, &argp); 700*7c478bd9Sstevel@tonic-gate if (ret != 0) 701*7c478bd9Sstevel@tonic-gate return (ret); 702*7c478bd9Sstevel@tonic-gate argp->txnid = (DB_TXN *)&argp[1]; 703*7c478bd9Sstevel@tonic-gate bp = recbuf; 704*7c478bd9Sstevel@tonic-gate memcpy(&argp->type, bp, sizeof(argp->type)); 705*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->type); 706*7c478bd9Sstevel@tonic-gate memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid)); 707*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->txnid->txnid); 708*7c478bd9Sstevel@tonic-gate memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN)); 709*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 710*7c478bd9Sstevel@tonic-gate memcpy(&argp->fileid, bp, sizeof(argp->fileid)); 711*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->fileid); 712*7c478bd9Sstevel@tonic-gate memcpy(&argp->opcode, bp, sizeof(argp->opcode)); 713*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->opcode); 714*7c478bd9Sstevel@tonic-gate memcpy(&argp->pgno, bp, sizeof(argp->pgno)); 715*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->pgno); 716*7c478bd9Sstevel@tonic-gate memcpy(&argp->pageimage.size, bp, sizeof(u_int32_t)); 717*7c478bd9Sstevel@tonic-gate bp += sizeof(u_int32_t); 718*7c478bd9Sstevel@tonic-gate argp->pageimage.data = bp; 719*7c478bd9Sstevel@tonic-gate bp += argp->pageimage.size; 720*7c478bd9Sstevel@tonic-gate memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn)); 721*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->pagelsn); 722*7c478bd9Sstevel@tonic-gate *argpp = argp; 723*7c478bd9Sstevel@tonic-gate return (0); 724*7c478bd9Sstevel@tonic-gate } 725*7c478bd9Sstevel@tonic-gate 726*7c478bd9Sstevel@tonic-gate /* 727*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_replace_log 728*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, 729*7c478bd9Sstevel@tonic-gate * PUBLIC: u_int32_t, db_pgno_t, u_int32_t, DB_LSN *, 730*7c478bd9Sstevel@tonic-gate * PUBLIC: int32_t, const DBT *, const DBT *, u_int32_t)); 731*7c478bd9Sstevel@tonic-gate */ 732*7c478bd9Sstevel@tonic-gate int __ham_replace_log(logp, txnid, ret_lsnp, flags, 733*7c478bd9Sstevel@tonic-gate fileid, pgno, ndx, pagelsn, off, olditem, 734*7c478bd9Sstevel@tonic-gate newitem, makedup) 735*7c478bd9Sstevel@tonic-gate DB_LOG *logp; 736*7c478bd9Sstevel@tonic-gate DB_TXN *txnid; 737*7c478bd9Sstevel@tonic-gate DB_LSN *ret_lsnp; 738*7c478bd9Sstevel@tonic-gate u_int32_t flags; 739*7c478bd9Sstevel@tonic-gate u_int32_t fileid; 740*7c478bd9Sstevel@tonic-gate db_pgno_t pgno; 741*7c478bd9Sstevel@tonic-gate u_int32_t ndx; 742*7c478bd9Sstevel@tonic-gate DB_LSN * pagelsn; 743*7c478bd9Sstevel@tonic-gate int32_t off; 744*7c478bd9Sstevel@tonic-gate const DBT *olditem; 745*7c478bd9Sstevel@tonic-gate const DBT *newitem; 746*7c478bd9Sstevel@tonic-gate u_int32_t makedup; 747*7c478bd9Sstevel@tonic-gate { 748*7c478bd9Sstevel@tonic-gate DBT logrec; 749*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp, null_lsn; 750*7c478bd9Sstevel@tonic-gate u_int32_t zero; 751*7c478bd9Sstevel@tonic-gate u_int32_t rectype, txn_num; 752*7c478bd9Sstevel@tonic-gate int ret; 753*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 754*7c478bd9Sstevel@tonic-gate 755*7c478bd9Sstevel@tonic-gate rectype = DB_ham_replace; 756*7c478bd9Sstevel@tonic-gate txn_num = txnid == NULL ? 0 : txnid->txnid; 757*7c478bd9Sstevel@tonic-gate if (txnid == NULL) { 758*7c478bd9Sstevel@tonic-gate ZERO_LSN(null_lsn); 759*7c478bd9Sstevel@tonic-gate lsnp = &null_lsn; 760*7c478bd9Sstevel@tonic-gate } else 761*7c478bd9Sstevel@tonic-gate lsnp = &txnid->last_lsn; 762*7c478bd9Sstevel@tonic-gate logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN) 763*7c478bd9Sstevel@tonic-gate + sizeof(fileid) 764*7c478bd9Sstevel@tonic-gate + sizeof(pgno) 765*7c478bd9Sstevel@tonic-gate + sizeof(ndx) 766*7c478bd9Sstevel@tonic-gate + sizeof(*pagelsn) 767*7c478bd9Sstevel@tonic-gate + sizeof(off) 768*7c478bd9Sstevel@tonic-gate + sizeof(u_int32_t) + (olditem == NULL ? 0 : olditem->size) 769*7c478bd9Sstevel@tonic-gate + sizeof(u_int32_t) + (newitem == NULL ? 0 : newitem->size) 770*7c478bd9Sstevel@tonic-gate + sizeof(makedup); 771*7c478bd9Sstevel@tonic-gate if ((ret = __os_malloc(logrec.size, NULL, &logrec.data)) != 0) 772*7c478bd9Sstevel@tonic-gate return (ret); 773*7c478bd9Sstevel@tonic-gate 774*7c478bd9Sstevel@tonic-gate bp = logrec.data; 775*7c478bd9Sstevel@tonic-gate memcpy(bp, &rectype, sizeof(rectype)); 776*7c478bd9Sstevel@tonic-gate bp += sizeof(rectype); 777*7c478bd9Sstevel@tonic-gate memcpy(bp, &txn_num, sizeof(txn_num)); 778*7c478bd9Sstevel@tonic-gate bp += sizeof(txn_num); 779*7c478bd9Sstevel@tonic-gate memcpy(bp, lsnp, sizeof(DB_LSN)); 780*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 781*7c478bd9Sstevel@tonic-gate memcpy(bp, &fileid, sizeof(fileid)); 782*7c478bd9Sstevel@tonic-gate bp += sizeof(fileid); 783*7c478bd9Sstevel@tonic-gate memcpy(bp, &pgno, sizeof(pgno)); 784*7c478bd9Sstevel@tonic-gate bp += sizeof(pgno); 785*7c478bd9Sstevel@tonic-gate memcpy(bp, &ndx, sizeof(ndx)); 786*7c478bd9Sstevel@tonic-gate bp += sizeof(ndx); 787*7c478bd9Sstevel@tonic-gate if (pagelsn != NULL) 788*7c478bd9Sstevel@tonic-gate memcpy(bp, pagelsn, sizeof(*pagelsn)); 789*7c478bd9Sstevel@tonic-gate else 790*7c478bd9Sstevel@tonic-gate memset(bp, 0, sizeof(*pagelsn)); 791*7c478bd9Sstevel@tonic-gate bp += sizeof(*pagelsn); 792*7c478bd9Sstevel@tonic-gate memcpy(bp, &off, sizeof(off)); 793*7c478bd9Sstevel@tonic-gate bp += sizeof(off); 794*7c478bd9Sstevel@tonic-gate if (olditem == NULL) { 795*7c478bd9Sstevel@tonic-gate zero = 0; 796*7c478bd9Sstevel@tonic-gate memcpy(bp, &zero, sizeof(u_int32_t)); 797*7c478bd9Sstevel@tonic-gate bp += sizeof(u_int32_t); 798*7c478bd9Sstevel@tonic-gate } else { 799*7c478bd9Sstevel@tonic-gate memcpy(bp, &olditem->size, sizeof(olditem->size)); 800*7c478bd9Sstevel@tonic-gate bp += sizeof(olditem->size); 801*7c478bd9Sstevel@tonic-gate memcpy(bp, olditem->data, olditem->size); 802*7c478bd9Sstevel@tonic-gate bp += olditem->size; 803*7c478bd9Sstevel@tonic-gate } 804*7c478bd9Sstevel@tonic-gate if (newitem == NULL) { 805*7c478bd9Sstevel@tonic-gate zero = 0; 806*7c478bd9Sstevel@tonic-gate memcpy(bp, &zero, sizeof(u_int32_t)); 807*7c478bd9Sstevel@tonic-gate bp += sizeof(u_int32_t); 808*7c478bd9Sstevel@tonic-gate } else { 809*7c478bd9Sstevel@tonic-gate memcpy(bp, &newitem->size, sizeof(newitem->size)); 810*7c478bd9Sstevel@tonic-gate bp += sizeof(newitem->size); 811*7c478bd9Sstevel@tonic-gate memcpy(bp, newitem->data, newitem->size); 812*7c478bd9Sstevel@tonic-gate bp += newitem->size; 813*7c478bd9Sstevel@tonic-gate } 814*7c478bd9Sstevel@tonic-gate memcpy(bp, &makedup, sizeof(makedup)); 815*7c478bd9Sstevel@tonic-gate bp += sizeof(makedup); 816*7c478bd9Sstevel@tonic-gate #ifdef DIAGNOSTIC 817*7c478bd9Sstevel@tonic-gate if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size) 818*7c478bd9Sstevel@tonic-gate fprintf(stderr, "Error in log record length"); 819*7c478bd9Sstevel@tonic-gate #endif 820*7c478bd9Sstevel@tonic-gate ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags); 821*7c478bd9Sstevel@tonic-gate if (txnid != NULL) 822*7c478bd9Sstevel@tonic-gate txnid->last_lsn = *ret_lsnp; 823*7c478bd9Sstevel@tonic-gate __os_free(logrec.data, 0); 824*7c478bd9Sstevel@tonic-gate return (ret); 825*7c478bd9Sstevel@tonic-gate } 826*7c478bd9Sstevel@tonic-gate 827*7c478bd9Sstevel@tonic-gate /* 828*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_replace_print 829*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); 830*7c478bd9Sstevel@tonic-gate */ 831*7c478bd9Sstevel@tonic-gate int 832*7c478bd9Sstevel@tonic-gate __ham_replace_print(notused1, dbtp, lsnp, notused2, notused3) 833*7c478bd9Sstevel@tonic-gate DB_LOG *notused1; 834*7c478bd9Sstevel@tonic-gate DBT *dbtp; 835*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp; 836*7c478bd9Sstevel@tonic-gate int notused2; 837*7c478bd9Sstevel@tonic-gate void *notused3; 838*7c478bd9Sstevel@tonic-gate { 839*7c478bd9Sstevel@tonic-gate __ham_replace_args *argp; 840*7c478bd9Sstevel@tonic-gate u_int32_t i; 841*7c478bd9Sstevel@tonic-gate u_int ch; 842*7c478bd9Sstevel@tonic-gate int ret; 843*7c478bd9Sstevel@tonic-gate 844*7c478bd9Sstevel@tonic-gate i = 0; 845*7c478bd9Sstevel@tonic-gate ch = 0; 846*7c478bd9Sstevel@tonic-gate notused1 = NULL; 847*7c478bd9Sstevel@tonic-gate notused2 = 0; 848*7c478bd9Sstevel@tonic-gate notused3 = NULL; 849*7c478bd9Sstevel@tonic-gate 850*7c478bd9Sstevel@tonic-gate if ((ret = __ham_replace_read(dbtp->data, &argp)) != 0) 851*7c478bd9Sstevel@tonic-gate return (ret); 852*7c478bd9Sstevel@tonic-gate printf("[%lu][%lu]ham_replace: rec: %lu txnid %lx prevlsn [%lu][%lu]\n", 853*7c478bd9Sstevel@tonic-gate (u_long)lsnp->file, 854*7c478bd9Sstevel@tonic-gate (u_long)lsnp->offset, 855*7c478bd9Sstevel@tonic-gate (u_long)argp->type, 856*7c478bd9Sstevel@tonic-gate (u_long)argp->txnid->txnid, 857*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.file, 858*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.offset); 859*7c478bd9Sstevel@tonic-gate printf("\tfileid: %lu\n", (u_long)argp->fileid); 860*7c478bd9Sstevel@tonic-gate printf("\tpgno: %lu\n", (u_long)argp->pgno); 861*7c478bd9Sstevel@tonic-gate printf("\tndx: %lu\n", (u_long)argp->ndx); 862*7c478bd9Sstevel@tonic-gate printf("\tpagelsn: [%lu][%lu]\n", 863*7c478bd9Sstevel@tonic-gate (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset); 864*7c478bd9Sstevel@tonic-gate printf("\toff: %ld\n", (long)argp->off); 865*7c478bd9Sstevel@tonic-gate printf("\tolditem: "); 866*7c478bd9Sstevel@tonic-gate for (i = 0; i < argp->olditem.size; i++) { 867*7c478bd9Sstevel@tonic-gate ch = ((u_int8_t *)argp->olditem.data)[i]; 868*7c478bd9Sstevel@tonic-gate if (isprint(ch) || ch == 0xa) 869*7c478bd9Sstevel@tonic-gate putchar(ch); 870*7c478bd9Sstevel@tonic-gate else 871*7c478bd9Sstevel@tonic-gate printf("%#x ", ch); 872*7c478bd9Sstevel@tonic-gate } 873*7c478bd9Sstevel@tonic-gate printf("\n"); 874*7c478bd9Sstevel@tonic-gate printf("\tnewitem: "); 875*7c478bd9Sstevel@tonic-gate for (i = 0; i < argp->newitem.size; i++) { 876*7c478bd9Sstevel@tonic-gate ch = ((u_int8_t *)argp->newitem.data)[i]; 877*7c478bd9Sstevel@tonic-gate if (isprint(ch) || ch == 0xa) 878*7c478bd9Sstevel@tonic-gate putchar(ch); 879*7c478bd9Sstevel@tonic-gate else 880*7c478bd9Sstevel@tonic-gate printf("%#x ", ch); 881*7c478bd9Sstevel@tonic-gate } 882*7c478bd9Sstevel@tonic-gate printf("\n"); 883*7c478bd9Sstevel@tonic-gate printf("\tmakedup: %lu\n", (u_long)argp->makedup); 884*7c478bd9Sstevel@tonic-gate printf("\n"); 885*7c478bd9Sstevel@tonic-gate __os_free(argp, 0); 886*7c478bd9Sstevel@tonic-gate return (0); 887*7c478bd9Sstevel@tonic-gate } 888*7c478bd9Sstevel@tonic-gate 889*7c478bd9Sstevel@tonic-gate /* 890*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_replace_read __P((void *, __ham_replace_args **)); 891*7c478bd9Sstevel@tonic-gate */ 892*7c478bd9Sstevel@tonic-gate int 893*7c478bd9Sstevel@tonic-gate __ham_replace_read(recbuf, argpp) 894*7c478bd9Sstevel@tonic-gate void *recbuf; 895*7c478bd9Sstevel@tonic-gate __ham_replace_args **argpp; 896*7c478bd9Sstevel@tonic-gate { 897*7c478bd9Sstevel@tonic-gate __ham_replace_args *argp; 898*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 899*7c478bd9Sstevel@tonic-gate int ret; 900*7c478bd9Sstevel@tonic-gate 901*7c478bd9Sstevel@tonic-gate ret = __os_malloc(sizeof(__ham_replace_args) + 902*7c478bd9Sstevel@tonic-gate sizeof(DB_TXN), NULL, &argp); 903*7c478bd9Sstevel@tonic-gate if (ret != 0) 904*7c478bd9Sstevel@tonic-gate return (ret); 905*7c478bd9Sstevel@tonic-gate argp->txnid = (DB_TXN *)&argp[1]; 906*7c478bd9Sstevel@tonic-gate bp = recbuf; 907*7c478bd9Sstevel@tonic-gate memcpy(&argp->type, bp, sizeof(argp->type)); 908*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->type); 909*7c478bd9Sstevel@tonic-gate memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid)); 910*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->txnid->txnid); 911*7c478bd9Sstevel@tonic-gate memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN)); 912*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 913*7c478bd9Sstevel@tonic-gate memcpy(&argp->fileid, bp, sizeof(argp->fileid)); 914*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->fileid); 915*7c478bd9Sstevel@tonic-gate memcpy(&argp->pgno, bp, sizeof(argp->pgno)); 916*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->pgno); 917*7c478bd9Sstevel@tonic-gate memcpy(&argp->ndx, bp, sizeof(argp->ndx)); 918*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->ndx); 919*7c478bd9Sstevel@tonic-gate memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn)); 920*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->pagelsn); 921*7c478bd9Sstevel@tonic-gate memcpy(&argp->off, bp, sizeof(argp->off)); 922*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->off); 923*7c478bd9Sstevel@tonic-gate memcpy(&argp->olditem.size, bp, sizeof(u_int32_t)); 924*7c478bd9Sstevel@tonic-gate bp += sizeof(u_int32_t); 925*7c478bd9Sstevel@tonic-gate argp->olditem.data = bp; 926*7c478bd9Sstevel@tonic-gate bp += argp->olditem.size; 927*7c478bd9Sstevel@tonic-gate memcpy(&argp->newitem.size, bp, sizeof(u_int32_t)); 928*7c478bd9Sstevel@tonic-gate bp += sizeof(u_int32_t); 929*7c478bd9Sstevel@tonic-gate argp->newitem.data = bp; 930*7c478bd9Sstevel@tonic-gate bp += argp->newitem.size; 931*7c478bd9Sstevel@tonic-gate memcpy(&argp->makedup, bp, sizeof(argp->makedup)); 932*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->makedup); 933*7c478bd9Sstevel@tonic-gate *argpp = argp; 934*7c478bd9Sstevel@tonic-gate return (0); 935*7c478bd9Sstevel@tonic-gate } 936*7c478bd9Sstevel@tonic-gate 937*7c478bd9Sstevel@tonic-gate /* 938*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_newpgno_log 939*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, 940*7c478bd9Sstevel@tonic-gate * PUBLIC: u_int32_t, u_int32_t, db_pgno_t, db_pgno_t, 941*7c478bd9Sstevel@tonic-gate * PUBLIC: u_int32_t, db_pgno_t, u_int32_t, DB_LSN *, 942*7c478bd9Sstevel@tonic-gate * PUBLIC: DB_LSN *)); 943*7c478bd9Sstevel@tonic-gate */ 944*7c478bd9Sstevel@tonic-gate int __ham_newpgno_log(logp, txnid, ret_lsnp, flags, 945*7c478bd9Sstevel@tonic-gate opcode, fileid, pgno, free_pgno, old_type, old_pgno, 946*7c478bd9Sstevel@tonic-gate new_type, pagelsn, metalsn) 947*7c478bd9Sstevel@tonic-gate DB_LOG *logp; 948*7c478bd9Sstevel@tonic-gate DB_TXN *txnid; 949*7c478bd9Sstevel@tonic-gate DB_LSN *ret_lsnp; 950*7c478bd9Sstevel@tonic-gate u_int32_t flags; 951*7c478bd9Sstevel@tonic-gate u_int32_t opcode; 952*7c478bd9Sstevel@tonic-gate u_int32_t fileid; 953*7c478bd9Sstevel@tonic-gate db_pgno_t pgno; 954*7c478bd9Sstevel@tonic-gate db_pgno_t free_pgno; 955*7c478bd9Sstevel@tonic-gate u_int32_t old_type; 956*7c478bd9Sstevel@tonic-gate db_pgno_t old_pgno; 957*7c478bd9Sstevel@tonic-gate u_int32_t new_type; 958*7c478bd9Sstevel@tonic-gate DB_LSN * pagelsn; 959*7c478bd9Sstevel@tonic-gate DB_LSN * metalsn; 960*7c478bd9Sstevel@tonic-gate { 961*7c478bd9Sstevel@tonic-gate DBT logrec; 962*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp, null_lsn; 963*7c478bd9Sstevel@tonic-gate u_int32_t rectype, txn_num; 964*7c478bd9Sstevel@tonic-gate int ret; 965*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 966*7c478bd9Sstevel@tonic-gate 967*7c478bd9Sstevel@tonic-gate rectype = DB_ham_newpgno; 968*7c478bd9Sstevel@tonic-gate txn_num = txnid == NULL ? 0 : txnid->txnid; 969*7c478bd9Sstevel@tonic-gate if (txnid == NULL) { 970*7c478bd9Sstevel@tonic-gate ZERO_LSN(null_lsn); 971*7c478bd9Sstevel@tonic-gate lsnp = &null_lsn; 972*7c478bd9Sstevel@tonic-gate } else 973*7c478bd9Sstevel@tonic-gate lsnp = &txnid->last_lsn; 974*7c478bd9Sstevel@tonic-gate logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN) 975*7c478bd9Sstevel@tonic-gate + sizeof(opcode) 976*7c478bd9Sstevel@tonic-gate + sizeof(fileid) 977*7c478bd9Sstevel@tonic-gate + sizeof(pgno) 978*7c478bd9Sstevel@tonic-gate + sizeof(free_pgno) 979*7c478bd9Sstevel@tonic-gate + sizeof(old_type) 980*7c478bd9Sstevel@tonic-gate + sizeof(old_pgno) 981*7c478bd9Sstevel@tonic-gate + sizeof(new_type) 982*7c478bd9Sstevel@tonic-gate + sizeof(*pagelsn) 983*7c478bd9Sstevel@tonic-gate + sizeof(*metalsn); 984*7c478bd9Sstevel@tonic-gate if ((ret = __os_malloc(logrec.size, NULL, &logrec.data)) != 0) 985*7c478bd9Sstevel@tonic-gate return (ret); 986*7c478bd9Sstevel@tonic-gate 987*7c478bd9Sstevel@tonic-gate bp = logrec.data; 988*7c478bd9Sstevel@tonic-gate memcpy(bp, &rectype, sizeof(rectype)); 989*7c478bd9Sstevel@tonic-gate bp += sizeof(rectype); 990*7c478bd9Sstevel@tonic-gate memcpy(bp, &txn_num, sizeof(txn_num)); 991*7c478bd9Sstevel@tonic-gate bp += sizeof(txn_num); 992*7c478bd9Sstevel@tonic-gate memcpy(bp, lsnp, sizeof(DB_LSN)); 993*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 994*7c478bd9Sstevel@tonic-gate memcpy(bp, &opcode, sizeof(opcode)); 995*7c478bd9Sstevel@tonic-gate bp += sizeof(opcode); 996*7c478bd9Sstevel@tonic-gate memcpy(bp, &fileid, sizeof(fileid)); 997*7c478bd9Sstevel@tonic-gate bp += sizeof(fileid); 998*7c478bd9Sstevel@tonic-gate memcpy(bp, &pgno, sizeof(pgno)); 999*7c478bd9Sstevel@tonic-gate bp += sizeof(pgno); 1000*7c478bd9Sstevel@tonic-gate memcpy(bp, &free_pgno, sizeof(free_pgno)); 1001*7c478bd9Sstevel@tonic-gate bp += sizeof(free_pgno); 1002*7c478bd9Sstevel@tonic-gate memcpy(bp, &old_type, sizeof(old_type)); 1003*7c478bd9Sstevel@tonic-gate bp += sizeof(old_type); 1004*7c478bd9Sstevel@tonic-gate memcpy(bp, &old_pgno, sizeof(old_pgno)); 1005*7c478bd9Sstevel@tonic-gate bp += sizeof(old_pgno); 1006*7c478bd9Sstevel@tonic-gate memcpy(bp, &new_type, sizeof(new_type)); 1007*7c478bd9Sstevel@tonic-gate bp += sizeof(new_type); 1008*7c478bd9Sstevel@tonic-gate if (pagelsn != NULL) 1009*7c478bd9Sstevel@tonic-gate memcpy(bp, pagelsn, sizeof(*pagelsn)); 1010*7c478bd9Sstevel@tonic-gate else 1011*7c478bd9Sstevel@tonic-gate memset(bp, 0, sizeof(*pagelsn)); 1012*7c478bd9Sstevel@tonic-gate bp += sizeof(*pagelsn); 1013*7c478bd9Sstevel@tonic-gate if (metalsn != NULL) 1014*7c478bd9Sstevel@tonic-gate memcpy(bp, metalsn, sizeof(*metalsn)); 1015*7c478bd9Sstevel@tonic-gate else 1016*7c478bd9Sstevel@tonic-gate memset(bp, 0, sizeof(*metalsn)); 1017*7c478bd9Sstevel@tonic-gate bp += sizeof(*metalsn); 1018*7c478bd9Sstevel@tonic-gate #ifdef DIAGNOSTIC 1019*7c478bd9Sstevel@tonic-gate if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size) 1020*7c478bd9Sstevel@tonic-gate fprintf(stderr, "Error in log record length"); 1021*7c478bd9Sstevel@tonic-gate #endif 1022*7c478bd9Sstevel@tonic-gate ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags); 1023*7c478bd9Sstevel@tonic-gate if (txnid != NULL) 1024*7c478bd9Sstevel@tonic-gate txnid->last_lsn = *ret_lsnp; 1025*7c478bd9Sstevel@tonic-gate __os_free(logrec.data, 0); 1026*7c478bd9Sstevel@tonic-gate return (ret); 1027*7c478bd9Sstevel@tonic-gate } 1028*7c478bd9Sstevel@tonic-gate 1029*7c478bd9Sstevel@tonic-gate /* 1030*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_newpgno_print 1031*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); 1032*7c478bd9Sstevel@tonic-gate */ 1033*7c478bd9Sstevel@tonic-gate int 1034*7c478bd9Sstevel@tonic-gate __ham_newpgno_print(notused1, dbtp, lsnp, notused2, notused3) 1035*7c478bd9Sstevel@tonic-gate DB_LOG *notused1; 1036*7c478bd9Sstevel@tonic-gate DBT *dbtp; 1037*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp; 1038*7c478bd9Sstevel@tonic-gate int notused2; 1039*7c478bd9Sstevel@tonic-gate void *notused3; 1040*7c478bd9Sstevel@tonic-gate { 1041*7c478bd9Sstevel@tonic-gate __ham_newpgno_args *argp; 1042*7c478bd9Sstevel@tonic-gate u_int32_t i; 1043*7c478bd9Sstevel@tonic-gate u_int ch; 1044*7c478bd9Sstevel@tonic-gate int ret; 1045*7c478bd9Sstevel@tonic-gate 1046*7c478bd9Sstevel@tonic-gate i = 0; 1047*7c478bd9Sstevel@tonic-gate ch = 0; 1048*7c478bd9Sstevel@tonic-gate notused1 = NULL; 1049*7c478bd9Sstevel@tonic-gate notused2 = 0; 1050*7c478bd9Sstevel@tonic-gate notused3 = NULL; 1051*7c478bd9Sstevel@tonic-gate 1052*7c478bd9Sstevel@tonic-gate if ((ret = __ham_newpgno_read(dbtp->data, &argp)) != 0) 1053*7c478bd9Sstevel@tonic-gate return (ret); 1054*7c478bd9Sstevel@tonic-gate printf("[%lu][%lu]ham_newpgno: rec: %lu txnid %lx prevlsn [%lu][%lu]\n", 1055*7c478bd9Sstevel@tonic-gate (u_long)lsnp->file, 1056*7c478bd9Sstevel@tonic-gate (u_long)lsnp->offset, 1057*7c478bd9Sstevel@tonic-gate (u_long)argp->type, 1058*7c478bd9Sstevel@tonic-gate (u_long)argp->txnid->txnid, 1059*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.file, 1060*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.offset); 1061*7c478bd9Sstevel@tonic-gate printf("\topcode: %lu\n", (u_long)argp->opcode); 1062*7c478bd9Sstevel@tonic-gate printf("\tfileid: %lu\n", (u_long)argp->fileid); 1063*7c478bd9Sstevel@tonic-gate printf("\tpgno: %lu\n", (u_long)argp->pgno); 1064*7c478bd9Sstevel@tonic-gate printf("\tfree_pgno: %lu\n", (u_long)argp->free_pgno); 1065*7c478bd9Sstevel@tonic-gate printf("\told_type: %lu\n", (u_long)argp->old_type); 1066*7c478bd9Sstevel@tonic-gate printf("\told_pgno: %lu\n", (u_long)argp->old_pgno); 1067*7c478bd9Sstevel@tonic-gate printf("\tnew_type: %lu\n", (u_long)argp->new_type); 1068*7c478bd9Sstevel@tonic-gate printf("\tpagelsn: [%lu][%lu]\n", 1069*7c478bd9Sstevel@tonic-gate (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset); 1070*7c478bd9Sstevel@tonic-gate printf("\tmetalsn: [%lu][%lu]\n", 1071*7c478bd9Sstevel@tonic-gate (u_long)argp->metalsn.file, (u_long)argp->metalsn.offset); 1072*7c478bd9Sstevel@tonic-gate printf("\n"); 1073*7c478bd9Sstevel@tonic-gate __os_free(argp, 0); 1074*7c478bd9Sstevel@tonic-gate return (0); 1075*7c478bd9Sstevel@tonic-gate } 1076*7c478bd9Sstevel@tonic-gate 1077*7c478bd9Sstevel@tonic-gate /* 1078*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_newpgno_read __P((void *, __ham_newpgno_args **)); 1079*7c478bd9Sstevel@tonic-gate */ 1080*7c478bd9Sstevel@tonic-gate int 1081*7c478bd9Sstevel@tonic-gate __ham_newpgno_read(recbuf, argpp) 1082*7c478bd9Sstevel@tonic-gate void *recbuf; 1083*7c478bd9Sstevel@tonic-gate __ham_newpgno_args **argpp; 1084*7c478bd9Sstevel@tonic-gate { 1085*7c478bd9Sstevel@tonic-gate __ham_newpgno_args *argp; 1086*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 1087*7c478bd9Sstevel@tonic-gate int ret; 1088*7c478bd9Sstevel@tonic-gate 1089*7c478bd9Sstevel@tonic-gate ret = __os_malloc(sizeof(__ham_newpgno_args) + 1090*7c478bd9Sstevel@tonic-gate sizeof(DB_TXN), NULL, &argp); 1091*7c478bd9Sstevel@tonic-gate if (ret != 0) 1092*7c478bd9Sstevel@tonic-gate return (ret); 1093*7c478bd9Sstevel@tonic-gate argp->txnid = (DB_TXN *)&argp[1]; 1094*7c478bd9Sstevel@tonic-gate bp = recbuf; 1095*7c478bd9Sstevel@tonic-gate memcpy(&argp->type, bp, sizeof(argp->type)); 1096*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->type); 1097*7c478bd9Sstevel@tonic-gate memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid)); 1098*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->txnid->txnid); 1099*7c478bd9Sstevel@tonic-gate memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN)); 1100*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 1101*7c478bd9Sstevel@tonic-gate memcpy(&argp->opcode, bp, sizeof(argp->opcode)); 1102*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->opcode); 1103*7c478bd9Sstevel@tonic-gate memcpy(&argp->fileid, bp, sizeof(argp->fileid)); 1104*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->fileid); 1105*7c478bd9Sstevel@tonic-gate memcpy(&argp->pgno, bp, sizeof(argp->pgno)); 1106*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->pgno); 1107*7c478bd9Sstevel@tonic-gate memcpy(&argp->free_pgno, bp, sizeof(argp->free_pgno)); 1108*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->free_pgno); 1109*7c478bd9Sstevel@tonic-gate memcpy(&argp->old_type, bp, sizeof(argp->old_type)); 1110*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->old_type); 1111*7c478bd9Sstevel@tonic-gate memcpy(&argp->old_pgno, bp, sizeof(argp->old_pgno)); 1112*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->old_pgno); 1113*7c478bd9Sstevel@tonic-gate memcpy(&argp->new_type, bp, sizeof(argp->new_type)); 1114*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->new_type); 1115*7c478bd9Sstevel@tonic-gate memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn)); 1116*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->pagelsn); 1117*7c478bd9Sstevel@tonic-gate memcpy(&argp->metalsn, bp, sizeof(argp->metalsn)); 1118*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->metalsn); 1119*7c478bd9Sstevel@tonic-gate *argpp = argp; 1120*7c478bd9Sstevel@tonic-gate return (0); 1121*7c478bd9Sstevel@tonic-gate } 1122*7c478bd9Sstevel@tonic-gate 1123*7c478bd9Sstevel@tonic-gate /* 1124*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_ovfl_log 1125*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, 1126*7c478bd9Sstevel@tonic-gate * PUBLIC: u_int32_t, db_pgno_t, u_int32_t, db_pgno_t, 1127*7c478bd9Sstevel@tonic-gate * PUBLIC: u_int32_t, DB_LSN *)); 1128*7c478bd9Sstevel@tonic-gate */ 1129*7c478bd9Sstevel@tonic-gate int __ham_ovfl_log(logp, txnid, ret_lsnp, flags, 1130*7c478bd9Sstevel@tonic-gate fileid, start_pgno, npages, free_pgno, ovflpoint, metalsn) 1131*7c478bd9Sstevel@tonic-gate DB_LOG *logp; 1132*7c478bd9Sstevel@tonic-gate DB_TXN *txnid; 1133*7c478bd9Sstevel@tonic-gate DB_LSN *ret_lsnp; 1134*7c478bd9Sstevel@tonic-gate u_int32_t flags; 1135*7c478bd9Sstevel@tonic-gate u_int32_t fileid; 1136*7c478bd9Sstevel@tonic-gate db_pgno_t start_pgno; 1137*7c478bd9Sstevel@tonic-gate u_int32_t npages; 1138*7c478bd9Sstevel@tonic-gate db_pgno_t free_pgno; 1139*7c478bd9Sstevel@tonic-gate u_int32_t ovflpoint; 1140*7c478bd9Sstevel@tonic-gate DB_LSN * metalsn; 1141*7c478bd9Sstevel@tonic-gate { 1142*7c478bd9Sstevel@tonic-gate DBT logrec; 1143*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp, null_lsn; 1144*7c478bd9Sstevel@tonic-gate u_int32_t rectype, txn_num; 1145*7c478bd9Sstevel@tonic-gate int ret; 1146*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 1147*7c478bd9Sstevel@tonic-gate 1148*7c478bd9Sstevel@tonic-gate rectype = DB_ham_ovfl; 1149*7c478bd9Sstevel@tonic-gate txn_num = txnid == NULL ? 0 : txnid->txnid; 1150*7c478bd9Sstevel@tonic-gate if (txnid == NULL) { 1151*7c478bd9Sstevel@tonic-gate ZERO_LSN(null_lsn); 1152*7c478bd9Sstevel@tonic-gate lsnp = &null_lsn; 1153*7c478bd9Sstevel@tonic-gate } else 1154*7c478bd9Sstevel@tonic-gate lsnp = &txnid->last_lsn; 1155*7c478bd9Sstevel@tonic-gate logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN) 1156*7c478bd9Sstevel@tonic-gate + sizeof(fileid) 1157*7c478bd9Sstevel@tonic-gate + sizeof(start_pgno) 1158*7c478bd9Sstevel@tonic-gate + sizeof(npages) 1159*7c478bd9Sstevel@tonic-gate + sizeof(free_pgno) 1160*7c478bd9Sstevel@tonic-gate + sizeof(ovflpoint) 1161*7c478bd9Sstevel@tonic-gate + sizeof(*metalsn); 1162*7c478bd9Sstevel@tonic-gate if ((ret = __os_malloc(logrec.size, NULL, &logrec.data)) != 0) 1163*7c478bd9Sstevel@tonic-gate return (ret); 1164*7c478bd9Sstevel@tonic-gate 1165*7c478bd9Sstevel@tonic-gate bp = logrec.data; 1166*7c478bd9Sstevel@tonic-gate memcpy(bp, &rectype, sizeof(rectype)); 1167*7c478bd9Sstevel@tonic-gate bp += sizeof(rectype); 1168*7c478bd9Sstevel@tonic-gate memcpy(bp, &txn_num, sizeof(txn_num)); 1169*7c478bd9Sstevel@tonic-gate bp += sizeof(txn_num); 1170*7c478bd9Sstevel@tonic-gate memcpy(bp, lsnp, sizeof(DB_LSN)); 1171*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 1172*7c478bd9Sstevel@tonic-gate memcpy(bp, &fileid, sizeof(fileid)); 1173*7c478bd9Sstevel@tonic-gate bp += sizeof(fileid); 1174*7c478bd9Sstevel@tonic-gate memcpy(bp, &start_pgno, sizeof(start_pgno)); 1175*7c478bd9Sstevel@tonic-gate bp += sizeof(start_pgno); 1176*7c478bd9Sstevel@tonic-gate memcpy(bp, &npages, sizeof(npages)); 1177*7c478bd9Sstevel@tonic-gate bp += sizeof(npages); 1178*7c478bd9Sstevel@tonic-gate memcpy(bp, &free_pgno, sizeof(free_pgno)); 1179*7c478bd9Sstevel@tonic-gate bp += sizeof(free_pgno); 1180*7c478bd9Sstevel@tonic-gate memcpy(bp, &ovflpoint, sizeof(ovflpoint)); 1181*7c478bd9Sstevel@tonic-gate bp += sizeof(ovflpoint); 1182*7c478bd9Sstevel@tonic-gate if (metalsn != NULL) 1183*7c478bd9Sstevel@tonic-gate memcpy(bp, metalsn, sizeof(*metalsn)); 1184*7c478bd9Sstevel@tonic-gate else 1185*7c478bd9Sstevel@tonic-gate memset(bp, 0, sizeof(*metalsn)); 1186*7c478bd9Sstevel@tonic-gate bp += sizeof(*metalsn); 1187*7c478bd9Sstevel@tonic-gate #ifdef DIAGNOSTIC 1188*7c478bd9Sstevel@tonic-gate if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size) 1189*7c478bd9Sstevel@tonic-gate fprintf(stderr, "Error in log record length"); 1190*7c478bd9Sstevel@tonic-gate #endif 1191*7c478bd9Sstevel@tonic-gate ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags); 1192*7c478bd9Sstevel@tonic-gate if (txnid != NULL) 1193*7c478bd9Sstevel@tonic-gate txnid->last_lsn = *ret_lsnp; 1194*7c478bd9Sstevel@tonic-gate __os_free(logrec.data, 0); 1195*7c478bd9Sstevel@tonic-gate return (ret); 1196*7c478bd9Sstevel@tonic-gate } 1197*7c478bd9Sstevel@tonic-gate 1198*7c478bd9Sstevel@tonic-gate /* 1199*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_ovfl_print 1200*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); 1201*7c478bd9Sstevel@tonic-gate */ 1202*7c478bd9Sstevel@tonic-gate int 1203*7c478bd9Sstevel@tonic-gate __ham_ovfl_print(notused1, dbtp, lsnp, notused2, notused3) 1204*7c478bd9Sstevel@tonic-gate DB_LOG *notused1; 1205*7c478bd9Sstevel@tonic-gate DBT *dbtp; 1206*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp; 1207*7c478bd9Sstevel@tonic-gate int notused2; 1208*7c478bd9Sstevel@tonic-gate void *notused3; 1209*7c478bd9Sstevel@tonic-gate { 1210*7c478bd9Sstevel@tonic-gate __ham_ovfl_args *argp; 1211*7c478bd9Sstevel@tonic-gate u_int32_t i; 1212*7c478bd9Sstevel@tonic-gate u_int ch; 1213*7c478bd9Sstevel@tonic-gate int ret; 1214*7c478bd9Sstevel@tonic-gate 1215*7c478bd9Sstevel@tonic-gate i = 0; 1216*7c478bd9Sstevel@tonic-gate ch = 0; 1217*7c478bd9Sstevel@tonic-gate notused1 = NULL; 1218*7c478bd9Sstevel@tonic-gate notused2 = 0; 1219*7c478bd9Sstevel@tonic-gate notused3 = NULL; 1220*7c478bd9Sstevel@tonic-gate 1221*7c478bd9Sstevel@tonic-gate if ((ret = __ham_ovfl_read(dbtp->data, &argp)) != 0) 1222*7c478bd9Sstevel@tonic-gate return (ret); 1223*7c478bd9Sstevel@tonic-gate printf("[%lu][%lu]ham_ovfl: rec: %lu txnid %lx prevlsn [%lu][%lu]\n", 1224*7c478bd9Sstevel@tonic-gate (u_long)lsnp->file, 1225*7c478bd9Sstevel@tonic-gate (u_long)lsnp->offset, 1226*7c478bd9Sstevel@tonic-gate (u_long)argp->type, 1227*7c478bd9Sstevel@tonic-gate (u_long)argp->txnid->txnid, 1228*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.file, 1229*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.offset); 1230*7c478bd9Sstevel@tonic-gate printf("\tfileid: %lu\n", (u_long)argp->fileid); 1231*7c478bd9Sstevel@tonic-gate printf("\tstart_pgno: %lu\n", (u_long)argp->start_pgno); 1232*7c478bd9Sstevel@tonic-gate printf("\tnpages: %lu\n", (u_long)argp->npages); 1233*7c478bd9Sstevel@tonic-gate printf("\tfree_pgno: %lu\n", (u_long)argp->free_pgno); 1234*7c478bd9Sstevel@tonic-gate printf("\tovflpoint: %lu\n", (u_long)argp->ovflpoint); 1235*7c478bd9Sstevel@tonic-gate printf("\tmetalsn: [%lu][%lu]\n", 1236*7c478bd9Sstevel@tonic-gate (u_long)argp->metalsn.file, (u_long)argp->metalsn.offset); 1237*7c478bd9Sstevel@tonic-gate printf("\n"); 1238*7c478bd9Sstevel@tonic-gate __os_free(argp, 0); 1239*7c478bd9Sstevel@tonic-gate return (0); 1240*7c478bd9Sstevel@tonic-gate } 1241*7c478bd9Sstevel@tonic-gate 1242*7c478bd9Sstevel@tonic-gate /* 1243*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_ovfl_read __P((void *, __ham_ovfl_args **)); 1244*7c478bd9Sstevel@tonic-gate */ 1245*7c478bd9Sstevel@tonic-gate int 1246*7c478bd9Sstevel@tonic-gate __ham_ovfl_read(recbuf, argpp) 1247*7c478bd9Sstevel@tonic-gate void *recbuf; 1248*7c478bd9Sstevel@tonic-gate __ham_ovfl_args **argpp; 1249*7c478bd9Sstevel@tonic-gate { 1250*7c478bd9Sstevel@tonic-gate __ham_ovfl_args *argp; 1251*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 1252*7c478bd9Sstevel@tonic-gate int ret; 1253*7c478bd9Sstevel@tonic-gate 1254*7c478bd9Sstevel@tonic-gate ret = __os_malloc(sizeof(__ham_ovfl_args) + 1255*7c478bd9Sstevel@tonic-gate sizeof(DB_TXN), NULL, &argp); 1256*7c478bd9Sstevel@tonic-gate if (ret != 0) 1257*7c478bd9Sstevel@tonic-gate return (ret); 1258*7c478bd9Sstevel@tonic-gate argp->txnid = (DB_TXN *)&argp[1]; 1259*7c478bd9Sstevel@tonic-gate bp = recbuf; 1260*7c478bd9Sstevel@tonic-gate memcpy(&argp->type, bp, sizeof(argp->type)); 1261*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->type); 1262*7c478bd9Sstevel@tonic-gate memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid)); 1263*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->txnid->txnid); 1264*7c478bd9Sstevel@tonic-gate memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN)); 1265*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 1266*7c478bd9Sstevel@tonic-gate memcpy(&argp->fileid, bp, sizeof(argp->fileid)); 1267*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->fileid); 1268*7c478bd9Sstevel@tonic-gate memcpy(&argp->start_pgno, bp, sizeof(argp->start_pgno)); 1269*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->start_pgno); 1270*7c478bd9Sstevel@tonic-gate memcpy(&argp->npages, bp, sizeof(argp->npages)); 1271*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->npages); 1272*7c478bd9Sstevel@tonic-gate memcpy(&argp->free_pgno, bp, sizeof(argp->free_pgno)); 1273*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->free_pgno); 1274*7c478bd9Sstevel@tonic-gate memcpy(&argp->ovflpoint, bp, sizeof(argp->ovflpoint)); 1275*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->ovflpoint); 1276*7c478bd9Sstevel@tonic-gate memcpy(&argp->metalsn, bp, sizeof(argp->metalsn)); 1277*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->metalsn); 1278*7c478bd9Sstevel@tonic-gate *argpp = argp; 1279*7c478bd9Sstevel@tonic-gate return (0); 1280*7c478bd9Sstevel@tonic-gate } 1281*7c478bd9Sstevel@tonic-gate 1282*7c478bd9Sstevel@tonic-gate /* 1283*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_copypage_log 1284*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t, 1285*7c478bd9Sstevel@tonic-gate * PUBLIC: u_int32_t, db_pgno_t, DB_LSN *, db_pgno_t, 1286*7c478bd9Sstevel@tonic-gate * PUBLIC: DB_LSN *, db_pgno_t, DB_LSN *, const DBT *)); 1287*7c478bd9Sstevel@tonic-gate */ 1288*7c478bd9Sstevel@tonic-gate int __ham_copypage_log(logp, txnid, ret_lsnp, flags, 1289*7c478bd9Sstevel@tonic-gate fileid, pgno, pagelsn, next_pgno, nextlsn, nnext_pgno, 1290*7c478bd9Sstevel@tonic-gate nnextlsn, page) 1291*7c478bd9Sstevel@tonic-gate DB_LOG *logp; 1292*7c478bd9Sstevel@tonic-gate DB_TXN *txnid; 1293*7c478bd9Sstevel@tonic-gate DB_LSN *ret_lsnp; 1294*7c478bd9Sstevel@tonic-gate u_int32_t flags; 1295*7c478bd9Sstevel@tonic-gate u_int32_t fileid; 1296*7c478bd9Sstevel@tonic-gate db_pgno_t pgno; 1297*7c478bd9Sstevel@tonic-gate DB_LSN * pagelsn; 1298*7c478bd9Sstevel@tonic-gate db_pgno_t next_pgno; 1299*7c478bd9Sstevel@tonic-gate DB_LSN * nextlsn; 1300*7c478bd9Sstevel@tonic-gate db_pgno_t nnext_pgno; 1301*7c478bd9Sstevel@tonic-gate DB_LSN * nnextlsn; 1302*7c478bd9Sstevel@tonic-gate const DBT *page; 1303*7c478bd9Sstevel@tonic-gate { 1304*7c478bd9Sstevel@tonic-gate DBT logrec; 1305*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp, null_lsn; 1306*7c478bd9Sstevel@tonic-gate u_int32_t zero; 1307*7c478bd9Sstevel@tonic-gate u_int32_t rectype, txn_num; 1308*7c478bd9Sstevel@tonic-gate int ret; 1309*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 1310*7c478bd9Sstevel@tonic-gate 1311*7c478bd9Sstevel@tonic-gate rectype = DB_ham_copypage; 1312*7c478bd9Sstevel@tonic-gate txn_num = txnid == NULL ? 0 : txnid->txnid; 1313*7c478bd9Sstevel@tonic-gate if (txnid == NULL) { 1314*7c478bd9Sstevel@tonic-gate ZERO_LSN(null_lsn); 1315*7c478bd9Sstevel@tonic-gate lsnp = &null_lsn; 1316*7c478bd9Sstevel@tonic-gate } else 1317*7c478bd9Sstevel@tonic-gate lsnp = &txnid->last_lsn; 1318*7c478bd9Sstevel@tonic-gate logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN) 1319*7c478bd9Sstevel@tonic-gate + sizeof(fileid) 1320*7c478bd9Sstevel@tonic-gate + sizeof(pgno) 1321*7c478bd9Sstevel@tonic-gate + sizeof(*pagelsn) 1322*7c478bd9Sstevel@tonic-gate + sizeof(next_pgno) 1323*7c478bd9Sstevel@tonic-gate + sizeof(*nextlsn) 1324*7c478bd9Sstevel@tonic-gate + sizeof(nnext_pgno) 1325*7c478bd9Sstevel@tonic-gate + sizeof(*nnextlsn) 1326*7c478bd9Sstevel@tonic-gate + sizeof(u_int32_t) + (page == NULL ? 0 : page->size); 1327*7c478bd9Sstevel@tonic-gate if ((ret = __os_malloc(logrec.size, NULL, &logrec.data)) != 0) 1328*7c478bd9Sstevel@tonic-gate return (ret); 1329*7c478bd9Sstevel@tonic-gate 1330*7c478bd9Sstevel@tonic-gate bp = logrec.data; 1331*7c478bd9Sstevel@tonic-gate memcpy(bp, &rectype, sizeof(rectype)); 1332*7c478bd9Sstevel@tonic-gate bp += sizeof(rectype); 1333*7c478bd9Sstevel@tonic-gate memcpy(bp, &txn_num, sizeof(txn_num)); 1334*7c478bd9Sstevel@tonic-gate bp += sizeof(txn_num); 1335*7c478bd9Sstevel@tonic-gate memcpy(bp, lsnp, sizeof(DB_LSN)); 1336*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 1337*7c478bd9Sstevel@tonic-gate memcpy(bp, &fileid, sizeof(fileid)); 1338*7c478bd9Sstevel@tonic-gate bp += sizeof(fileid); 1339*7c478bd9Sstevel@tonic-gate memcpy(bp, &pgno, sizeof(pgno)); 1340*7c478bd9Sstevel@tonic-gate bp += sizeof(pgno); 1341*7c478bd9Sstevel@tonic-gate if (pagelsn != NULL) 1342*7c478bd9Sstevel@tonic-gate memcpy(bp, pagelsn, sizeof(*pagelsn)); 1343*7c478bd9Sstevel@tonic-gate else 1344*7c478bd9Sstevel@tonic-gate memset(bp, 0, sizeof(*pagelsn)); 1345*7c478bd9Sstevel@tonic-gate bp += sizeof(*pagelsn); 1346*7c478bd9Sstevel@tonic-gate memcpy(bp, &next_pgno, sizeof(next_pgno)); 1347*7c478bd9Sstevel@tonic-gate bp += sizeof(next_pgno); 1348*7c478bd9Sstevel@tonic-gate if (nextlsn != NULL) 1349*7c478bd9Sstevel@tonic-gate memcpy(bp, nextlsn, sizeof(*nextlsn)); 1350*7c478bd9Sstevel@tonic-gate else 1351*7c478bd9Sstevel@tonic-gate memset(bp, 0, sizeof(*nextlsn)); 1352*7c478bd9Sstevel@tonic-gate bp += sizeof(*nextlsn); 1353*7c478bd9Sstevel@tonic-gate memcpy(bp, &nnext_pgno, sizeof(nnext_pgno)); 1354*7c478bd9Sstevel@tonic-gate bp += sizeof(nnext_pgno); 1355*7c478bd9Sstevel@tonic-gate if (nnextlsn != NULL) 1356*7c478bd9Sstevel@tonic-gate memcpy(bp, nnextlsn, sizeof(*nnextlsn)); 1357*7c478bd9Sstevel@tonic-gate else 1358*7c478bd9Sstevel@tonic-gate memset(bp, 0, sizeof(*nnextlsn)); 1359*7c478bd9Sstevel@tonic-gate bp += sizeof(*nnextlsn); 1360*7c478bd9Sstevel@tonic-gate if (page == NULL) { 1361*7c478bd9Sstevel@tonic-gate zero = 0; 1362*7c478bd9Sstevel@tonic-gate memcpy(bp, &zero, sizeof(u_int32_t)); 1363*7c478bd9Sstevel@tonic-gate bp += sizeof(u_int32_t); 1364*7c478bd9Sstevel@tonic-gate } else { 1365*7c478bd9Sstevel@tonic-gate memcpy(bp, &page->size, sizeof(page->size)); 1366*7c478bd9Sstevel@tonic-gate bp += sizeof(page->size); 1367*7c478bd9Sstevel@tonic-gate memcpy(bp, page->data, page->size); 1368*7c478bd9Sstevel@tonic-gate bp += page->size; 1369*7c478bd9Sstevel@tonic-gate } 1370*7c478bd9Sstevel@tonic-gate #ifdef DIAGNOSTIC 1371*7c478bd9Sstevel@tonic-gate if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size) 1372*7c478bd9Sstevel@tonic-gate fprintf(stderr, "Error in log record length"); 1373*7c478bd9Sstevel@tonic-gate #endif 1374*7c478bd9Sstevel@tonic-gate ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags); 1375*7c478bd9Sstevel@tonic-gate if (txnid != NULL) 1376*7c478bd9Sstevel@tonic-gate txnid->last_lsn = *ret_lsnp; 1377*7c478bd9Sstevel@tonic-gate __os_free(logrec.data, 0); 1378*7c478bd9Sstevel@tonic-gate return (ret); 1379*7c478bd9Sstevel@tonic-gate } 1380*7c478bd9Sstevel@tonic-gate 1381*7c478bd9Sstevel@tonic-gate /* 1382*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_copypage_print 1383*7c478bd9Sstevel@tonic-gate * PUBLIC: __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); 1384*7c478bd9Sstevel@tonic-gate */ 1385*7c478bd9Sstevel@tonic-gate int 1386*7c478bd9Sstevel@tonic-gate __ham_copypage_print(notused1, dbtp, lsnp, notused2, notused3) 1387*7c478bd9Sstevel@tonic-gate DB_LOG *notused1; 1388*7c478bd9Sstevel@tonic-gate DBT *dbtp; 1389*7c478bd9Sstevel@tonic-gate DB_LSN *lsnp; 1390*7c478bd9Sstevel@tonic-gate int notused2; 1391*7c478bd9Sstevel@tonic-gate void *notused3; 1392*7c478bd9Sstevel@tonic-gate { 1393*7c478bd9Sstevel@tonic-gate __ham_copypage_args *argp; 1394*7c478bd9Sstevel@tonic-gate u_int32_t i; 1395*7c478bd9Sstevel@tonic-gate u_int ch; 1396*7c478bd9Sstevel@tonic-gate int ret; 1397*7c478bd9Sstevel@tonic-gate 1398*7c478bd9Sstevel@tonic-gate i = 0; 1399*7c478bd9Sstevel@tonic-gate ch = 0; 1400*7c478bd9Sstevel@tonic-gate notused1 = NULL; 1401*7c478bd9Sstevel@tonic-gate notused2 = 0; 1402*7c478bd9Sstevel@tonic-gate notused3 = NULL; 1403*7c478bd9Sstevel@tonic-gate 1404*7c478bd9Sstevel@tonic-gate if ((ret = __ham_copypage_read(dbtp->data, &argp)) != 0) 1405*7c478bd9Sstevel@tonic-gate return (ret); 1406*7c478bd9Sstevel@tonic-gate printf("[%lu][%lu]ham_copypage: rec: %lu txnid %lx prevlsn [%lu][%lu]\n", 1407*7c478bd9Sstevel@tonic-gate (u_long)lsnp->file, 1408*7c478bd9Sstevel@tonic-gate (u_long)lsnp->offset, 1409*7c478bd9Sstevel@tonic-gate (u_long)argp->type, 1410*7c478bd9Sstevel@tonic-gate (u_long)argp->txnid->txnid, 1411*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.file, 1412*7c478bd9Sstevel@tonic-gate (u_long)argp->prev_lsn.offset); 1413*7c478bd9Sstevel@tonic-gate printf("\tfileid: %lu\n", (u_long)argp->fileid); 1414*7c478bd9Sstevel@tonic-gate printf("\tpgno: %lu\n", (u_long)argp->pgno); 1415*7c478bd9Sstevel@tonic-gate printf("\tpagelsn: [%lu][%lu]\n", 1416*7c478bd9Sstevel@tonic-gate (u_long)argp->pagelsn.file, (u_long)argp->pagelsn.offset); 1417*7c478bd9Sstevel@tonic-gate printf("\tnext_pgno: %lu\n", (u_long)argp->next_pgno); 1418*7c478bd9Sstevel@tonic-gate printf("\tnextlsn: [%lu][%lu]\n", 1419*7c478bd9Sstevel@tonic-gate (u_long)argp->nextlsn.file, (u_long)argp->nextlsn.offset); 1420*7c478bd9Sstevel@tonic-gate printf("\tnnext_pgno: %lu\n", (u_long)argp->nnext_pgno); 1421*7c478bd9Sstevel@tonic-gate printf("\tnnextlsn: [%lu][%lu]\n", 1422*7c478bd9Sstevel@tonic-gate (u_long)argp->nnextlsn.file, (u_long)argp->nnextlsn.offset); 1423*7c478bd9Sstevel@tonic-gate printf("\tpage: "); 1424*7c478bd9Sstevel@tonic-gate for (i = 0; i < argp->page.size; i++) { 1425*7c478bd9Sstevel@tonic-gate ch = ((u_int8_t *)argp->page.data)[i]; 1426*7c478bd9Sstevel@tonic-gate if (isprint(ch) || ch == 0xa) 1427*7c478bd9Sstevel@tonic-gate putchar(ch); 1428*7c478bd9Sstevel@tonic-gate else 1429*7c478bd9Sstevel@tonic-gate printf("%#x ", ch); 1430*7c478bd9Sstevel@tonic-gate } 1431*7c478bd9Sstevel@tonic-gate printf("\n"); 1432*7c478bd9Sstevel@tonic-gate printf("\n"); 1433*7c478bd9Sstevel@tonic-gate __os_free(argp, 0); 1434*7c478bd9Sstevel@tonic-gate return (0); 1435*7c478bd9Sstevel@tonic-gate } 1436*7c478bd9Sstevel@tonic-gate 1437*7c478bd9Sstevel@tonic-gate /* 1438*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_copypage_read __P((void *, __ham_copypage_args **)); 1439*7c478bd9Sstevel@tonic-gate */ 1440*7c478bd9Sstevel@tonic-gate int 1441*7c478bd9Sstevel@tonic-gate __ham_copypage_read(recbuf, argpp) 1442*7c478bd9Sstevel@tonic-gate void *recbuf; 1443*7c478bd9Sstevel@tonic-gate __ham_copypage_args **argpp; 1444*7c478bd9Sstevel@tonic-gate { 1445*7c478bd9Sstevel@tonic-gate __ham_copypage_args *argp; 1446*7c478bd9Sstevel@tonic-gate u_int8_t *bp; 1447*7c478bd9Sstevel@tonic-gate int ret; 1448*7c478bd9Sstevel@tonic-gate 1449*7c478bd9Sstevel@tonic-gate ret = __os_malloc(sizeof(__ham_copypage_args) + 1450*7c478bd9Sstevel@tonic-gate sizeof(DB_TXN), NULL, &argp); 1451*7c478bd9Sstevel@tonic-gate if (ret != 0) 1452*7c478bd9Sstevel@tonic-gate return (ret); 1453*7c478bd9Sstevel@tonic-gate argp->txnid = (DB_TXN *)&argp[1]; 1454*7c478bd9Sstevel@tonic-gate bp = recbuf; 1455*7c478bd9Sstevel@tonic-gate memcpy(&argp->type, bp, sizeof(argp->type)); 1456*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->type); 1457*7c478bd9Sstevel@tonic-gate memcpy(&argp->txnid->txnid, bp, sizeof(argp->txnid->txnid)); 1458*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->txnid->txnid); 1459*7c478bd9Sstevel@tonic-gate memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN)); 1460*7c478bd9Sstevel@tonic-gate bp += sizeof(DB_LSN); 1461*7c478bd9Sstevel@tonic-gate memcpy(&argp->fileid, bp, sizeof(argp->fileid)); 1462*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->fileid); 1463*7c478bd9Sstevel@tonic-gate memcpy(&argp->pgno, bp, sizeof(argp->pgno)); 1464*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->pgno); 1465*7c478bd9Sstevel@tonic-gate memcpy(&argp->pagelsn, bp, sizeof(argp->pagelsn)); 1466*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->pagelsn); 1467*7c478bd9Sstevel@tonic-gate memcpy(&argp->next_pgno, bp, sizeof(argp->next_pgno)); 1468*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->next_pgno); 1469*7c478bd9Sstevel@tonic-gate memcpy(&argp->nextlsn, bp, sizeof(argp->nextlsn)); 1470*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->nextlsn); 1471*7c478bd9Sstevel@tonic-gate memcpy(&argp->nnext_pgno, bp, sizeof(argp->nnext_pgno)); 1472*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->nnext_pgno); 1473*7c478bd9Sstevel@tonic-gate memcpy(&argp->nnextlsn, bp, sizeof(argp->nnextlsn)); 1474*7c478bd9Sstevel@tonic-gate bp += sizeof(argp->nnextlsn); 1475*7c478bd9Sstevel@tonic-gate memcpy(&argp->page.size, bp, sizeof(u_int32_t)); 1476*7c478bd9Sstevel@tonic-gate bp += sizeof(u_int32_t); 1477*7c478bd9Sstevel@tonic-gate argp->page.data = bp; 1478*7c478bd9Sstevel@tonic-gate bp += argp->page.size; 1479*7c478bd9Sstevel@tonic-gate *argpp = argp; 1480*7c478bd9Sstevel@tonic-gate return (0); 1481*7c478bd9Sstevel@tonic-gate } 1482*7c478bd9Sstevel@tonic-gate 1483*7c478bd9Sstevel@tonic-gate /* 1484*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_init_print __P((DB_ENV *)); 1485*7c478bd9Sstevel@tonic-gate */ 1486*7c478bd9Sstevel@tonic-gate int 1487*7c478bd9Sstevel@tonic-gate __ham_init_print(dbenv) 1488*7c478bd9Sstevel@tonic-gate DB_ENV *dbenv; 1489*7c478bd9Sstevel@tonic-gate { 1490*7c478bd9Sstevel@tonic-gate int ret; 1491*7c478bd9Sstevel@tonic-gate 1492*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1493*7c478bd9Sstevel@tonic-gate __ham_insdel_print, DB_ham_insdel)) != 0) 1494*7c478bd9Sstevel@tonic-gate return (ret); 1495*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1496*7c478bd9Sstevel@tonic-gate __ham_newpage_print, DB_ham_newpage)) != 0) 1497*7c478bd9Sstevel@tonic-gate return (ret); 1498*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1499*7c478bd9Sstevel@tonic-gate __ham_splitmeta_print, DB_ham_splitmeta)) != 0) 1500*7c478bd9Sstevel@tonic-gate return (ret); 1501*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1502*7c478bd9Sstevel@tonic-gate __ham_splitdata_print, DB_ham_splitdata)) != 0) 1503*7c478bd9Sstevel@tonic-gate return (ret); 1504*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1505*7c478bd9Sstevel@tonic-gate __ham_replace_print, DB_ham_replace)) != 0) 1506*7c478bd9Sstevel@tonic-gate return (ret); 1507*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1508*7c478bd9Sstevel@tonic-gate __ham_newpgno_print, DB_ham_newpgno)) != 0) 1509*7c478bd9Sstevel@tonic-gate return (ret); 1510*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1511*7c478bd9Sstevel@tonic-gate __ham_ovfl_print, DB_ham_ovfl)) != 0) 1512*7c478bd9Sstevel@tonic-gate return (ret); 1513*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1514*7c478bd9Sstevel@tonic-gate __ham_copypage_print, DB_ham_copypage)) != 0) 1515*7c478bd9Sstevel@tonic-gate return (ret); 1516*7c478bd9Sstevel@tonic-gate return (0); 1517*7c478bd9Sstevel@tonic-gate } 1518*7c478bd9Sstevel@tonic-gate 1519*7c478bd9Sstevel@tonic-gate /* 1520*7c478bd9Sstevel@tonic-gate * PUBLIC: int __ham_init_recover __P((DB_ENV *)); 1521*7c478bd9Sstevel@tonic-gate */ 1522*7c478bd9Sstevel@tonic-gate int 1523*7c478bd9Sstevel@tonic-gate __ham_init_recover(dbenv) 1524*7c478bd9Sstevel@tonic-gate DB_ENV *dbenv; 1525*7c478bd9Sstevel@tonic-gate { 1526*7c478bd9Sstevel@tonic-gate int ret; 1527*7c478bd9Sstevel@tonic-gate 1528*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1529*7c478bd9Sstevel@tonic-gate __ham_insdel_recover, DB_ham_insdel)) != 0) 1530*7c478bd9Sstevel@tonic-gate return (ret); 1531*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1532*7c478bd9Sstevel@tonic-gate __ham_newpage_recover, DB_ham_newpage)) != 0) 1533*7c478bd9Sstevel@tonic-gate return (ret); 1534*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1535*7c478bd9Sstevel@tonic-gate __ham_splitmeta_recover, DB_ham_splitmeta)) != 0) 1536*7c478bd9Sstevel@tonic-gate return (ret); 1537*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1538*7c478bd9Sstevel@tonic-gate __ham_splitdata_recover, DB_ham_splitdata)) != 0) 1539*7c478bd9Sstevel@tonic-gate return (ret); 1540*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1541*7c478bd9Sstevel@tonic-gate __ham_replace_recover, DB_ham_replace)) != 0) 1542*7c478bd9Sstevel@tonic-gate return (ret); 1543*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1544*7c478bd9Sstevel@tonic-gate __ham_newpgno_recover, DB_ham_newpgno)) != 0) 1545*7c478bd9Sstevel@tonic-gate return (ret); 1546*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1547*7c478bd9Sstevel@tonic-gate __ham_ovfl_recover, DB_ham_ovfl)) != 0) 1548*7c478bd9Sstevel@tonic-gate return (ret); 1549*7c478bd9Sstevel@tonic-gate if ((ret = __db_add_recovery(dbenv, 1550*7c478bd9Sstevel@tonic-gate __ham_copypage_recover, DB_ham_copypage)) != 0) 1551*7c478bd9Sstevel@tonic-gate return (ret); 1552*7c478bd9Sstevel@tonic-gate return (0); 1553*7c478bd9Sstevel@tonic-gate } 1554*7c478bd9Sstevel@tonic-gate 1555