switch (context)
{ case ASTREAMER_MEMBER_HEADER: /* Initial setup plus decide which checks to perform. */
member_verify_header(streamer, member); break;
case ASTREAMER_MEMBER_CONTENTS: /* Incremental work required to verify file contents. */ if (mystreamer->verify_checksum)
member_compute_checksum(streamer, member, data, len); if (mystreamer->verify_control_data)
member_copy_control_data(streamer, member, data, len); break;
case ASTREAMER_MEMBER_TRAILER: /* Now we've got all the file data. */ if (mystreamer->verify_checksum)
member_verify_checksum(streamer); if (mystreamer->verify_control_data)
member_verify_control_data(streamer);
/* Reset for next archive member. */
member_reset_info(streamer); break;
case ASTREAMER_ARCHIVE_TRAILER: break;
default: /* Shouldn't happen. */
pg_fatal("unexpected state while parsing tar archive");
}
}
/* Ignore any files that are listed in the ignore list. */ if (should_ignore_relpath(mystreamer->context, pathname)) return;
/* Check whether there's an entry in the manifest hash. */
m = manifest_files_lookup(mystreamer->context->manifest->files, pathname); if (m == NULL)
{
report_backup_error(mystreamer->context, "file \"%s\" is present in archive \"%s\" but not in the manifest",
member->pathname, mystreamer->archive_name); return;
}
mystreamer->mfile = m;
/* Flag this entry as having been encountered in a tar archive. */
m->matched = true;
/* Check that the size matches. */ if (m->size != member->size)
{
report_backup_error(mystreamer->context, "file \"%s\" has size %llu in archive \"%s\" but size %" PRIu64 " in the manifest",
member->pathname,
(unsignedlonglong) member->size,
mystreamer->archive_name,
m->size);
m->bad = true; return;
}
/* If we're going to verify the checksum, initial a checksum context. */ if (mystreamer->verify_checksum &&
pg_checksum_init(mystreamer->checksum_ctx, m->checksum_type) < 0)
{
report_backup_error(mystreamer->context, "%s: could not initialize checksum of file \"%s\"",
mystreamer->archive_name, m->pathname);
/* *It'sunclearhowthiscouldfail,butlet'scheckanywaytobesafe.
*/ if (mystreamer->checksum_bytes != m->size)
{
report_backup_error(mystreamer->context, "file \"%s\" in archive \"%s\" should contain %" PRIu64 " bytes, but %" PRIu64 " bytes were read",
m->pathname, mystreamer->archive_name,
m->size,
mystreamer->checksum_bytes); return;
}
/* Get the final checksum. */
checksumlen = pg_checksum_final(mystreamer->checksum_ctx, checksumbuf); if (checksumlen < 0)
{
report_backup_error(mystreamer->context, "could not finalize checksum of file \"%s\"",
m->pathname); return;
}
/* And check it against the manifest. */ if (checksumlen != m->checksum_length)
report_backup_error(mystreamer->context, "file \"%s\" in archive \"%s\" has checksum of length %d, but expected %d",
m->pathname, mystreamer->archive_name,
m->checksum_length, checksumlen); elseif (memcmp(checksumbuf, m->checksum_payload, checksumlen) != 0)
report_backup_error(mystreamer->context, "checksum mismatch for file \"%s\" in archive \"%s\"",
m->pathname, mystreamer->archive_name);
}
/* Should be here only for control file */
Assert(strcmp(mystreamer->mfile->pathname, XLOG_CONTROL_FILE) == 0);
Assert(mystreamer->verify_control_data);
/* Control file contents not meaningful if CRC is bad. */ if (!EQ_CRC32C(crc, mystreamer->control_file.crc))
report_fatal_error("%s: %s: CRC is incorrect",
mystreamer->archive_name,
mystreamer->mfile->pathname);
/* Can't interpret control file if not current version. */ if (mystreamer->control_file.pg_control_version != PG_CONTROL_VERSION)
report_fatal_error("%s: %s: unexpected control file version",
mystreamer->archive_name,
mystreamer->mfile->pathname);
/* System identifiers should match. */ if (manifest->system_identifier !=
mystreamer->control_file.system_identifier)
report_fatal_error("%s: %s: manifest system identifier is %" PRIu64 ", but control file has %" PRIu64,
mystreamer->archive_name,
mystreamer->mfile->pathname,
manifest->system_identifier,
mystreamer->control_file.system_identifier);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.