- tdb_len_t recovery_size;
- unsigned char *data, *p;
- const struct tdb_methods *methods = tdb->transaction->io_methods;
- struct tdb_recovery_record *rec;
- tdb_off_t recovery_offset, recovery_max_size;
- tdb_off_t old_map_size = tdb->transaction->old_map_size;
- uint64_t magic, tailer;
- int i;
-
- /*
- check that the recovery area has enough space
- */
- if (tdb_recovery_allocate(tdb, &recovery_size,
- &recovery_offset, &recovery_max_size) == -1) {
- return -1;
- }
-
- data = (unsigned char *)malloc(recovery_size + sizeof(*rec));
- if (data == NULL) {
- tdb_logerr(tdb, TDB_ERR_OOM, TDB_LOG_ERROR,
- "transaction_setup_recovery: cannot allocate");
- return -1;
- }
-
- rec = (struct tdb_recovery_record *)data;
- set_recovery_header(rec, TDB_RECOVERY_INVALID_MAGIC,
- recovery_size, recovery_max_size, old_map_size);
- tdb_convert(tdb, rec, sizeof(*rec));
-
- /* build the recovery data into a single blob to allow us to do a single
- large write, which should be more efficient */
- p = data + sizeof(*rec);
- for (i=0;i<tdb->transaction->num_blocks;i++) {
- tdb_off_t offset;
- tdb_len_t length;
+ tdb_len_t recovery_size = 0;
+ tdb_off_t recovery_off = 0;
+ tdb_off_t old_map_size = tdb->tdb2.transaction->old_map_size;
+ struct tdb_recovery_record *recovery;
+ const struct tdb_methods *methods = tdb->tdb2.transaction->io_methods;
+ uint64_t magic;
+ enum TDB_ERROR ecode;