~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to db/btree/btree_auto.c

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Do not edit: automatically built by gen_rec.awk. */
 
2
#include "db_config.h"
 
3
 
 
4
#ifndef NO_SYSTEM_INCLUDES
 
5
#include <sys/types.h>
 
6
 
 
7
#include <ctype.h>
 
8
#include <string.h>
 
9
#endif
 
10
 
 
11
#include "db_int.h"
 
12
#include "db_page.h"
 
13
#include "db_dispatch.h"
 
14
#include "db_am.h"
 
15
#include "btree.h"
 
16
#include "txn.h"
 
17
 
 
18
/*
 
19
 * PUBLIC: int __bam_pg_alloc_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t,
 
20
 * PUBLIC:      int32_t, DB_LSN *, DB_LSN *, db_pgno_t, u_int32_t, db_pgno_t));
 
21
 */
 
22
int
 
23
__bam_pg_alloc_log(dbenv, txnid, ret_lsnp, flags,
 
24
        fileid, meta_lsn, page_lsn, pgno, ptype, next)
 
25
        DB_ENV *dbenv;
 
26
        DB_TXN *txnid;
 
27
        DB_LSN *ret_lsnp;
 
28
        u_int32_t flags;
 
29
        int32_t fileid;
 
30
        DB_LSN * meta_lsn;
 
31
        DB_LSN * page_lsn;
 
32
        db_pgno_t pgno;
 
33
        u_int32_t ptype;
 
34
        db_pgno_t next;
 
