33 off_t off,
size_t len);
86 srcfd = open(srcpath, O_RDONLY |
PG_BINARY, 0);
88 pg_fatal(
"could not open source file \"%s\": %m",
102 pg_fatal(
"could not read file \"%s\": %m", srcpath);
103 else if (read_len == 0)
107 written_len += read_len;
114 if (written_len !=
len)
115 pg_fatal(
"size of source file \"%s\" changed concurrently: %d bytes expected, %d copied",
116 srcpath, (
int)
len, (
int) written_len);
118 if (
close(srcfd) != 0)
119 pg_fatal(
"could not close file \"%s\": %m", srcpath);
134 off_t end = off +
len;
138 srcfd = open(srcpath, O_RDONLY |
PG_BINARY, 0);
140 pg_fatal(
"could not open source file \"%s\": %m",
143 if (lseek(srcfd, begin, SEEK_SET) == -1)
144 pg_fatal(
"could not seek in source file: %m");
148 while (end - begin > 0)
153 if (end - begin >
sizeof(
buf))
154 thislen =
sizeof(
buf);
156 thislen = end - begin;
158 readlen =
read(srcfd,
buf.data, thislen);
161 pg_fatal(
"could not read file \"%s\": %m", srcpath);
162 else if (readlen == 0)
163 pg_fatal(
"unexpected EOF while reading file \"%s\"", srcpath);
169 if (
close(srcfd) != 0)
170 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)