IncrementalBackupInfo *ib);
static void parse_basebackup_options(List *options, basebackup_options *opt);
static int compareWalFileNames(const ListCell *a, const ListCell *b);
-static int basebackup_read_file(int fd, char *buf, size_t nbytes, off_t offset,
- const char *filename, bool partial_read_ok);
+static ssize_t basebackup_read_file(int fd, char *buf, size_t nbytes, off_t offset,
+ const char *filename, bool partial_read_ok);
/* Was the backup currently in-progress initiated in recovery mode? */
static bool backup_started_in_recovery = false;
{
char *walFileName = (char *) lfirst(lc);
int fd;
- size_t cnt;
+ ssize_t cnt;
pgoff_t len = 0;
snprintf(pathbuf, MAXPGPATH, XLOGDIR "/%s", walFileName);
*
* Returns the number of bytes read.
*/
-static int
+static ssize_t
basebackup_read_file(int fd, char *buf, size_t nbytes, off_t offset,
const char *filename, bool partial_read_ok)
{
- int rc;
+ ssize_t rc;
pgstat_report_wait_start(WAIT_EVENT_BASEBACKUP_READ);
rc = pg_pread(fd, buf, nbytes, offset);
if (!partial_read_ok && rc > 0 && rc != nbytes)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not read file \"%s\": read %d of %zu",
+ errmsg("could not read file \"%s\": read %zd of %zu",
filename, rc, nbytes)));
return rc;
static void
read_bytes(rfile *rf, void *buffer, unsigned length)
{
- unsigned rb = read(rf->fd, buffer, length);
+ int rb = read(rf->fd, buffer, length);
if (rb != length)
{
pg_fatal("could not read file \"%s\": %m", rf->filename);
else
pg_fatal("could not read file \"%s\": read only %d of %d bytes",
- rf->filename, (int) rb, length);
+ rf->filename, rb, length);
}
}
{
uint8 buffer[BLCKSZ];
rfile *s = sourcemap[i];
- unsigned wb;
+ int wb;
/* Update accounting information. */
if (s == NULL)
}
else
{
- unsigned rb;
+ int rb;
/* Read the block from the correct source, except if dry-run. */
rb = pg_pread(s->fd, buffer, BLCKSZ, offsetmap[i]);
if (rb < 0)
pg_fatal("could not read file \"%s\": %m", s->filename);
else
- pg_fatal("could not read file \"%s\": read only %d of %d bytes at offset %u",
- s->filename, (int) rb, BLCKSZ,
- (unsigned) offsetmap[i]);
+ pg_fatal("could not read file \"%s\": read only %d of %d bytes at offset %llu",
+ s->filename, rb, BLCKSZ,
+ (unsigned long long) offsetmap[i]);
}
}
pg_fatal("could not write file \"%s\": %m", output_filename);
else
pg_fatal("could not write file \"%s\": wrote only %d of %d bytes",
- output_filename, (int) wb, BLCKSZ);
+ output_filename, wb, BLCKSZ);
}
/* Update the checksum computation. */