xref: /illumos-gate/usr/src/cmd/sendmail/db/txn/txn_auto.c (revision 7c478bd9)
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 "txn.h"
16*7c478bd9Sstevel@tonic-gate #include "db_am.h"
17*7c478bd9Sstevel@tonic-gate /*
18*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __txn_regop_log
19*7c478bd9Sstevel@tonic-gate  * PUBLIC:     __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
20*7c478bd9Sstevel@tonic-gate  * PUBLIC:     u_int32_t));
21*7c478bd9Sstevel@tonic-gate  */
__txn_regop_log(logp,txnid,ret_lsnp,flags,opcode)22*7c478bd9Sstevel@tonic-gate int __txn_regop_log(logp, txnid, ret_lsnp, flags,
23*7c478bd9Sstevel@tonic-gate 	opcode)
24*7c478bd9Sstevel@tonic-gate 	DB_LOG *logp;
25*7c478bd9Sstevel@tonic-gate 	DB_TXN *txnid;
26*7c478bd9Sstevel@tonic-gate 	DB_LSN *ret_lsnp;
27*7c478bd9Sstevel@tonic-gate 	u_int32_t flags;
28*7c478bd9Sstevel@tonic-gate 	u_int32_t opcode;
29*7c478bd9Sstevel@tonic-gate {
30*7c478bd9Sstevel@tonic-gate 	DBT logrec;
31*7c478bd9Sstevel@tonic-gate 	DB_LSN *lsnp, null_lsn;
32*7c478bd9Sstevel@tonic-gate 	u_int32_t rectype, txn_num;
33*7c478bd9Sstevel@tonic-gate 	int ret;
34*7c478bd9Sstevel@tonic-gate 	u_int8_t *bp;
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate 	rectype = DB_txn_regop;
37*7c478bd9Sstevel@tonic-gate 	txn_num = txnid == NULL ? 0 : txnid->txnid;
38*7c478bd9Sstevel@tonic-gate 	if (txnid == NULL) {
39*7c478bd9Sstevel@tonic-gate 		ZERO_LSN(null_lsn);
40*7c478bd9Sstevel@tonic-gate 		lsnp = &null_lsn;
41*7c478bd9Sstevel@tonic-gate 	} else
42*7c478bd9Sstevel@tonic-gate 		lsnp = &txnid->last_lsn;
43*7c478bd9Sstevel@tonic-gate 	logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
44*7c478bd9Sstevel@tonic-gate 	    + sizeof(opcode);
45*7c478bd9Sstevel@tonic-gate 	if ((ret = __os_malloc(logrec.size, NULL, &logrec.data)) != 0)
46*7c478bd9Sstevel@tonic-gate 		return (ret);
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate 	bp = logrec.data;
49*7c478bd9Sstevel@tonic-gate 	memcpy(bp, &rectype, sizeof(rectype));
50*7c478bd9Sstevel@tonic-gate 	bp += sizeof(rectype);
51*7c478bd9Sstevel@tonic-gate 	memcpy(bp, &txn_num, sizeof(txn_num));
52*7c478bd9Sstevel@tonic-gate 	bp += sizeof(txn_num);
53*7c478bd9Sstevel@tonic-gate 	memcpy(bp, lsnp, sizeof(DB_LSN));
54*7c478bd9Sstevel@tonic-gate 	bp += sizeof(DB_LSN);
55*7c478bd9Sstevel@tonic-gate 	memcpy(bp, &opcode, sizeof(opcode));
56*7c478bd9Sstevel@tonic-gate 	bp += sizeof(opcode);
57*7c478bd9Sstevel@tonic-gate #ifdef DIAGNOSTIC
58*7c478bd9Sstevel@tonic-gate 	if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
59*7c478bd9Sstevel@tonic-gate 		fprintf(stderr, "Error in log record length");
60*7c478bd9Sstevel@tonic-gate #endif
61*7c478bd9Sstevel@tonic-gate 	ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
62*7c478bd9Sstevel@tonic-gate 	if (txnid != NULL)
63*7c478bd9Sstevel@tonic-gate 		txnid->last_lsn = *ret_lsnp;
64*7c478bd9Sstevel@tonic-gate 	__os_free(logrec.data, 0);
65*7c478bd9Sstevel@tonic-gate 	return (ret);
66*7c478bd9Sstevel@tonic-gate }
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate /*
69*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __txn_regop_print
70*7c478bd9Sstevel@tonic-gate  * PUBLIC:    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
71*7c478bd9Sstevel@tonic-gate  */
72*7c478bd9Sstevel@tonic-gate int
__txn_regop_print(notused1,dbtp,lsnp,notused2,notused3)73*7c478bd9Sstevel@tonic-gate __txn_regop_print(notused1, dbtp, lsnp, notused2, notused3)
74*7c478bd9Sstevel@tonic-gate 	DB_LOG *notused1;
75*7c478bd9Sstevel@tonic-gate 	DBT *dbtp;
76*7c478bd9Sstevel@tonic-gate 	DB_LSN *lsnp;
77*7c478bd9Sstevel@tonic-gate 	int notused2;
78*7c478bd9Sstevel@tonic-gate 	void *notused3;
79*7c478bd9Sstevel@tonic-gate {
80*7c478bd9Sstevel@tonic-gate 	__txn_regop_args *argp;
81*7c478bd9Sstevel@tonic-gate 	u_int32_t i;
82*7c478bd9Sstevel@tonic-gate 	u_int ch;
83*7c478bd9Sstevel@tonic-gate 	int ret;
84*7c478bd9Sstevel@tonic-gate 
85*7c478bd9Sstevel@tonic-gate 	i = 0;
86*7c478bd9Sstevel@tonic-gate 	ch = 0;
87*7c478bd9Sstevel@tonic-gate 	notused1 = NULL;
88*7c478bd9Sstevel@tonic-gate 	notused2 = 0;
89*7c478bd9Sstevel@tonic-gate 	notused3 = NULL;
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate 	if ((ret = __txn_regop_read(dbtp->data, &argp)) != 0)
92*7c478bd9Sstevel@tonic-gate 		return (ret);
93*7c478bd9Sstevel@tonic-gate 	printf("[%lu][%lu]txn_regop: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
94*7c478bd9Sstevel@tonic-gate 	    (u_long)lsnp->file,
95*7c478bd9Sstevel@tonic-gate 	    (u_long)lsnp->offset,
96*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->type,
97*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->txnid->txnid,
98*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->prev_lsn.file,
99*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->prev_lsn.offset);
100*7c478bd9Sstevel@tonic-gate 	printf("\topcode: %lu\n", (u_long)argp->opcode);
101*7c478bd9Sstevel@tonic-gate 	printf("\n");
102*7c478bd9Sstevel@tonic-gate 	__os_free(argp, 0);
103*7c478bd9Sstevel@tonic-gate 	return (0);
104*7c478bd9Sstevel@tonic-gate }
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate /*
107*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __txn_regop_read __P((void *, __txn_regop_args **));
108*7c478bd9Sstevel@tonic-gate  */
109*7c478bd9Sstevel@tonic-gate int
__txn_regop_read(recbuf,argpp)110*7c478bd9Sstevel@tonic-gate __txn_regop_read(recbuf, argpp)
111*7c478bd9Sstevel@tonic-gate 	void *recbuf;
112*7c478bd9Sstevel@tonic-gate 	__txn_regop_args **argpp;
113*7c478bd9Sstevel@tonic-gate {
114*7c478bd9Sstevel@tonic-gate 	__txn_regop_args *argp;
115*7c478bd9Sstevel@tonic-gate 	u_int8_t *bp;
116*7c478bd9Sstevel@tonic-gate 	int ret;
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate 	ret = __os_malloc(sizeof(__txn_regop_args) +
119*7c478bd9Sstevel@tonic-gate 	    sizeof(DB_TXN), NULL, &argp);
120*7c478bd9Sstevel@tonic-gate 	if (ret != 0)
121*7c478bd9Sstevel@tonic-gate 		return (ret);
122*7c478bd9Sstevel@tonic-gate 	argp->txnid = (DB_TXN *)&argp[1];
123*7c478bd9Sstevel@tonic-gate 	bp = recbuf;
124*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->type, bp, sizeof(argp->type));
125*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->type);
126*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
127*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->txnid->txnid);
128*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
129*7c478bd9Sstevel@tonic-gate 	bp += sizeof(DB_LSN);
130*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->opcode, bp, sizeof(argp->opcode));
131*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->opcode);
132*7c478bd9Sstevel@tonic-gate 	*argpp = argp;
133*7c478bd9Sstevel@tonic-gate 	return (0);
134*7c478bd9Sstevel@tonic-gate }
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate /*
137*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __txn_ckp_log
138*7c478bd9Sstevel@tonic-gate  * PUBLIC:     __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
139*7c478bd9Sstevel@tonic-gate  * PUBLIC:     DB_LSN *, DB_LSN *));
140*7c478bd9Sstevel@tonic-gate  */
__txn_ckp_log(logp,txnid,ret_lsnp,flags,ckp_lsn,last_ckp)141*7c478bd9Sstevel@tonic-gate int __txn_ckp_log(logp, txnid, ret_lsnp, flags,
142*7c478bd9Sstevel@tonic-gate 	ckp_lsn, last_ckp)
143*7c478bd9Sstevel@tonic-gate 	DB_LOG *logp;
144*7c478bd9Sstevel@tonic-gate 	DB_TXN *txnid;
145*7c478bd9Sstevel@tonic-gate 	DB_LSN *ret_lsnp;
146*7c478bd9Sstevel@tonic-gate 	u_int32_t flags;
147*7c478bd9Sstevel@tonic-gate 	DB_LSN * ckp_lsn;
148*7c478bd9Sstevel@tonic-gate 	DB_LSN * last_ckp;
149*7c478bd9Sstevel@tonic-gate {
150*7c478bd9Sstevel@tonic-gate 	DBT logrec;
151*7c478bd9Sstevel@tonic-gate 	DB_LSN *lsnp, null_lsn;
152*7c478bd9Sstevel@tonic-gate 	u_int32_t rectype, txn_num;
153*7c478bd9Sstevel@tonic-gate 	int ret;
154*7c478bd9Sstevel@tonic-gate 	u_int8_t *bp;
155*7c478bd9Sstevel@tonic-gate 
156*7c478bd9Sstevel@tonic-gate 	rectype = DB_txn_ckp;
157*7c478bd9Sstevel@tonic-gate 	txn_num = txnid == NULL ? 0 : txnid->txnid;
158*7c478bd9Sstevel@tonic-gate 	if (txnid == NULL) {
159*7c478bd9Sstevel@tonic-gate 		ZERO_LSN(null_lsn);
160*7c478bd9Sstevel@tonic-gate 		lsnp = &null_lsn;
161*7c478bd9Sstevel@tonic-gate 	} else
162*7c478bd9Sstevel@tonic-gate 		lsnp = &txnid->last_lsn;
163*7c478bd9Sstevel@tonic-gate 	logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
164*7c478bd9Sstevel@tonic-gate 	    + sizeof(*ckp_lsn)
165*7c478bd9Sstevel@tonic-gate 	    + sizeof(*last_ckp);
166*7c478bd9Sstevel@tonic-gate 	if ((ret = __os_malloc(logrec.size, NULL, &logrec.data)) != 0)
167*7c478bd9Sstevel@tonic-gate 		return (ret);
168*7c478bd9Sstevel@tonic-gate 
169*7c478bd9Sstevel@tonic-gate 	bp = logrec.data;
170*7c478bd9Sstevel@tonic-gate 	memcpy(bp, &rectype, sizeof(rectype));
171*7c478bd9Sstevel@tonic-gate 	bp += sizeof(rectype);
172*7c478bd9Sstevel@tonic-gate 	memcpy(bp, &txn_num, sizeof(txn_num));
173*7c478bd9Sstevel@tonic-gate 	bp += sizeof(txn_num);
174*7c478bd9Sstevel@tonic-gate 	memcpy(bp, lsnp, sizeof(DB_LSN));
175*7c478bd9Sstevel@tonic-gate 	bp += sizeof(DB_LSN);
176*7c478bd9Sstevel@tonic-gate 	if (ckp_lsn != NULL)
177*7c478bd9Sstevel@tonic-gate 		memcpy(bp, ckp_lsn, sizeof(*ckp_lsn));
178*7c478bd9Sstevel@tonic-gate 	else
179*7c478bd9Sstevel@tonic-gate 		memset(bp, 0, sizeof(*ckp_lsn));
180*7c478bd9Sstevel@tonic-gate 	bp += sizeof(*ckp_lsn);
181*7c478bd9Sstevel@tonic-gate 	if (last_ckp != NULL)
182*7c478bd9Sstevel@tonic-gate 		memcpy(bp, last_ckp, sizeof(*last_ckp));
183*7c478bd9Sstevel@tonic-gate 	else
184*7c478bd9Sstevel@tonic-gate 		memset(bp, 0, sizeof(*last_ckp));
185*7c478bd9Sstevel@tonic-gate 	bp += sizeof(*last_ckp);
186*7c478bd9Sstevel@tonic-gate #ifdef DIAGNOSTIC
187*7c478bd9Sstevel@tonic-gate 	if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
188*7c478bd9Sstevel@tonic-gate 		fprintf(stderr, "Error in log record length");
189*7c478bd9Sstevel@tonic-gate #endif
190*7c478bd9Sstevel@tonic-gate 	ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
191*7c478bd9Sstevel@tonic-gate 	if (txnid != NULL)
192*7c478bd9Sstevel@tonic-gate 		txnid->last_lsn = *ret_lsnp;
193*7c478bd9Sstevel@tonic-gate 	__os_free(logrec.data, 0);
194*7c478bd9Sstevel@tonic-gate 	return (ret);
195*7c478bd9Sstevel@tonic-gate }
196*7c478bd9Sstevel@tonic-gate 
197*7c478bd9Sstevel@tonic-gate /*
198*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __txn_ckp_print
199*7c478bd9Sstevel@tonic-gate  * PUBLIC:    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
200*7c478bd9Sstevel@tonic-gate  */
201*7c478bd9Sstevel@tonic-gate int
__txn_ckp_print(notused1,dbtp,lsnp,notused2,notused3)202*7c478bd9Sstevel@tonic-gate __txn_ckp_print(notused1, dbtp, lsnp, notused2, notused3)
203*7c478bd9Sstevel@tonic-gate 	DB_LOG *notused1;
204*7c478bd9Sstevel@tonic-gate 	DBT *dbtp;
205*7c478bd9Sstevel@tonic-gate 	DB_LSN *lsnp;
206*7c478bd9Sstevel@tonic-gate 	int notused2;
207*7c478bd9Sstevel@tonic-gate 	void *notused3;
208*7c478bd9Sstevel@tonic-gate {
209*7c478bd9Sstevel@tonic-gate 	__txn_ckp_args *argp;
210*7c478bd9Sstevel@tonic-gate 	u_int32_t i;
211*7c478bd9Sstevel@tonic-gate 	u_int ch;
212*7c478bd9Sstevel@tonic-gate 	int ret;
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate 	i = 0;
215*7c478bd9Sstevel@tonic-gate 	ch = 0;
216*7c478bd9Sstevel@tonic-gate 	notused1 = NULL;
217*7c478bd9Sstevel@tonic-gate 	notused2 = 0;
218*7c478bd9Sstevel@tonic-gate 	notused3 = NULL;
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate 	if ((ret = __txn_ckp_read(dbtp->data, &argp)) != 0)
221*7c478bd9Sstevel@tonic-gate 		return (ret);
222*7c478bd9Sstevel@tonic-gate 	printf("[%lu][%lu]txn_ckp: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
223*7c478bd9Sstevel@tonic-gate 	    (u_long)lsnp->file,
224*7c478bd9Sstevel@tonic-gate 	    (u_long)lsnp->offset,
225*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->type,
226*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->txnid->txnid,
227*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->prev_lsn.file,
228*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->prev_lsn.offset);
229*7c478bd9Sstevel@tonic-gate 	printf("\tckp_lsn: [%lu][%lu]\n",
230*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->ckp_lsn.file, (u_long)argp->ckp_lsn.offset);
231*7c478bd9Sstevel@tonic-gate 	printf("\tlast_ckp: [%lu][%lu]\n",
232*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->last_ckp.file, (u_long)argp->last_ckp.offset);
233*7c478bd9Sstevel@tonic-gate 	printf("\n");
234*7c478bd9Sstevel@tonic-gate 	__os_free(argp, 0);
235*7c478bd9Sstevel@tonic-gate 	return (0);
236*7c478bd9Sstevel@tonic-gate }
237*7c478bd9Sstevel@tonic-gate 
238*7c478bd9Sstevel@tonic-gate /*
239*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __txn_ckp_read __P((void *, __txn_ckp_args **));
240*7c478bd9Sstevel@tonic-gate  */
241*7c478bd9Sstevel@tonic-gate int
__txn_ckp_read(recbuf,argpp)242*7c478bd9Sstevel@tonic-gate __txn_ckp_read(recbuf, argpp)
243*7c478bd9Sstevel@tonic-gate 	void *recbuf;
244*7c478bd9Sstevel@tonic-gate 	__txn_ckp_args **argpp;
245*7c478bd9Sstevel@tonic-gate {
246*7c478bd9Sstevel@tonic-gate 	__txn_ckp_args *argp;
247*7c478bd9Sstevel@tonic-gate 	u_int8_t *bp;
248*7c478bd9Sstevel@tonic-gate 	int ret;
249*7c478bd9Sstevel@tonic-gate 
250*7c478bd9Sstevel@tonic-gate 	ret = __os_malloc(sizeof(__txn_ckp_args) +
251*7c478bd9Sstevel@tonic-gate 	    sizeof(DB_TXN), NULL, &argp);
252*7c478bd9Sstevel@tonic-gate 	if (ret != 0)
253*7c478bd9Sstevel@tonic-gate 		return (ret);
254*7c478bd9Sstevel@tonic-gate 	argp->txnid = (DB_TXN *)&argp[1];
255*7c478bd9Sstevel@tonic-gate 	bp = recbuf;
256*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->type, bp, sizeof(argp->type));
257*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->type);
258*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
259*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->txnid->txnid);
260*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
261*7c478bd9Sstevel@tonic-gate 	bp += sizeof(DB_LSN);
262*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->ckp_lsn, bp,  sizeof(argp->ckp_lsn));
263*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->ckp_lsn);
264*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->last_ckp, bp,  sizeof(argp->last_ckp));
265*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->last_ckp);
266*7c478bd9Sstevel@tonic-gate 	*argpp = argp;
267*7c478bd9Sstevel@tonic-gate 	return (0);
268*7c478bd9Sstevel@tonic-gate }
269*7c478bd9Sstevel@tonic-gate 
270*7c478bd9Sstevel@tonic-gate /*
271*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __txn_xa_regop_log
272*7c478bd9Sstevel@tonic-gate  * PUBLIC:     __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
273*7c478bd9Sstevel@tonic-gate  * PUBLIC:     u_int32_t, const DBT *, int32_t, u_int32_t,
274*7c478bd9Sstevel@tonic-gate  * PUBLIC:     u_int32_t, DB_LSN *));
275*7c478bd9Sstevel@tonic-gate  */
__txn_xa_regop_log(logp,txnid,ret_lsnp,flags,opcode,xid,formatID,gtrid,bqual,begin_lsn)276*7c478bd9Sstevel@tonic-gate int __txn_xa_regop_log(logp, txnid, ret_lsnp, flags,
277*7c478bd9Sstevel@tonic-gate 	opcode, xid, formatID, gtrid, bqual, begin_lsn)
278*7c478bd9Sstevel@tonic-gate 	DB_LOG *logp;
279*7c478bd9Sstevel@tonic-gate 	DB_TXN *txnid;
280*7c478bd9Sstevel@tonic-gate 	DB_LSN *ret_lsnp;
281*7c478bd9Sstevel@tonic-gate 	u_int32_t flags;
282*7c478bd9Sstevel@tonic-gate 	u_int32_t opcode;
283*7c478bd9Sstevel@tonic-gate 	const DBT *xid;
284*7c478bd9Sstevel@tonic-gate 	int32_t formatID;
285*7c478bd9Sstevel@tonic-gate 	u_int32_t gtrid;
286*7c478bd9Sstevel@tonic-gate 	u_int32_t bqual;
287*7c478bd9Sstevel@tonic-gate 	DB_LSN * begin_lsn;
288*7c478bd9Sstevel@tonic-gate {
289*7c478bd9Sstevel@tonic-gate 	DBT logrec;
290*7c478bd9Sstevel@tonic-gate 	DB_LSN *lsnp, null_lsn;
291*7c478bd9Sstevel@tonic-gate 	u_int32_t zero;
292*7c478bd9Sstevel@tonic-gate 	u_int32_t rectype, txn_num;
293*7c478bd9Sstevel@tonic-gate 	int ret;
294*7c478bd9Sstevel@tonic-gate 	u_int8_t *bp;
295*7c478bd9Sstevel@tonic-gate 
296*7c478bd9Sstevel@tonic-gate 	rectype = DB_txn_xa_regop;
297*7c478bd9Sstevel@tonic-gate 	txn_num = txnid == NULL ? 0 : txnid->txnid;
298*7c478bd9Sstevel@tonic-gate 	if (txnid == NULL) {
299*7c478bd9Sstevel@tonic-gate 		ZERO_LSN(null_lsn);
300*7c478bd9Sstevel@tonic-gate 		lsnp = &null_lsn;
301*7c478bd9Sstevel@tonic-gate 	} else
302*7c478bd9Sstevel@tonic-gate 		lsnp = &txnid->last_lsn;
303*7c478bd9Sstevel@tonic-gate 	logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
304*7c478bd9Sstevel@tonic-gate 	    + sizeof(opcode)
305*7c478bd9Sstevel@tonic-gate 	    + sizeof(u_int32_t) + (xid == NULL ? 0 : xid->size)
306*7c478bd9Sstevel@tonic-gate 	    + sizeof(formatID)
307*7c478bd9Sstevel@tonic-gate 	    + sizeof(gtrid)
308*7c478bd9Sstevel@tonic-gate 	    + sizeof(bqual)
309*7c478bd9Sstevel@tonic-gate 	    + sizeof(*begin_lsn);
310*7c478bd9Sstevel@tonic-gate 	if ((ret = __os_malloc(logrec.size, NULL, &logrec.data)) != 0)
311*7c478bd9Sstevel@tonic-gate 		return (ret);
312*7c478bd9Sstevel@tonic-gate 
313*7c478bd9Sstevel@tonic-gate 	bp = logrec.data;
314*7c478bd9Sstevel@tonic-gate 	memcpy(bp, &rectype, sizeof(rectype));
315*7c478bd9Sstevel@tonic-gate 	bp += sizeof(rectype);
316*7c478bd9Sstevel@tonic-gate 	memcpy(bp, &txn_num, sizeof(txn_num));
317*7c478bd9Sstevel@tonic-gate 	bp += sizeof(txn_num);
318*7c478bd9Sstevel@tonic-gate 	memcpy(bp, lsnp, sizeof(DB_LSN));
319*7c478bd9Sstevel@tonic-gate 	bp += sizeof(DB_LSN);
320*7c478bd9Sstevel@tonic-gate 	memcpy(bp, &opcode, sizeof(opcode));
321*7c478bd9Sstevel@tonic-gate 	bp += sizeof(opcode);
322*7c478bd9Sstevel@tonic-gate 	if (xid == NULL) {
323*7c478bd9Sstevel@tonic-gate 		zero = 0;
324*7c478bd9Sstevel@tonic-gate 		memcpy(bp, &zero, sizeof(u_int32_t));
325*7c478bd9Sstevel@tonic-gate 		bp += sizeof(u_int32_t);
326*7c478bd9Sstevel@tonic-gate 	} else {
327*7c478bd9Sstevel@tonic-gate 		memcpy(bp, &xid->size, sizeof(xid->size));
328*7c478bd9Sstevel@tonic-gate 		bp += sizeof(xid->size);
329*7c478bd9Sstevel@tonic-gate 		memcpy(bp, xid->data, xid->size);
330*7c478bd9Sstevel@tonic-gate 		bp += xid->size;
331*7c478bd9Sstevel@tonic-gate 	}
332*7c478bd9Sstevel@tonic-gate 	memcpy(bp, &formatID, sizeof(formatID));
333*7c478bd9Sstevel@tonic-gate 	bp += sizeof(formatID);
334*7c478bd9Sstevel@tonic-gate 	memcpy(bp, &gtrid, sizeof(gtrid));
335*7c478bd9Sstevel@tonic-gate 	bp += sizeof(gtrid);
336*7c478bd9Sstevel@tonic-gate 	memcpy(bp, &bqual, sizeof(bqual));
337*7c478bd9Sstevel@tonic-gate 	bp += sizeof(bqual);
338*7c478bd9Sstevel@tonic-gate 	if (begin_lsn != NULL)
339*7c478bd9Sstevel@tonic-gate 		memcpy(bp, begin_lsn, sizeof(*begin_lsn));
340*7c478bd9Sstevel@tonic-gate 	else
341*7c478bd9Sstevel@tonic-gate 		memset(bp, 0, sizeof(*begin_lsn));
342*7c478bd9Sstevel@tonic-gate 	bp += sizeof(*begin_lsn);
343*7c478bd9Sstevel@tonic-gate #ifdef DIAGNOSTIC
344*7c478bd9Sstevel@tonic-gate 	if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
345*7c478bd9Sstevel@tonic-gate 		fprintf(stderr, "Error in log record length");
346*7c478bd9Sstevel@tonic-gate #endif
347*7c478bd9Sstevel@tonic-gate 	ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
348*7c478bd9Sstevel@tonic-gate 	if (txnid != NULL)
349*7c478bd9Sstevel@tonic-gate 		txnid->last_lsn = *ret_lsnp;
350*7c478bd9Sstevel@tonic-gate 	__os_free(logrec.data, 0);
351*7c478bd9Sstevel@tonic-gate 	return (ret);
352*7c478bd9Sstevel@tonic-gate }
353*7c478bd9Sstevel@tonic-gate 
354*7c478bd9Sstevel@tonic-gate /*
355*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __txn_xa_regop_print
356*7c478bd9Sstevel@tonic-gate  * PUBLIC:    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
357*7c478bd9Sstevel@tonic-gate  */
358*7c478bd9Sstevel@tonic-gate int
__txn_xa_regop_print(notused1,dbtp,lsnp,notused2,notused3)359*7c478bd9Sstevel@tonic-gate __txn_xa_regop_print(notused1, dbtp, lsnp, notused2, notused3)
360*7c478bd9Sstevel@tonic-gate 	DB_LOG *notused1;
361*7c478bd9Sstevel@tonic-gate 	DBT *dbtp;
362*7c478bd9Sstevel@tonic-gate 	DB_LSN *lsnp;
363*7c478bd9Sstevel@tonic-gate 	int notused2;
364*7c478bd9Sstevel@tonic-gate 	void *notused3;
365*7c478bd9Sstevel@tonic-gate {
366*7c478bd9Sstevel@tonic-gate 	__txn_xa_regop_args *argp;
367*7c478bd9Sstevel@tonic-gate 	u_int32_t i;
368*7c478bd9Sstevel@tonic-gate 	u_int ch;
369*7c478bd9Sstevel@tonic-gate 	int ret;
370*7c478bd9Sstevel@tonic-gate 
371*7c478bd9Sstevel@tonic-gate 	i = 0;
372*7c478bd9Sstevel@tonic-gate 	ch = 0;
373*7c478bd9Sstevel@tonic-gate 	notused1 = NULL;
374*7c478bd9Sstevel@tonic-gate 	notused2 = 0;
375*7c478bd9Sstevel@tonic-gate 	notused3 = NULL;
376*7c478bd9Sstevel@tonic-gate 
377*7c478bd9Sstevel@tonic-gate 	if ((ret = __txn_xa_regop_read(dbtp->data, &argp)) != 0)
378*7c478bd9Sstevel@tonic-gate 		return (ret);
379*7c478bd9Sstevel@tonic-gate 	printf("[%lu][%lu]txn_xa_regop: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
380*7c478bd9Sstevel@tonic-gate 	    (u_long)lsnp->file,
381*7c478bd9Sstevel@tonic-gate 	    (u_long)lsnp->offset,
382*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->type,
383*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->txnid->txnid,
384*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->prev_lsn.file,
385*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->prev_lsn.offset);
386*7c478bd9Sstevel@tonic-gate 	printf("\topcode: %lu\n", (u_long)argp->opcode);
387*7c478bd9Sstevel@tonic-gate 	printf("\txid: ");
388*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < argp->xid.size; i++) {
389*7c478bd9Sstevel@tonic-gate 		ch = ((u_int8_t *)argp->xid.data)[i];
390*7c478bd9Sstevel@tonic-gate 		if (isprint(ch) || ch == 0xa)
391*7c478bd9Sstevel@tonic-gate 			putchar(ch);
392*7c478bd9Sstevel@tonic-gate 		else
393*7c478bd9Sstevel@tonic-gate 			printf("%#x ", ch);
394*7c478bd9Sstevel@tonic-gate 	}
395*7c478bd9Sstevel@tonic-gate 	printf("\n");
396*7c478bd9Sstevel@tonic-gate 	printf("\tformatID: %ld\n", (long)argp->formatID);
397*7c478bd9Sstevel@tonic-gate 	printf("\tgtrid: %u\n", argp->gtrid);
398*7c478bd9Sstevel@tonic-gate 	printf("\tbqual: %u\n", argp->bqual);
399*7c478bd9Sstevel@tonic-gate 	printf("\tbegin_lsn: [%lu][%lu]\n",
400*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->begin_lsn.file, (u_long)argp->begin_lsn.offset);
401*7c478bd9Sstevel@tonic-gate 	printf("\n");
402*7c478bd9Sstevel@tonic-gate 	__os_free(argp, 0);
403*7c478bd9Sstevel@tonic-gate 	return (0);
404*7c478bd9Sstevel@tonic-gate }
405*7c478bd9Sstevel@tonic-gate 
406*7c478bd9Sstevel@tonic-gate /*
407*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __txn_xa_regop_read __P((void *, __txn_xa_regop_args **));
408*7c478bd9Sstevel@tonic-gate  */
409*7c478bd9Sstevel@tonic-gate int
__txn_xa_regop_read(recbuf,argpp)410*7c478bd9Sstevel@tonic-gate __txn_xa_regop_read(recbuf, argpp)
411*7c478bd9Sstevel@tonic-gate 	void *recbuf;
412*7c478bd9Sstevel@tonic-gate 	__txn_xa_regop_args **argpp;
413*7c478bd9Sstevel@tonic-gate {
414*7c478bd9Sstevel@tonic-gate 	__txn_xa_regop_args *argp;
415*7c478bd9Sstevel@tonic-gate 	u_int8_t *bp;
416*7c478bd9Sstevel@tonic-gate 	int ret;
417*7c478bd9Sstevel@tonic-gate 
418*7c478bd9Sstevel@tonic-gate 	ret = __os_malloc(sizeof(__txn_xa_regop_args) +
419*7c478bd9Sstevel@tonic-gate 	    sizeof(DB_TXN), NULL, &argp);
420*7c478bd9Sstevel@tonic-gate 	if (ret != 0)
421*7c478bd9Sstevel@tonic-gate 		return (ret);
422*7c478bd9Sstevel@tonic-gate 	argp->txnid = (DB_TXN *)&argp[1];
423*7c478bd9Sstevel@tonic-gate 	bp = recbuf;
424*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->type, bp, sizeof(argp->type));
425*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->type);
426*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
427*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->txnid->txnid);
428*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
429*7c478bd9Sstevel@tonic-gate 	bp += sizeof(DB_LSN);
430*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->opcode, bp, sizeof(argp->opcode));
431*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->opcode);
432*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->xid.size, bp, sizeof(u_int32_t));
433*7c478bd9Sstevel@tonic-gate 	bp += sizeof(u_int32_t);
434*7c478bd9Sstevel@tonic-gate 	argp->xid.data = bp;
435*7c478bd9Sstevel@tonic-gate 	bp += argp->xid.size;
436*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->formatID, bp, sizeof(argp->formatID));
437*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->formatID);
438*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->gtrid, bp, sizeof(argp->gtrid));
439*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->gtrid);
440*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->bqual, bp, sizeof(argp->bqual));
441*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->bqual);
442*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->begin_lsn, bp,  sizeof(argp->begin_lsn));
443*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->begin_lsn);
444*7c478bd9Sstevel@tonic-gate 	*argpp = argp;
445*7c478bd9Sstevel@tonic-gate 	return (0);
446*7c478bd9Sstevel@tonic-gate }
447*7c478bd9Sstevel@tonic-gate 
448*7c478bd9Sstevel@tonic-gate /*
449*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __txn_child_log
450*7c478bd9Sstevel@tonic-gate  * PUBLIC:     __P((DB_LOG *, DB_TXN *, DB_LSN *, u_int32_t,
451*7c478bd9Sstevel@tonic-gate  * PUBLIC:     u_int32_t, u_int32_t));
452*7c478bd9Sstevel@tonic-gate  */
__txn_child_log(logp,txnid,ret_lsnp,flags,opcode,parent)453*7c478bd9Sstevel@tonic-gate int __txn_child_log(logp, txnid, ret_lsnp, flags,
454*7c478bd9Sstevel@tonic-gate 	opcode, parent)
455*7c478bd9Sstevel@tonic-gate 	DB_LOG *logp;
456*7c478bd9Sstevel@tonic-gate 	DB_TXN *txnid;
457*7c478bd9Sstevel@tonic-gate 	DB_LSN *ret_lsnp;
458*7c478bd9Sstevel@tonic-gate 	u_int32_t flags;
459*7c478bd9Sstevel@tonic-gate 	u_int32_t opcode;
460*7c478bd9Sstevel@tonic-gate 	u_int32_t parent;
461*7c478bd9Sstevel@tonic-gate {
462*7c478bd9Sstevel@tonic-gate 	DBT logrec;
463*7c478bd9Sstevel@tonic-gate 	DB_LSN *lsnp, null_lsn;
464*7c478bd9Sstevel@tonic-gate 	u_int32_t rectype, txn_num;
465*7c478bd9Sstevel@tonic-gate 	int ret;
466*7c478bd9Sstevel@tonic-gate 	u_int8_t *bp;
467*7c478bd9Sstevel@tonic-gate 
468*7c478bd9Sstevel@tonic-gate 	rectype = DB_txn_child;
469*7c478bd9Sstevel@tonic-gate 	txn_num = txnid == NULL ? 0 : txnid->txnid;
470*7c478bd9Sstevel@tonic-gate 	if (txnid == NULL) {
471*7c478bd9Sstevel@tonic-gate 		ZERO_LSN(null_lsn);
472*7c478bd9Sstevel@tonic-gate 		lsnp = &null_lsn;
473*7c478bd9Sstevel@tonic-gate 	} else
474*7c478bd9Sstevel@tonic-gate 		lsnp = &txnid->last_lsn;
475*7c478bd9Sstevel@tonic-gate 	logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
476*7c478bd9Sstevel@tonic-gate 	    + sizeof(opcode)
477*7c478bd9Sstevel@tonic-gate 	    + sizeof(parent);
478*7c478bd9Sstevel@tonic-gate 	if ((ret = __os_malloc(logrec.size, NULL, &logrec.data)) != 0)
479*7c478bd9Sstevel@tonic-gate 		return (ret);
480*7c478bd9Sstevel@tonic-gate 
481*7c478bd9Sstevel@tonic-gate 	bp = logrec.data;
482*7c478bd9Sstevel@tonic-gate 	memcpy(bp, &rectype, sizeof(rectype));
483*7c478bd9Sstevel@tonic-gate 	bp += sizeof(rectype);
484*7c478bd9Sstevel@tonic-gate 	memcpy(bp, &txn_num, sizeof(txn_num));
485*7c478bd9Sstevel@tonic-gate 	bp += sizeof(txn_num);
486*7c478bd9Sstevel@tonic-gate 	memcpy(bp, lsnp, sizeof(DB_LSN));
487*7c478bd9Sstevel@tonic-gate 	bp += sizeof(DB_LSN);
488*7c478bd9Sstevel@tonic-gate 	memcpy(bp, &opcode, sizeof(opcode));
489*7c478bd9Sstevel@tonic-gate 	bp += sizeof(opcode);
490*7c478bd9Sstevel@tonic-gate 	memcpy(bp, &parent, sizeof(parent));
491*7c478bd9Sstevel@tonic-gate 	bp += sizeof(parent);
492*7c478bd9Sstevel@tonic-gate #ifdef DIAGNOSTIC
493*7c478bd9Sstevel@tonic-gate 	if ((u_int32_t)(bp - (u_int8_t *)logrec.data) != logrec.size)
494*7c478bd9Sstevel@tonic-gate 		fprintf(stderr, "Error in log record length");
495*7c478bd9Sstevel@tonic-gate #endif
496*7c478bd9Sstevel@tonic-gate 	ret = log_put(logp, ret_lsnp, (DBT *)&logrec, flags);
497*7c478bd9Sstevel@tonic-gate 	if (txnid != NULL)
498*7c478bd9Sstevel@tonic-gate 		txnid->last_lsn = *ret_lsnp;
499*7c478bd9Sstevel@tonic-gate 	__os_free(logrec.data, 0);
500*7c478bd9Sstevel@tonic-gate 	return (ret);
501*7c478bd9Sstevel@tonic-gate }
502*7c478bd9Sstevel@tonic-gate 
503*7c478bd9Sstevel@tonic-gate /*
504*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __txn_child_print
505*7c478bd9Sstevel@tonic-gate  * PUBLIC:    __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
506*7c478bd9Sstevel@tonic-gate  */
507*7c478bd9Sstevel@tonic-gate int
__txn_child_print(notused1,dbtp,lsnp,notused2,notused3)508*7c478bd9Sstevel@tonic-gate __txn_child_print(notused1, dbtp, lsnp, notused2, notused3)
509*7c478bd9Sstevel@tonic-gate 	DB_LOG *notused1;
510*7c478bd9Sstevel@tonic-gate 	DBT *dbtp;
511*7c478bd9Sstevel@tonic-gate 	DB_LSN *lsnp;
512*7c478bd9Sstevel@tonic-gate 	int notused2;
513*7c478bd9Sstevel@tonic-gate 	void *notused3;
514*7c478bd9Sstevel@tonic-gate {
515*7c478bd9Sstevel@tonic-gate 	__txn_child_args *argp;
516*7c478bd9Sstevel@tonic-gate 	u_int32_t i;
517*7c478bd9Sstevel@tonic-gate 	u_int ch;
518*7c478bd9Sstevel@tonic-gate 	int ret;
519*7c478bd9Sstevel@tonic-gate 
520*7c478bd9Sstevel@tonic-gate 	i = 0;
521*7c478bd9Sstevel@tonic-gate 	ch = 0;
522*7c478bd9Sstevel@tonic-gate 	notused1 = NULL;
523*7c478bd9Sstevel@tonic-gate 	notused2 = 0;
524*7c478bd9Sstevel@tonic-gate 	notused3 = NULL;
525*7c478bd9Sstevel@tonic-gate 
526*7c478bd9Sstevel@tonic-gate 	if ((ret = __txn_child_read(dbtp->data, &argp)) != 0)
527*7c478bd9Sstevel@tonic-gate 		return (ret);
528*7c478bd9Sstevel@tonic-gate 	printf("[%lu][%lu]txn_child: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
529*7c478bd9Sstevel@tonic-gate 	    (u_long)lsnp->file,
530*7c478bd9Sstevel@tonic-gate 	    (u_long)lsnp->offset,
531*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->type,
532*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->txnid->txnid,
533*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->prev_lsn.file,
534*7c478bd9Sstevel@tonic-gate 	    (u_long)argp->prev_lsn.offset);
535*7c478bd9Sstevel@tonic-gate 	printf("\topcode: %lu\n", (u_long)argp->opcode);
536*7c478bd9Sstevel@tonic-gate 	printf("\tparent: %lu\n", (u_long)argp->parent);
537*7c478bd9Sstevel@tonic-gate 	printf("\n");
538*7c478bd9Sstevel@tonic-gate 	__os_free(argp, 0);
539*7c478bd9Sstevel@tonic-gate 	return (0);
540*7c478bd9Sstevel@tonic-gate }
541*7c478bd9Sstevel@tonic-gate 
542*7c478bd9Sstevel@tonic-gate /*
543*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __txn_child_read __P((void *, __txn_child_args **));
544*7c478bd9Sstevel@tonic-gate  */
545*7c478bd9Sstevel@tonic-gate int
__txn_child_read(recbuf,argpp)546*7c478bd9Sstevel@tonic-gate __txn_child_read(recbuf, argpp)
547*7c478bd9Sstevel@tonic-gate 	void *recbuf;
548*7c478bd9Sstevel@tonic-gate 	__txn_child_args **argpp;
549*7c478bd9Sstevel@tonic-gate {
550*7c478bd9Sstevel@tonic-gate 	__txn_child_args *argp;
551*7c478bd9Sstevel@tonic-gate 	u_int8_t *bp;
552*7c478bd9Sstevel@tonic-gate 	int ret;
553*7c478bd9Sstevel@tonic-gate 
554*7c478bd9Sstevel@tonic-gate 	ret = __os_malloc(sizeof(__txn_child_args) +
555*7c478bd9Sstevel@tonic-gate 	    sizeof(DB_TXN), NULL, &argp);
556*7c478bd9Sstevel@tonic-gate 	if (ret != 0)
557*7c478bd9Sstevel@tonic-gate 		return (ret);
558*7c478bd9Sstevel@tonic-gate 	argp->txnid = (DB_TXN *)&argp[1];
559*7c478bd9Sstevel@tonic-gate 	bp = recbuf;
560*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->type, bp, sizeof(argp->type));
561*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->type);
562*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
563*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->txnid->txnid);
564*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
565*7c478bd9Sstevel@tonic-gate 	bp += sizeof(DB_LSN);
566*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->opcode, bp, sizeof(argp->opcode));
567*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->opcode);
568*7c478bd9Sstevel@tonic-gate 	memcpy(&argp->parent, bp, sizeof(argp->parent));
569*7c478bd9Sstevel@tonic-gate 	bp += sizeof(argp->parent);
570*7c478bd9Sstevel@tonic-gate 	*argpp = argp;
571*7c478bd9Sstevel@tonic-gate 	return (0);
572*7c478bd9Sstevel@tonic-gate }
573*7c478bd9Sstevel@tonic-gate 
574*7c478bd9Sstevel@tonic-gate /*
575*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __txn_init_print __P((DB_ENV *));
576*7c478bd9Sstevel@tonic-gate  */
577*7c478bd9Sstevel@tonic-gate int
__txn_init_print(dbenv)578*7c478bd9Sstevel@tonic-gate __txn_init_print(dbenv)
579*7c478bd9Sstevel@tonic-gate 	DB_ENV *dbenv;
580*7c478bd9Sstevel@tonic-gate {
581*7c478bd9Sstevel@tonic-gate 	int ret;
582*7c478bd9Sstevel@tonic-gate 
583*7c478bd9Sstevel@tonic-gate 	if ((ret = __db_add_recovery(dbenv,
584*7c478bd9Sstevel@tonic-gate 	    __txn_regop_print, DB_txn_regop)) != 0)
585*7c478bd9Sstevel@tonic-gate 		return (ret);
586*7c478bd9Sstevel@tonic-gate 	if ((ret = __db_add_recovery(dbenv,
587*7c478bd9Sstevel@tonic-gate 	    __txn_ckp_print, DB_txn_ckp)) != 0)
588*7c478bd9Sstevel@tonic-gate 		return (ret);
589*7c478bd9Sstevel@tonic-gate 	if ((ret = __db_add_recovery(dbenv,
590*7c478bd9Sstevel@tonic-gate 	    __txn_xa_regop_print, DB_txn_xa_regop)) != 0)
591*7c478bd9Sstevel@tonic-gate 		return (ret);
592*7c478bd9Sstevel@tonic-gate 	if ((ret = __db_add_recovery(dbenv,
593*7c478bd9Sstevel@tonic-gate 	    __txn_child_print, DB_txn_child)) != 0)
594*7c478bd9Sstevel@tonic-gate 		return (ret);
595*7c478bd9Sstevel@tonic-gate 	return (0);
596*7c478bd9Sstevel@tonic-gate }
597*7c478bd9Sstevel@tonic-gate 
598*7c478bd9Sstevel@tonic-gate /*
599*7c478bd9Sstevel@tonic-gate  * PUBLIC: int __txn_init_recover __P((DB_ENV *));
600*7c478bd9Sstevel@tonic-gate  */
601*7c478bd9Sstevel@tonic-gate int
__txn_init_recover(dbenv)602*7c478bd9Sstevel@tonic-gate __txn_init_recover(dbenv)
603*7c478bd9Sstevel@tonic-gate 	DB_ENV *dbenv;
604*7c478bd9Sstevel@tonic-gate {
605*7c478bd9Sstevel@tonic-gate 	int ret;
606*7c478bd9Sstevel@tonic-gate 
607*7c478bd9Sstevel@tonic-gate 	if ((ret = __db_add_recovery(dbenv,
608*7c478bd9Sstevel@tonic-gate 	    __txn_regop_recover, DB_txn_regop)) != 0)
609*7c478bd9Sstevel@tonic-gate 		return (ret);
610*7c478bd9Sstevel@tonic-gate 	if ((ret = __db_add_recovery(dbenv,
611*7c478bd9Sstevel@tonic-gate 	    __txn_ckp_recover, DB_txn_ckp)) != 0)
612*7c478bd9Sstevel@tonic-gate 		return (ret);
613*7c478bd9Sstevel@tonic-gate 	if ((ret = __db_add_recovery(dbenv,
614*7c478bd9Sstevel@tonic-gate 	    __txn_xa_regop_recover, DB_txn_xa_regop)) != 0)
615*7c478bd9Sstevel@tonic-gate 		return (ret);
616*7c478bd9Sstevel@tonic-gate 	if ((ret = __db_add_recovery(dbenv,
617*7c478bd9Sstevel@tonic-gate 	    __txn_child_recover, DB_txn_child)) != 0)
618*7c478bd9Sstevel@tonic-gate 		return (ret);
619*7c478bd9Sstevel@tonic-gate 	return (0);
620*7c478bd9Sstevel@tonic-gate }
621*7c478bd9Sstevel@tonic-gate 
622