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