54 if (
dstfd != -1 && !trunc &&
67 pg_fatal(
"could not open target file \"%s\": %m",
81 pg_fatal(
"could not close target file \"%s\": %m",
100 if (lseek(
dstfd, begin, SEEK_SET) == -1)
101 pg_fatal(
"could not seek in target file \"%s\": %m",
106 while (writeleft > 0)
117 pg_fatal(
"could not write file \"%s\": %m",
122 writeleft -= writelen;
150 pg_fatal(
"undefined file type for \"%s\"", entry->
path);
173 pg_fatal(
"invalid action (CREATE) for regular file");
177 pg_fatal(
"undefined file type for \"%s\"", entry->
path);
197 if (errno == ENOENT && missing_ok)
200 pg_fatal(
"could not remove file \"%s\": %m",
218 pg_fatal(
"could not open file \"%s\" for truncation: %m",
222 pg_fatal(
"could not truncate file \"%s\" to %u: %m",
223 dstpath, (
unsigned int) newsize);
238 pg_fatal(
"could not create directory \"%s\": %m",
252 pg_fatal(
"could not remove directory \"%s\": %m",
266 pg_fatal(
"could not create symbolic link at \"%s\": %m",
280 pg_fatal(
"could not remove symbolic link \"%s\": %m",
325 if ((
fd = open(fullpath, O_RDONLY |
PG_BINARY, 0)) == -1)
326 pg_fatal(
"could not open file \"%s\" for reading: %m",
330 pg_fatal(
"could not open file \"%s\" for reading: %m",
341 pg_fatal(
"could not read file \"%s\": %m",
344 pg_fatal(
"could not read file \"%s\": read %d of %zu",
386 xldir =
opendir(fullparentpath);
388 pg_fatal(
"could not open directory \"%s\": %m",
391 while (errno = 0, (xlde =
readdir(xldir)) != NULL)
397 if (strcmp(xlde->
d_name,
".") == 0 ||
398 strcmp(xlde->
d_name,
"..") == 0)
401 snprintf(fullpath,
sizeof(fullpath),
"%s/%s", fullparentpath, xlde->
d_name);
403 if (
lstat(fullpath, &fst) < 0)
417 pg_fatal(
"could not stat file \"%s\": %m",
439 len =
readlink(fullpath, link_target,
sizeof(link_target));
441 pg_fatal(
"could not read symbolic link \"%s\": %m",
443 if (
len >=
sizeof(link_target))
444 pg_fatal(
"symbolic link \"%s\" target is too long",
446 link_target[
len] =
'\0';
455 if ((parentpath && strcmp(parentpath,
PG_TBLSPC_DIR) == 0) ||
456 strcmp(path,
"pg_wal") == 0)
462 pg_fatal(
"could not read directory \"%s\": %m",
466 pg_fatal(
"could not close directory \"%s\": %m",
#define Assert(condition)
struct dirent * readdir(DIR *)
DIR * opendir(const char *)
void * pg_malloc(size_t size)
void remove_target_file(const char *path, bool missing_ok)
static char dstpath[MAXPGPATH]
void traverse_datadir(const char *datadir, process_file_callback_t callback)
static void remove_target_dir(const char *path)
char * slurpFile(const char *datadir, const char *path, size_t *filesize)
void close_target_file(void)
static void create_target_symlink(const char *path, const char *link)
void truncate_target_file(const char *path, off_t newsize)
void remove_target(file_entry_t *entry)
void sync_target_dir(void)
void create_target(file_entry_t *entry)
void open_target_file(const char *path, bool trunc)
static void create_target_dir(const char *path)
void write_target_range(char *buf, off_t begin, size_t size)
static void remove_target_symlink(const char *path)
static void recurse_dir(const char *datadir, const char *parentpath, process_file_callback_t callback)
void(* process_file_callback_t)(const char *path, file_type_t type, size_t size, const char *link_target)
static DataDirSyncMethod sync_method
static void progress_report(uint64 relations_total, uint64 relations_checked, uint64 relpages_total, uint64 relpages_checked, const char *datname, bool force, bool finished)
static PgChecksumMode mode
static int fd(const char *x, int i)
static pg_noinline void Size size
char * source_link_target
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
#define symlink(oldpath, newpath)
#define readlink(path, buf, size)