Remove definition of builtin function
[platform/upstream/db4.git] / fileops / fileops_auto.c
1 /* Do not edit: automatically built by gen_rec.awk. */
2
3 #include "db_config.h"
4 #include "db_int.h"
5 #include "dbinc/crypto.h"
6 #include "dbinc/db_page.h"
7 #include "dbinc/db_am.h"
8 #include "dbinc/log.h"
9 #include "dbinc/txn.h"
10 #include "dbinc/fop.h"
11
12 /*
13  * PUBLIC: int __fop_create_42_read __P((ENV *, void *,
14  * PUBLIC:     __fop_create_42_args **));
15  */
16 int
17 __fop_create_42_read(env, recbuf, argpp)
18         ENV *env;
19         void *recbuf;
20         __fop_create_42_args **argpp;
21 {
22         __fop_create_42_args *argp;
23         u_int8_t *bp;
24         int ret;
25
26         if ((ret = __os_malloc(env,
27             sizeof(__fop_create_42_args) + sizeof(DB_TXN), &argp)) != 0)
28                 return (ret);
29         bp = recbuf;
30         argp->txnp = (DB_TXN *)&argp[1];
31         memset(argp->txnp, 0, sizeof(DB_TXN));
32
33         LOGCOPY_32(env, &argp->type, bp);
34         bp += sizeof(argp->type);
35
36         LOGCOPY_32(env, &argp->txnp->txnid, bp);
37         bp += sizeof(argp->txnp->txnid);
38
39         LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
40         bp += sizeof(DB_LSN);
41
42         memset(&argp->name, 0, sizeof(argp->name));
43         LOGCOPY_32(env,&argp->name.size, bp);
44         bp += sizeof(u_int32_t);
45         argp->name.data = bp;
46         bp += argp->name.size;
47
48         LOGCOPY_32(env, &argp->appname, bp);
49         bp += sizeof(argp->appname);
50
51         LOGCOPY_32(env, &argp->mode, bp);
52         bp += sizeof(argp->mode);
53
54         *argpp = argp;
55         return (ret);
56 }
57
58 /*
59  * PUBLIC: int __fop_create_read __P((ENV *, void *, __fop_create_args **));
60  */
61 int
62 __fop_create_read(env, recbuf, argpp)
63         ENV *env;
64         void *recbuf;
65         __fop_create_args **argpp;
66 {
67         __fop_create_args *argp;
68         u_int8_t *bp;
69         int ret;
70
71         if ((ret = __os_malloc(env,
72             sizeof(__fop_create_args) + sizeof(DB_TXN), &argp)) != 0)
73                 return (ret);
74         bp = recbuf;
75         argp->txnp = (DB_TXN *)&argp[1];
76         memset(argp->txnp, 0, sizeof(DB_TXN));
77
78         LOGCOPY_32(env, &argp->type, bp);
79         bp += sizeof(argp->type);
80
81         LOGCOPY_32(env, &argp->txnp->txnid, bp);
82         bp += sizeof(argp->txnp->txnid);
83
84         LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
85         bp += sizeof(DB_LSN);
86
87         memset(&argp->name, 0, sizeof(argp->name));
88         LOGCOPY_32(env,&argp->name.size, bp);
89         bp += sizeof(u_int32_t);
90         argp->name.data = bp;
91         bp += argp->name.size;
92
93         memset(&argp->dirname, 0, sizeof(argp->dirname));
94         LOGCOPY_32(env,&argp->dirname.size, bp);
95         bp += sizeof(u_int32_t);
96         argp->dirname.data = bp;
97         bp += argp->dirname.size;
98
99         LOGCOPY_32(env, &argp->appname, bp);
100         bp += sizeof(argp->appname);
101
102         LOGCOPY_32(env, &argp->mode, bp);
103         bp += sizeof(argp->mode);
104
105         *argpp = argp;
106         return (ret);
107 }
108
109 /*
110  * PUBLIC: int __fop_create_log __P((ENV *, DB_TXN *, DB_LSN *,
111  * PUBLIC:     u_int32_t, const DBT *, const DBT *, u_int32_t, u_int32_t));
112  */
113 int
114 __fop_create_log(env, txnp, ret_lsnp, flags,
115     name, dirname, appname, mode)
116         ENV *env;
117         DB_TXN *txnp;
118         DB_LSN *ret_lsnp;
119         u_int32_t flags;
120         const DBT *name;
121         const DBT *dirname;
122         u_int32_t appname;
123         u_int32_t mode;
124 {
125         DBT logrec;
126         DB_LSN *lsnp, null_lsn, *rlsnp;
127         DB_TXNLOGREC *lr;
128         u_int32_t zero, rectype, txn_num;
129         u_int npad;
130         u_int8_t *bp;
131         int is_durable, ret;
132
133         COMPQUIET(lr, NULL);
134
135         rlsnp = ret_lsnp;
136         rectype = DB___fop_create;
137         npad = 0;
138         ret = 0;
139
140         if (LF_ISSET(DB_LOG_NOT_DURABLE)) {
141                 if (txnp == NULL)
142                         return (0);
143                 is_durable = 0;
144         } else
145                 is_durable = 1;
146
147         if (txnp == NULL) {
148                 txn_num = 0;
149                 lsnp = &null_lsn;
150                 null_lsn.file = null_lsn.offset = 0;
151         } else {
152                 if (TAILQ_FIRST(&txnp->kids) != NULL &&
153                     (ret = __txn_activekids(env, rectype, txnp)) != 0)
154                         return (ret);
155                 /*
156                  * We need to assign begin_lsn while holding region mutex.
157                  * That assignment is done inside the DbEnv->log_put call,
158                  * so pass in the appropriate memory location to be filled
159                  * in by the log_put code.
160                  */
161                 DB_SET_TXN_LSNP(txnp, &rlsnp, &lsnp);
162                 txn_num = txnp->txnid;
163         }
164
165         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
166             + sizeof(u_int32_t) + (name == NULL ? 0 : name->size)
167             + sizeof(u_int32_t) + (dirname == NULL ? 0 : dirname->size)
168             + sizeof(u_int32_t)
169             + sizeof(u_int32_t);
170         if (CRYPTO_ON(env)) {
171                 npad = env->crypto_handle->adj_size(logrec.size);
172                 logrec.size += npad;
173         }
174
175         if (is_durable || txnp == NULL) {
176                 if ((ret =
177                     __os_malloc(env, logrec.size, &logrec.data)) != 0)
178                         return (ret);
179         } else {
180                 if ((ret = __os_malloc(env,
181                     logrec.size + sizeof(DB_TXNLOGREC), &lr)) != 0)
182                         return (ret);
183 #ifdef DIAGNOSTIC
184                 if ((ret =
185                     __os_malloc(env, logrec.size, &logrec.data)) != 0) {
186                         __os_free(env, lr);
187                         return (ret);
188                 }
189 #else
190                 logrec.data = lr->data;
191 #endif
192         }
193         if (npad > 0)
194                 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
195
196         bp = logrec.data;
197
198         LOGCOPY_32(env, bp, &rectype);
199         bp += sizeof(rectype);
200
201         LOGCOPY_32(env, bp, &txn_num);
202         bp += sizeof(txn_num);
203
204         LOGCOPY_FROMLSN(env, bp, lsnp);
205         bp += sizeof(DB_LSN);
206
207         if (name == NULL) {
208                 zero = 0;
209                 LOGCOPY_32(env, bp, &zero);
210                 bp += sizeof(u_int32_t);
211         } else {
212                 LOGCOPY_32(env, bp, &name->size);
213                 bp += sizeof(name->size);
214                 memcpy(bp, name->data, name->size);
215                 bp += name->size;
216         }
217
218         if (dirname == NULL) {
219                 zero = 0;
220                 LOGCOPY_32(env, bp, &zero);
221                 bp += sizeof(u_int32_t);
222         } else {
223                 LOGCOPY_32(env, bp, &dirname->size);
224                 bp += sizeof(dirname->size);
225                 memcpy(bp, dirname->data, dirname->size);
226                 bp += dirname->size;
227         }
228
229         LOGCOPY_32(env, bp, &appname);
230         bp += sizeof(appname);
231
232         LOGCOPY_32(env, bp, &mode);
233         bp += sizeof(mode);
234
235         DB_ASSERT(env,
236             (u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
237
238         if (is_durable || txnp == NULL) {
239                 if ((ret = __log_put(env, rlsnp,(DBT *)&logrec,
240                     flags | DB_LOG_NOCOPY)) == 0 && txnp != NULL) {
241                         *lsnp = *rlsnp;
242                         if (rlsnp != ret_lsnp)
243                                  *ret_lsnp = *rlsnp;
244                 }
245         } else {
246                 ret = 0;
247 #ifdef DIAGNOSTIC
248                 /*
249                  * Set the debug bit if we are going to log non-durable
250                  * transactions so they will be ignored by recovery.
251                  */
252                 memcpy(lr->data, logrec.data, logrec.size);
253                 rectype |= DB_debug_FLAG;
254                 LOGCOPY_32(env, logrec.data, &rectype);
255
256                 if (!IS_REP_CLIENT(env))
257                         ret = __log_put(env,
258                             rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
259 #endif
260                 STAILQ_INSERT_HEAD(&txnp->logs, lr, links);
261                 F_SET((TXN_DETAIL *)txnp->td, TXN_DTL_INMEMORY);
262                 LSN_NOT_LOGGED(*ret_lsnp);
263         }
264
265 #ifdef LOG_DIAGNOSTIC
266         if (ret != 0)
267                 (void)__fop_create_print(env,
268                     (DBT *)&logrec, ret_lsnp, DB_TXN_PRINT, NULL);
269 #endif
270
271 #ifdef DIAGNOSTIC
272         __os_free(env, logrec.data);
273 #else
274         if (is_durable || txnp == NULL)
275                 __os_free(env, logrec.data);
276 #endif
277         return (ret);
278 }
279
280 /*
281  * PUBLIC: int __fop_remove_read __P((ENV *, void *, __fop_remove_args **));
282  */
283 int
284 __fop_remove_read(env, recbuf, argpp)
285         ENV *env;
286         void *recbuf;
287         __fop_remove_args **argpp;
288 {
289         __fop_remove_args *argp;
290         u_int8_t *bp;
291         int ret;
292
293         if ((ret = __os_malloc(env,
294             sizeof(__fop_remove_args) + sizeof(DB_TXN), &argp)) != 0)
295                 return (ret);
296         bp = recbuf;
297         argp->txnp = (DB_TXN *)&argp[1];
298         memset(argp->txnp, 0, sizeof(DB_TXN));
299
300         LOGCOPY_32(env, &argp->type, bp);
301         bp += sizeof(argp->type);
302
303         LOGCOPY_32(env, &argp->txnp->txnid, bp);
304         bp += sizeof(argp->txnp->txnid);
305
306         LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
307         bp += sizeof(DB_LSN);
308
309         memset(&argp->name, 0, sizeof(argp->name));
310         LOGCOPY_32(env,&argp->name.size, bp);
311         bp += sizeof(u_int32_t);
312         argp->name.data = bp;
313         bp += argp->name.size;
314
315         memset(&argp->fid, 0, sizeof(argp->fid));
316         LOGCOPY_32(env,&argp->fid.size, bp);
317         bp += sizeof(u_int32_t);
318         argp->fid.data = bp;
319         bp += argp->fid.size;
320
321         LOGCOPY_32(env, &argp->appname, bp);
322         bp += sizeof(argp->appname);
323
324         *argpp = argp;
325         return (ret);
326 }
327
328 /*
329  * PUBLIC: int __fop_remove_log __P((ENV *, DB_TXN *, DB_LSN *,
330  * PUBLIC:     u_int32_t, const DBT *, const DBT *, u_int32_t));
331  */
332 int
333 __fop_remove_log(env, txnp, ret_lsnp, flags,
334     name, fid, appname)
335         ENV *env;
336         DB_TXN *txnp;
337         DB_LSN *ret_lsnp;
338         u_int32_t flags;
339         const DBT *name;
340         const DBT *fid;
341         u_int32_t appname;
342 {
343         DBT logrec;
344         DB_LSN *lsnp, null_lsn, *rlsnp;
345         DB_TXNLOGREC *lr;
346         u_int32_t zero, rectype, txn_num;
347         u_int npad;
348         u_int8_t *bp;
349         int is_durable, ret;
350
351         COMPQUIET(lr, NULL);
352
353         rlsnp = ret_lsnp;
354         rectype = DB___fop_remove;
355         npad = 0;
356         ret = 0;
357
358         if (LF_ISSET(DB_LOG_NOT_DURABLE)) {
359                 if (txnp == NULL)
360                         return (0);
361                 is_durable = 0;
362         } else
363                 is_durable = 1;
364
365         if (txnp == NULL) {
366                 txn_num = 0;
367                 lsnp = &null_lsn;
368                 null_lsn.file = null_lsn.offset = 0;
369         } else {
370                 if (TAILQ_FIRST(&txnp->kids) != NULL &&
371                     (ret = __txn_activekids(env, rectype, txnp)) != 0)
372                         return (ret);
373                 /*
374                  * We need to assign begin_lsn while holding region mutex.
375                  * That assignment is done inside the DbEnv->log_put call,
376                  * so pass in the appropriate memory location to be filled
377                  * in by the log_put code.
378                  */
379                 DB_SET_TXN_LSNP(txnp, &rlsnp, &lsnp);
380                 txn_num = txnp->txnid;
381         }
382
383         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
384             + sizeof(u_int32_t) + (name == NULL ? 0 : name->size)
385             + sizeof(u_int32_t) + (fid == NULL ? 0 : fid->size)
386             + sizeof(u_int32_t);
387         if (CRYPTO_ON(env)) {
388                 npad = env->crypto_handle->adj_size(logrec.size);
389                 logrec.size += npad;
390         }
391
392         if (is_durable || txnp == NULL) {
393                 if ((ret =
394                     __os_malloc(env, logrec.size, &logrec.data)) != 0)
395                         return (ret);
396         } else {
397                 if ((ret = __os_malloc(env,
398                     logrec.size + sizeof(DB_TXNLOGREC), &lr)) != 0)
399                         return (ret);
400 #ifdef DIAGNOSTIC
401                 if ((ret =
402                     __os_malloc(env, logrec.size, &logrec.data)) != 0) {
403                         __os_free(env, lr);
404                         return (ret);
405                 }
406 #else
407                 logrec.data = lr->data;
408 #endif
409         }
410         if (npad > 0)
411                 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
412
413         bp = logrec.data;
414
415         LOGCOPY_32(env, bp, &rectype);
416         bp += sizeof(rectype);
417
418         LOGCOPY_32(env, bp, &txn_num);
419         bp += sizeof(txn_num);
420
421         LOGCOPY_FROMLSN(env, bp, lsnp);
422         bp += sizeof(DB_LSN);
423
424         if (name == NULL) {
425                 zero = 0;
426                 LOGCOPY_32(env, bp, &zero);
427                 bp += sizeof(u_int32_t);
428         } else {
429                 LOGCOPY_32(env, bp, &name->size);
430                 bp += sizeof(name->size);
431                 memcpy(bp, name->data, name->size);
432                 bp += name->size;
433         }
434
435         if (fid == NULL) {
436                 zero = 0;
437                 LOGCOPY_32(env, bp, &zero);
438                 bp += sizeof(u_int32_t);
439         } else {
440                 LOGCOPY_32(env, bp, &fid->size);
441                 bp += sizeof(fid->size);
442                 memcpy(bp, fid->data, fid->size);
443                 bp += fid->size;
444         }
445
446         LOGCOPY_32(env, bp, &appname);
447         bp += sizeof(appname);
448
449         DB_ASSERT(env,
450             (u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
451
452         if (is_durable || txnp == NULL) {
453                 if ((ret = __log_put(env, rlsnp,(DBT *)&logrec,
454                     flags | DB_LOG_NOCOPY)) == 0 && txnp != NULL) {
455                         *lsnp = *rlsnp;
456                         if (rlsnp != ret_lsnp)
457                                  *ret_lsnp = *rlsnp;
458                 }
459         } else {
460                 ret = 0;
461 #ifdef DIAGNOSTIC
462                 /*
463                  * Set the debug bit if we are going to log non-durable
464                  * transactions so they will be ignored by recovery.
465                  */
466                 memcpy(lr->data, logrec.data, logrec.size);
467                 rectype |= DB_debug_FLAG;
468                 LOGCOPY_32(env, logrec.data, &rectype);
469
470                 if (!IS_REP_CLIENT(env))
471                         ret = __log_put(env,
472                             rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
473 #endif
474                 STAILQ_INSERT_HEAD(&txnp->logs, lr, links);
475                 F_SET((TXN_DETAIL *)txnp->td, TXN_DTL_INMEMORY);
476                 LSN_NOT_LOGGED(*ret_lsnp);
477         }
478
479 #ifdef LOG_DIAGNOSTIC
480         if (ret != 0)
481                 (void)__fop_remove_print(env,
482                     (DBT *)&logrec, ret_lsnp, DB_TXN_PRINT, NULL);
483 #endif
484
485 #ifdef DIAGNOSTIC
486         __os_free(env, logrec.data);
487 #else
488         if (is_durable || txnp == NULL)
489                 __os_free(env, logrec.data);
490 #endif
491         return (ret);
492 }
493
494 /*
495  * PUBLIC: int __fop_write_42_read __P((ENV *, void *,
496  * PUBLIC:     __fop_write_42_args **));
497  */
498 int
499 __fop_write_42_read(env, recbuf, argpp)
500         ENV *env;
501         void *recbuf;
502         __fop_write_42_args **argpp;
503 {
504         __fop_write_42_args *argp;
505         u_int32_t uinttmp;
506         u_int8_t *bp;
507         int ret;
508
509         if ((ret = __os_malloc(env,
510             sizeof(__fop_write_42_args) + sizeof(DB_TXN), &argp)) != 0)
511                 return (ret);
512         bp = recbuf;
513         argp->txnp = (DB_TXN *)&argp[1];
514         memset(argp->txnp, 0, sizeof(DB_TXN));
515
516         LOGCOPY_32(env, &argp->type, bp);
517         bp += sizeof(argp->type);
518
519         LOGCOPY_32(env, &argp->txnp->txnid, bp);
520         bp += sizeof(argp->txnp->txnid);
521
522         LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
523         bp += sizeof(DB_LSN);
524
525         memset(&argp->name, 0, sizeof(argp->name));
526         LOGCOPY_32(env,&argp->name.size, bp);
527         bp += sizeof(u_int32_t);
528         argp->name.data = bp;
529         bp += argp->name.size;
530
531         LOGCOPY_32(env, &argp->appname, bp);
532         bp += sizeof(argp->appname);
533
534         LOGCOPY_32(env, &argp->pgsize, bp);
535         bp += sizeof(argp->pgsize);
536
537         LOGCOPY_32(env, &uinttmp, bp);
538         argp->pageno = (db_pgno_t)uinttmp;
539         bp += sizeof(uinttmp);
540
541         LOGCOPY_32(env, &argp->offset, bp);
542         bp += sizeof(argp->offset);
543
544         memset(&argp->page, 0, sizeof(argp->page));
545         LOGCOPY_32(env,&argp->page.size, bp);
546         bp += sizeof(u_int32_t);
547         argp->page.data = bp;
548         bp += argp->page.size;
549
550         LOGCOPY_32(env, &argp->flag, bp);
551         bp += sizeof(argp->flag);
552
553         *argpp = argp;
554         return (ret);
555 }
556
557 /*
558  * PUBLIC: int __fop_write_read __P((ENV *, void *, __fop_write_args **));
559  */
560 int
561 __fop_write_read(env, recbuf, argpp)
562         ENV *env;
563         void *recbuf;
564         __fop_write_args **argpp;
565 {
566         __fop_write_args *argp;
567         u_int32_t uinttmp;
568         u_int8_t *bp;
569         int ret;
570
571         if ((ret = __os_malloc(env,
572             sizeof(__fop_write_args) + sizeof(DB_TXN), &argp)) != 0)
573                 return (ret);
574         bp = recbuf;
575         argp->txnp = (DB_TXN *)&argp[1];
576         memset(argp->txnp, 0, sizeof(DB_TXN));
577
578         LOGCOPY_32(env, &argp->type, bp);
579         bp += sizeof(argp->type);
580
581         LOGCOPY_32(env, &argp->txnp->txnid, bp);
582         bp += sizeof(argp->txnp->txnid);
583
584         LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
585         bp += sizeof(DB_LSN);
586
587         memset(&argp->name, 0, sizeof(argp->name));
588         LOGCOPY_32(env,&argp->name.size, bp);
589         bp += sizeof(u_int32_t);
590         argp->name.data = bp;
591         bp += argp->name.size;
592
593         memset(&argp->dirname, 0, sizeof(argp->dirname));
594         LOGCOPY_32(env,&argp->dirname.size, bp);
595         bp += sizeof(u_int32_t);
596         argp->dirname.data = bp;
597         bp += argp->dirname.size;
598
599         LOGCOPY_32(env, &argp->appname, bp);
600         bp += sizeof(argp->appname);
601
602         LOGCOPY_32(env, &argp->pgsize, bp);
603         bp += sizeof(argp->pgsize);
604
605         LOGCOPY_32(env, &uinttmp, bp);
606         argp->pageno = (db_pgno_t)uinttmp;
607         bp += sizeof(uinttmp);
608
609         LOGCOPY_32(env, &argp->offset, bp);
610         bp += sizeof(argp->offset);
611
612         memset(&argp->page, 0, sizeof(argp->page));
613         LOGCOPY_32(env,&argp->page.size, bp);
614         bp += sizeof(u_int32_t);
615         argp->page.data = bp;
616         bp += argp->page.size;
617
618         LOGCOPY_32(env, &argp->flag, bp);
619         bp += sizeof(argp->flag);
620
621         *argpp = argp;
622         return (ret);
623 }
624
625 /*
626  * PUBLIC: int __fop_write_log __P((ENV *, DB_TXN *, DB_LSN *,
627  * PUBLIC:     u_int32_t, const DBT *, const DBT *, u_int32_t, u_int32_t,
628  * PUBLIC:     db_pgno_t, u_int32_t, const DBT *, u_int32_t));
629  */
630 int
631 __fop_write_log(env, txnp, ret_lsnp, flags,
632     name, dirname, appname, pgsize, pageno, offset,
633     page, flag)
634         ENV *env;
635         DB_TXN *txnp;
636         DB_LSN *ret_lsnp;
637         u_int32_t flags;
638         const DBT *name;
639         const DBT *dirname;
640         u_int32_t appname;
641         u_int32_t pgsize;
642         db_pgno_t pageno;
643         u_int32_t offset;
644         const DBT *page;
645         u_int32_t flag;
646 {
647         DBT logrec;
648         DB_LSN *lsnp, null_lsn, *rlsnp;
649         DB_TXNLOGREC *lr;
650         u_int32_t zero, uinttmp, rectype, txn_num;
651         u_int npad;
652         u_int8_t *bp;
653         int is_durable, ret;
654
655         COMPQUIET(lr, NULL);
656
657         rlsnp = ret_lsnp;
658         rectype = DB___fop_write;
659         npad = 0;
660         ret = 0;
661
662         if (LF_ISSET(DB_LOG_NOT_DURABLE)) {
663                 if (txnp == NULL)
664                         return (0);
665                 is_durable = 0;
666         } else
667                 is_durable = 1;
668
669         if (txnp == NULL) {
670                 txn_num = 0;
671                 lsnp = &null_lsn;
672                 null_lsn.file = null_lsn.offset = 0;
673         } else {
674                 if (TAILQ_FIRST(&txnp->kids) != NULL &&
675                     (ret = __txn_activekids(env, rectype, txnp)) != 0)
676                         return (ret);
677                 /*
678                  * We need to assign begin_lsn while holding region mutex.
679                  * That assignment is done inside the DbEnv->log_put call,
680                  * so pass in the appropriate memory location to be filled
681                  * in by the log_put code.
682                  */
683                 DB_SET_TXN_LSNP(txnp, &rlsnp, &lsnp);
684                 txn_num = txnp->txnid;
685         }
686
687         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
688             + sizeof(u_int32_t) + (name == NULL ? 0 : name->size)
689             + sizeof(u_int32_t) + (dirname == NULL ? 0 : dirname->size)
690             + sizeof(u_int32_t)
691             + sizeof(u_int32_t)
692             + sizeof(u_int32_t)
693             + sizeof(u_int32_t)
694             + sizeof(u_int32_t) + (page == NULL ? 0 : page->size)
695             + sizeof(u_int32_t);
696         if (CRYPTO_ON(env)) {
697                 npad = env->crypto_handle->adj_size(logrec.size);
698                 logrec.size += npad;
699         }
700
701         if (is_durable || txnp == NULL) {
702                 if ((ret =
703                     __os_malloc(env, logrec.size, &logrec.data)) != 0)
704                         return (ret);
705         } else {
706                 if ((ret = __os_malloc(env,
707                     logrec.size + sizeof(DB_TXNLOGREC), &lr)) != 0)
708                         return (ret);
709 #ifdef DIAGNOSTIC
710                 if ((ret =
711                     __os_malloc(env, logrec.size, &logrec.data)) != 0) {
712                         __os_free(env, lr);
713                         return (ret);
714                 }
715 #else
716                 logrec.data = lr->data;
717 #endif
718         }
719         if (npad > 0)
720                 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
721
722         bp = logrec.data;
723
724         LOGCOPY_32(env, bp, &rectype);
725         bp += sizeof(rectype);
726
727         LOGCOPY_32(env, bp, &txn_num);
728         bp += sizeof(txn_num);
729
730         LOGCOPY_FROMLSN(env, bp, lsnp);
731         bp += sizeof(DB_LSN);
732
733         if (name == NULL) {
734                 zero = 0;
735                 LOGCOPY_32(env, bp, &zero);
736                 bp += sizeof(u_int32_t);
737         } else {
738                 LOGCOPY_32(env, bp, &name->size);
739                 bp += sizeof(name->size);
740                 memcpy(bp, name->data, name->size);
741                 bp += name->size;
742         }
743
744         if (dirname == NULL) {
745                 zero = 0;
746                 LOGCOPY_32(env, bp, &zero);
747                 bp += sizeof(u_int32_t);
748         } else {
749                 LOGCOPY_32(env, bp, &dirname->size);
750                 bp += sizeof(dirname->size);
751                 memcpy(bp, dirname->data, dirname->size);
752                 bp += dirname->size;
753         }
754
755         LOGCOPY_32(env, bp, &appname);
756         bp += sizeof(appname);
757
758         LOGCOPY_32(env, bp, &pgsize);
759         bp += sizeof(pgsize);
760
761         uinttmp = (u_int32_t)pageno;
762         LOGCOPY_32(env,bp, &uinttmp);
763         bp += sizeof(uinttmp);
764
765         LOGCOPY_32(env, bp, &offset);
766         bp += sizeof(offset);
767
768         if (page == NULL) {
769                 zero = 0;
770                 LOGCOPY_32(env, bp, &zero);
771                 bp += sizeof(u_int32_t);
772         } else {
773                 LOGCOPY_32(env, bp, &page->size);
774                 bp += sizeof(page->size);
775                 memcpy(bp, page->data, page->size);
776                 bp += page->size;
777         }
778
779         LOGCOPY_32(env, bp, &flag);
780         bp += sizeof(flag);
781
782         DB_ASSERT(env,
783             (u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
784
785         if (is_durable || txnp == NULL) {
786                 if ((ret = __log_put(env, rlsnp,(DBT *)&logrec,
787                     flags | DB_LOG_NOCOPY)) == 0 && txnp != NULL) {
788                         *lsnp = *rlsnp;
789                         if (rlsnp != ret_lsnp)
790                                  *ret_lsnp = *rlsnp;
791                 }
792         } else {
793                 ret = 0;
794 #ifdef DIAGNOSTIC
795                 /*
796                  * Set the debug bit if we are going to log non-durable
797                  * transactions so they will be ignored by recovery.
798                  */
799                 memcpy(lr->data, logrec.data, logrec.size);
800                 rectype |= DB_debug_FLAG;
801                 LOGCOPY_32(env, logrec.data, &rectype);
802
803                 if (!IS_REP_CLIENT(env))
804                         ret = __log_put(env,
805                             rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
806 #endif
807                 STAILQ_INSERT_HEAD(&txnp->logs, lr, links);
808                 F_SET((TXN_DETAIL *)txnp->td, TXN_DTL_INMEMORY);
809                 LSN_NOT_LOGGED(*ret_lsnp);
810         }
811
812 #ifdef LOG_DIAGNOSTIC
813         if (ret != 0)
814                 (void)__fop_write_print(env,
815                     (DBT *)&logrec, ret_lsnp, DB_TXN_PRINT, NULL);
816 #endif
817
818 #ifdef DIAGNOSTIC
819         __os_free(env, logrec.data);
820 #else
821         if (is_durable || txnp == NULL)
822                 __os_free(env, logrec.data);
823 #endif
824         return (ret);
825 }
826
827 /*
828  * PUBLIC: int __fop_rename_42_read __P((ENV *, void *,
829  * PUBLIC:     __fop_rename_42_args **));
830  */
831 int
832 __fop_rename_42_read(env, recbuf, argpp)
833         ENV *env;
834         void *recbuf;
835         __fop_rename_42_args **argpp;
836 {
837         __fop_rename_42_args *argp;
838         u_int8_t *bp;
839         int ret;
840
841         if ((ret = __os_malloc(env,
842             sizeof(__fop_rename_42_args) + sizeof(DB_TXN), &argp)) != 0)
843                 return (ret);
844         bp = recbuf;
845         argp->txnp = (DB_TXN *)&argp[1];
846         memset(argp->txnp, 0, sizeof(DB_TXN));
847
848         LOGCOPY_32(env, &argp->type, bp);
849         bp += sizeof(argp->type);
850
851         LOGCOPY_32(env, &argp->txnp->txnid, bp);
852         bp += sizeof(argp->txnp->txnid);
853
854         LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
855         bp += sizeof(DB_LSN);
856
857         memset(&argp->oldname, 0, sizeof(argp->oldname));
858         LOGCOPY_32(env,&argp->oldname.size, bp);
859         bp += sizeof(u_int32_t);
860         argp->oldname.data = bp;
861         bp += argp->oldname.size;
862
863         memset(&argp->newname, 0, sizeof(argp->newname));
864         LOGCOPY_32(env,&argp->newname.size, bp);
865         bp += sizeof(u_int32_t);
866         argp->newname.data = bp;
867         bp += argp->newname.size;
868
869         memset(&argp->fileid, 0, sizeof(argp->fileid));
870         LOGCOPY_32(env,&argp->fileid.size, bp);
871         bp += sizeof(u_int32_t);
872         argp->fileid.data = bp;
873         bp += argp->fileid.size;
874
875         LOGCOPY_32(env, &argp->appname, bp);
876         bp += sizeof(argp->appname);
877
878         *argpp = argp;
879         return (ret);
880 }
881
882 /*
883  * PUBLIC: int __fop_rename_read __P((ENV *, void *, __fop_rename_args **));
884  */
885 int
886 __fop_rename_read(env, recbuf, argpp)
887         ENV *env;
888         void *recbuf;
889         __fop_rename_args **argpp;
890 {
891         __fop_rename_args *argp;
892         u_int8_t *bp;
893         int ret;
894
895         if ((ret = __os_malloc(env,
896             sizeof(__fop_rename_args) + sizeof(DB_TXN), &argp)) != 0)
897                 return (ret);
898         bp = recbuf;
899         argp->txnp = (DB_TXN *)&argp[1];
900         memset(argp->txnp, 0, sizeof(DB_TXN));
901
902         LOGCOPY_32(env, &argp->type, bp);
903         bp += sizeof(argp->type);
904
905         LOGCOPY_32(env, &argp->txnp->txnid, bp);
906         bp += sizeof(argp->txnp->txnid);
907
908         LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
909         bp += sizeof(DB_LSN);
910
911         memset(&argp->oldname, 0, sizeof(argp->oldname));
912         LOGCOPY_32(env,&argp->oldname.size, bp);
913         bp += sizeof(u_int32_t);
914         argp->oldname.data = bp;
915         bp += argp->oldname.size;
916
917         memset(&argp->newname, 0, sizeof(argp->newname));
918         LOGCOPY_32(env,&argp->newname.size, bp);
919         bp += sizeof(u_int32_t);
920         argp->newname.data = bp;
921         bp += argp->newname.size;
922
923         memset(&argp->dirname, 0, sizeof(argp->dirname));
924         LOGCOPY_32(env,&argp->dirname.size, bp);
925         bp += sizeof(u_int32_t);
926         argp->dirname.data = bp;
927         bp += argp->dirname.size;
928
929         memset(&argp->fileid, 0, sizeof(argp->fileid));
930         LOGCOPY_32(env,&argp->fileid.size, bp);
931         bp += sizeof(u_int32_t);
932         argp->fileid.data = bp;
933         bp += argp->fileid.size;
934
935         LOGCOPY_32(env, &argp->appname, bp);
936         bp += sizeof(argp->appname);
937
938         *argpp = argp;
939         return (ret);
940 }
941
942 /*
943  * PUBLIC: int __fop_rename_log __P((ENV *, DB_TXN *, DB_LSN *,
944  * PUBLIC:     u_int32_t, const DBT *, const DBT *, const DBT *, const DBT *,
945  * PUBLIC:     u_int32_t));
946  */
947 /*
948  * PUBLIC: int __fop_rename_noundo_log __P((ENV *, DB_TXN *,
949  * PUBLIC:     DB_LSN *, u_int32_t, const DBT *, const DBT *, const DBT *,
950  * PUBLIC:     const DBT *, u_int32_t));
951  */
952 /*
953  * PUBLIC: int __fop_rename_int_log __P((ENV *, DB_TXN *, DB_LSN *,
954  * PUBLIC:     u_int32_t, const DBT *, const DBT *, const DBT *, const DBT *,
955  * PUBLIC:     u_int32_t, u_int32_t));
956  */
957 int
958 __fop_rename_log(env, txnp, ret_lsnp, flags,
959     oldname, newname, dirname, fileid, appname)
960         ENV *env;
961         DB_TXN *txnp;
962         DB_LSN *ret_lsnp;
963         u_int32_t flags;
964         const DBT *oldname;
965         const DBT *newname;
966         const DBT *dirname;
967         const DBT *fileid;
968         u_int32_t appname;
969
970 {
971         return (__fop_rename_int_log(env, txnp, ret_lsnp, flags,
972     oldname, newname, dirname, fileid, appname, DB___fop_rename));
973 }
974 int
975 __fop_rename_noundo_log(env, txnp, ret_lsnp, flags,
976     oldname, newname, dirname, fileid, appname)
977         ENV *env;
978         DB_TXN *txnp;
979         DB_LSN *ret_lsnp;
980         u_int32_t flags;
981         const DBT *oldname;
982         const DBT *newname;
983         const DBT *dirname;
984         const DBT *fileid;
985         u_int32_t appname;
986
987 {
988         return (__fop_rename_int_log(env, txnp, ret_lsnp, flags,
989     oldname, newname, dirname, fileid, appname, DB___fop_rename_noundo));
990 }
991 int
992 __fop_rename_int_log(env, txnp, ret_lsnp, flags,
993     oldname, newname, dirname, fileid, appname, type)
994         ENV *env;
995         DB_TXN *txnp;
996         DB_LSN *ret_lsnp;
997         u_int32_t flags;
998         const DBT *oldname;
999         const DBT *newname;
1000         const DBT *dirname;
1001         const DBT *fileid;
1002         u_int32_t appname;
1003         u_int32_t type;
1004 {
1005         DBT logrec;
1006         DB_LSN *lsnp, null_lsn, *rlsnp;
1007         DB_TXNLOGREC *lr;
1008         u_int32_t zero, rectype, txn_num;
1009         u_int npad;
1010         u_int8_t *bp;
1011         int is_durable, ret;
1012
1013         COMPQUIET(lr, NULL);
1014
1015         rlsnp = ret_lsnp;
1016         rectype = type;
1017         npad = 0;
1018         ret = 0;
1019
1020         if (LF_ISSET(DB_LOG_NOT_DURABLE)) {
1021                 if (txnp == NULL)
1022                         return (0);
1023                 is_durable = 0;
1024         } else
1025                 is_durable = 1;
1026
1027         if (txnp == NULL) {
1028                 txn_num = 0;
1029                 lsnp = &null_lsn;
1030                 null_lsn.file = null_lsn.offset = 0;
1031         } else {
1032                 if (TAILQ_FIRST(&txnp->kids) != NULL &&
1033                     (ret = __txn_activekids(env, rectype, txnp)) != 0)
1034                         return (ret);
1035                 /*
1036                  * We need to assign begin_lsn while holding region mutex.
1037                  * That assignment is done inside the DbEnv->log_put call,
1038                  * so pass in the appropriate memory location to be filled
1039                  * in by the log_put code.
1040                  */
1041                 DB_SET_TXN_LSNP(txnp, &rlsnp, &lsnp);
1042                 txn_num = txnp->txnid;
1043         }
1044
1045         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
1046             + sizeof(u_int32_t) + (oldname == NULL ? 0 : oldname->size)
1047             + sizeof(u_int32_t) + (newname == NULL ? 0 : newname->size)
1048             + sizeof(u_int32_t) + (dirname == NULL ? 0 : dirname->size)
1049             + sizeof(u_int32_t) + (fileid == NULL ? 0 : fileid->size)
1050             + sizeof(u_int32_t);
1051         if (CRYPTO_ON(env)) {
1052                 npad = env->crypto_handle->adj_size(logrec.size);
1053                 logrec.size += npad;
1054         }
1055
1056         if (is_durable || txnp == NULL) {
1057                 if ((ret =
1058                     __os_malloc(env, logrec.size, &logrec.data)) != 0)
1059                         return (ret);
1060         } else {
1061                 if ((ret = __os_malloc(env,
1062                     logrec.size + sizeof(DB_TXNLOGREC), &lr)) != 0)
1063                         return (ret);
1064 #ifdef DIAGNOSTIC
1065                 if ((ret =
1066                     __os_malloc(env, logrec.size, &logrec.data)) != 0) {
1067                         __os_free(env, lr);
1068                         return (ret);
1069                 }
1070 #else
1071                 logrec.data = lr->data;
1072 #endif
1073         }
1074         if (npad > 0)
1075                 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
1076
1077         bp = logrec.data;
1078
1079         LOGCOPY_32(env, bp, &rectype);
1080         bp += sizeof(rectype);
1081
1082         LOGCOPY_32(env, bp, &txn_num);
1083         bp += sizeof(txn_num);
1084
1085         LOGCOPY_FROMLSN(env, bp, lsnp);
1086         bp += sizeof(DB_LSN);
1087
1088         if (oldname == NULL) {
1089                 zero = 0;
1090                 LOGCOPY_32(env, bp, &zero);
1091                 bp += sizeof(u_int32_t);
1092         } else {
1093                 LOGCOPY_32(env, bp, &oldname->size);
1094                 bp += sizeof(oldname->size);
1095                 memcpy(bp, oldname->data, oldname->size);
1096                 bp += oldname->size;
1097         }
1098
1099         if (newname == NULL) {
1100                 zero = 0;
1101                 LOGCOPY_32(env, bp, &zero);
1102                 bp += sizeof(u_int32_t);
1103         } else {
1104                 LOGCOPY_32(env, bp, &newname->size);
1105                 bp += sizeof(newname->size);
1106                 memcpy(bp, newname->data, newname->size);
1107                 bp += newname->size;
1108         }
1109
1110         if (dirname == NULL) {
1111                 zero = 0;
1112                 LOGCOPY_32(env, bp, &zero);
1113                 bp += sizeof(u_int32_t);
1114         } else {
1115                 LOGCOPY_32(env, bp, &dirname->size);
1116                 bp += sizeof(dirname->size);
1117                 memcpy(bp, dirname->data, dirname->size);
1118                 bp += dirname->size;
1119         }
1120
1121         if (fileid == NULL) {
1122                 zero = 0;
1123                 LOGCOPY_32(env, bp, &zero);
1124                 bp += sizeof(u_int32_t);
1125         } else {
1126                 LOGCOPY_32(env, bp, &fileid->size);
1127                 bp += sizeof(fileid->size);
1128                 memcpy(bp, fileid->data, fileid->size);
1129                 bp += fileid->size;
1130         }
1131
1132         LOGCOPY_32(env, bp, &appname);
1133         bp += sizeof(appname);
1134
1135         DB_ASSERT(env,
1136             (u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
1137
1138         if (is_durable || txnp == NULL) {
1139                 if ((ret = __log_put(env, rlsnp,(DBT *)&logrec,
1140                     flags | DB_LOG_NOCOPY)) == 0 && txnp != NULL) {
1141                         *lsnp = *rlsnp;
1142                         if (rlsnp != ret_lsnp)
1143                                  *ret_lsnp = *rlsnp;
1144                 }
1145         } else {
1146                 ret = 0;
1147 #ifdef DIAGNOSTIC
1148                 /*
1149                  * Set the debug bit if we are going to log non-durable
1150                  * transactions so they will be ignored by recovery.
1151                  */
1152                 memcpy(lr->data, logrec.data, logrec.size);
1153                 rectype |= DB_debug_FLAG;
1154                 LOGCOPY_32(env, logrec.data, &rectype);
1155
1156                 if (!IS_REP_CLIENT(env))
1157                         ret = __log_put(env,
1158                             rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
1159 #endif
1160                 STAILQ_INSERT_HEAD(&txnp->logs, lr, links);
1161                 F_SET((TXN_DETAIL *)txnp->td, TXN_DTL_INMEMORY);
1162                 LSN_NOT_LOGGED(*ret_lsnp);
1163         }
1164
1165 #ifdef LOG_DIAGNOSTIC
1166         if (ret != 0)
1167                 (void)__fop_rename_print(env,
1168                     (DBT *)&logrec, ret_lsnp, DB_TXN_PRINT, NULL);
1169 #endif
1170
1171 #ifdef DIAGNOSTIC
1172         __os_free(env, logrec.data);
1173 #else
1174         if (is_durable || txnp == NULL)
1175                 __os_free(env, logrec.data);
1176 #endif
1177         return (ret);
1178 }
1179
1180 /*
1181  * PUBLIC: int __fop_file_remove_read __P((ENV *, void *,
1182  * PUBLIC:     __fop_file_remove_args **));
1183  */
1184 int
1185 __fop_file_remove_read(env, recbuf, argpp)
1186         ENV *env;
1187         void *recbuf;
1188         __fop_file_remove_args **argpp;
1189 {
1190         __fop_file_remove_args *argp;
1191         u_int8_t *bp;
1192         int ret;
1193
1194         if ((ret = __os_malloc(env,
1195             sizeof(__fop_file_remove_args) + sizeof(DB_TXN), &argp)) != 0)
1196                 return (ret);
1197         bp = recbuf;
1198         argp->txnp = (DB_TXN *)&argp[1];
1199         memset(argp->txnp, 0, sizeof(DB_TXN));
1200
1201         LOGCOPY_32(env, &argp->type, bp);
1202         bp += sizeof(argp->type);
1203
1204         LOGCOPY_32(env, &argp->txnp->txnid, bp);
1205         bp += sizeof(argp->txnp->txnid);
1206
1207         LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
1208         bp += sizeof(DB_LSN);
1209
1210         memset(&argp->real_fid, 0, sizeof(argp->real_fid));
1211         LOGCOPY_32(env,&argp->real_fid.size, bp);
1212         bp += sizeof(u_int32_t);
1213         argp->real_fid.data = bp;
1214         bp += argp->real_fid.size;
1215
1216         memset(&argp->tmp_fid, 0, sizeof(argp->tmp_fid));
1217         LOGCOPY_32(env,&argp->tmp_fid.size, bp);
1218         bp += sizeof(u_int32_t);
1219         argp->tmp_fid.data = bp;
1220         bp += argp->tmp_fid.size;
1221
1222         memset(&argp->name, 0, sizeof(argp->name));
1223         LOGCOPY_32(env,&argp->name.size, bp);
1224         bp += sizeof(u_int32_t);
1225         argp->name.data = bp;
1226         bp += argp->name.size;
1227
1228         LOGCOPY_32(env, &argp->appname, bp);
1229         bp += sizeof(argp->appname);
1230
1231         LOGCOPY_32(env, &argp->child, bp);
1232         bp += sizeof(argp->child);
1233
1234         *argpp = argp;
1235         return (ret);
1236 }
1237
1238 /*
1239  * PUBLIC: int __fop_file_remove_log __P((ENV *, DB_TXN *, DB_LSN *,
1240  * PUBLIC:     u_int32_t, const DBT *, const DBT *, const DBT *, u_int32_t,
1241  * PUBLIC:     u_int32_t));
1242  */
1243 int
1244 __fop_file_remove_log(env, txnp, ret_lsnp, flags,
1245     real_fid, tmp_fid, name, appname, child)
1246         ENV *env;
1247         DB_TXN *txnp;
1248         DB_LSN *ret_lsnp;
1249         u_int32_t flags;
1250         const DBT *real_fid;
1251         const DBT *tmp_fid;
1252         const DBT *name;
1253         u_int32_t appname;
1254         u_int32_t child;
1255 {
1256         DBT logrec;
1257         DB_LSN *lsnp, null_lsn, *rlsnp;
1258         DB_TXNLOGREC *lr;
1259         u_int32_t zero, rectype, txn_num;
1260         u_int npad;
1261         u_int8_t *bp;
1262         int is_durable, ret;
1263
1264         COMPQUIET(lr, NULL);
1265
1266         rlsnp = ret_lsnp;
1267         rectype = DB___fop_file_remove;
1268         npad = 0;
1269         ret = 0;
1270
1271         if (LF_ISSET(DB_LOG_NOT_DURABLE)) {
1272                 if (txnp == NULL)
1273                         return (0);
1274                 is_durable = 0;
1275         } else
1276                 is_durable = 1;
1277
1278         if (txnp == NULL) {
1279                 txn_num = 0;
1280                 lsnp = &null_lsn;
1281                 null_lsn.file = null_lsn.offset = 0;
1282         } else {
1283                 if (TAILQ_FIRST(&txnp->kids) != NULL &&
1284                     (ret = __txn_activekids(env, rectype, txnp)) != 0)
1285                         return (ret);
1286                 /*
1287                  * We need to assign begin_lsn while holding region mutex.
1288                  * That assignment is done inside the DbEnv->log_put call,
1289                  * so pass in the appropriate memory location to be filled
1290                  * in by the log_put code.
1291                  */
1292                 DB_SET_TXN_LSNP(txnp, &rlsnp, &lsnp);
1293                 txn_num = txnp->txnid;
1294         }
1295
1296         logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
1297             + sizeof(u_int32_t) + (real_fid == NULL ? 0 : real_fid->size)
1298             + sizeof(u_int32_t) + (tmp_fid == NULL ? 0 : tmp_fid->size)
1299             + sizeof(u_int32_t) + (name == NULL ? 0 : name->size)
1300             + sizeof(u_int32_t)
1301             + sizeof(u_int32_t);
1302         if (CRYPTO_ON(env)) {
1303                 npad = env->crypto_handle->adj_size(logrec.size);
1304                 logrec.size += npad;
1305         }
1306
1307         if (is_durable || txnp == NULL) {
1308                 if ((ret =
1309                     __os_malloc(env, logrec.size, &logrec.data)) != 0)
1310                         return (ret);
1311         } else {
1312                 if ((ret = __os_malloc(env,
1313                     logrec.size + sizeof(DB_TXNLOGREC), &lr)) != 0)
1314                         return (ret);
1315 #ifdef DIAGNOSTIC
1316                 if ((ret =
1317                     __os_malloc(env, logrec.size, &logrec.data)) != 0) {
1318                         __os_free(env, lr);
1319                         return (ret);
1320                 }
1321 #else
1322                 logrec.data = lr->data;
1323 #endif
1324         }
1325         if (npad > 0)
1326                 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
1327
1328         bp = logrec.data;
1329
1330         LOGCOPY_32(env, bp, &rectype);
1331         bp += sizeof(rectype);
1332
1333         LOGCOPY_32(env, bp, &txn_num);
1334         bp += sizeof(txn_num);
1335
1336         LOGCOPY_FROMLSN(env, bp, lsnp);
1337         bp += sizeof(DB_LSN);
1338
1339         if (real_fid == NULL) {
1340                 zero = 0;
1341                 LOGCOPY_32(env, bp, &zero);
1342                 bp += sizeof(u_int32_t);
1343         } else {
1344                 LOGCOPY_32(env, bp, &real_fid->size);
1345                 bp += sizeof(real_fid->size);
1346                 memcpy(bp, real_fid->data, real_fid->size);
1347                 bp += real_fid->size;
1348         }
1349
1350         if (tmp_fid == NULL) {
1351                 zero = 0;
1352                 LOGCOPY_32(env, bp, &zero);
1353                 bp += sizeof(u_int32_t);
1354         } else {
1355                 LOGCOPY_32(env, bp, &tmp_fid->size);
1356                 bp += sizeof(tmp_fid->size);
1357                 memcpy(bp, tmp_fid->data, tmp_fid->size);
1358                 bp += tmp_fid->size;
1359         }
1360
1361         if (name == NULL) {
1362                 zero = 0;
1363                 LOGCOPY_32(env, bp, &zero);
1364                 bp += sizeof(u_int32_t);
1365         } else {
1366                 LOGCOPY_32(env, bp, &name->size);
1367                 bp += sizeof(name->size);
1368                 memcpy(bp, name->data, name->size);
1369                 bp += name->size;
1370         }
1371
1372         LOGCOPY_32(env, bp, &appname);
1373         bp += sizeof(appname);
1374
1375         LOGCOPY_32(env, bp, &child);
1376         bp += sizeof(child);
1377
1378         DB_ASSERT(env,
1379             (u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
1380
1381         if (is_durable || txnp == NULL) {
1382                 if ((ret = __log_put(env, rlsnp,(DBT *)&logrec,
1383                     flags | DB_LOG_NOCOPY)) == 0 && txnp != NULL) {
1384                         *lsnp = *rlsnp;
1385                         if (rlsnp != ret_lsnp)
1386                                  *ret_lsnp = *rlsnp;
1387                 }
1388         } else {
1389                 ret = 0;
1390 #ifdef DIAGNOSTIC
1391                 /*
1392                  * Set the debug bit if we are going to log non-durable
1393                  * transactions so they will be ignored by recovery.
1394                  */
1395                 memcpy(lr->data, logrec.data, logrec.size);
1396                 rectype |= DB_debug_FLAG;
1397                 LOGCOPY_32(env, logrec.data, &rectype);
1398
1399                 if (!IS_REP_CLIENT(env))
1400                         ret = __log_put(env,
1401                             rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
1402 #endif
1403                 STAILQ_INSERT_HEAD(&txnp->logs, lr, links);
1404                 F_SET((TXN_DETAIL *)txnp->td, TXN_DTL_INMEMORY);
1405                 LSN_NOT_LOGGED(*ret_lsnp);
1406         }
1407
1408 #ifdef LOG_DIAGNOSTIC
1409         if (ret != 0)
1410                 (void)__fop_file_remove_print(env,
1411                     (DBT *)&logrec, ret_lsnp, DB_TXN_PRINT, NULL);
1412 #endif
1413
1414 #ifdef DIAGNOSTIC
1415         __os_free(env, logrec.data);
1416 #else
1417         if (is_durable || txnp == NULL)
1418                 __os_free(env, logrec.data);
1419 #endif
1420         return (ret);
1421 }
1422
1423 /*
1424  * PUBLIC: int __fop_init_recover __P((ENV *, DB_DISTAB *));
1425  */
1426 int
1427 __fop_init_recover(env, dtabp)
1428         ENV *env;
1429         DB_DISTAB *dtabp;
1430 {
1431         int ret;
1432
1433         if ((ret = __db_add_recovery_int(env, dtabp,
1434             __fop_create_recover, DB___fop_create)) != 0)
1435                 return (ret);
1436         if ((ret = __db_add_recovery_int(env, dtabp,
1437             __fop_remove_recover, DB___fop_remove)) != 0)
1438                 return (ret);
1439         if ((ret = __db_add_recovery_int(env, dtabp,
1440             __fop_write_recover, DB___fop_write)) != 0)
1441                 return (ret);
1442         if ((ret = __db_add_recovery_int(env, dtabp,
1443             __fop_rename_recover, DB___fop_rename)) != 0)
1444                 return (ret);
1445         if ((ret = __db_add_recovery_int(env, dtabp,
1446             __fop_rename_noundo_recover, DB___fop_rename_noundo)) != 0)
1447                 return (ret);
1448         if ((ret = __db_add_recovery_int(env, dtabp,
1449             __fop_file_remove_recover, DB___fop_file_remove)) != 0)
1450                 return (ret);
1451         return (0);
1452 }