98 uint8 **checksum_payload,
297 char *path =
psprintf(
"%s/backup_manifest",
304 pg_log_warning(
"manifest file \"%s\" contains no entry for file \"%s\"",
312 *checksum_payload =
pg_malloc(*checksum_length);
335 &checksum_ctx, copy_method,
dry_run);
336 else if (
sidx == 0 &&
source[0]->header_length != 0)
338 pg_fatal(
"full backup contains unexpected incremental file \"%s\"",
345 &checksum_ctx, copy_method,
421 pg_fatal(
"file \"%s\" is too short: expected %lld, found %lld",
424 (
long long)
sb.st_size);
463 pg_fatal(
"file \"%s\" has bad incremental magic number (0x%x, expected 0x%x)",
469 pg_fatal(
"file \"%s\" has block count %u in excess of segment size %u",
474 sizeof(
rf->truncation_block_length));
476 pg_fatal(
"file \"%s\" has truncation block length %u in excess of segment size %u",
480 if (
rf->num_blocks > 0)
482 rf->relative_block_numbers =
489 rf->header_length =
sizeof(magic) +
sizeof(
rf->num_blocks) +
490 sizeof(
rf->truncation_block_length) +
498 if ((
rf->num_blocks > 0) && ((
rf->header_length %
BLCKSZ) != 0))
541 pg_fatal(
"could not read file \"%s\": %m",
rf->filename);
543 pg_fatal(
"could not read file \"%s\": read %zd of %zu",
544 rf->filename,
rb, length);
571 unsigned current_block = 0;
575 pg_log_debug(
"would reconstruct \"%s\" (%u blocks, checksum %s)",
579 pg_log_debug(
"reconstructing \"%s\" (%u blocks, checksum %s)",
689#if defined(HAVE_COPY_FILE_RANGE)
705 pg_fatal(
"error while copying file range from \"%s\" to \"%s\": %m",
708 pg_fatal(
"unexpected end of file while copying file range from \"%s\" to \"%s\"",
725 pg_fatal(
"could not update checksum of file \"%s\"",
728 pg_fatal(
"copy_file_range not supported on this platform");
765 pg_fatal(
"could not write file \"%s\": wrote %zd of %zu",
771 pg_fatal(
"could not update checksum of file \"%s\"",
790 pg_fatal(
"could not read from file \"%s\", offset %lld: read %zd of %zu",
#define INCREMENTAL_MAGIC
#define Assert(condition)
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
int pg_checksum_final(pg_checksum_context *context, uint8 *output)
char * pg_checksum_type_name(pg_checksum_type type)
int pg_checksum_update(pg_checksum_context *context, const uint8 *input, size_t len)
int pg_checksum_init(pg_checksum_context *context, pg_checksum_type type)
#define PG_CHECKSUM_MAX_LENGTH
@ COPY_METHOD_COPY_FILE_RANGE
void copy_file(const char *fromfile, const char *tofile)
void * pg_malloc(size_t size)
#define pg_malloc0_object(type)
#define pg_malloc0_array(type, count)
#define pg_log_debug(...)
char * pstrdup(const char *in)
void pfree(void *pointer)
static rewind_source * source
#define pg_log_warning(...)
static int fd(const char *x, int i)
char * psprintf(const char *fmt,...)
static void read_block(const rfile *s, off_t off, uint8 *buffer)
static void debug_reconstruction(int n_source, rfile **sources, bool dry_run)
void reconstruct_from_incremental_file(char *input_filename, char *output_filename, char *relative_path, char *bare_file_name, int n_prior_backups, char **prior_backup_dirs, manifest_data **manifests, char *manifest_path, pg_checksum_type checksum_type, int *checksum_length, uint8 **checksum_payload, CopyMethod copy_method, bool debug, bool dry_run)
static void write_block(int fd, const char *output_filename, const uint8 *buffer, pg_checksum_context *checksum_ctx)
static void read_bytes(const rfile *rf, void *buffer, size_t length)
static rfile * make_rfile(const char *filename, bool missing_ok)
static rfile * make_incremental_rfile(const char *filename)
static unsigned find_reconstructed_block_length(const rfile *s)
static void write_reconstructed_file(const char *input_filename, const char *output_filename, unsigned block_length, rfile **sourcemap, const off_t *offsetmap, pg_checksum_context *checksum_ctx, CopyMethod copy_method, bool debug, bool dry_run)
void resetStringInfo(StringInfo str)
void appendStringInfo(StringInfo str, const char *fmt,...)
void initStringInfo(StringInfo str)
pg_checksum_type checksum_type
off_t highest_offset_read
BlockNumber * relative_block_numbers
unsigned truncation_block_length