37 copydir(
char *fromdir,
char *todir,
bool recurse)
47 errmsg(
"could not create directory \"%s\": %m", todir)));
51 while ((xlde =
ReadDir(xldir, fromdir)) != NULL)
58 if (strcmp(xlde->
d_name,
".") == 0 ||
59 strcmp(xlde->
d_name,
"..") == 0)
62 snprintf(fromfile,
sizeof(fromfile),
"%s/%s", fromdir, xlde->
d_name);
65 if (
lstat(fromfile, &fst) < 0)
68 errmsg(
"could not stat file \"%s\": %m", fromfile)));
74 copydir(fromfile, tofile,
true);
90 while ((xlde =
ReadDir(xldir, todir)) != NULL)
94 if (strcmp(xlde->
d_name,
".") == 0 ||
95 strcmp(xlde->
d_name,
"..") == 0)
104 if (
lstat(tofile, &fst) < 0)
107 errmsg(
"could not stat file \"%s\": %m", tofile)));
137 #define COPY_BUF_SIZE (8 * BLCKSZ)
145 #if defined(__darwin__)
146 #define FLUSH_DISTANCE (32 * 1024 * 1024)
148 #define FLUSH_DISTANCE (1024 * 1024)
161 errmsg(
"could not open file \"%s\": %m", fromfile)));
167 errmsg(
"could not create file \"%s\": %m", tofile)));
173 for (offset = 0;; offset += nbytes)
186 flush_offset = offset;
195 errmsg(
"could not read file \"%s\": %m", fromfile)));
200 if ((
int)
write(
dstfd, buffer, nbytes) != nbytes)
207 errmsg(
"could not write to file \"%s\": %m", tofile)));
212 if (offset > flush_offset)
218 errmsg(
"could not close file \"%s\": %m", tofile)));
223 errmsg(
"could not close file \"%s\": %m", fromfile)));
void copydir(char *fromdir, char *todir, bool recurse)
void copy_file(char *fromfile, char *tofile)
int errcode_for_file_access(void)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
struct dirent * ReadDir(DIR *dir, const char *dirname)
void pg_flush_data(int fd, off_t offset, off_t nbytes)
int MakePGDirectory(const char *directoryName)
int CloseTransientFile(int fd)
void fsync_fname(const char *fname, bool isdir)
int OpenTransientFile(const char *fileName, int fileFlags)
DIR * AllocateDir(const char *dirname)
void pfree(void *pointer)
#define CHECK_FOR_INTERRUPTS()
@ WAIT_EVENT_COPY_FILE_READ
@ WAIT_EVENT_COPY_FILE_WRITE
static void pgstat_report_wait_start(uint32 wait_event_info)
static void pgstat_report_wait_end(void)