35
{
 
36
        DBT logrec;
 
37
        DB_LSN *lsnp, null_lsn;
 
38
        u_int32_t rectype, txn_num;
 
39
        int ret;
 
40
        u_int8_t *bp;
 
41
 
 
42
        rectype = DB_bam_pg_alloc;
 
43
        if (txnid != NULL &&
 
44
            TAILQ_FIRST(&txnid->kids) != NULL &&
 
45
            (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
 
46
                return (ret);
 
47
        txn_num = txnid == NULL ? 0 : txnid->txnid;
 
48
        if (txnid == NULL) {
 
49
                ZERO_LSN(null_lsn);
 
50
                lsnp = &null_lsn;
 
51
        } else
 
52
                lsnp = &txnid->last_lsn;
 
53
        logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
 
54
            + sizeof(fileid)
 
55
            + sizeof(*meta_lsn)
 
56
            + sizeof(*page_lsn)
 
57
            + sizeof(pgno)
 
58
            + sizeof(ptype)
 
59
            + sizeof(next);
 
60
        if ((ret = __os_malloc(dbenv, logrec.size, &logrec.data)) != 0)
 
61
                return (ret);
 
62
 
 
63
        bp = logrec.data;
 
64
        memcpy(bp, &rectype, sizeof(rectype));
 
65
        bp += sizeof(rectype);
 
66
        memcpy(bp, &txn_num, sizeof(txn_num));
 
67
        bp += sizeof(txn_num);
 
68
        memcpy(bp, lsnp, sizeof(DB_LSN));
 
69
        bp += sizeof(DB_LSN);
 
70
        memcpy(bp, &fileid, sizeof(fileid));
 
71
        bp += sizeof(fileid);
 
72
        if (meta_lsn != NULL)
 
73
                memcpy(bp, meta_lsn, sizeof(*meta_lsn));
 
74
        else
 
75
                memset(bp, 0, sizeof(*meta_lsn));
 
76
        bp += sizeof(*meta_lsn);
 
77
        if (page_lsn != NULL)
 
78
                memcpy(bp, page_lsn, sizeof(*page_lsn));
 
79
        else
 
80
                memset(bp, 0, sizeof(*page_lsn));
 
81
        bp += sizeof(*page_lsn);
 
82
        memcpy(bp, &pgno, sizeof(pgno));
 
83
        bp += sizeof(pgno);
 
84
        memcpy(bp, &ptype, sizeof(ptype));
 
85
        bp += sizeof(ptype);
 
86
        memcpy(bp, &next, sizeof(next));
 
87
        bp += sizeof(next);
 
88
        DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
 
89
        ret = log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
 
90
        if (txnid != NULL && ret == 0)
 
91
                txnid->last_lsn = *ret_lsnp;
 
92
#ifdef LOG_DIAGNOSTIC
 
93
        if (ret != 0)
 
94
                (void)__bam_pg_alloc_print(dbenv,
 
95
                    (DBT *)&logrec, ret_lsnp, NULL, NULL);
 
96
#endif
 
97
        __os_free(dbenv, logrec.data, logrec.size);
 
98
        return (ret);
 
99
}
 
100
 
 
101
/*
 
102
 * PUBLIC: int __bam_pg_alloc_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
 
103
 * PUBLIC:      void *));
 
104
 */
 
105
int
 
106
__bam_pg_alloc_print(dbenv, dbtp, lsnp, notused2, notused3)
 
107
        DB_ENV *dbenv;
 
108
        DBT *dbtp;
 
109
        DB_LSN *lsnp;
 
110
        db_recops notused2;
 
111
        void *notused3;
 
112
{
 
113
        __bam_pg_alloc_args *argp;
 
114
        u_int32_t i;
 
115
        u_int ch;
 
116
        int ret;
 
117
 
 
118
        i = 0;
 
119
        ch = 0;
 
120
        notused2 = DB_TXN_ABORT;
 
121
        notused3 = NULL;
 
122
 
 
123
        if ((ret = __bam_pg_alloc_read(dbenv, dbtp->data, &argp)) != 0)
 
124
                return (ret);
 
125
        (void)printf(
 
126
            "[%lu][%lu]bam_pg_alloc: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
 
127
            (u_long)lsnp->file,
 
128
            (u_long)lsnp->offset,
 
129
            (u_long)argp->type,
 
130
            (u_long)argp->txnid->txnid,
 
131
            (u_long)argp->prev_lsn.file,
 
132
            (u_long)argp->prev_lsn.offset);
 
133
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
 
134
        (void)printf("\tmeta_lsn: [%lu][%lu]\n",
 
135
            (u_long)argp->meta_lsn.file, (u_long)argp->meta_lsn.offset);
 
136
        (void)printf("\tpage_lsn: [%lu][%lu]\n",
 
137
            (u_long)argp->page_lsn.file, (u_long)argp->page_lsn.offset);
 
138
        (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
 
139
        (void)printf("\tptype: %lu\n", (u_long)argp->ptype);
 
140
        (void)printf("\tnext: %lu\n", (u_long)argp->next);
 
141
        (void)printf("\n");
 
142
        __os_free(dbenv, argp, 0);
 
143
        return (0);
 
144
}
 
145
 
 
146
/*
 
147
 * PUBLIC: int __bam_pg_alloc_read __P((DB_ENV *, void *,
 
148
 * PUBLIC:      __bam_pg_alloc_args **));
 
149
 */
 
150
int
 
151
__bam_pg_alloc_read(dbenv, recbuf, argpp)
 
152
        DB_ENV *dbenv;
 
153
        void *recbuf;
 
154
        __bam_pg_alloc_args **argpp;
 
155
{
 
156
        __bam_pg_alloc_args *argp;
 
157
        u_int8_t *bp;
 
158
        int ret;
 
159
 
 
160
        ret = __os_malloc(dbenv, sizeof(__bam_pg_alloc_args) +
 
161
            sizeof(DB_TXN), &argp);
 
162
        if (ret != 0)
 
163
                return (ret);
 
164
        argp->txnid = (DB_TXN *)&argp[1];
 
165
        bp = recbuf;
 
166
        memcpy(&argp->type, bp, sizeof(argp->type));
 
167
        bp += sizeof(argp->type);
 
168
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
 
169
        bp += sizeof(argp->txnid->txnid);
 
170
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
 
171
        bp += sizeof(DB_LSN);
 
172
        memcpy(&argp->fileid, bp, sizeof(argp->fileid));
 
173
        bp += sizeof(argp->fileid);
 
174
        memcpy(&argp->meta_lsn, bp,  sizeof(argp->meta_lsn));
 
175
        bp += sizeof(argp->meta_lsn);
 
176
        memcpy(&argp->page_lsn, bp,  sizeof(argp->page_lsn));
 
177
        bp += sizeof(argp->page_lsn);
 
178
        memcpy(&argp->pgno, bp, sizeof(argp->pgno));
 
179
        bp += sizeof(argp->pgno);
 
180
        memcpy(&argp->ptype, bp, sizeof(argp->ptype));
 
181
        bp += sizeof(argp->ptype);
 
182
        memcpy(&argp->next, bp, sizeof(argp->next));
 
183
        bp += sizeof(argp->next);
 
184
        *argpp = argp;
 
185
        return (0);
 
186
}
 
187
 
 
188
/*
 
189
 * PUBLIC: int __bam_pg_alloc1_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
 
190
 * PUBLIC:      void *));
 
191
 */
 
192
int
 
193
__bam_pg_alloc1_print(dbenv, dbtp, lsnp, notused2, notused3)
 
194
        DB_ENV *dbenv;
 
195
        DBT *dbtp;
 
196
        DB_LSN *lsnp;
 
197
        db_recops notused2;
 
198
        void *notused3;
 
199
{
 
200
        __bam_pg_alloc1_args *argp;
 
201
        u_int32_t i;
 
202
        u_int ch;
 
203
        int ret;
 
204
 
 
205
        i = 0;
 
206
        ch = 0;
 
207
        notused2 = DB_TXN_ABORT;
 
208
        notused3 = NULL;
 
209
 
 
210
        if ((ret = __bam_pg_alloc1_read(dbenv, dbtp->data, &argp)) != 0)
 
211
                return (ret);
 
212
        (void)printf(
 
213
            "[%lu][%lu]bam_pg_alloc1: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
 
214
            (u_long)lsnp->file,
 
215
            (u_long)lsnp->offset,
 
216
            (u_long)argp->type,
 
217
            (u_long)argp->txnid->txnid,
 
218
            (u_long)argp->prev_lsn.file,
 
219
            (u_long)argp->prev_lsn.offset);
 
220
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
 
221
        (void)printf("\tmeta_lsn: [%lu][%lu]\n",
 
222
            (u_long)argp->meta_lsn.file, (u_long)argp->meta_lsn.offset);
 
223
        (void)printf("\talloc_lsn: [%lu][%lu]\n",
 
224
            (u_long)argp->alloc_lsn.file, (u_long)argp->alloc_lsn.offset);
 
225
        (void)printf("\tpage_lsn: [%lu][%lu]\n",
 
226
            (u_long)argp->page_lsn.file, (u_long)argp->page_lsn.offset);
 
227
        (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
 
228
        (void)printf("\tptype: %lu\n", (u_long)argp->ptype);
 
229
        (void)printf("\tnext: %lu\n", (u_long)argp->next);
 
230
        (void)printf("\n");
 
231
        __os_free(dbenv, argp, 0);
 
232
        return (0);
 
233
}
 
234
 
 
235
/*
 
236
 * PUBLIC: int __bam_pg_alloc1_read __P((DB_ENV *, void *,
 
237
 * PUBLIC:      __bam_pg_alloc1_args **));
 
238
 */
 
239
int
 
240
__bam_pg_alloc1_read(dbenv, recbuf, argpp)
 
241
        DB_ENV *dbenv;
 
242
        void *recbuf;
 
243
        __bam_pg_alloc1_args **argpp;
 
244
{
 
245
        __bam_pg_alloc1_args *argp;
 
246
        u_int8_t *bp;
 
247
        int ret;
 
248
 
 
249
        ret = __os_malloc(dbenv, sizeof(__bam_pg_alloc1_args) +
 
250
            sizeof(DB_TXN), &argp);
 
251
        if (ret != 0)
 
252
                return (ret);
 
253
        argp->txnid = (DB_TXN *)&argp[1];
 
254
        bp = recbuf;
 
255
        memcpy(&argp->type, bp, sizeof(argp->type));
 
256
        bp += sizeof(argp->type);
 
257
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
 
258
        bp += sizeof(argp->txnid->txnid);
 
259
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
 
260
        bp += sizeof(DB_LSN);
 
261
        memcpy(&argp->fileid, bp, sizeof(argp->fileid));
 
262
        bp += sizeof(argp->fileid);
 
263
        memcpy(&argp->meta_lsn, bp,  sizeof(argp->meta_lsn));
 
264
        bp += sizeof(argp->meta_lsn);
 
265
        memcpy(&argp->alloc_lsn, bp,  sizeof(argp->alloc_lsn));
 
266
        bp += sizeof(argp->alloc_lsn);
 
267
        memcpy(&argp->page_lsn, bp,  sizeof(argp->page_lsn));
 
268
        bp += sizeof(argp->page_lsn);
 
269
        memcpy(&argp->pgno, bp, sizeof(argp->pgno));
 
270
        bp += sizeof(argp->pgno);
 
271
        memcpy(&argp->ptype, bp, sizeof(argp->ptype));
 
272
        bp += sizeof(argp->ptype);
 
273
        memcpy(&argp->next, bp, sizeof(argp->next));
 
274
        bp += sizeof(argp->next);
 
275
        *argpp = argp;
 
276
        return (0);
 
277
}
 
278
 
 
279
/*
 
280
 * PUBLIC: int __bam_pg_free_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t,
 
281
 * PUBLIC:      int32_t, db_pgno_t, DB_LSN *, const DBT *, db_pgno_t));
 
282
 */
 
283
int
 
284
__bam_pg_free_log(dbenv, txnid, ret_lsnp, flags,
 
285
        fileid, pgno, meta_lsn, header, next)
 
286
        DB_ENV *dbenv;
 
287
        DB_TXN *txnid;
 
288
        DB_LSN *ret_lsnp;
 
289
        u_int32_t flags;
 
290
        int32_t fileid;
 
291
        db_pgno_t pgno;
 
292
        DB_LSN * meta_lsn;
 
293
        const DBT *header;
 
294
        db_pgno_t next;
 
295
{
 
296
        DBT logrec;
 
297
        DB_LSN *lsnp, null_lsn;
 
298
        u_int32_t zero;
 
299
        u_int32_t rectype, txn_num;
 
300
        int ret;
 
301
        u_int8_t *bp;
 
302
 
 
303
        rectype = DB_bam_pg_free;
 
304
        if (txnid != NULL &&
 
305
            TAILQ_FIRST(&txnid->kids) != NULL &&
 
306
            (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
 
307
                return (ret);
 
308
        txn_num = txnid == NULL ? 0 : txnid->txnid;
 
309
        if (txnid == NULL) {
 
310
                ZERO_LSN(null_lsn);
 
311
                lsnp = &null_lsn;
 
312
        } else
 
313
                lsnp = &txnid->last_lsn;
 
314
        logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
 
315
            + sizeof(fileid)
 
316
            + sizeof(pgno)
 
317
            + sizeof(*meta_lsn)
 
318
            + sizeof(u_int32_t) + (header == NULL ? 0 : header->size)
 
319
            + sizeof(next);
 
320
        if ((ret = __os_malloc(dbenv, logrec.size, &logrec.data)) != 0)
 
321
                return (ret);
 
322
 
 
323
        bp = logrec.data;
 
324
        memcpy(bp, &rectype, sizeof(rectype));
 
325
        bp += sizeof(rectype);
 
326
        memcpy(bp, &txn_num, sizeof(txn_num));
 
327
        bp += sizeof(txn_num);
 
328
        memcpy(bp, lsnp, sizeof(DB_LSN));
 
329
        bp += sizeof(DB_LSN);
 
330
        memcpy(bp, &fileid, sizeof(fileid));
 
331
        bp += sizeof(fileid);
 
332
        memcpy(bp, &pgno, sizeof(pgno));
 
333
        bp += sizeof(pgno);
 
334
        if (meta_lsn != NULL)
 
335
                memcpy(bp, meta_lsn, sizeof(*meta_lsn));
 
336
        else
 
337
                memset(bp, 0, sizeof(*meta_lsn));
 
338
        bp += sizeof(*meta_lsn);
 
339
        if (header == NULL) {
 
340
                zero = 0;
 
341
                memcpy(bp, &zero, sizeof(u_int32_t));
 
342
                bp += sizeof(u_int32_t);
 
343
        } else {
 
344
                memcpy(bp, &header->size, sizeof(header->size));
 
345
                bp += sizeof(header->size);
 
346
                memcpy(bp, header->data, header->size);
 
347
                bp += header->size;
 
348
        }
 
349
        memcpy(bp, &next, sizeof(next));
 
350
        bp += sizeof(next);
 
351
        DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
 
352
        ret = log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
 
353
        if (txnid != NULL && ret == 0)
 
354
                txnid->last_lsn = *ret_lsnp;
 
355
#ifdef LOG_DIAGNOSTIC
 
356
        if (ret != 0)
 
357
                (void)__bam_pg_free_print(dbenv,
 
358
                    (DBT *)&logrec, ret_lsnp, NULL, NULL);
 
359
#endif
 
360
        __os_free(dbenv, logrec.data, logrec.size);
 
361
        return (ret);
 
362
}
 
363
 
 
364
/*
 
365
 * PUBLIC: int __bam_pg_free_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
 
366
 * PUBLIC:      void *));
 
367
 */
 
368
int
 
369
__bam_pg_free_print(dbenv, dbtp, lsnp, notused2, notused3)
 
370
        DB_ENV *dbenv;
 
371
        DBT *dbtp;
 
372
        DB_LSN *lsnp;
 
373
        db_recops notused2;
 
374
        void *notused3;
 
375
{
 
376
        __bam_pg_free_args *argp;
 
377
        u_int32_t i;
 
378
        u_int ch;
 
379
        int ret;
 
380
 
 
381
        i = 0;
 
382
        ch = 0;
 
383
        notused2 = DB_TXN_ABORT;
 
384
        notused3 = NULL;
 
385
 
 
386
        if ((ret = __bam_pg_free_read(dbenv, dbtp->data, &argp)) != 0)
 
387
                return (ret);
 
388
        (void)printf(
 
389
            "[%lu][%lu]bam_pg_free: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
 
390
            (u_long)lsnp->file,
 
391
            (u_long)lsnp->offset,
 
392
            (u_long)argp->type,
 
393
            (u_long)argp->txnid->txnid,
 
394
            (u_long)argp->prev_lsn.file,
 
395
            (u_long)argp->prev_lsn.offset);
 
396
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
 
397
        (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
 
398
        (void)printf("\tmeta_lsn: [%lu][%lu]\n",
 
399
            (u_long)argp->meta_lsn.file, (u_long)argp->meta_lsn.offset);
 
400
        (void)printf("\theader: ");
 
401
        for (i = 0; i < argp->header.size; i++) {
 
402
                ch = ((u_int8_t *)argp->header.data)[i];
 
403
                if (isprint(ch) || ch == 0xa)
 
404
                        (void)putchar(ch);
 
405
                else
 
406
                        (void)printf("%#x ", ch);
 
407
        }
 
408
        (void)printf("\n");
 
409
        (void)printf("\tnext: %lu\n", (u_long)argp->next);
 
410
        (void)printf("\n");
 
411
        __os_free(dbenv, argp, 0);
 
412
        return (0);
 
413
}
 
414
 
 
415
/*
 
416
 * PUBLIC: int __bam_pg_free_read __P((DB_ENV *, void *,
 
417
 * PUBLIC:      __bam_pg_free_args **));
 
418
 */
 
419
int
 
420
__bam_pg_free_read(dbenv, recbuf, argpp)
 
421
        DB_ENV *dbenv;
 
422
        void *recbuf;
 
423
        __bam_pg_free_args **argpp;
 
424
{
 
425
        __bam_pg_free_args *argp;
 
426
        u_int8_t *bp;
 
427
        int ret;
 
428
 
 
429
        ret = __os_malloc(dbenv, sizeof(__bam_pg_free_args) +
 
430
            sizeof(DB_TXN), &argp);
 
431
        if (ret != 0)
 
432
                return (ret);
 
433
        argp->txnid = (DB_TXN *)&argp[1];
 
434
        bp = recbuf;
 
435
        memcpy(&argp->type, bp, sizeof(argp->type));
 
436
        bp += sizeof(argp->type);
 
437
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
 
438
        bp += sizeof(argp->txnid->txnid);
 
439
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
 
440
        bp += sizeof(DB_LSN);
 
441
        memcpy(&argp->fileid, bp, sizeof(argp->fileid));
 
442
        bp += sizeof(argp->fileid);
 
443
        memcpy(&argp->pgno, bp, sizeof(argp->pgno));
 
444
        bp += sizeof(argp->pgno);
 
445
        memcpy(&argp->meta_lsn, bp,  sizeof(argp->meta_lsn));
 
446
        bp += sizeof(argp->meta_lsn);
 
447
        memset(&argp->header, 0, sizeof(argp->header));
 
448
        memcpy(&argp->header.size, bp, sizeof(u_int32_t));
 
449
        bp += sizeof(u_int32_t);
 
450
        argp->header.data = bp;
 
451
        bp += argp->header.size;
 
452
        memcpy(&argp->next, bp, sizeof(argp->next));
 
453
        bp += sizeof(argp->next);
 
454
        *argpp = argp;
 
455
        return (0);
 
456
}
 
457
 
 
458
/*
 
459
 * PUBLIC: int __bam_pg_free1_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
 
460
 * PUBLIC:      void *));
 
461
 */
 
462
int
 
463
__bam_pg_free1_print(dbenv, dbtp, lsnp, notused2, notused3)
 
464
        DB_ENV *dbenv;
 
465
        DBT *dbtp;
 
466
        DB_LSN *lsnp;
 
467
        db_recops notused2;
 
468
        void *notused3;
 
469
{
 
470
        __bam_pg_free1_args *argp;
 
471
        u_int32_t i;
 
472
        u_int ch;
 
473
        int ret;
 
474
 
 
475
        i = 0;
 
476
        ch = 0;
 
477
        notused2 = DB_TXN_ABORT;
 
478
        notused3 = NULL;
 
479
 
 
480
        if ((ret = __bam_pg_free1_read(dbenv, dbtp->data, &argp)) != 0)
 
481
                return (ret);
 
482
        (void)printf(
 
483
            "[%lu][%lu]bam_pg_free1: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
 
484
            (u_long)lsnp->file,
 
485
            (u_long)lsnp->offset,
 
486
            (u_long)argp->type,
 
487
            (u_long)argp->txnid->txnid,
 
488
            (u_long)argp->prev_lsn.file,
 
489
            (u_long)argp->prev_lsn.offset);
 
490
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
 
491
        (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
 
492
        (void)printf("\tmeta_lsn: [%lu][%lu]\n",
 
493
            (u_long)argp->meta_lsn.file, (u_long)argp->meta_lsn.offset);
 
494
        (void)printf("\talloc_lsn: [%lu][%lu]\n",
 
495
            (u_long)argp->alloc_lsn.file, (u_long)argp->alloc_lsn.offset);
 
496
        (void)printf("\theader: ");
 
497
        for (i = 0; i < argp->header.size; i++) {
 
498
                ch = ((u_int8_t *)argp->header.data)[i];
 
499
                if (isprint(ch) || ch == 0xa)
 
500
                        (void)putchar(ch);
 
501
                else
 
502
                        (void)printf("%#x ", ch);
 
503
        }
 
504
        (void)printf("\n");
 
505
        (void)printf("\tnext: %lu\n", (u_long)argp->next);
 
506
        (void)printf("\n");
 
507
        __os_free(dbenv, argp, 0);
 
508
        return (0);
 
509
}
 
510
 
 
511
/*
 
512
 * PUBLIC: int __bam_pg_free1_read __P((DB_ENV *, void *,
 
513
 * PUBLIC:      __bam_pg_free1_args **));
 
514
 */
 
515
int
 
516
__bam_pg_free1_read(dbenv, recbuf, argpp)
 
517
        DB_ENV *dbenv;
 
518
        void *recbuf;
 
519
        __bam_pg_free1_args **argpp;
 
520
{
 
521
        __bam_pg_free1_args *argp;
 
522
        u_int8_t *bp;
 
523
        int ret;
 
524
 
 
525
        ret = __os_malloc(dbenv, sizeof(__bam_pg_free1_args) +
 
526
            sizeof(DB_TXN), &argp);
 
527
        if (ret != 0)
 
528
                return (ret);
 
529
        argp->txnid = (DB_TXN *)&argp[1];
 
530
        bp = recbuf;
 
531
        memcpy(&argp->type, bp, sizeof(argp->type));
 
532
        bp += sizeof(argp->type);
 
533
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
 
534
        bp += sizeof(argp->txnid->txnid);
 
535
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
 
536
        bp += sizeof(DB_LSN);
 
537
        memcpy(&argp->fileid, bp, sizeof(argp->fileid));
 
538
        bp += sizeof(argp->fileid);
 
539
        memcpy(&argp->pgno, bp, sizeof(argp->pgno));
 
540
        bp += sizeof(argp->pgno);
 
541
        memcpy(&argp->meta_lsn, bp,  sizeof(argp->meta_lsn));
 
542
        bp += sizeof(argp->meta_lsn);
 
543
        memcpy(&argp->alloc_lsn, bp,  sizeof(argp->alloc_lsn));
 
544
        bp += sizeof(argp->alloc_lsn);
 
545
        memset(&argp->header, 0, sizeof(argp->header));
 
546
        memcpy(&argp->header.size, bp, sizeof(u_int32_t));
 
547
        bp += sizeof(u_int32_t);
 
548
        argp->header.data = bp;
 
549
        bp += argp->header.size;
 
550
        memcpy(&argp->next, bp, sizeof(argp->next));
 
551
        bp += sizeof(argp->next);
 
552
        *argpp = argp;
 
553
        return (0);
 
554
}
 
555
 
 
556
/*
 
557
 * PUBLIC: int __bam_split1_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
 
558
 * PUBLIC:      void *));
 
559
 */
 
560
int
 
561
__bam_split1_print(dbenv, dbtp, lsnp, notused2, notused3)
 
562
        DB_ENV *dbenv;
 
563
        DBT *dbtp;
 
564
        DB_LSN *lsnp;
 
565
        db_recops notused2;
 
566
        void *notused3;
 
567
{
 
568
        __bam_split1_args *argp;
 
569
        u_int32_t i;
 
570
        u_int ch;
 
571
        int ret;
 
572
 
 
573
        i = 0;
 
574
        ch = 0;
 
575
        notused2 = DB_TXN_ABORT;
 
576
        notused3 = NULL;
 
577
 
 
578
        if ((ret = __bam_split1_read(dbenv, dbtp->data, &argp)) != 0)
 
579
                return (ret);
 
580
        (void)printf(
 
581
            "[%lu][%lu]bam_split1: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
 
582
            (u_long)lsnp->file,
 
583
            (u_long)lsnp->offset,
 
584
            (u_long)argp->type,
 
585
            (u_long)argp->txnid->txnid,
 
586
            (u_long)argp->prev_lsn.file,
 
587
            (u_long)argp->prev_lsn.offset);
 
588
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
 
589
        (void)printf("\tleft: %lu\n", (u_long)argp->left);
 
590
        (void)printf("\tllsn: [%lu][%lu]\n",
 
591
            (u_long)argp->llsn.file, (u_long)argp->llsn.offset);
 
592
        (void)printf("\tright: %lu\n", (u_long)argp->right);
 
593
        (void)printf("\trlsn: [%lu][%lu]\n",
 
594
            (u_long)argp->rlsn.file, (u_long)argp->rlsn.offset);
 
595
        (void)printf("\tindx: %lu\n", (u_long)argp->indx);
 
596
        (void)printf("\tnpgno: %lu\n", (u_long)argp->npgno);
 
597
        (void)printf("\tnlsn: [%lu][%lu]\n",
 
598
            (u_long)argp->nlsn.file, (u_long)argp->nlsn.offset);
 
599
        (void)printf("\tpg: ");
 
600
        for (i = 0; i < argp->pg.size; i++) {
 
601
                ch = ((u_int8_t *)argp->pg.data)[i];
 
602
                if (isprint(ch) || ch == 0xa)
 
603
                        (void)putchar(ch);
 
604
                else
 
605
                        (void)printf("%#x ", ch);
 
606
        }
 
607
        (void)printf("\n");
 
608
        (void)printf("\n");
 
609
        __os_free(dbenv, argp, 0);
 
610
        return (0);
 
611
}
 
612
 
 
613
/*
 
614
 * PUBLIC: int __bam_split1_read __P((DB_ENV *, void *, __bam_split1_args **));
 
615
 */
 
616
int
 
617
__bam_split1_read(dbenv, recbuf, argpp)
 
618
        DB_ENV *dbenv;
 
619
        void *recbuf;
 
620
        __bam_split1_args **argpp;
 
621
{
 
622
        __bam_split1_args *argp;
 
623
        u_int8_t *bp;
 
624
        int ret;
 
625
 
 
626
        ret = __os_malloc(dbenv, sizeof(__bam_split1_args) +
 
627
            sizeof(DB_TXN), &argp);
 
628
        if (ret != 0)
 
629
                return (ret);
 
630
        argp->txnid = (DB_TXN *)&argp[1];
 
631
        bp = recbuf;
 
632
        memcpy(&argp->type, bp, sizeof(argp->type));
 
633
        bp += sizeof(argp->type);
 
634
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
 
635
        bp += sizeof(argp->txnid->txnid);
 
636
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
 
637
        bp += sizeof(DB_LSN);
 
638
        memcpy(&argp->fileid, bp, sizeof(argp->fileid));
 
639
        bp += sizeof(argp->fileid);
 
640
        memcpy(&argp->left, bp, sizeof(argp->left));
 
641
        bp += sizeof(argp->left);
 
642
        memcpy(&argp->llsn, bp,  sizeof(argp->llsn));
 
643
        bp += sizeof(argp->llsn);
 
644
        memcpy(&argp->right, bp, sizeof(argp->right));
 
645
        bp += sizeof(argp->right);
 
646
        memcpy(&argp->rlsn, bp,  sizeof(argp->rlsn));
 
647
        bp += sizeof(argp->rlsn);
 
648
        memcpy(&argp->indx, bp, sizeof(argp->indx));
 
649
        bp += sizeof(argp->indx);
 
650
        memcpy(&argp->npgno, bp, sizeof(argp->npgno));
 
651
        bp += sizeof(argp->npgno);
 
652
        memcpy(&argp->nlsn, bp,  sizeof(argp->nlsn));
 
653
        bp += sizeof(argp->nlsn);
 
654
        memset(&argp->pg, 0, sizeof(argp->pg));
 
655
        memcpy(&argp->pg.size, bp, sizeof(u_int32_t));
 
656
        bp += sizeof(u_int32_t);
 
657
        argp->pg.data = bp;
 
658
        bp += argp->pg.size;
 
659
        *argpp = argp;
 
660
        return (0);
 
661
}
 
662
 
 
663
/*
 
664
 * PUBLIC: int __bam_split_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t,
 
665
 * PUBLIC:      int32_t, db_pgno_t, DB_LSN *, db_pgno_t, DB_LSN *, u_int32_t, db_pgno_t, DB_LSN *,
 
666
 * PUBLIC:      db_pgno_t, const DBT *, u_int32_t));
 
667
 */
 
668
int
 
669
__bam_split_log(dbenv, txnid, ret_lsnp, flags,
 
670
        fileid, left, llsn, right, rlsn, indx,
 
671
        npgno, nlsn, root_pgno, pg, opflags)
 
672
        DB_ENV *dbenv;
 
673
        DB_TXN *txnid;
 
674
        DB_LSN *ret_lsnp;
 
675
        u_int32_t flags;
 
676
        int32_t fileid;
 
677
        db_pgno_t left;
 
678
        DB_LSN * llsn;
 
679
        db_pgno_t right;
 
680
        DB_LSN * rlsn;
 
681
        u_int32_t indx;
 
682
        db_pgno_t npgno;
 
683
        DB_LSN * nlsn;
 
684
        db_pgno_t root_pgno;
 
685
        const DBT *pg;
 
686
        u_int32_t opflags;
 
687
{
 
688
        DBT logrec;
 
689
        DB_LSN *lsnp, null_lsn;
 
690
        u_int32_t zero;
 
691
        u_int32_t rectype, txn_num;
 
692
        int ret;
 
693
        u_int8_t *bp;
 
694
 
 
695
        rectype = DB_bam_split;
 
696
        if (txnid != NULL &&
 
697
            TAILQ_FIRST(&txnid->kids) != NULL &&
 
698
            (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
 
699
                return (ret);
 
700
        txn_num = txnid == NULL ? 0 : txnid->txnid;
 
701
        if (txnid == NULL) {
 
702
                ZERO_LSN(null_lsn);
 
703
                lsnp = &null_lsn;
 
704
        } else
 
705
                lsnp = &txnid->last_lsn;
 
706
        logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
 
707
            + sizeof(fileid)
 
708
            + sizeof(left)
 
709
            + sizeof(*llsn)
 
710
            + sizeof(right)
 
711
            + sizeof(*rlsn)
 
712
            + sizeof(indx)
 
713
            + sizeof(npgno)
 
714
            + sizeof(*nlsn)
 
715
            + sizeof(root_pgno)
 
716
            + sizeof(u_int32_t) + (pg == NULL ? 0 : pg->size)
 
717
            + sizeof(opflags);
 
718
        if ((ret = __os_malloc(dbenv, logrec.size, &logrec.data)) != 0)
 
719
                return (ret);
 
720
 
 
721
        bp = logrec.data;
 
722
        memcpy(bp, &rectype, sizeof(rectype));
 
723
        bp += sizeof(rectype);
 
724
        memcpy(bp, &txn_num, sizeof(txn_num));
 
725
        bp += sizeof(txn_num);
 
726
        memcpy(bp, lsnp, sizeof(DB_LSN));
 
727
        bp += sizeof(DB_LSN);
 
728
        memcpy(bp, &fileid, sizeof(fileid));
 
729
        bp += sizeof(fileid);
 
730
        memcpy(bp, &left, sizeof(left));
 
731
        bp += sizeof(left);
 
732
        if (llsn != NULL)
 
733
                memcpy(bp, llsn, sizeof(*llsn));
 
734
        else
 
735
                memset(bp, 0, sizeof(*llsn));
 
736
        bp += sizeof(*llsn);
 
737
        memcpy(bp, &right, sizeof(right));
 
738
        bp += sizeof(right);
 
739
        if (rlsn != NULL)
 
740
                memcpy(bp, rlsn, sizeof(*rlsn));
 
741
        else
 
742
                memset(bp, 0, sizeof(*rlsn));
 
743
        bp += sizeof(*rlsn);
 
744
        memcpy(bp, &indx, sizeof(indx));
 
745
        bp += sizeof(indx);
 
746
        memcpy(bp, &npgno, sizeof(npgno));
 
747
        bp += sizeof(npgno);
 
748
        if (nlsn != NULL)
 
749
                memcpy(bp, nlsn, sizeof(*nlsn));
 
750
        else
 
751
                memset(bp, 0, sizeof(*nlsn));
 
752
        bp += sizeof(*nlsn);
 
753
        memcpy(bp, &root_pgno, sizeof(root_pgno));
 
754
        bp += sizeof(root_pgno);
 
755
        if (pg == NULL) {
 
756
                zero = 0;
 
757
                memcpy(bp, &zero, sizeof(u_int32_t));
 
758
                bp += sizeof(u_int32_t);
 
759
        } else {
 
760
                memcpy(bp, &pg->size, sizeof(pg->size));
 
761
                bp += sizeof(pg->size);
 
762
                memcpy(bp, pg->data, pg->size);
 
763
                bp += pg->size;
 
764
        }
 
765
        memcpy(bp, &opflags, sizeof(opflags));
 
766
        bp += sizeof(opflags);
 
767
        DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
 
768
        ret = log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
 
769
        if (txnid != NULL && ret == 0)
 
770
                txnid->last_lsn = *ret_lsnp;
 
771
#ifdef LOG_DIAGNOSTIC
 
772
        if (ret != 0)
 
773
                (void)__bam_split_print(dbenv,
 
774
                    (DBT *)&logrec, ret_lsnp, NULL, NULL);
 
775
#endif
 
776
        __os_free(dbenv, logrec.data, logrec.size);
 
777
        return (ret);
 
778
}
 
779
 
 
780
/*
 
781
 * PUBLIC: int __bam_split_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
 
782
 * PUBLIC:      void *));
 
783
 */
 
784
int
 
785
__bam_split_print(dbenv, dbtp, lsnp, notused2, notused3)
 
786
        DB_ENV *dbenv;
 
787
        DBT *dbtp;
 
788
        DB_LSN *lsnp;
 
789
        db_recops notused2;
 
790
        void *notused3;
 
791
{
 
792
        __bam_split_args *argp;
 
793
        u_int32_t i;
 
794
        u_int ch;
 
795
        int ret;
 
796
 
 
797
        i = 0;
 
798
        ch = 0;
 
799
        notused2 = DB_TXN_ABORT;
 
800
        notused3 = NULL;
 
801
 
 
802
        if ((ret = __bam_split_read(dbenv, dbtp->data, &argp)) != 0)
 
803
                return (ret);
 
804
        (void)printf(
 
805
            "[%lu][%lu]bam_split: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
 
806
            (u_long)lsnp->file,
 
807
            (u_long)lsnp->offset,
 
808
            (u_long)argp->type,
 
809
            (u_long)argp->txnid->txnid,
 
810
            (u_long)argp->prev_lsn.file,
 
811
            (u_long)argp->prev_lsn.offset);
 
812
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
 
813
        (void)printf("\tleft: %lu\n", (u_long)argp->left);
 
814
        (void)printf("\tllsn: [%lu][%lu]\n",
 
815
            (u_long)argp->llsn.file, (u_long)argp->llsn.offset);
 
816
        (void)printf("\tright: %lu\n", (u_long)argp->right);
 
817
        (void)printf("\trlsn: [%lu][%lu]\n",
 
818
            (u_long)argp->rlsn.file, (u_long)argp->rlsn.offset);
 
819
        (void)printf("\tindx: %lu\n", (u_long)argp->indx);
 
820
        (void)printf("\tnpgno: %lu\n", (u_long)argp->npgno);
 
821
        (void)printf("\tnlsn: [%lu][%lu]\n",
 
822
            (u_long)argp->nlsn.file, (u_long)argp->nlsn.offset);
 
823
        (void)printf("\troot_pgno: %lu\n", (u_long)argp->root_pgno);
 
824
        (void)printf("\tpg: ");
 
825
        for (i = 0; i < argp->pg.size; i++) {
 
826
                ch = ((u_int8_t *)argp->pg.data)[i];
 
827
                if (isprint(ch) || ch == 0xa)
 
828
                        (void)putchar(ch);
 
829
                else
 
830
                        (void)printf("%#x ", ch);
 
831
        }
 
832
        (void)printf("\n");
 
833
        (void)printf("\topflags: %lu\n", (u_long)argp->opflags);
 
834
        (void)printf("\n");
 
835
        __os_free(dbenv, argp, 0);
 
836
        return (0);
 
837
}
 
838
 
 
839
/*
 
840
 * PUBLIC: int __bam_split_read __P((DB_ENV *, void *, __bam_split_args **));
 
841
 */
 
842
int
 
843
__bam_split_read(dbenv, recbuf, argpp)
 
844
        DB_ENV *dbenv;
 
845
        void *recbuf;
 
846
        __bam_split_args **argpp;
 
847
{
 
848
        __bam_split_args *argp;
 
849
        u_int8_t *bp;
 
850
        int ret;
 
851
 
 
852
        ret = __os_malloc(dbenv, sizeof(__bam_split_args) +
 
853
            sizeof(DB_TXN), &argp);
 
854
        if (ret != 0)
 
855
                return (ret);
 
856
        argp->txnid = (DB_TXN *)&argp[1];
 
857
        bp = recbuf;
 
858
        memcpy(&argp->type, bp, sizeof(argp->type));
 
859
        bp += sizeof(argp->type);
 
860
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
 
861
        bp += sizeof(argp->txnid->txnid);
 
862
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
 
863
        bp += sizeof(DB_LSN);
 
864
        memcpy(&argp->fileid, bp, sizeof(argp->fileid));
 
865
        bp += sizeof(argp->fileid);
 
866
        memcpy(&argp->left, bp, sizeof(argp->left));
 
867
        bp += sizeof(argp->left);
 
868
        memcpy(&argp->llsn, bp,  sizeof(argp->llsn));
 
869
        bp += sizeof(argp->llsn);
 
870
        memcpy(&argp->right, bp, sizeof(argp->right));
 
871
        bp += sizeof(argp->right);
 
872
        memcpy(&argp->rlsn, bp,  sizeof(argp->rlsn));
 
873
        bp += sizeof(argp->rlsn);
 
874
        memcpy(&argp->indx, bp, sizeof(argp->indx));
 
875
        bp += sizeof(argp->indx);
 
876
        memcpy(&argp->npgno, bp, sizeof(argp->npgno));
 
877
        bp += sizeof(argp->npgno);
 
878
        memcpy(&argp->nlsn, bp,  sizeof(argp->nlsn));
 
879
        bp += sizeof(argp->nlsn);
 
880
        memcpy(&argp->root_pgno, bp, sizeof(argp->root_pgno));
 
881
        bp += sizeof(argp->root_pgno);
 
882
        memset(&argp->pg, 0, sizeof(argp->pg));
 
883
        memcpy(&argp->pg.size, bp, sizeof(u_int32_t));
 
884
        bp += sizeof(u_int32_t);
 
885
        argp->pg.data = bp;
 
886
        bp += argp->pg.size;
 
887
        memcpy(&argp->opflags, bp, sizeof(argp->opflags));
 
888
        bp += sizeof(argp->opflags);
 
889
        *argpp = argp;
 
890
        return (0);
 
891
}
 
892
 
 
893
/*
 
894
 * PUBLIC: int __bam_rsplit1_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
 
895
 * PUBLIC:      void *));
 
896
 */
 
897
int
 
898
__bam_rsplit1_print(dbenv, dbtp, lsnp, notused2, notused3)
 
899
        DB_ENV *dbenv;
 
900
        DBT *dbtp;
 
901
        DB_LSN *lsnp;
 
902
        db_recops notused2;
 
903
        void *notused3;
 
904
{
 
905
        __bam_rsplit1_args *argp;
 
906
        u_int32_t i;
 
907
        u_int ch;
 
908
        int ret;
 
909
 
 
910
        i = 0;
 
911
        ch = 0;
 
912
        notused2 = DB_TXN_ABORT;
 
913
        notused3 = NULL;
 
914
 
 
915
        if ((ret = __bam_rsplit1_read(dbenv, dbtp->data, &argp)) != 0)
 
916
                return (ret);
 
917
        (void)printf(
 
918
            "[%lu][%lu]bam_rsplit1: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
 
919
            (u_long)lsnp->file,
 
920
            (u_long)lsnp->offset,
 
921
            (u_long)argp->type,
 
922
            (u_long)argp->txnid->txnid,
 
923
            (u_long)argp->prev_lsn.file,
 
924
            (u_long)argp->prev_lsn.offset);
 
925
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
 
926
        (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
 
927
        (void)printf("\tpgdbt: ");
 
928
        for (i = 0; i < argp->pgdbt.size; i++) {
 
929
                ch = ((u_int8_t *)argp->pgdbt.data)[i];
 
930
                if (isprint(ch) || ch == 0xa)
 
931
                        (void)putchar(ch);
 
932
                else
 
933
                        (void)printf("%#x ", ch);
 
934
        }
 
935
        (void)printf("\n");
 
936
        (void)printf("\tnrec: %lu\n", (u_long)argp->nrec);
 
937
        (void)printf("\trootent: ");
 
938
        for (i = 0; i < argp->rootent.size; i++) {
 
939
                ch = ((u_int8_t *)argp->rootent.data)[i];
 
940
                if (isprint(ch) || ch == 0xa)
 
941
                        (void)putchar(ch);
 
942
                else
 
943
                        (void)printf("%#x ", ch);
 
944
        }
 
945
        (void)printf("\n");
 
946
        (void)printf("\trootlsn: [%lu][%lu]\n",
 
947
            (u_long)argp->rootlsn.file, (u_long)argp->rootlsn.offset);
 
948
        (void)printf("\n");
 
949
        __os_free(dbenv, argp, 0);
 
950
        return (0);
 
951
}
 
952
 
 
953
/*
 
954
 * PUBLIC: int __bam_rsplit1_read __P((DB_ENV *, void *,
 
955
 * PUBLIC:      __bam_rsplit1_args **));
 
956
 */
 
957
int
 
958
__bam_rsplit1_read(dbenv, recbuf, argpp)
 
959
        DB_ENV *dbenv;
 
960
        void *recbuf;
 
961
        __bam_rsplit1_args **argpp;
 
962
{
 
963
        __bam_rsplit1_args *argp;
 
964
        u_int8_t *bp;
 
965
        int ret;
 
966
 
 
967
        ret = __os_malloc(dbenv, sizeof(__bam_rsplit1_args) +
 
968
            sizeof(DB_TXN), &argp);
 
969
        if (ret != 0)
 
970
                return (ret);
 
971
        argp->txnid = (DB_TXN *)&argp[1];
 
972
        bp = recbuf;
 
973
        memcpy(&argp->type, bp, sizeof(argp->type));
 
974
        bp += sizeof(argp->type);
 
975
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
 
976
        bp += sizeof(argp->txnid->txnid);
 
977
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
 
978
        bp += sizeof(DB_LSN);
 
979
        memcpy(&argp->fileid, bp, sizeof(argp->fileid));
 
980
        bp += sizeof(argp->fileid);
 
981
        memcpy(&argp->pgno, bp, sizeof(argp->pgno));
 
982
        bp += sizeof(argp->pgno);
 
983
        memset(&argp->pgdbt, 0, sizeof(argp->pgdbt));
 
984
        memcpy(&argp->pgdbt.size, bp, sizeof(u_int32_t));
 
985
        bp += sizeof(u_int32_t);
 
986
        argp->pgdbt.data = bp;
 
987
        bp += argp->pgdbt.size;
 
988
        memcpy(&argp->nrec, bp, sizeof(argp->nrec));
 
989
        bp += sizeof(argp->nrec);
 
990
        memset(&argp->rootent, 0, sizeof(argp->rootent));
 
991
        memcpy(&argp->rootent.size, bp, sizeof(u_int32_t));
 
992
        bp += sizeof(u_int32_t);
 
993
        argp->rootent.data = bp;
 
994
        bp += argp->rootent.size;
 
995
        memcpy(&argp->rootlsn, bp,  sizeof(argp->rootlsn));
 
996
        bp += sizeof(argp->rootlsn);
 
997
        *argpp = argp;
 
998
        return (0);
 
999
}
 
1000
 
 
1001
/*
 
1002
 * PUBLIC: int __bam_rsplit_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t,
 
1003
 * PUBLIC:      int32_t, db_pgno_t, const DBT *, db_pgno_t, db_pgno_t, const DBT *, DB_LSN *));
 
1004
 */
 
1005
int
 
1006
__bam_rsplit_log(dbenv, txnid, ret_lsnp, flags,
 
1007
        fileid, pgno, pgdbt, root_pgno, nrec, rootent,
 
1008
        rootlsn)
 
1009
        DB_ENV *dbenv;
 
1010
        DB_TXN *txnid;
 
1011
        DB_LSN *ret_lsnp;
 
1012
        u_int32_t flags;
 
1013
        int32_t fileid;
 
1014
        db_pgno_t pgno;
 
1015
        const DBT *pgdbt;
 
1016
        db_pgno_t root_pgno;
 
1017
        db_pgno_t nrec;
 
1018
        const DBT *rootent;
 
1019
        DB_LSN * rootlsn;
 
1020
{
 
1021
        DBT logrec;
 
1022
        DB_LSN *lsnp, null_lsn;
 
1023
        u_int32_t zero;
 
1024
        u_int32_t rectype, txn_num;
 
1025
        int ret;
 
1026
        u_int8_t *bp;
 
1027
 
 
1028
        rectype = DB_bam_rsplit;
 
1029
        if (txnid != NULL &&
 
1030
            TAILQ_FIRST(&txnid->kids) != NULL &&
 
1031
            (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
 
1032
                return (ret);
 
1033
        txn_num = txnid == NULL ? 0 : txnid->txnid;
 
1034
        if (txnid == NULL) {
 
1035
                ZERO_LSN(null_lsn);
 
1036
                lsnp = &null_lsn;
 
1037
        } else
 
1038
                lsnp = &txnid->last_lsn;
 
1039
        logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
 
1040
            + sizeof(fileid)
 
1041
            + sizeof(pgno)
 
1042
            + sizeof(u_int32_t) + (pgdbt == NULL ? 0 : pgdbt->size)
 
1043
            + sizeof(root_pgno)
 
1044
            + sizeof(nrec)
 
1045
            + sizeof(u_int32_t) + (rootent == NULL ? 0 : rootent->size)
 
1046
            + sizeof(*rootlsn);
 
1047
        if ((ret = __os_malloc(dbenv, logrec.size, &logrec.data)) != 0)
 
1048
                return (ret);
 
1049
 
 
1050
        bp = logrec.data;
 
1051
        memcpy(bp, &rectype, sizeof(rectype));
 
1052
        bp += sizeof(rectype);
 
1053
        memcpy(bp, &txn_num, sizeof(txn_num));
 
1054
        bp += sizeof(txn_num);
 
1055
        memcpy(bp, lsnp, sizeof(DB_LSN));
 
1056
        bp += sizeof(DB_LSN);
 
1057
        memcpy(bp, &fileid, sizeof(fileid));
 
1058
        bp += sizeof(fileid);
 
1059
        memcpy(bp, &pgno, sizeof(pgno));
 
1060
        bp += sizeof(pgno);
 
1061
        if (pgdbt == NULL) {
 
1062
                zero = 0;
 
1063
                memcpy(bp, &zero, sizeof(u_int32_t));
 
1064
                bp += sizeof(u_int32_t);
 
1065
        } else {
 
1066
                memcpy(bp, &pgdbt->size, sizeof(pgdbt->size));
 
1067
                bp += sizeof(pgdbt->size);
 
1068
                memcpy(bp, pgdbt->data, pgdbt->size);
 
1069
                bp += pgdbt->size;
 
1070
        }
 
1071
        memcpy(bp, &root_pgno, sizeof(root_pgno));
 
1072
        bp += sizeof(root_pgno);
 
1073
        memcpy(bp, &nrec, sizeof(nrec));
 
1074
        bp += sizeof(nrec);
 
1075
        if (rootent == NULL) {
 
1076
                zero = 0;
 
1077
                memcpy(bp, &zero, sizeof(u_int32_t));
 
1078
                bp += sizeof(u_int32_t);
 
1079
        } else {
 
1080
                memcpy(bp, &rootent->size, sizeof(rootent->size));
 
1081
                bp += sizeof(rootent->size);
 
1082
                memcpy(bp, rootent->data, rootent->size);
 
1083
                bp += rootent->size;
 
1084
        }
 
1085
        if (rootlsn != NULL)
 
1086
                memcpy(bp, rootlsn, sizeof(*rootlsn));
 
1087
        else
 
1088
                memset(bp, 0, sizeof(*rootlsn));
 
1089
        bp += sizeof(*rootlsn);
 
1090
        DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
 
1091
        ret = log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
 
1092
        if (txnid != NULL && ret == 0)
 
1093
                txnid->last_lsn = *ret_lsnp;
 
1094
#ifdef LOG_DIAGNOSTIC
 
1095
        if (ret != 0)
 
1096
                (void)__bam_rsplit_print(dbenv,
 
1097
                    (DBT *)&logrec, ret_lsnp, NULL, NULL);
 
1098
#endif
 
1099
        __os_free(dbenv, logrec.data, logrec.size);
 
1100
        return (ret);
 
1101
}
 
1102
 
 
1103
/*
 
1104
 * PUBLIC: int __bam_rsplit_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
 
1105
 * PUBLIC:      void *));
 
1106
 */
 
1107
int
 
1108
__bam_rsplit_print(dbenv, dbtp, lsnp, notused2, notused3)
 
1109
        DB_ENV *dbenv;
 
1110
        DBT *dbtp;
 
1111
        DB_LSN *lsnp;
 
1112
        db_recops notused2;
 
1113
        void *notused3;
 
1114
{
 
1115
        __bam_rsplit_args *argp;
 
1116
        u_int32_t i;
 
1117
        u_int ch;
 
1118
        int ret;
 
1119
 
 
1120
        i = 0;
 
1121
        ch = 0;
 
1122
        notused2 = DB_TXN_ABORT;
 
1123
        notused3 = NULL;
 
1124
 
 
1125
        if ((ret = __bam_rsplit_read(dbenv, dbtp->data, &argp)) != 0)
 
1126
                return (ret);
 
1127
        (void)printf(
 
1128
            "[%lu][%lu]bam_rsplit: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
 
1129
            (u_long)lsnp->file,
 
1130
            (u_long)lsnp->offset,
 
1131
            (u_long)argp->type,
 
1132
            (u_long)argp->txnid->txnid,
 
1133
            (u_long)argp->prev_lsn.file,
 
1134
            (u_long)argp->prev_lsn.offset);
 
1135
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
 
1136
        (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
 
1137
        (void)printf("\tpgdbt: ");
 
1138
        for (i = 0; i < argp->pgdbt.size; i++) {
 
1139
                ch = ((u_int8_t *)argp->pgdbt.data)[i];
 
1140
                if (isprint(ch) || ch == 0xa)
 
1141
                        (void)putchar(ch);
 
1142
                else
 
1143
                        (void)printf("%#x ", ch);
 
1144
        }
 
1145
        (void)printf("\n");
 
1146
        (void)printf("\troot_pgno: %lu\n", (u_long)argp->root_pgno);
 
1147
        (void)printf("\tnrec: %lu\n", (u_long)argp->nrec);
 
1148
        (void)printf("\trootent: ");
 
1149
        for (i = 0; i < argp->rootent.size; i++) {
 
1150
                ch = ((u_int8_t *)argp->rootent.data)[i];
 
1151
                if (isprint(ch) || ch == 0xa)
 
1152
                        (void)putchar(ch);
 
1153
                else
 
1154
                        (void)printf("%#x ", ch);
 
1155
        }
 
1156
        (void)printf("\n");
 
1157
        (void)printf("\trootlsn: [%lu][%lu]\n",
 
1158
            (u_long)argp->rootlsn.file, (u_long)argp->rootlsn.offset);
 
1159
        (void)printf("\n");
 
1160
        __os_free(dbenv, argp, 0);
 
1161
        return (0);
 
1162
}
 
1163
 
 
1164
/*
 
1165
 * PUBLIC: int __bam_rsplit_read __P((DB_ENV *, void *, __bam_rsplit_args **));
 
1166
 */
 
1167
int
 
1168
__bam_rsplit_read(dbenv, recbuf, argpp)
 
1169
        DB_ENV *dbenv;
 
1170
        void *recbuf;
 
1171
        __bam_rsplit_args **argpp;
 
1172
{
 
1173
        __bam_rsplit_args *argp;
 
1174
        u_int8_t *bp;
 
1175
        int ret;
 
1176
 
 
1177
        ret = __os_malloc(dbenv, sizeof(__bam_rsplit_args) +
 
1178
            sizeof(DB_TXN), &argp);
 
1179
        if (ret != 0)
 
1180
                return (ret);
 
1181
        argp->txnid = (DB_TXN *)&argp[1];
 
1182
        bp = recbuf;
 
1183
        memcpy(&argp->type, bp, sizeof(argp->type));
 
1184
        bp += sizeof(argp->type);
 
1185
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
 
1186
        bp += sizeof(argp->txnid->txnid);
 
1187
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
 
1188
        bp += sizeof(DB_LSN);
 
1189
        memcpy(&argp->fileid, bp, sizeof(argp->fileid));
 
1190
        bp += sizeof(argp->fileid);
 
1191
        memcpy(&argp->pgno, bp, sizeof(argp->pgno));
 
1192
        bp += sizeof(argp->pgno);
 
1193
        memset(&argp->pgdbt, 0, sizeof(argp->pgdbt));
 
1194
        memcpy(&argp->pgdbt.size, bp, sizeof(u_int32_t));
 
1195
        bp += sizeof(u_int32_t);
 
1196
        argp->pgdbt.data = bp;
 
1197
        bp += argp->pgdbt.size;
 
1198
        memcpy(&argp->root_pgno, bp, sizeof(argp->root_pgno));
 
1199
        bp += sizeof(argp->root_pgno);
 
1200
        memcpy(&argp->nrec, bp, sizeof(argp->nrec));
 
1201
        bp += sizeof(argp->nrec);
 
1202
        memset(&argp->rootent, 0, sizeof(argp->rootent));
 
1203
        memcpy(&argp->rootent.size, bp, sizeof(u_int32_t));
 
1204
        bp += sizeof(u_int32_t);
 
1205
        argp->rootent.data = bp;
 
1206
        bp += argp->rootent.size;
 
1207
        memcpy(&argp->rootlsn, bp,  sizeof(argp->rootlsn));
 
1208
        bp += sizeof(argp->rootlsn);
 
1209
        *argpp = argp;
 
1210
        return (0);
 
1211
}
 
1212
 
 
1213
/*
 
1214
 * PUBLIC: int __bam_adj_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t,
 
1215
 * PUBLIC:      int32_t, db_pgno_t, DB_LSN *, u_int32_t, u_int32_t, u_int32_t));
 
1216
 */
 
1217
int
 
1218
__bam_adj_log(dbenv, txnid, ret_lsnp, flags,
 
1219
        fileid, pgno, lsn, indx, indx_copy, is_insert)
 
1220
        DB_ENV *dbenv;
 
1221
        DB_TXN *txnid;
 
1222
        DB_LSN *ret_lsnp;
 
1223
        u_int32_t flags;
 
1224
        int32_t fileid;
 
1225
        db_pgno_t pgno;
 
1226
        DB_LSN * lsn;
 
1227
        u_int32_t indx;
 
1228
        u_int32_t indx_copy;
 
1229
        u_int32_t is_insert;
 
1230
{
 
1231
        DBT logrec;
 
1232
        DB_LSN *lsnp, null_lsn;
 
1233
        u_int32_t rectype, txn_num;
 
1234
        int ret;
 
1235
        u_int8_t *bp;
 
1236
 
 
1237
        rectype = DB_bam_adj;
 
1238
        if (txnid != NULL &&
 
1239
            TAILQ_FIRST(&txnid->kids) != NULL &&
 
1240
            (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
 
1241
                return (ret);
 
1242
        txn_num = txnid == NULL ? 0 : txnid->txnid;
 
1243
        if (txnid == NULL) {
 
1244
                ZERO_LSN(null_lsn);
 
1245
                lsnp = &null_lsn;
 
1246
        } else
 
1247
                lsnp = &txnid->last_lsn;
 
1248
        logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
 
1249
            + sizeof(fileid)
 
1250
            + sizeof(pgno)
 
1251
            + sizeof(*lsn)
 
1252
            + sizeof(indx)
 
1253
            + sizeof(indx_copy)
 
1254
            + sizeof(is_insert);
 
1255
        if ((ret = __os_malloc(dbenv, logrec.size, &logrec.data)) != 0)
 
1256
                return (ret);
 
1257
 
 
1258
        bp = logrec.data;
 
1259
        memcpy(bp, &rectype, sizeof(rectype));
 
1260
        bp += sizeof(rectype);
 
1261
        memcpy(bp, &txn_num, sizeof(txn_num));
 
1262
        bp += sizeof(txn_num);
 
1263
        memcpy(bp, lsnp, sizeof(DB_LSN));
 
1264
        bp += sizeof(DB_LSN);
 
1265
        memcpy(bp, &fileid, sizeof(fileid));
 
1266
        bp += sizeof(fileid);
 
1267
        memcpy(bp, &pgno, sizeof(pgno));
 
1268
        bp += sizeof(pgno);
 
1269
        if (lsn != NULL)
 
1270
                memcpy(bp, lsn, sizeof(*lsn));
 
1271
        else
 
1272
                memset(bp, 0, sizeof(*lsn));
 
1273
        bp += sizeof(*lsn);
 
1274
        memcpy(bp, &indx, sizeof(indx));
 
1275
        bp += sizeof(indx);
 
1276
        memcpy(bp, &indx_copy, sizeof(indx_copy));
 
1277
        bp += sizeof(indx_copy);
 
1278
        memcpy(bp, &is_insert, sizeof(is_insert));
 
1279
        bp += sizeof(is_insert);
 
1280
        DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
 
1281
        ret = log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
 
1282
        if (txnid != NULL && ret == 0)
 
1283
                txnid->last_lsn = *ret_lsnp;
 
1284
#ifdef LOG_DIAGNOSTIC
 
1285
        if (ret != 0)
 
1286
                (void)__bam_adj_print(dbenv,
 
1287
                    (DBT *)&logrec, ret_lsnp, NULL, NULL);
 
1288
#endif
 
1289
        __os_free(dbenv, logrec.data, logrec.size);
 
1290
        return (ret);
 
1291
}
 
1292
 
 
1293
/*
 
1294
 * PUBLIC: int __bam_adj_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
 
1295
 * PUBLIC:      void *));
 
1296
 */
 
1297
int
 
1298
__bam_adj_print(dbenv, dbtp, lsnp, notused2, notused3)
 
1299
        DB_ENV *dbenv;
 
1300
        DBT *dbtp;
 
1301
        DB_LSN *lsnp;
 
1302
        db_recops notused2;
 
1303
        void *notused3;
 
1304
{
 
1305
        __bam_adj_args *argp;
 
1306
        u_int32_t i;
 
1307
        u_int ch;
 
1308
        int ret;
 
1309
 
 
1310
        i = 0;
 
1311
        ch = 0;
 
1312
        notused2 = DB_TXN_ABORT;
 
1313
        notused3 = NULL;
 
1314
 
 
1315
        if ((ret = __bam_adj_read(dbenv, dbtp->data, &argp)) != 0)
 
1316
                return (ret);
 
1317
        (void)printf(
 
1318
            "[%lu][%lu]bam_adj: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
 
1319
            (u_long)lsnp->file,
 
1320
            (u_long)lsnp->offset,
 
1321
            (u_long)argp->type,
 
1322
            (u_long)argp->txnid->txnid,
 
1323
            (u_long)argp->prev_lsn.file,
 
1324
            (u_long)argp->prev_lsn.offset);
 
1325
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
 
1326
        (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
 
1327
        (void)printf("\tlsn: [%lu][%lu]\n",
 
1328
            (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
 
1329
        (void)printf("\tindx: %lu\n", (u_long)argp->indx);
 
1330
        (void)printf("\tindx_copy: %lu\n", (u_long)argp->indx_copy);
 
1331
        (void)printf("\tis_insert: %lu\n", (u_long)argp->is_insert);
 
1332
        (void)printf("\n");
 
1333
        __os_free(dbenv, argp, 0);
 
1334
        return (0);
 
1335
}
 
1336
 
 
1337
/*
 
1338
 * PUBLIC: int __bam_adj_read __P((DB_ENV *, void *, __bam_adj_args **));
 
1339
 */
 
1340
int
 
1341
__bam_adj_read(dbenv, recbuf, argpp)
 
1342
        DB_ENV *dbenv;
 
1343
        void *recbuf;
 
1344
        __bam_adj_args **argpp;
 
1345
{
 
1346
        __bam_adj_args *argp;
 
1347
        u_int8_t *bp;
 
1348
        int ret;
 
1349
 
 
1350
        ret = __os_malloc(dbenv, sizeof(__bam_adj_args) +
 
1351
            sizeof(DB_TXN), &argp);
 
1352
        if (ret != 0)
 
1353
                return (ret);
 
1354
        argp->txnid = (DB_TXN *)&argp[1];
 
1355
        bp = recbuf;
 
1356
        memcpy(&argp->type, bp, sizeof(argp->type));
 
1357
        bp += sizeof(argp->type);
 
1358
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
 
1359
        bp += sizeof(argp->txnid->txnid);
 
1360
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
 
1361
        bp += sizeof(DB_LSN);
 
1362
        memcpy(&argp->fileid, bp, sizeof(argp->fileid));
 
1363
        bp += sizeof(argp->fileid);
 
1364
        memcpy(&argp->pgno, bp, sizeof(argp->pgno));
 
1365
        bp += sizeof(argp->pgno);
 
1366
        memcpy(&argp->lsn, bp,  sizeof(argp->lsn));
 
1367
        bp += sizeof(argp->lsn);
 
1368
        memcpy(&argp->indx, bp, sizeof(argp->indx));
 
1369
        bp += sizeof(argp->indx);
 
1370
        memcpy(&argp->indx_copy, bp, sizeof(argp->indx_copy));
 
1371
        bp += sizeof(argp->indx_copy);
 
1372
        memcpy(&argp->is_insert, bp, sizeof(argp->is_insert));
 
1373
        bp += sizeof(argp->is_insert);
 
1374
        *argpp = argp;
 
1375
        return (0);
 
1376
}
 
1377
 
 
1378
/*
 
1379
 * PUBLIC: int __bam_cadjust_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t,
 
1380
 * PUBLIC:      int32_t, db_pgno_t, DB_LSN *, u_int32_t, int32_t, u_int32_t));
 
1381
 */
 
1382
int
 
1383
__bam_cadjust_log(dbenv, txnid, ret_lsnp, flags,
 
1384
        fileid, pgno, lsn, indx, adjust, opflags)
 
1385
        DB_ENV *dbenv;
 
1386
        DB_TXN *txnid;
 
1387
        DB_LSN *ret_lsnp;
 
1388
        u_int32_t flags;
 
1389
        int32_t fileid;
 
1390
        db_pgno_t pgno;
 
1391
        DB_LSN * lsn;
 
1392
        u_int32_t indx;
 
1393
        int32_t adjust;
 
1394
        u_int32_t opflags;
 
1395
{
 
1396
        DBT logrec;
 
1397
        DB_LSN *lsnp, null_lsn;
 
1398
        u_int32_t rectype, txn_num;
 
1399
        int ret;
 
1400
        u_int8_t *bp;
 
1401
 
 
1402
        rectype = DB_bam_cadjust;
 
1403
        if (txnid != NULL &&
 
1404
            TAILQ_FIRST(&txnid->kids) != NULL &&
 
1405
            (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
 
1406
                return (ret);
 
1407
        txn_num = txnid == NULL ? 0 : txnid->txnid;
 
1408
        if (txnid == NULL) {
 
1409
                ZERO_LSN(null_lsn);
 
1410
                lsnp = &null_lsn;
 
1411
        } else
 
1412
                lsnp = &txnid->last_lsn;
 
1413
        logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
 
1414
            + sizeof(fileid)
 
1415
            + sizeof(pgno)
 
1416
            + sizeof(*lsn)
 
1417
            + sizeof(indx)
 
1418
            + sizeof(adjust)
 
1419
            + sizeof(opflags);
 
1420
        if ((ret = __os_malloc(dbenv, logrec.size, &logrec.data)) != 0)
 
1421
                return (ret);
 
1422
 
 
1423
        bp = logrec.data;
 
1424
        memcpy(bp, &rectype, sizeof(rectype));
 
1425
        bp += sizeof(rectype);
 
1426
        memcpy(bp, &txn_num, sizeof(txn_num));
 
1427
        bp += sizeof(txn_num);
 
1428
        memcpy(bp, lsnp, sizeof(DB_LSN));
 
1429
        bp += sizeof(DB_LSN);
 
1430
        memcpy(bp, &fileid, sizeof(fileid));
 
1431
        bp += sizeof(fileid);
 
1432
        memcpy(bp, &pgno, sizeof(pgno));
 
1433
        bp += sizeof(pgno);
 
1434
        if (lsn != NULL)
 
1435
                memcpy(bp, lsn, sizeof(*lsn));
 
1436
        else
 
1437
                memset(bp, 0, sizeof(*lsn));
 
1438
        bp += sizeof(*lsn);
 
1439
        memcpy(bp, &indx, sizeof(indx));
 
1440
        bp += sizeof(indx);
 
1441
        memcpy(bp, &adjust, sizeof(adjust));
 
1442
        bp += sizeof(adjust);
 
1443
        memcpy(bp, &opflags, sizeof(opflags));
 
1444
        bp += sizeof(opflags);
 
1445
        DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
 
1446
        ret = log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
 
1447
        if (txnid != NULL && ret == 0)
 
1448
                txnid->last_lsn = *ret_lsnp;
 
1449
#ifdef LOG_DIAGNOSTIC
 
1450
        if (ret != 0)
 
1451
                (void)__bam_cadjust_print(dbenv,
 
1452
                    (DBT *)&logrec, ret_lsnp, NULL, NULL);
 
1453
#endif
 
1454
        __os_free(dbenv, logrec.data, logrec.size);
 
1455
        return (ret);
 
1456
}
 
1457
 
 
1458
/*
 
1459
 * PUBLIC: int __bam_cadjust_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
 
1460
 * PUBLIC:      void *));
 
1461
 */
 
1462
int
 
1463
__bam_cadjust_print(dbenv, dbtp, lsnp, notused2, notused3)
 
1464
        DB_ENV *dbenv;
 
1465
        DBT *dbtp;
 
1466
        DB_LSN *lsnp;
 
1467
        db_recops notused2;
 
1468
        void *notused3;
 
1469
{
 
1470
        __bam_cadjust_args *argp;
 
1471
        u_int32_t i;
 
1472
        u_int ch;
 
1473
        int ret;
 
1474
 
 
1475
        i = 0;
 
1476
        ch = 0;
 
1477
        notused2 = DB_TXN_ABORT;
 
1478
        notused3 = NULL;
 
1479
 
 
1480
        if ((ret = __bam_cadjust_read(dbenv, dbtp->data, &argp)) != 0)
 
1481
                return (ret);
 
1482
        (void)printf(
 
1483
            "[%lu][%lu]bam_cadjust: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
 
1484
            (u_long)lsnp->file,
 
1485
            (u_long)lsnp->offset,
 
1486
            (u_long)argp->type,
 
1487
            (u_long)argp->txnid->txnid,
 
1488
            (u_long)argp->prev_lsn.file,
 
1489
            (u_long)argp->prev_lsn.offset);
 
1490
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
 
1491
        (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
 
1492
        (void)printf("\tlsn: [%lu][%lu]\n",
 
1493
            (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
 
1494
        (void)printf("\tindx: %lu\n", (u_long)argp->indx);
 
1495
        (void)printf("\tadjust: %ld\n", (long)argp->adjust);
 
1496
        (void)printf("\topflags: %lu\n", (u_long)argp->opflags);
 
1497
        (void)printf("\n");
 
1498
        __os_free(dbenv, argp, 0);
 
1499
        return (0);
 
1500
}
 
1501
 
 
1502
/*
 
1503
 * PUBLIC: int __bam_cadjust_read __P((DB_ENV *, void *,
 
1504
 * PUBLIC:      __bam_cadjust_args **));
 
1505
 */
 
1506
int
 
1507
__bam_cadjust_read(dbenv, recbuf, argpp)
 
1508
        DB_ENV *dbenv;
 
1509
        void *recbuf;
 
1510
        __bam_cadjust_args **argpp;
 
1511
{
 
1512
        __bam_cadjust_args *argp;
 
1513
        u_int8_t *bp;
 
1514
        int ret;
 
1515
 
 
1516
        ret = __os_malloc(dbenv, sizeof(__bam_cadjust_args) +
 
1517
            sizeof(DB_TXN), &argp);
 
1518
        if (ret != 0)
 
1519
                return (ret);
 
1520
        argp->txnid = (DB_TXN *)&argp[1];
 
1521
        bp = recbuf;
 
1522
        memcpy(&argp->type, bp, sizeof(argp->type));
 
1523
        bp += sizeof(argp->type);
 
1524
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
 
1525
        bp += sizeof(argp->txnid->txnid);
 
1526
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
 
1527
        bp += sizeof(DB_LSN);
 
1528
        memcpy(&argp->fileid, bp, sizeof(argp->fileid));
 
1529
        bp += sizeof(argp->fileid);
 
1530
        memcpy(&argp->pgno, bp, sizeof(argp->pgno));
 
1531
        bp += sizeof(argp->pgno);
 
1532
        memcpy(&argp->lsn, bp,  sizeof(argp->lsn));
 
1533
        bp += sizeof(argp->lsn);
 
1534
        memcpy(&argp->indx, bp, sizeof(argp->indx));
 
1535
        bp += sizeof(argp->indx);
 
1536
        memcpy(&argp->adjust, bp, sizeof(argp->adjust));
 
1537
        bp += sizeof(argp->adjust);
 
1538
        memcpy(&argp->opflags, bp, sizeof(argp->opflags));
 
1539
        bp += sizeof(argp->opflags);
 
1540
        *argpp = argp;
 
1541
        return (0);
 
1542
}
 
1543
 
 
1544
/*
 
1545
 * PUBLIC: int __bam_cdel_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t,
 
1546
 * PUBLIC:      int32_t, db_pgno_t, DB_LSN *, u_int32_t));
 
1547
 */
 
1548
int
 
1549
__bam_cdel_log(dbenv, txnid, ret_lsnp, flags,
 
1550
        fileid, pgno, lsn, indx)
 
1551
        DB_ENV *dbenv;
 
1552
        DB_TXN *txnid;
 
1553
        DB_LSN *ret_lsnp;
 
1554
        u_int32_t flags;
 
1555
        int32_t fileid;
 
1556
        db_pgno_t pgno;
 
1557
        DB_LSN * lsn;
 
1558
        u_int32_t indx;
 
1559
{
 
1560
        DBT logrec;
 
1561
        DB_LSN *lsnp, null_lsn;
 
1562
        u_int32_t rectype, txn_num;
 
1563
        int ret;
 
1564
        u_int8_t *bp;
 
1565
 
 
1566
        rectype = DB_bam_cdel;
 
1567
        if (txnid != NULL &&
 
1568
            TAILQ_FIRST(&txnid->kids) != NULL &&
 
1569
            (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
 
1570
                return (ret);
 
1571
        txn_num = txnid == NULL ? 0 : txnid->txnid;
 
1572
        if (txnid == NULL) {
 
1573
                ZERO_LSN(null_lsn);
 
1574
                lsnp = &null_lsn;
 
1575
        } else
 
1576
                lsnp = &txnid->last_lsn;
 
1577
        logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
 
1578
            + sizeof(fileid)
 
1579
            + sizeof(pgno)
 
1580
            + sizeof(*lsn)
 
1581
            + sizeof(indx);
 
1582
        if ((ret = __os_malloc(dbenv, logrec.size, &logrec.data)) != 0)
 
1583
                return (ret);
 
1584
 
 
1585
        bp = logrec.data;
 
1586
        memcpy(bp, &rectype, sizeof(rectype));
 
1587
        bp += sizeof(rectype);
 
1588
        memcpy(bp, &txn_num, sizeof(txn_num));
 
1589
        bp += sizeof(txn_num);
 
1590
        memcpy(bp, lsnp, sizeof(DB_LSN));
 
1591
        bp += sizeof(DB_LSN);
 
1592
        memcpy(bp, &fileid, sizeof(fileid));
 
1593
        bp += sizeof(fileid);
 
1594
        memcpy(bp, &pgno, sizeof(pgno));
 
1595
        bp += sizeof(pgno);
 
1596
        if (lsn != NULL)
 
1597
                memcpy(bp, lsn, sizeof(*lsn));
 
1598
        else
 
1599
                memset(bp, 0, sizeof(*lsn));
 
1600
        bp += sizeof(*lsn);
 
1601
        memcpy(bp, &indx, sizeof(indx));
 
1602
        bp += sizeof(indx);
 
1603
        DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
 
1604
        ret = log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
 
1605
        if (txnid != NULL && ret == 0)
 
1606
                txnid->last_lsn = *ret_lsnp;
 
1607
#ifdef LOG_DIAGNOSTIC
 
1608
        if (ret != 0)
 
1609
                (void)__bam_cdel_print(dbenv,
 
1610
                    (DBT *)&logrec, ret_lsnp, NULL, NULL);
 
1611
#endif
 
1612
        __os_free(dbenv, logrec.data, logrec.size);
 
1613
        return (ret);
 
1614
}
 
1615
 
 
1616
/*
 
1617
 * PUBLIC: int __bam_cdel_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
 
1618
 * PUBLIC:      void *));
 
1619
 */
 
1620
int
 
1621
__bam_cdel_print(dbenv, dbtp, lsnp, notused2, notused3)
 
1622
        DB_ENV *dbenv;
 
1623
        DBT *dbtp;
 
1624
        DB_LSN *lsnp;
 
1625
        db_recops notused2;
 
1626
        void *notused3;
 
1627
{
 
1628
        __bam_cdel_args *argp;
 
1629
        u_int32_t i;
 
1630
        u_int ch;
 
1631
        int ret;
 
1632
 
 
1633
        i = 0;
 
1634
        ch = 0;
 
1635
        notused2 = DB_TXN_ABORT;
 
1636
        notused3 = NULL;
 
1637
 
 
1638
        if ((ret = __bam_cdel_read(dbenv, dbtp->data, &argp)) != 0)
 
1639
                return (ret);
 
1640
        (void)printf(
 
1641
            "[%lu][%lu]bam_cdel: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
 
1642
            (u_long)lsnp->file,
 
1643
            (u_long)lsnp->offset,
 
1644
            (u_long)argp->type,
 
1645
            (u_long)argp->txnid->txnid,
 
1646
            (u_long)argp->prev_lsn.file,
 
1647
            (u_long)argp->prev_lsn.offset);
 
1648
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
 
1649
        (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
 
1650
        (void)printf("\tlsn: [%lu][%lu]\n",
 
1651
            (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
 
1652
        (void)printf("\tindx: %lu\n", (u_long)argp->indx);
 
1653
        (void)printf("\n");
 
1654
        __os_free(dbenv, argp, 0);
 
1655
        return (0);
 
1656
}
 
1657
 
 
1658
/*
 
1659
 * PUBLIC: int __bam_cdel_read __P((DB_ENV *, void *, __bam_cdel_args **));
 
1660
 */
 
1661
int
 
1662
__bam_cdel_read(dbenv, recbuf, argpp)
 
1663
        DB_ENV *dbenv;
 
1664
        void *recbuf;
 
1665
        __bam_cdel_args **argpp;
 
1666
{
 
1667
        __bam_cdel_args *argp;
 
1668
        u_int8_t *bp;
 
1669
        int ret;
 
1670
 
 
1671
        ret = __os_malloc(dbenv, sizeof(__bam_cdel_args) +
 
1672
            sizeof(DB_TXN), &argp);
 
1673
        if (ret != 0)
 
1674
                return (ret);
 
1675
        argp->txnid = (DB_TXN *)&argp[1];
 
1676
        bp = recbuf;
 
1677
        memcpy(&argp->type, bp, sizeof(argp->type));
 
1678
        bp += sizeof(argp->type);
 
1679
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
 
1680
        bp += sizeof(argp->txnid->txnid);
 
1681
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
 
1682
        bp += sizeof(DB_LSN);
 
1683
        memcpy(&argp->fileid, bp, sizeof(argp->fileid));
 
1684
        bp += sizeof(argp->fileid);
 
1685
        memcpy(&argp->pgno, bp, sizeof(argp->pgno));
 
1686
        bp += sizeof(argp->pgno);
 
1687
        memcpy(&argp->lsn, bp,  sizeof(argp->lsn));
 
1688
        bp += sizeof(argp->lsn);
 
1689
        memcpy(&argp->indx, bp, sizeof(argp->indx));
 
1690
        bp += sizeof(argp->indx);
 
1691
        *argpp = argp;
 
1692
        return (0);
 
1693
}
 
1694
 
 
1695
/*
 
1696
 * PUBLIC: int __bam_repl_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t,
 
1697
 * PUBLIC:      int32_t, db_pgno_t, DB_LSN *, u_int32_t, u_int32_t, const DBT *, const DBT *,
 
1698
 * PUBLIC:      u_int32_t, u_int32_t));
 
1699
 */
 
1700
int
 
1701
__bam_repl_log(dbenv, txnid, ret_lsnp, flags,
 
1702
        fileid, pgno, lsn, indx, isdeleted, orig,
 
1703
        repl, prefix, suffix)
 
1704
        DB_ENV *dbenv;
 
1705
        DB_TXN *txnid;
 
1706
        DB_LSN *ret_lsnp;
 
1707
        u_int32_t flags;
 
1708
        int32_t fileid;
 
1709
        db_pgno_t pgno;
 
1710
        DB_LSN * lsn;
 
1711
        u_int32_t indx;
 
1712
        u_int32_t isdeleted;
 
1713
        const DBT *orig;
 
1714
        const DBT *repl;
 
1715
        u_int32_t prefix;
 
1716
        u_int32_t suffix;
 
1717
{
 
1718
        DBT logrec;
 
1719
        DB_LSN *lsnp, null_lsn;
 
1720
        u_int32_t zero;
 
1721
        u_int32_t rectype, txn_num;
 
1722
        int ret;
 
1723
        u_int8_t *bp;
 
1724
 
 
1725
        rectype = DB_bam_repl;
 
1726
        if (txnid != NULL &&
 
1727
            TAILQ_FIRST(&txnid->kids) != NULL &&
 
1728
            (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
 
1729
                return (ret);
 
1730
        txn_num = txnid == NULL ? 0 : txnid->txnid;
 
1731
        if (txnid == NULL) {
 
1732
                ZERO_LSN(null_lsn);
 
1733
                lsnp = &null_lsn;
 
1734
        } else
 
1735
                lsnp = &txnid->last_lsn;
 
1736
        logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
 
1737
            + sizeof(fileid)
 
1738
            + sizeof(pgno)
 
1739
            + sizeof(*lsn)
 
1740
            + sizeof(indx)
 
1741
            + sizeof(isdeleted)
 
1742
            + sizeof(u_int32_t) + (orig == NULL ? 0 : orig->size)
 
1743
            + sizeof(u_int32_t) + (repl == NULL ? 0 : repl->size)
 
1744
            + sizeof(prefix)
 
1745
            + sizeof(suffix);
 
1746
        if ((ret = __os_malloc(dbenv, logrec.size, &logrec.data)) != 0)
 
1747
                return (ret);
 
1748
 
 
1749
        bp = logrec.data;
 
1750
        memcpy(bp, &rectype, sizeof(rectype));
 
1751
        bp += sizeof(rectype);
 
1752
        memcpy(bp, &txn_num, sizeof(txn_num));
 
1753
        bp += sizeof(txn_num);
 
1754
        memcpy(bp, lsnp, sizeof(DB_LSN));
 
1755
        bp += sizeof(DB_LSN);
 
1756
        memcpy(bp, &fileid, sizeof(fileid));
 
1757
        bp += sizeof(fileid);
 
1758
        memcpy(bp, &pgno, sizeof(pgno));
 
1759
        bp += sizeof(pgno);
 
1760
        if (lsn != NULL)
 
1761
                memcpy(bp, lsn, sizeof(*lsn));
 
1762
        else
 
1763
                memset(bp, 0, sizeof(*lsn));
 
1764
        bp += sizeof(*lsn);
 
1765
        memcpy(bp, &indx, sizeof(indx));
 
1766
        bp += sizeof(indx);
 
1767
        memcpy(bp, &isdeleted, sizeof(isdeleted));
 
1768
        bp += sizeof(isdeleted);
 
1769
        if (orig == NULL) {
 
1770
                zero = 0;
 
1771
                memcpy(bp, &zero, sizeof(u_int32_t));
 
1772
                bp += sizeof(u_int32_t);
 
1773
        } else {
 
1774
                memcpy(bp, &orig->size, sizeof(orig->size));
 
1775
                bp += sizeof(orig->size);
 
1776
                memcpy(bp, orig->data, orig->size);
 
1777
                bp += orig->size;
 
1778
        }
 
1779
        if (repl == NULL) {
 
1780
                zero = 0;
 
1781
                memcpy(bp, &zero, sizeof(u_int32_t));
 
1782
                bp += sizeof(u_int32_t);
 
1783
        } else {
 
1784
                memcpy(bp, &repl->size, sizeof(repl->size));
 
1785
                bp += sizeof(repl->size);
 
1786
                memcpy(bp, repl->data, repl->size);
 
1787
                bp += repl->size;
 
1788
        }
 
1789
        memcpy(bp, &prefix, sizeof(prefix));
 
1790
        bp += sizeof(prefix);
 
1791
        memcpy(bp, &suffix, sizeof(suffix));
 
1792
        bp += sizeof(suffix);
 
1793
        DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
 
1794
        ret = log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
 
1795
        if (txnid != NULL && ret == 0)
 
1796
                txnid->last_lsn = *ret_lsnp;
 
1797
#ifdef LOG_DIAGNOSTIC
 
1798
        if (ret != 0)
 
1799
                (void)__bam_repl_print(dbenv,
 
1800
                    (DBT *)&logrec, ret_lsnp, NULL, NULL);
 
1801
#endif
 
1802
        __os_free(dbenv, logrec.data, logrec.size);
 
1803
        return (ret);
 
1804
}
 
1805
 
 
1806
/*
 
1807
 * PUBLIC: int __bam_repl_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
 
1808
 * PUBLIC:      void *));
 
1809
 */
 
1810
int
 
1811
__bam_repl_print(dbenv, dbtp, lsnp, notused2, notused3)
 
1812
        DB_ENV *dbenv;
 
1813
        DBT *dbtp;
 
1814
        DB_LSN *lsnp;
 
1815
        db_recops notused2;
 
1816
        void *notused3;
 
1817
{
 
1818
        __bam_repl_args *argp;
 
1819
        u_int32_t i;
 
1820
        u_int ch;
 
1821
        int ret;
 
1822
 
 
1823
        i = 0;
 
1824
        ch = 0;
 
1825
        notused2 = DB_TXN_ABORT;
 
1826
        notused3 = NULL;
 
1827
 
 
1828
        if ((ret = __bam_repl_read(dbenv, dbtp->data, &argp)) != 0)
 
1829
                return (ret);
 
1830
        (void)printf(
 
1831
            "[%lu][%lu]bam_repl: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
 
1832
            (u_long)lsnp->file,
 
1833
            (u_long)lsnp->offset,
 
1834
            (u_long)argp->type,
 
1835
            (u_long)argp->txnid->txnid,
 
1836
            (u_long)argp->prev_lsn.file,
 
1837
            (u_long)argp->prev_lsn.offset);
 
1838
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
 
1839
        (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
 
1840
        (void)printf("\tlsn: [%lu][%lu]\n",
 
1841
            (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
 
1842
        (void)printf("\tindx: %lu\n", (u_long)argp->indx);
 
1843
        (void)printf("\tisdeleted: %lu\n", (u_long)argp->isdeleted);
 
1844
        (void)printf("\torig: ");
 
1845
        for (i = 0; i < argp->orig.size; i++) {
 
1846
                ch = ((u_int8_t *)argp->orig.data)[i];
 
1847
                if (isprint(ch) || ch == 0xa)
 
1848
                        (void)putchar(ch);
 
1849
                else
 
1850
                        (void)printf("%#x ", ch);
 
1851
        }
 
1852
        (void)printf("\n");
 
1853
        (void)printf("\trepl: ");
 
1854
        for (i = 0; i < argp->repl.size; i++) {
 
1855
                ch = ((u_int8_t *)argp->repl.data)[i];
 
1856
                if (isprint(ch) || ch == 0xa)
 
1857
                        (void)putchar(ch);
 
1858
                else
 
1859
                        (void)printf("%#x ", ch);
 
1860
        }
 
1861
        (void)printf("\n");
 
1862
        (void)printf("\tprefix: %lu\n", (u_long)argp->prefix);
 
1863
        (void)printf("\tsuffix: %lu\n", (u_long)argp->suffix);
 
1864
        (void)printf("\n");
 
1865
        __os_free(dbenv, argp, 0);
 
1866
        return (0);
 
1867
}
 
1868
 
 
1869
/*
 
1870
 * PUBLIC: int __bam_repl_read __P((DB_ENV *, void *, __bam_repl_args **));
 
1871
 */
 
1872
int
 
1873
__bam_repl_read(dbenv, recbuf, argpp)
 
1874
        DB_ENV *dbenv;
 
1875
        void *recbuf;
 
1876
        __bam_repl_args **argpp;
 
1877
{
 
1878
        __bam_repl_args *argp;
 
1879
        u_int8_t *bp;
 
1880
        int ret;
 
1881
 
 
1882
        ret = __os_malloc(dbenv, sizeof(__bam_repl_args) +
 
1883
            sizeof(DB_TXN), &argp);
 
1884
        if (ret != 0)
 
1885
                return (ret);
 
1886
        argp->txnid = (DB_TXN *)&argp[1];
 
1887
        bp = recbuf;
 
1888
        memcpy(&argp->type, bp, sizeof(argp->type));
 
1889
        bp += sizeof(argp->type);
 
1890
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
 
1891
        bp += sizeof(argp->txnid->txnid);
 
1892
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
 
1893
        bp += sizeof(DB_LSN);
 
1894
        memcpy(&argp->fileid, bp, sizeof(argp->fileid));
 
1895
        bp += sizeof(argp->fileid);
 
1896
        memcpy(&argp->pgno, bp, sizeof(argp->pgno));
 
1897
        bp += sizeof(argp->pgno);
 
1898
        memcpy(&argp->lsn, bp,  sizeof(argp->lsn));
 
1899
        bp += sizeof(argp->lsn);
 
1900
        memcpy(&argp->indx, bp, sizeof(argp->indx));
 
1901
        bp += sizeof(argp->indx);
 
1902
        memcpy(&argp->isdeleted, bp, sizeof(argp->isdeleted));
 
1903
        bp += sizeof(argp->isdeleted);
 
1904
        memset(&argp->orig, 0, sizeof(argp->orig));
 
1905
        memcpy(&argp->orig.size, bp, sizeof(u_int32_t));
 
1906
        bp += sizeof(u_int32_t);
 
1907
        argp->orig.data = bp;
 
1908
        bp += argp->orig.size;
 
1909
        memset(&argp->repl, 0, sizeof(argp->repl));
 
1910
        memcpy(&argp->repl.size, bp, sizeof(u_int32_t));
 
1911
        bp += sizeof(u_int32_t);
 
1912
        argp->repl.data = bp;
 
1913
        bp += argp->repl.size;
 
1914
        memcpy(&argp->prefix, bp, sizeof(argp->prefix));
 
1915
        bp += sizeof(argp->prefix);
 
1916
        memcpy(&argp->suffix, bp, sizeof(argp->suffix));
 
1917
        bp += sizeof(argp->suffix);
 
1918
        *argpp = argp;
 
1919
        return (0);
 
1920
}
 
1921
 
 
1922
/*
 
1923
 * PUBLIC: int __bam_root_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t,
 
1924
 * PUBLIC:      int32_t, db_pgno_t, db_pgno_t, DB_LSN *));
 
1925
 */
 
1926
int
 
1927
__bam_root_log(dbenv, txnid, ret_lsnp, flags,
 
1928
        fileid, meta_pgno, root_pgno, meta_lsn)
 
1929
        DB_ENV *dbenv;
 
1930
        DB_TXN *txnid;
 
1931
        DB_LSN *ret_lsnp;
 
1932
        u_int32_t flags;
 
1933
        int32_t fileid;
 
1934
        db_pgno_t meta_pgno;
 
1935
        db_pgno_t root_pgno;
 
1936
        DB_LSN * meta_lsn;
 
1937
{
 
1938
        DBT logrec;
 
1939
        DB_LSN *lsnp, null_lsn;
 
1940
        u_int32_t rectype, txn_num;
 
1941
        int ret;
 
1942
        u_int8_t *bp;
 
1943
 
 
1944
        rectype = DB_bam_root;
 
1945
        if (txnid != NULL &&
 
1946
            TAILQ_FIRST(&txnid->kids) != NULL &&
 
1947
            (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
 
1948
                return (ret);
 
1949
        txn_num = txnid == NULL ? 0 : txnid->txnid;
 
1950
        if (txnid == NULL) {
 
1951
                ZERO_LSN(null_lsn);
 
1952
                lsnp = &null_lsn;
 
1953
        } else
 
1954
                lsnp = &txnid->last_lsn;
 
1955
        logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
 
1956
            + sizeof(fileid)
 
1957
            + sizeof(meta_pgno)
 
1958
            + sizeof(root_pgno)
 
1959
            + sizeof(*meta_lsn);
 
1960
        if ((ret = __os_malloc(dbenv, logrec.size, &logrec.data)) != 0)
 
1961
                return (ret);
 
1962
 
 
1963
        bp = logrec.data;
 
1964
        memcpy(bp, &rectype, sizeof(rectype));
 
1965
        bp += sizeof(rectype);
 
1966
        memcpy(bp, &txn_num, sizeof(txn_num));
 
1967
        bp += sizeof(txn_num);
 
1968
        memcpy(bp, lsnp, sizeof(DB_LSN));
 
1969
        bp += sizeof(DB_LSN);
 
1970
        memcpy(bp, &fileid, sizeof(fileid));
 
1971
        bp += sizeof(fileid);
 
1972
        memcpy(bp, &meta_pgno, sizeof(meta_pgno));
 
1973
        bp += sizeof(meta_pgno);
 
1974
        memcpy(bp, &root_pgno, sizeof(root_pgno));
 
1975
        bp += sizeof(root_pgno);
 
1976
        if (meta_lsn != NULL)
 
1977
                memcpy(bp, meta_lsn, sizeof(*meta_lsn));
 
1978
        else
 
1979
                memset(bp, 0, sizeof(*meta_lsn));
 
1980
        bp += sizeof(*meta_lsn);
 
1981
        DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
 
1982
        ret = log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
 
1983
        if (txnid != NULL && ret == 0)
 
1984
                txnid->last_lsn = *ret_lsnp;
 
1985
#ifdef LOG_DIAGNOSTIC
 
1986
        if (ret != 0)
 
1987
                (void)__bam_root_print(dbenv,
 
1988
                    (DBT *)&logrec, ret_lsnp, NULL, NULL);
 
1989
#endif
 
1990
        __os_free(dbenv, logrec.data, logrec.size);
 
1991
        return (ret);
 
1992
}
 
1993
 
 
1994
/*
 
1995
 * PUBLIC: int __bam_root_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
 
1996
 * PUBLIC:      void *));
 
1997
 */
 
1998
int
 
1999
__bam_root_print(dbenv, dbtp, lsnp, notused2, notused3)
 
2000
        DB_ENV *dbenv;
 
2001
        DBT *dbtp;
 
2002
        DB_LSN *lsnp;
 
2003
        db_recops notused2;
 
2004
        void *notused3;
 
2005
{
 
2006
        __bam_root_args *argp;
 
2007
        u_int32_t i;
 
2008
        u_int ch;
 
2009
        int ret;
 
2010
 
 
2011
        i = 0;
 
2012
        ch = 0;
 
2013
        notused2 = DB_TXN_ABORT;
 
2014
        notused3 = NULL;
 
2015
 
 
2016
        if ((ret = __bam_root_read(dbenv, dbtp->data, &argp)) != 0)
 
2017
                return (ret);
 
2018
        (void)printf(
 
2019
            "[%lu][%lu]bam_root: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
 
2020
            (u_long)lsnp->file,
 
2021
            (u_long)lsnp->offset,
 
2022
            (u_long)argp->type,
 
2023
            (u_long)argp->txnid->txnid,
 
2024
            (u_long)argp->prev_lsn.file,
 
2025
            (u_long)argp->prev_lsn.offset);
 
2026
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
 
2027
        (void)printf("\tmeta_pgno: %lu\n", (u_long)argp->meta_pgno);
 
2028
        (void)printf("\troot_pgno: %lu\n", (u_long)argp->root_pgno);
 
2029
        (void)printf("\tmeta_lsn: [%lu][%lu]\n",
 
2030
            (u_long)argp->meta_lsn.file, (u_long)argp->meta_lsn.offset);
 
2031
        (void)printf("\n");
 
2032
        __os_free(dbenv, argp, 0);
 
2033
        return (0);
 
2034
}
 
2035
 
 
2036
/*
 
2037
 * PUBLIC: int __bam_root_read __P((DB_ENV *, void *, __bam_root_args **));
 
2038
 */
 
2039
int
 
2040
__bam_root_read(dbenv, recbuf, argpp)
 
2041
        DB_ENV *dbenv;
 
2042
        void *recbuf;
 
2043
        __bam_root_args **argpp;
 
2044
{
 
2045
        __bam_root_args *argp;
 
2046
        u_int8_t *bp;
 
2047
        int ret;
 
2048
 
 
2049
        ret = __os_malloc(dbenv, sizeof(__bam_root_args) +
 
2050
            sizeof(DB_TXN), &argp);
 
2051
        if (ret != 0)
 
2052
                return (ret);
 
2053
        argp->txnid = (DB_TXN *)&argp[1];
 
2054
        bp = recbuf;
 
2055
        memcpy(&argp->type, bp, sizeof(argp->type));
 
2056
        bp += sizeof(argp->type);
 
2057
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
 
2058
        bp += sizeof(argp->txnid->txnid);
 
2059
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
 
2060
        bp += sizeof(DB_LSN);
 
2061
        memcpy(&argp->fileid, bp, sizeof(argp->fileid));
 
2062
        bp += sizeof(argp->fileid);
 
2063
        memcpy(&argp->meta_pgno, bp, sizeof(argp->meta_pgno));
 
2064
        bp += sizeof(argp->meta_pgno);
 
2065
        memcpy(&argp->root_pgno, bp, sizeof(argp->root_pgno));
 
2066
        bp += sizeof(argp->root_pgno);
 
2067
        memcpy(&argp->meta_lsn, bp,  sizeof(argp->meta_lsn));
 
2068
        bp += sizeof(argp->meta_lsn);
 
2069
        *argpp = argp;
 
2070
        return (0);
 
2071
}
 
2072
 
 
2073
/*
 
2074
 * PUBLIC: int __bam_curadj_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t,
 
2075
 * PUBLIC:      int32_t, db_ca_mode, db_pgno_t, db_pgno_t, db_pgno_t, u_int32_t, u_int32_t,
 
2076
 * PUBLIC:      u_int32_t));
 
2077
 */
 
2078
int
 
2079
__bam_curadj_log(dbenv, txnid, ret_lsnp, flags,
 
2080
        fileid, mode, from_pgno, to_pgno, left_pgno, first_indx,
 
2081
        from_indx, to_indx)
 
2082
        DB_ENV *dbenv;
 
2083
        DB_TXN *txnid;
 
2084
        DB_LSN *ret_lsnp;
 
2085
        u_int32_t flags;
 
2086
        int32_t fileid;
 
2087
        db_ca_mode mode;
 
2088
        db_pgno_t from_pgno;
 
2089
        db_pgno_t to_pgno;
 
2090
        db_pgno_t left_pgno;
 
2091
        u_int32_t first_indx;
 
2092
        u_int32_t from_indx;
 
2093
        u_int32_t to_indx;
 
2094
{
 
2095
        DBT logrec;
 
2096
        DB_LSN *lsnp, null_lsn;
 
2097
        u_int32_t rectype, txn_num;
 
2098
        int ret;
 
2099
        u_int8_t *bp;
 
2100
 
 
2101
        rectype = DB_bam_curadj;
 
2102
        if (txnid != NULL &&
 
2103
            TAILQ_FIRST(&txnid->kids) != NULL &&
 
2104
            (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
 
2105
                return (ret);
 
2106
        txn_num = txnid == NULL ? 0 : txnid->txnid;
 
2107
        if (txnid == NULL) {
 
2108
                ZERO_LSN(null_lsn);
 
2109
                lsnp = &null_lsn;
 
2110
        } else
 
2111
                lsnp = &txnid->last_lsn;
 
2112
        logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
 
2113
            + sizeof(fileid)
 
2114
            + sizeof(mode)
 
2115
            + sizeof(from_pgno)
 
2116
            + sizeof(to_pgno)
 
2117
            + sizeof(left_pgno)
 
2118
            + sizeof(first_indx)
 
2119
            + sizeof(from_indx)
 
2120
            + sizeof(to_indx);
 
2121
        if ((ret = __os_malloc(dbenv, logrec.size, &logrec.data)) != 0)
 
2122
                return (ret);
 
2123
 
 
2124
        bp = logrec.data;
 
2125
        memcpy(bp, &rectype, sizeof(rectype));
 
2126
        bp += sizeof(rectype);
 
2127
        memcpy(bp, &txn_num, sizeof(txn_num));
 
2128
        bp += sizeof(txn_num);
 
2129
        memcpy(bp, lsnp, sizeof(DB_LSN));
 
2130
        bp += sizeof(DB_LSN);
 
2131
        memcpy(bp, &fileid, sizeof(fileid));
 
2132
        bp += sizeof(fileid);
 
2133
        memcpy(bp, &mode, sizeof(mode));
 
2134
        bp += sizeof(mode);
 
2135
        memcpy(bp, &from_pgno, sizeof(from_pgno));
 
2136
        bp += sizeof(from_pgno);
 
2137
        memcpy(bp, &to_pgno, sizeof(to_pgno));
 
2138
        bp += sizeof(to_pgno);
 
2139
        memcpy(bp, &left_pgno, sizeof(left_pgno));
 
2140
        bp += sizeof(left_pgno);
 
2141
        memcpy(bp, &first_indx, sizeof(first_indx));
 
2142
        bp += sizeof(first_indx);
 
2143
        memcpy(bp, &from_indx, sizeof(from_indx));
 
2144
        bp += sizeof(from_indx);
 
2145
        memcpy(bp, &to_indx, sizeof(to_indx));
 
2146
        bp += sizeof(to_indx);
 
2147
        DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
 
2148
        ret = log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
 
2149
        if (txnid != NULL && ret == 0)
 
2150
                txnid->last_lsn = *ret_lsnp;
 
2151
#ifdef LOG_DIAGNOSTIC
 
2152
        if (ret != 0)
 
2153
                (void)__bam_curadj_print(dbenv,
 
2154
                    (DBT *)&logrec, ret_lsnp, NULL, NULL);
 
2155
#endif
 
2156
        __os_free(dbenv, logrec.data, logrec.size);
 
2157
        return (ret);
 
2158
}
 
2159
 
 
2160
/*
 
2161
 * PUBLIC: int __bam_curadj_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
 
2162
 * PUBLIC:      void *));
 
2163
 */
 
2164
int
 
2165
__bam_curadj_print(dbenv, dbtp, lsnp, notused2, notused3)
 
2166
        DB_ENV *dbenv;
 
2167
        DBT *dbtp;
 
2168
        DB_LSN *lsnp;
 
2169
        db_recops notused2;
 
2170
        void *notused3;
 
2171
{
 
2172
        __bam_curadj_args *argp;
 
2173
        u_int32_t i;
 
2174
        u_int ch;
 
2175
        int ret;
 
2176
 
 
2177
        i = 0;
 
2178
        ch = 0;
 
2179
        notused2 = DB_TXN_ABORT;
 
2180
        notused3 = NULL;
 
2181
 
 
2182
        if ((ret = __bam_curadj_read(dbenv, dbtp->data, &argp)) != 0)
 
2183
                return (ret);
 
2184
        (void)printf(
 
2185
            "[%lu][%lu]bam_curadj: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
 
2186
            (u_long)lsnp->file,
 
2187
            (u_long)lsnp->offset,
 
2188
            (u_long)argp->type,
 
2189
            (u_long)argp->txnid->txnid,
 
2190
            (u_long)argp->prev_lsn.file,
 
2191
            (u_long)argp->prev_lsn.offset);
 
2192
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
 
2193
        (void)printf("\tmode: %ld\n", (long)argp->mode);
 
2194
        (void)printf("\tfrom_pgno: %lu\n", (u_long)argp->from_pgno);
 
2195
        (void)printf("\tto_pgno: %lu\n", (u_long)argp->to_pgno);
 
2196
        (void)printf("\tleft_pgno: %lu\n", (u_long)argp->left_pgno);
 
2197
        (void)printf("\tfirst_indx: %lu\n", (u_long)argp->first_indx);
 
2198
        (void)printf("\tfrom_indx: %lu\n", (u_long)argp->from_indx);
 
2199
        (void)printf("\tto_indx: %lu\n", (u_long)argp->to_indx);
 
2200
        (void)printf("\n");
 
2201
        __os_free(dbenv, argp, 0);
 
2202
        return (0);
 
2203
}
 
2204
 
 
2205
/*
 
2206
 * PUBLIC: int __bam_curadj_read __P((DB_ENV *, void *, __bam_curadj_args **));
 
2207
 */
 
2208
int
 
2209
__bam_curadj_read(dbenv, recbuf, argpp)
 
2210
        DB_ENV *dbenv;
 
2211
        void *recbuf;
 
2212
        __bam_curadj_args **argpp;
 
2213
{
 
2214
        __bam_curadj_args *argp;
 
2215
        u_int8_t *bp;
 
2216
        int ret;
 
2217
 
 
2218
        ret = __os_malloc(dbenv, sizeof(__bam_curadj_args) +
 
2219
            sizeof(DB_TXN), &argp);
 
2220
        if (ret != 0)
 
2221
                return (ret);
 
2222
        argp->txnid = (DB_TXN *)&argp[1];
 
2223
        bp = recbuf;
 
2224
        memcpy(&argp->type, bp, sizeof(argp->type));
 
2225
        bp += sizeof(argp->type);
 
2226
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
 
2227
        bp += sizeof(argp->txnid->txnid);
 
2228
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
 
2229
        bp += sizeof(DB_LSN);
 
2230
        memcpy(&argp->fileid, bp, sizeof(argp->fileid));
 
2231
        bp += sizeof(argp->fileid);
 
2232
        memcpy(&argp->mode, bp, sizeof(argp->mode));
 
2233
        bp += sizeof(argp->mode);
 
2234
        memcpy(&argp->from_pgno, bp, sizeof(argp->from_pgno));
 
2235
        bp += sizeof(argp->from_pgno);
 
2236
        memcpy(&argp->to_pgno, bp, sizeof(argp->to_pgno));
 
2237
        bp += sizeof(argp->to_pgno);
 
2238
        memcpy(&argp->left_pgno, bp, sizeof(argp->left_pgno));
 
2239
        bp += sizeof(argp->left_pgno);
 
2240
        memcpy(&argp->first_indx, bp, sizeof(argp->first_indx));
 
2241
        bp += sizeof(argp->first_indx);
 
2242
        memcpy(&argp->from_indx, bp, sizeof(argp->from_indx));
 
2243
        bp += sizeof(argp->from_indx);
 
2244
        memcpy(&argp->to_indx, bp, sizeof(argp->to_indx));
 
2245
        bp += sizeof(argp->to_indx);
 
2246
        *argpp = argp;
 
2247
        return (0);
 
2248
}
 
2249
 
 
2250
/*
 
2251
 * PUBLIC: int __bam_rcuradj_log __P((DB_ENV *, DB_TXN *, DB_LSN *, u_int32_t,
 
2252
 * PUBLIC:      int32_t, ca_recno_arg, db_pgno_t, db_recno_t, u_int32_t));
 
2253
 */
 
2254
int
 
2255
__bam_rcuradj_log(dbenv, txnid, ret_lsnp, flags,
 
2256
        fileid, mode, root, recno, order)
 
2257
        DB_ENV *dbenv;
 
2258
        DB_TXN *txnid;
 
2259
        DB_LSN *ret_lsnp;
 
2260
        u_int32_t flags;
 
2261
        int32_t fileid;
 
2262
        ca_recno_arg mode;
 
2263
        db_pgno_t root;
 
2264
        db_recno_t recno;
 
2265
        u_int32_t order;
 
2266
{
 
2267
        DBT logrec;
 
2268
        DB_LSN *lsnp, null_lsn;
 
2269
        u_int32_t rectype, txn_num;
 
2270
        int ret;
 
2271
        u_int8_t *bp;
 
2272
 
 
2273
        rectype = DB_bam_rcuradj;
 
2274
        if (txnid != NULL &&
 
2275
            TAILQ_FIRST(&txnid->kids) != NULL &&
 
2276
            (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
 
2277
                return (ret);
 
2278
        txn_num = txnid == NULL ? 0 : txnid->txnid;
 
2279
        if (txnid == NULL) {
 
2280
                ZERO_LSN(null_lsn);
 
2281
                lsnp = &null_lsn;
 
2282
        } else
 
2283
                lsnp = &txnid->last_lsn;
 
2284
        logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
 
2285
            + sizeof(fileid)
 
2286
            + sizeof(mode)
 
2287
            + sizeof(root)
 
2288
            + sizeof(recno)
 
2289
            + sizeof(order);
 
2290
        if ((ret = __os_malloc(dbenv, logrec.size, &logrec.data)) != 0)
 
2291
                return (ret);
 
2292
 
 
2293
        bp = logrec.data;
 
2294
        memcpy(bp, &rectype, sizeof(rectype));
 
2295
        bp += sizeof(rectype);
 
2296
        memcpy(bp, &txn_num, sizeof(txn_num));
 
2297
        bp += sizeof(txn_num);
 
2298
        memcpy(bp, lsnp, sizeof(DB_LSN));
 
2299
        bp += sizeof(DB_LSN);
 
2300
        memcpy(bp, &fileid, sizeof(fileid));
 
2301
        bp += sizeof(fileid);
 
2302
        memcpy(bp, &mode, sizeof(mode));
 
2303
        bp += sizeof(mode);
 
2304
        memcpy(bp, &root, sizeof(root));
 
2305
        bp += sizeof(root);
 
2306
        memcpy(bp, &recno, sizeof(recno));
 
2307
        bp += sizeof(recno);
 
2308
        memcpy(bp, &order, sizeof(order));
 
2309
        bp += sizeof(order);
 
2310
        DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) == logrec.size);
 
2311
        ret = log_put(dbenv, ret_lsnp, (DBT *)&logrec, flags);
 
2312
        if (txnid != NULL && ret == 0)
 
2313
                txnid->last_lsn = *ret_lsnp;
 
2314
#ifdef LOG_DIAGNOSTIC
 
2315
        if (ret != 0)
 
2316
                (void)__bam_rcuradj_print(dbenv,
 
2317
                    (DBT *)&logrec, ret_lsnp, NULL, NULL);
 
2318
#endif
 
2319
        __os_free(dbenv, logrec.data, logrec.size);
 
2320
        return (ret);
 
2321
}
 
2322
 
 
2323
/*
 
2324
 * PUBLIC: int __bam_rcuradj_print __P((DB_ENV *, DBT *, DB_LSN *, db_recops,
 
2325
 * PUBLIC:      void *));
 
2326
 */
 
2327
int
 
2328
__bam_rcuradj_print(dbenv, dbtp, lsnp, notused2, notused3)
 
2329
        DB_ENV *dbenv;
 
2330
        DBT *dbtp;
 
2331
        DB_LSN *lsnp;
 
2332
        db_recops notused2;
 
2333
        void *notused3;
 
2334
{
 
2335
        __bam_rcuradj_args *argp;
 
2336
        u_int32_t i;
 
2337
        u_int ch;
 
2338
        int ret;
 
2339
 
 
2340
        i = 0;
 
2341
        ch = 0;
 
2342
        notused2 = DB_TXN_ABORT;
 
2343
        notused3 = NULL;
 
2344
 
 
2345
        if ((ret = __bam_rcuradj_read(dbenv, dbtp->data, &argp)) != 0)
 
2346
                return (ret);
 
2347
        (void)printf(
 
2348
            "[%lu][%lu]bam_rcuradj: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
 
2349
            (u_long)lsnp->file,
 
2350
            (u_long)lsnp->offset,
 
2351
            (u_long)argp->type,
 
2352
            (u_long)argp->txnid->txnid,
 
2353
            (u_long)argp->prev_lsn.file,
 
2354
            (u_long)argp->prev_lsn.offset);
 
2355
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
 
2356
        (void)printf("\tmode: %ld\n", (long)argp->mode);
 
2357
        (void)printf("\troot: %ld\n", (long)argp->root);
 
2358
        (void)printf("\trecno: %ld\n", (long)argp->recno);
 
2359
        (void)printf("\torder: %ld\n", (long)argp->order);
 
2360
        (void)printf("\n");
 
2361
        __os_free(dbenv, argp, 0);
 
2362
        return (0);
 
2363
}
 
2364
 
 
2365
/*
 
2366
 * PUBLIC: int __bam_rcuradj_read __P((DB_ENV *, void *,
 
2367
 * PUBLIC:      __bam_rcuradj_args **));
 
2368
 */
 
2369
int
 
2370
__bam_rcuradj_read(dbenv, recbuf, argpp)
 
2371
        DB_ENV *dbenv;
 
2372
        void *recbuf;
 
2373
        __bam_rcuradj_args **argpp;
 
2374
{
 
2375
        __bam_rcuradj_args *argp;
 
2376
        u_int8_t *bp;
 
2377
        int ret;
 
2378
 
 
2379
        ret = __os_malloc(dbenv, sizeof(__bam_rcuradj_args) +
 
2380
            sizeof(DB_TXN), &argp);
 
2381
        if (ret != 0)
 
2382
                return (ret);
 
2383
        argp->txnid = (DB_TXN *)&argp[1];
 
2384
        bp = recbuf;
 
2385
        memcpy(&argp->type, bp, sizeof(argp->type));
 
2386
        bp += sizeof(argp->type);
 
2387
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
 
2388
        bp += sizeof(argp->txnid->txnid);
 
2389
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
 
2390
        bp += sizeof(DB_LSN);
 
2391
        memcpy(&argp->fileid, bp, sizeof(argp->fileid));
 
2392
        bp += sizeof(argp->fileid);
 
2393
        memcpy(&argp->mode, bp, sizeof(argp->mode));
 
2394
        bp += sizeof(argp->mode);
 
2395
        memcpy(&argp->root, bp, sizeof(argp->root));
 
2396
        bp += sizeof(argp->root);
 
2397
        memcpy(&argp->recno, bp, sizeof(argp->recno));
 
2398
        bp += sizeof(argp->recno);
 
2399
        memcpy(&argp->order, bp, sizeof(argp->order));
 
2400
        bp += sizeof(argp->order);
 
2401
        *argpp = argp;
 
2402
        return (0);
 
2403
}
 
2404
 
 
2405
/*
 
2406
 * PUBLIC: int __bam_init_print __P((DB_ENV *));
 
2407
 */
 
2408
int
 
2409
__bam_init_print(dbenv)
 
2410
        DB_ENV *dbenv;
 
2411
{
 
2412
        int ret;
 
2413
 
 
2414
        if ((ret = __db_add_recovery(dbenv,
 
2415
            __bam_pg_alloc_print, DB_bam_pg_alloc)) != 0)
 
2416
                return (ret);
 
2417
        if ((ret = __db_add_recovery(dbenv,
 
2418
            __bam_pg_alloc1_print, DB_bam_pg_alloc1)) != 0)
 
2419
                return (ret);
 
2420
        if ((ret = __db_add_recovery(dbenv,
 
2421
            __bam_pg_free_print, DB_bam_pg_free)) != 0)
 
2422
                return (ret);
 
2423
        if ((ret = __db_add_recovery(dbenv,
 
2424
            __bam_pg_free1_print, DB_bam_pg_free1)) != 0)
 
2425
                return (ret);
 
2426
        if ((ret = __db_add_recovery(dbenv,
 
2427
            __bam_split1_print, DB_bam_split1)) != 0)
 
2428
                return (ret);
 
2429
        if ((ret = __db_add_recovery(dbenv,
 
2430
            __bam_split_print, DB_bam_split)) != 0)
 
2431
                return (ret);
 
2432
        if ((ret = __db_add_recovery(dbenv,
 
2433
            __bam_rsplit1_print, DB_bam_rsplit1)) != 0)
 
2434
                return (ret);
 
2435
        if ((ret = __db_add_recovery(dbenv,
 
2436
            __bam_rsplit_print, DB_bam_rsplit)) != 0)
 
2437
                return (ret);
 
2438
        if ((ret = __db_add_recovery(dbenv,
 
2439
            __bam_adj_print, DB_bam_adj)) != 0)
 
2440
                return (ret);
 
2441
        if ((ret = __db_add_recovery(dbenv,
 
2442
            __bam_cadjust_print, DB_bam_cadjust)) != 0)
 
2443
                return (ret);
 
2444
        if ((ret = __db_add_recovery(dbenv,
 
2445
            __bam_cdel_print, DB_bam_cdel)) != 0)
 
2446
                return (ret);
 
2447
        if ((ret = __db_add_recovery(dbenv,
 
2448
            __bam_repl_print, DB_bam_repl)) != 0)
 
2449
                return (ret);
 
2450
        if ((ret = __db_add_recovery(dbenv,
 
2451
            __bam_root_print, DB_bam_root)) != 0)
 
2452
                return (ret);
 
2453
        if ((ret = __db_add_recovery(dbenv,
 
2454
            __bam_curadj_print, DB_bam_curadj)) != 0)
 
2455
                return (ret);
 
2456
        if ((ret = __db_add_recovery(dbenv,
 
2457
            __bam_rcuradj_print, DB_bam_rcuradj)) != 0)
 
2458
                return (ret);
 
2459
        return (0);
 
2460
}
 
2461
 
 
2462
/*
 
2463
 * PUBLIC: int __bam_init_recover __P((DB_ENV *));
 
2464
 */
 
2465
int
 
2466
__bam_init_recover(dbenv)
 
2467
        DB_ENV *dbenv;
 
2468
{
 
2469
        int ret;
 
2470
 
 
2471
        if ((ret = __db_add_recovery(dbenv,
 
2472
            __bam_pg_alloc_recover, DB_bam_pg_alloc)) != 0)
 
2473
                return (ret);
 
2474
        if ((ret = __db_add_recovery(dbenv,
 
2475
            __deprecated_recover, DB_bam_pg_alloc1)) != 0)
 
2476
                return (ret);
 
2477
        if ((ret = __db_add_recovery(dbenv,
 
2478
            __bam_pg_free_recover, DB_bam_pg_free)) != 0)
 
2479
                return (ret);
 
2480
        if ((ret = __db_add_recovery(dbenv,
 
2481
            __deprecated_recover, DB_bam_pg_free1)) != 0)
 
2482
                return (ret);
 
2483
        if ((ret = __db_add_recovery(dbenv,
 
2484
            __deprecated_recover, DB_bam_split1)) != 0)
 
2485
                return (ret);
 
2486
        if ((ret = __db_add_recovery(dbenv,
 
2487
            __bam_split_recover, DB_bam_split)) != 0)
 
2488
                return (ret);
 
2489
        if ((ret = __db_add_recovery(dbenv,
 
2490
            __deprecated_recover, DB_bam_rsplit1)) != 0)
 
2491
                return (ret);
 
2492
        if ((ret = __db_add_recovery(dbenv,
 
2493
            __bam_rsplit_recover, DB_bam_rsplit)) != 0)
 
2494
                return (ret);
 
2495
        if ((ret = __db_add_recovery(dbenv,
 
2496
            __bam_adj_recover, DB_bam_adj)) != 0)
 
2497
                return (ret);
 
2498
        if ((ret = __db_add_recovery(dbenv,
 
2499
            __bam_cadjust_recover, DB_bam_cadjust)) != 0)
 
2500
                return (ret);
 
2501
        if ((ret = __db_add_recovery(dbenv,
 
2502
            __bam_cdel_recover, DB_bam_cdel)) != 0)
 
2503
                return (ret);
 
2504
        if ((ret = __db_add_recovery(dbenv,
 
2505
            __bam_repl_recover, DB_bam_repl)) != 0)
 
2506
                return (ret);
 
2507
        if ((ret = __db_add_recovery(dbenv,
 
2508
            __bam_root_recover, DB_bam_root)) != 0)
 
2509
                return (ret);
 
2510
        if ((ret = __db_add_recovery(dbenv,
 
2511
            __bam_curadj_recover, DB_bam_curadj)) != 0)
 
2512
                return (ret);
 
2513
        if ((ret = __db_add_recovery(dbenv,
 
2514
            __bam_rcuradj_recover, DB_bam_rcuradj)) != 0)
 
2515
                return (ret);
 
2516
        return (0);
 
2517
}