1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-01-24 11:46:31 +02:00

change mode for fopen w->PG_BINARY_W, r->PG_BINARY_R

This commit is contained in:
Victor Spirin 2018-05-11 18:17:54 +03:00
parent 83d64c5b9d
commit ac98fefc6e
6 changed files with 17 additions and 16 deletions

View File

@ -287,7 +287,7 @@ static void remote_copy_file(PGconn *conn, pgFile* file)
DATABASE_DIR);
join_path_components(to_path, database_path, file->path);
out = fopen(to_path, "w");
out = fopen(to_path, PG_BINARY_W);
if (out == NULL)
{
int errno_tmp = errno;
@ -562,6 +562,7 @@ do_backup_instance(void)
#ifdef WIN32
sleep(10);
#endif
if (conn == NULL)
elog(ERROR, "Cannot continue backup because stream connect has failed.");
@ -1715,7 +1716,7 @@ pg_stop_backup(pgBackup *backup)
/* Write backup_label */
join_path_components(backup_label, path, PG_BACKUP_LABEL_FILE);
fp = fopen(backup_label, "w");
fp = fopen(backup_label, PG_BINARY_W);
if (fp == NULL)
elog(ERROR, "can't open backup label file \"%s\": %s",
backup_label, strerror(errno));
@ -1763,7 +1764,7 @@ pg_stop_backup(pgBackup *backup)
char tablespace_map[MAXPGPATH];
join_path_components(tablespace_map, path, PG_TABLESPACE_MAP_FILE);
fp = fopen(tablespace_map, "w");
fp = fopen(tablespace_map, PG_BINARY_W);
if (fp == NULL)
elog(ERROR, "can't open tablespace map file \"%s\": %s",
tablespace_map, strerror(errno));

View File

@ -421,7 +421,7 @@ backup_data_file(backup_files_args* arguments,
INIT_CRC32C(file->crc);
/* open backup mode file for read */
in = fopen(file->path, "r");
in = fopen(file->path, PG_BINARY_R);
if (in == NULL)
{
FIN_CRC32C(file->crc);
@ -455,7 +455,7 @@ backup_data_file(backup_files_args* arguments,
/* open backup file for write */
join_path_components(to_path, to_root, file->path + strlen(from_root) + 1);
out = fopen(to_path, "w");
out = fopen(to_path, PG_BINARY_W);
if (out == NULL)
{
int errno_tmp = errno;
@ -547,7 +547,7 @@ restore_data_file(const char *from_root,
BlockNumber blknum;
/* open backup mode file for read */
in = fopen(file->path, "r");
in = fopen(file->path, PG_BINARY_R);
if (in == NULL)
{
elog(ERROR, "cannot open backup file \"%s\": %s", file->path,
@ -562,7 +562,7 @@ restore_data_file(const char *from_root,
join_path_components(to_path, to_root, file->path + strlen(from_root) + 1);
out = fopen(to_path, "r+");
if (out == NULL && errno == ENOENT)
out = fopen(to_path, "w");
out = fopen(to_path, PG_BINARY_W);
if (out == NULL)
{
int errno_tmp = errno;
@ -694,7 +694,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
file->write_size = 0;
/* open backup mode file for read */
in = fopen(file->path, "r");
in = fopen(file->path, PG_BINARY_R);
if (in == NULL)
{
FIN_CRC32C(crc);
@ -710,7 +710,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
/* open backup file for write */
join_path_components(to_path, to_root, file->path + strlen(from_root) + 1);
out = fopen(to_path, "w");
out = fopen(to_path, PG_BINARY_W);
if (out == NULL)
{
int errno_tmp = errno;
@ -1189,7 +1189,7 @@ calc_file_checksum(pgFile *file)
file->write_size = 0;
/* open backup mode file for read */
in = fopen(file->path, "r");
in = fopen(file->path, PG_BINARY_R);
if (in == NULL)
{
FIN_CRC32C(crc);

View File

@ -216,7 +216,7 @@ pgFileGetCRC(pgFile *file)
int errno_tmp;
/* open file in binary read mode */
fp = fopen(file->path, "r");
fp = fopen(file->path, PG_BINARY_R);
if (fp == NULL)
elog(ERROR, "cannot open file \"%s\": %s",
file->path, strerror(errno));
@ -333,7 +333,7 @@ dir_list_file(parray *files, const char *root, bool exclude, bool omit_symlink,
char black_item[MAXPGPATH * 2];
black_list = parray_new();
black_list_file = fopen(path, "r");
black_list_file = fopen(path, PG_BINARY_R);
if (black_list_file == NULL)
elog(ERROR, "cannot open black_list: %s", strerror(errno));

View File

@ -181,13 +181,13 @@ main(int argc, char *argv[])
/* Check if backup_path is directory. */
struct stat stat_buf;
int rc;
/* initialize configuration */
pgBackup_init(&current);
PROGRAM_NAME = get_progname(argv[0]);
set_pglocale_pgservice(argv[0], "pgscripts");
/* Parse subcommands and non-subcommand options */
if (argc > 1)
{

View File

@ -38,7 +38,7 @@ get_pgpid(void)
snprintf(pid_file, lengthof(pid_file), "%s/postmaster.pid", pgdata);
pidf = fopen(pid_file, "r");
pidf = fopen(pid_file, PG_BINARY_R);
if (pidf == NULL)
{
/* No pid file, not an error on startup */

View File

@ -515,7 +515,7 @@ open_logfile(FILE **file, const char *filename_format)
{
char buf[1024];
control_file = fopen(control, "r");
control_file = fopen(control, PG_BINARY_R);
if (control_file == NULL)
elog(ERROR, "cannot open rotation file \"%s\": %s",
control, strerror(errno));
@ -561,7 +561,7 @@ logfile_open:
{
time_t timestamp = time(NULL);
control_file = fopen(control, "w");
control_file = fopen(control, PG_BINARY_W);
if (control_file == NULL)
elog(ERROR, "cannot open rotation file \"%s\": %s",
control, strerror(errno));