35 off_t off,
size_t len);
88 srcfd = open(srcpath, O_RDONLY |
PG_BINARY, 0);
90 pg_fatal(
"could not open source file \"%s\": %m",
101 read_len =
read(srcfd,
buf.data,
sizeof(
buf));
104 pg_fatal(
"could not read file \"%s\": %m", srcpath);
105 else if (read_len == 0)
109 written_len += read_len;
116 if (written_len !=
len)
117 pg_fatal(
"size of source file \"%s\" changed concurrently: %d bytes expected, %d copied",
118 srcpath, (
int)
len, (
int) written_len);
120 if (
close(srcfd) != 0)
121 pg_fatal(
"could not close file \"%s\": %m", srcpath);
136 off_t end = off +
len;
140 srcfd = open(srcpath, O_RDONLY |
PG_BINARY, 0);
142 pg_fatal(
"could not open source file \"%s\": %m",
145 if (lseek(srcfd, begin, SEEK_SET) == -1)
146 pg_fatal(
"could not seek in source file: %m");
150 while (end - begin > 0)
155 if (end - begin >
sizeof(
buf))
156 thislen =
sizeof(
buf);
158 thislen = end - begin;
160 readlen =
read(srcfd,
buf.data, thislen);
163 pg_fatal(
"could not read file \"%s\": %m", srcpath);
164 else if (readlen == 0)
165 pg_fatal(
"unexpected EOF while reading file \"%s\"", srcpath);
171 if (
close(srcfd) != 0)
172 pg_fatal(
"could not close file \"%s\": %m", srcpath);
void * pg_malloc0(size_t size)
void traverse_datadir(const char *datadir, process_file_callback_t callback)
char * slurpFile(const char *datadir, const char *path, size_t *filesize)
void open_target_file(const char *path, bool trunc)
void write_target_range(char *buf, off_t begin, size_t size)
void(* process_file_callback_t)(const char *path, file_type_t type, size_t size, const char *link_target)
static void local_queue_fetch_file(rewind_source *source, const char *path, size_t len)
static void local_destroy(rewind_source *source)
rewind_source * init_local_source(const char *datadir)
static void local_traverse_files(rewind_source *source, process_file_callback_t callback)
static char * local_fetch_file(rewind_source *source, const char *path, size_t *filesize)
static void local_finish_fetch(rewind_source *source)
static void local_queue_fetch_range(rewind_source *source, const char *path, off_t off, size_t len)
void pfree(void *pointer)
static rewind_source * source
void(* queue_fetch_file)(struct rewind_source *, const char *path, size_t len)
void(* traverse_files)(struct rewind_source *, process_file_callback_t callback)
void(* finish_fetch)(struct rewind_source *)
XLogRecPtr(* get_current_wal_insert_lsn)(struct rewind_source *)
void(* queue_fetch_range)(struct rewind_source *, const char *path, off_t offset, size_t len)
char *(* fetch_file)(struct rewind_source *, const char *path, size_t *filesize)
void(* destroy)(struct rewind_source *)
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)